From a2521bd23c4869a829b3653070730f63105956e6 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 18 Mar 2012 23:31:04 +0000 Subject: [PATCH] fix a bunch of issues to properly support dynamic linking of libtorrent with visibility=hidden. Still requires a small patch to boost --- CMakeLists.txt | 3 +- Jamfile | 30 +++-- configure.ac | 7 +- examples/client_test.cpp | 22 ++-- include/libtorrent/alert.hpp | 2 +- include/libtorrent/allocator.hpp | 6 +- include/libtorrent/aux_/session_impl.hpp | 2 +- include/libtorrent/bandwidth_limit.hpp | 2 +- include/libtorrent/bandwidth_manager.hpp | 2 +- include/libtorrent/bandwidth_queue_entry.hpp | 2 +- include/libtorrent/bencode.hpp | 2 +- include/libtorrent/bloom_filter.hpp | 6 +- include/libtorrent/broadcast_socket.hpp | 6 +- include/libtorrent/bt_peer_connection.hpp | 2 +- include/libtorrent/chained_buffer.hpp | 2 +- include/libtorrent/config.hpp | 21 ++- include/libtorrent/connection_queue.hpp | 2 +- include/libtorrent/create_torrent.hpp | 122 +----------------- include/libtorrent/disk_buffer_holder.hpp | 2 +- include/libtorrent/disk_buffer_pool.hpp | 2 +- include/libtorrent/disk_io_thread.hpp | 2 +- include/libtorrent/escape_string.hpp | 60 ++++----- include/libtorrent/gzip.hpp | 2 +- include/libtorrent/hasher.hpp | 8 +- include/libtorrent/instantiate_connection.hpp | 2 +- include/libtorrent/kademlia/node.hpp | 2 +- include/libtorrent/kademlia/node_id.hpp | 12 +- include/libtorrent/packet_buffer.hpp | 2 +- include/libtorrent/parse_url.hpp | 2 +- include/libtorrent/pe_crypto.hpp | 6 +- include/libtorrent/peer.hpp | 2 +- include/libtorrent/peer_request.hpp | 2 +- include/libtorrent/piece_picker.hpp | 4 +- include/libtorrent/policy.hpp | 10 +- include/libtorrent/rsa.hpp | 6 +- include/libtorrent/socket_io.hpp | 2 +- include/libtorrent/socket_type.hpp | 2 +- include/libtorrent/socks5_stream.hpp | 2 +- include/libtorrent/stat.hpp | 4 +- include/libtorrent/storage.hpp | 14 +- include/libtorrent/thread.hpp | 2 +- include/libtorrent/timestamp_history.hpp | 2 +- include/libtorrent/torrent.hpp | 2 +- include/libtorrent/tracker_manager.hpp | 12 +- include/libtorrent/udp_tracker_connection.hpp | 2 +- include/libtorrent/utp_stream.hpp | 2 +- include/libtorrent/web_connection_base.hpp | 2 +- include/libtorrent/web_peer_connection.hpp | 2 +- src/Makefile.am | 7 +- src/create_torrent.cpp | 116 +++++++++++++++++ test/Jamfile | 2 +- test/test_rss.cpp | 2 + 52 files changed, 286 insertions(+), 258 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d249d16b..677ebe9d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ set(sources alert allocator asio + asio_ssl assert bandwidth_limit bandwidth_manager @@ -240,7 +241,7 @@ endforeach (s) 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) set (LIBDIR "lib64") diff --git a/Jamfile b/Jamfile index b57aed141..9c159ff7e 100755 --- a/Jamfile +++ b/Jamfile @@ -31,17 +31,6 @@ rule linking ( properties * ) { local result ; - if shared in $(properties) - { - # make sure asio symbols are properly exported - # and imported - result += BOOST_ASIO_DYN_LINK ; - } - else - { - result += BOOST_ASIO_SEPARATE_COMPILATION ; - } - # openssl libraries, if enabled if openssl in $(properties) { @@ -209,6 +198,15 @@ rule building ( properties * ) { local result ; + if shared in $(properties) && 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 += TORRENT_EXPORT_EXTRA ; + } + if ( debug in $(properties) || on in $(properties) ) { @@ -249,7 +247,7 @@ rule building ( properties * ) # hide non-external symbols # use ms-compat because boost.asio (as of 1.47.0 # appears to have some types not fulle exported) - result += -fvisibility-ms-compat ; + result += -fvisibility=hidden ; result += -fvisibility-inlines-hidden ; result += -W1,-Bsymbolic ; } @@ -378,6 +376,10 @@ feature fpic : off on : composite propagated link-incompatible ; feature.compose on : -fPIC ; feature.compose off : darwin:-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 lib ssleay32 : : ssleay32 ; lib libeay32 : : libeay32 ; @@ -560,6 +562,10 @@ local usage-requirements = system:$(LDFLAGS) # this works around a bug in asio in boost-1.39 BOOST_ASIO_HASH_MAP_BUCKETS=1021 +# make sure asio symbols are properly exported +# and imported + shared:BOOST_ASIO_DYN_LINK + static:BOOST_ASIO_SEPARATE_COMPILATION @tag ; diff --git a/configure.ac b/configure.ac index fb3feb36f..fef61be1e 100644 --- a/configure.ac +++ b/configure.ac @@ -159,7 +159,7 @@ AC_CHECK_FUNCS([clock_gettime], [], 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([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.]) 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 AC_ARG_VAR([PYTHON_INSTALL_PARAMS], [Set specific install parameters for python bindings.]) AS_IF([test "x$PYTHON_INSTALL_PARAMS" = "x"], diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 4ed519537..9b5283e53 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1250,8 +1250,8 @@ int main(int argc, char* argv[]) // match it against the @ format if (strlen(argv[i]) > 45 && is_hex(argv[i], 40) - && (string_begins_no_case(argv[i] + 40, "@http://") - || string_begins_no_case(argv[i] + 40, "@udp://"))) + && (strncmp(argv[i] + 40, "@http://", 8) == 0 + || strncmp(argv[i] + 40, "@udp://", 7) == 0)) { sha1_hash info_hash; from_hex(argv[i], 40, (char*)&info_hash[0]); @@ -1488,18 +1488,13 @@ int main(int argc, char* argv[]) std::vector buf; if (std::strstr(i->c_str(), "magnet:") == i->c_str()) { - std::string btih = url_has_argument(*i, "xt"); - if (btih.empty()) continue; + add_torrent_params tmp; + parse_magnet_uri(*i, tmp, ec); - if (btih.compare(0, 9, "urn:btih:") != 0) - 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))); + if (ec) continue; 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) p.resume_data = &buf; @@ -1864,8 +1859,11 @@ int main(int argc, char* argv[]) feed_status st = i->get_feed_status(); 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() - , st.updating ? "updating" : to_string(st.next_update).elems + , st.updating ? "updating" : update_timer , int(st.items.size()) , st.error ? st.error.message().c_str() : ""); out += str; diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 3a2989f19..bb4baeea5 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -125,7 +125,7 @@ namespace libtorrent { ptime m_timestamp; }; - class TORRENT_EXPORT alert_manager + class TORRENT_EXTRA_EXPORT alert_manager { public: alert_manager(io_service& ios, int queue_limit diff --git a/include/libtorrent/allocator.hpp b/include/libtorrent/allocator.hpp index 2a52320ce..10ed517de 100644 --- a/include/libtorrent/allocator.hpp +++ b/include/libtorrent/allocator.hpp @@ -39,9 +39,9 @@ POSSIBILITY OF SUCH DAMAGE. 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::ptrdiff_t difference_type; @@ -50,7 +50,7 @@ namespace libtorrent static void free(char* const block); }; - struct TORRENT_EXPORT aligned_holder + struct TORRENT_EXTRA_EXPORT aligned_holder { aligned_holder(): m_buf(0) {} aligned_holder(int size): m_buf(page_aligned_allocator::malloc(size)) {} diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 06113baf4..6f847a088 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -181,7 +181,7 @@ namespace libtorrent // this is the link between the main thread and the // 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 { #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING diff --git a/include/libtorrent/bandwidth_limit.hpp b/include/libtorrent/bandwidth_limit.hpp index 727f0c8a3..4cffe514c 100644 --- a/include/libtorrent/bandwidth_limit.hpp +++ b/include/libtorrent/bandwidth_limit.hpp @@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { // member of peer_connection -struct TORRENT_EXPORT bandwidth_channel +struct TORRENT_EXTRA_EXPORT bandwidth_channel { static const int inf = boost::integer_traits::const_max; diff --git a/include/libtorrent/bandwidth_manager.hpp b/include/libtorrent/bandwidth_manager.hpp index 5dc85c959..95220eeae 100644 --- a/include/libtorrent/bandwidth_manager.hpp +++ b/include/libtorrent/bandwidth_manager.hpp @@ -54,7 +54,7 @@ using boost::intrusive_ptr; namespace libtorrent { -struct TORRENT_EXPORT bandwidth_manager +struct TORRENT_EXTRA_EXPORT bandwidth_manager { bandwidth_manager(int channel #ifdef TORRENT_VERBOSE_BANDWIDTH_LIMIT diff --git a/include/libtorrent/bandwidth_queue_entry.hpp b/include/libtorrent/bandwidth_queue_entry.hpp index 82c4d9dfd..6a9c72a45 100644 --- a/include/libtorrent/bandwidth_queue_entry.hpp +++ b/include/libtorrent/bandwidth_queue_entry.hpp @@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -struct TORRENT_EXPORT bw_request +struct TORRENT_EXTRA_EXPORT bw_request { bw_request(boost::intrusive_ptr const& pe , int blk, int prio); diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index 126b7014f..f5bc2d92e 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -100,7 +100,7 @@ namespace libtorrent 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 int write_integer(OutIt& out, entry::integer_type val) diff --git a/include/libtorrent/bloom_filter.hpp b/include/libtorrent/bloom_filter.hpp index 64de92ca1..fb86c0576 100644 --- a/include/libtorrent/bloom_filter.hpp +++ b/include/libtorrent/bloom_filter.hpp @@ -41,9 +41,9 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - TORRENT_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_EXPORT int count_zero_bits(boost::uint8_t const* bits, int len); + TORRENT_EXTRA_EXPORT void set_bits(boost::uint8_t const* b, boost::uint8_t* bits, int len); + TORRENT_EXTRA_EXPORT bool has_bits(boost::uint8_t const* b, boost::uint8_t const* bits, int len); + TORRENT_EXTRA_EXPORT int count_zero_bits(boost::uint8_t const* bits, int len); template struct bloom_filter diff --git a/include/libtorrent/broadcast_socket.hpp b/include/libtorrent/broadcast_socket.hpp index 56021294e..f5763861e 100644 --- a/include/libtorrent/broadcast_socket.hpp +++ b/include/libtorrent/broadcast_socket.hpp @@ -50,12 +50,12 @@ namespace libtorrent TORRENT_EXPORT bool is_multicast(address const& addr); TORRENT_EXPORT bool is_any(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 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); TORRENT_EXPORT address guess_local_address(io_service&); @@ -63,7 +63,7 @@ namespace libtorrent typedef boost::function receive_handler_t; - class TORRENT_EXPORT broadcast_socket + class TORRENT_EXTRA_EXPORT broadcast_socket { public: broadcast_socket(io_service& ios, udp::endpoint const& multicast_endpoint diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 971581e3a..86ba9f49d 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -76,7 +76,7 @@ namespace libtorrent struct session_impl; } - class TORRENT_EXPORT bt_peer_connection + class TORRENT_EXTRA_EXPORT bt_peer_connection : public peer_connection { friend class invariant_access; diff --git a/include/libtorrent/chained_buffer.hpp b/include/libtorrent/chained_buffer.hpp index c1698ee3b..6f68f846b 100644 --- a/include/libtorrent/chained_buffer.hpp +++ b/include/libtorrent/chained_buffer.hpp @@ -50,7 +50,7 @@ namespace libtorrent #if BOOST_VERSION >= 103500 namespace asio = boost::asio; #endif - struct TORRENT_EXPORT chained_buffer + struct TORRENT_EXTRA_EXPORT chained_buffer { chained_buffer(): m_bytes(0), m_capacity(0) { diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index f484ef894..dbb0abbdc 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -66,6 +66,20 @@ POSSIBILITY OF SUCH DAMAGE. # define TORRENT_EXPORT BOOST_SYMBOL_IMPORT #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 ========= #if defined __GNUC__ @@ -200,13 +214,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_USE_ICONV #define TORRENT_USE_ICONV 0 #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 === #elif defined __GNU__ diff --git a/include/libtorrent/connection_queue.hpp b/include/libtorrent/connection_queue.hpp index e17e7a841..ee8875668 100644 --- a/include/libtorrent/connection_queue.hpp +++ b/include/libtorrent/connection_queue.hpp @@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -class TORRENT_EXPORT connection_queue : public boost::noncopyable +class TORRENT_EXTRA_EXPORT connection_queue : public boost::noncopyable { public: connection_queue(io_service& ios); diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index a7412665c..14631be13 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -190,54 +190,9 @@ namespace libtorrent int TORRENT_EXPORT get_file_attributes(std::string const& p); std::string TORRENT_EXPORT get_symlink_path(std::string const& p); - template - void add_files_impl(file_storage& fs, std::string const& p - , std::string const& l, Pred 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); - } - } - } + TORRENT_EXPORT void add_files_impl(file_storage& fs, std::string const& p + , std::string const& l, boost::function pred + , boost::uint32_t flags); } template @@ -252,75 +207,8 @@ namespace libtorrent , detail::default_pred, flags); } - 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; - }; - - template - void set_piece_hashes(create_torrent& t, std::string const& p, Fun f - , error_code& ec) - { - file_pool fp; - boost::scoped_ptr st( - default_storage_constructor(const_cast(t.files()), 0, p, fp - , std::vector())); - - // 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); - } - } + TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::string const& p + , boost::function f, error_code& ec); #ifndef BOOST_NO_EXCEPTIONS template diff --git a/include/libtorrent/disk_buffer_holder.hpp b/include/libtorrent/disk_buffer_holder.hpp index e342f1185..376531e49 100644 --- a/include/libtorrent/disk_buffer_holder.hpp +++ b/include/libtorrent/disk_buffer_holder.hpp @@ -43,7 +43,7 @@ namespace libtorrent namespace aux { struct session_impl; } 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(disk_buffer_pool& disk_pool, char* buf); diff --git a/include/libtorrent/disk_buffer_pool.hpp b/include/libtorrent/disk_buffer_pool.hpp index c9d1cbbb2..017d9b178 100644 --- a/include/libtorrent/disk_buffer_pool.hpp +++ b/include/libtorrent/disk_buffer_pool.hpp @@ -48,7 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. 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); #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index c8c946452..76ab86a4e 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -225,7 +225,7 @@ namespace libtorrent // this is a singleton consisting of the thread and a queue // 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 , boost::function const& queue_callback diff --git a/include/libtorrent/escape_string.hpp b/include/libtorrent/escape_string.hpp index 5aa7163a7..5be3dbe4a 100644 --- a/include/libtorrent/escape_string.hpp +++ b/include/libtorrent/escape_string.hpp @@ -42,57 +42,57 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - TORRENT_EXPORT boost::array::digits10> to_string(size_type n); - TORRENT_EXPORT bool is_alpha(char c); - TORRENT_EXPORT bool is_digit(char c); - TORRENT_EXPORT bool is_print(char c); - TORRENT_EXPORT bool is_space(char c); - TORRENT_EXPORT char to_lower(char c); + TORRENT_EXTRA_EXPORT boost::array::digits10> to_string(size_type n); + TORRENT_EXTRA_EXPORT bool is_alpha(char c); + TORRENT_EXTRA_EXPORT bool is_digit(char c); + TORRENT_EXTRA_EXPORT bool is_print(char c); + TORRENT_EXTRA_EXPORT bool is_space(char c); + TORRENT_EXTRA_EXPORT char to_lower(char c); - TORRENT_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_EXPORT bool string_equal_no_case(char const* s1, char const* s2); + TORRENT_EXTRA_EXPORT int split_string(char const** tags, int buf_size, char* in); + TORRENT_EXTRA_EXPORT bool string_begins_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 - 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 '/' - 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 // 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 - TORRENT_EXPORT std::string base64encode(std::string const& s); - TORRENT_EXPORT std::string base64decode(std::string const& s); + TORRENT_EXTRA_EXPORT std::string base64encode(std::string const& s); + TORRENT_EXTRA_EXPORT std::string base64decode(std::string const& s); // encodes a string using the base32 scheme - TORRENT_EXPORT std::string base32encode(std::string const& s); - TORRENT_EXPORT std::string base32decode(std::string const& s); + TORRENT_EXTRA_EXPORT std::string base32encode(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); // 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_EXPORT std::string to_hex(std::string const& s); - TORRENT_EXPORT bool is_hex(char const *in, int len); - TORRENT_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 std::string read_until(char const*& str, char delim, char const* end); + TORRENT_EXTRA_EXPORT std::string to_hex(std::string const& s); + TORRENT_EXTRA_EXPORT bool is_hex(char const *in, int len); + TORRENT_EXTRA_EXPORT void to_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 - TORRENT_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::wstring convert_to_wstring(std::string const& s); + TORRENT_EXTRA_EXPORT std::string convert_from_wstring(std::wstring const& s); #endif #if TORRENT_USE_ICONV || TORRENT_USE_LOCALE - TORRENT_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_to_native(std::string const& s); + TORRENT_EXTRA_EXPORT std::string convert_from_native(std::string const& s); #else 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; } diff --git a/include/libtorrent/gzip.hpp b/include/libtorrent/gzip.hpp index 2db984c2e..a871954da 100644 --- a/include/libtorrent/gzip.hpp +++ b/include/libtorrent/gzip.hpp @@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - TORRENT_EXPORT bool inflate_gzip( + TORRENT_EXTRA_EXPORT bool inflate_gzip( char const* in, int size , std::vector& buffer , int maximum_size diff --git a/include/libtorrent/hasher.hpp b/include/libtorrent/hasher.hpp index 158ca984f..b5e13d510 100644 --- a/include/libtorrent/hasher.hpp +++ b/include/libtorrent/hasher.hpp @@ -48,16 +48,16 @@ extern "C" } #else // from sha1.cpp -struct TORRENT_EXPORT SHA_CTX +struct TORRENT_EXTRA_EXPORT SHA_CTX { boost::uint32_t state[5]; boost::uint32_t count[2]; boost::uint8_t buffer[64]; }; -TORRENT_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_EXPORT void SHA1_Final(boost::uint8_t* digest, SHA_CTX* context); +TORRENT_EXTRA_EXPORT void SHA1_Init(SHA_CTX* context); +TORRENT_EXTRA_EXPORT void SHA1_Update(SHA_CTX* context, boost::uint8_t const* data, boost::uint32_t len); +TORRENT_EXTRA_EXPORT void SHA1_Final(boost::uint8_t* digest, SHA_CTX* context); #endif diff --git a/include/libtorrent/instantiate_connection.hpp b/include/libtorrent/instantiate_connection.hpp index 19f0a5460..cd19d2ef9 100644 --- a/include/libtorrent/instantiate_connection.hpp +++ b/include/libtorrent/instantiate_connection.hpp @@ -45,7 +45,7 @@ namespace libtorrent // if from is specified, a new socket will be created // using the same underlying socket object as 'from'. // 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 , void* ssl_context = 0 , utp_socket_manager* sm = 0 diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index f7a57cd06..846b6b7e3 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -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 table_t; typedef std::map dht_immutable_table_t; diff --git a/include/libtorrent/kademlia/node_id.hpp b/include/libtorrent/kademlia/node_id.hpp index d709422b2..fe906aad4 100644 --- a/include/libtorrent/kademlia/node_id.hpp +++ b/include/libtorrent/kademlia/node_id.hpp @@ -47,19 +47,19 @@ typedef libtorrent::big_number node_id; // returns the distance between the two nodes // 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) -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) // 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_EXPORT generate_random_id(); +node_id TORRENT_EXTRA_EXPORT generate_id(address const& external_ip); +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 diff --git a/include/libtorrent/packet_buffer.hpp b/include/libtorrent/packet_buffer.hpp index a64562721..35f194d5a 100644 --- a/include/libtorrent/packet_buffer.hpp +++ b/include/libtorrent/packet_buffer.hpp @@ -66,7 +66,7 @@ namespace libtorrent // whenever the element at the cursor is removed, the // cursor is bumped to the next occupied element - class TORRENT_EXPORT packet_buffer + class TORRENT_EXTRA_EXPORT packet_buffer { public: typedef boost::uint32_t index_type; diff --git a/include/libtorrent/parse_url.hpp b/include/libtorrent/parse_url.hpp index 8b2698069..1e5284194 100644 --- a/include/libtorrent/parse_url.hpp +++ b/include/libtorrent/parse_url.hpp @@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - TORRENT_EXPORT boost::tuple parse_url_components(std::string url, error_code& ec); diff --git a/include/libtorrent/pe_crypto.hpp b/include/libtorrent/pe_crypto.hpp index f2dc6696c..ca1cf046a 100644 --- a/include/libtorrent/pe_crypto.hpp +++ b/include/libtorrent/pe_crypto.hpp @@ -50,8 +50,8 @@ struct rc4 { unsigned char buf[256]; }; -void TORRENT_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); +void TORRENT_EXTRA_EXPORT rc4_init(const unsigned char* in, unsigned long len, rc4 *state); +unsigned long TORRENT_EXTRA_EXPORT rc4_encrypt(unsigned char *out, unsigned long outlen, rc4 *state); #endif #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 { - class TORRENT_EXPORT dh_key_exchange + class TORRENT_EXTRA_EXPORT dh_key_exchange { public: dh_key_exchange(); diff --git a/include/libtorrent/peer.hpp b/include/libtorrent/peer.hpp index c404a611d..3c75cc44e 100644 --- a/include/libtorrent/peer.hpp +++ b/include/libtorrent/peer.hpp @@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - struct TORRENT_EXPORT peer_entry + struct TORRENT_EXTRA_EXPORT peer_entry { std::string ip; int port; diff --git a/include/libtorrent/peer_request.hpp b/include/libtorrent/peer_request.hpp index 801a61770..0f7cf6e93 100644 --- a/include/libtorrent/peer_request.hpp +++ b/include/libtorrent/peer_request.hpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - struct TORRENT_EXPORT peer_request + struct TORRENT_EXTRA_EXPORT peer_request { int piece; int start; diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 1c2eec8d2..828bc1ed8 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -60,7 +60,7 @@ namespace libtorrent class peer_connection; struct bitfield; - struct TORRENT_EXPORT piece_block + struct TORRENT_EXTRA_EXPORT piece_block { const static piece_block invalid; @@ -90,7 +90,7 @@ namespace libtorrent }; - class TORRENT_EXPORT piece_picker + class TORRENT_EXTRA_EXPORT piece_picker { public: diff --git a/include/libtorrent/policy.hpp b/include/libtorrent/policy.hpp index 40d7ee03f..2c4d6ee52 100644 --- a/include/libtorrent/policy.hpp +++ b/include/libtorrent/policy.hpp @@ -102,7 +102,7 @@ namespace libtorrent void request_a_block(torrent& t, peer_connection& c); - class TORRENT_EXPORT policy + class TORRENT_EXTRA_EXPORT policy { public: @@ -165,7 +165,7 @@ namespace libtorrent // supports_holepunch // 43 1 1 // 44 - struct TORRENT_EXPORT peer + struct TORRENT_EXTRA_EXPORT peer { peer(boost::uint16_t port, bool connectable, int src); @@ -316,7 +316,7 @@ namespace libtorrent #endif }; - struct TORRENT_EXPORT ipv4_peer : peer + struct TORRENT_EXTRA_EXPORT ipv4_peer : peer { ipv4_peer(tcp::endpoint const& ip, bool connectable, int src); @@ -324,7 +324,7 @@ namespace libtorrent }; #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(); @@ -334,7 +334,7 @@ namespace libtorrent #endif #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); diff --git a/include/libtorrent/rsa.hpp b/include/libtorrent/rsa.hpp index 065b315b5..0455cc59a 100644 --- a/include/libtorrent/rsa.hpp +++ b/include/libtorrent/rsa.hpp @@ -41,19 +41,19 @@ namespace libtorrent // both of these use SHA-1 as the message digest to be signed/verified // 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* signature, int sig_len); // 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* signature, int sig_len); // returns false if it fails, for instance if the key // buffers are too small. public_len and private_len // 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); } diff --git a/include/libtorrent/socket_io.hpp b/include/libtorrent/socket_io.hpp index 73e78cd1f..e9b3f9848 100644 --- a/include/libtorrent/socket_io.hpp +++ b/include/libtorrent/socket_io.hpp @@ -47,7 +47,7 @@ namespace libtorrent TORRENT_EXPORT std::string print_endpoint(tcp::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 void hash_address(address const& ip, sha1_hash& h); + TORRENT_EXTRA_EXPORT void hash_address(address const& ip, sha1_hash& h); namespace detail { diff --git a/include/libtorrent/socket_type.hpp b/include/libtorrent/socket_type.hpp index 40f98426d..7de256d5e 100644 --- a/include/libtorrent/socket_type.hpp +++ b/include/libtorrent/socket_type.hpp @@ -170,7 +170,7 @@ namespace libtorrent { enum { value = 9 }; }; #endif - struct TORRENT_EXPORT socket_type + struct TORRENT_EXTRA_EXPORT socket_type { typedef stream_socket::endpoint_type endpoint_type; typedef stream_socket::protocol_type protocol_type; diff --git a/include/libtorrent/socks5_stream.hpp b/include/libtorrent/socks5_stream.hpp index 1d35561ba..55976cfc1 100644 --- a/include/libtorrent/socks5_stream.hpp +++ b/include/libtorrent/socks5_stream.hpp @@ -63,7 +63,7 @@ namespace libtorrent { typedef asio::error::error_category socks_error_category; #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 std::string message(int ev) const; diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index 4a7a849dd..7bd58ae66 100644 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - class TORRENT_EXPORT stat_channel + class TORRENT_EXTRA_EXPORT stat_channel { public: @@ -118,7 +118,7 @@ namespace libtorrent size_type m_total_counter; }; - class TORRENT_EXPORT stat + class TORRENT_EXTRA_EXPORT stat { friend class invariant_access; public: diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 6c4b5b375..8814aa651 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -72,26 +72,26 @@ namespace libtorrent struct disk_buffer_pool; struct session_settings; - TORRENT_EXPORT std::vector > get_filesizes( + TORRENT_EXTRA_EXPORT std::vector > get_filesizes( file_storage const& t , std::string const& p); - TORRENT_EXPORT bool match_filesizes( + TORRENT_EXTRA_EXPORT bool match_filesizes( file_storage const& t , std::string const& p , std::vector > const& sizes , bool compact_mode , 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) {} virtual const char* what() const throw() { return m_msg.c_str(); } virtual ~file_allocation_failed() throw() {} std::string m_msg; }; - - struct TORRENT_EXPORT partial_hash +*/ + struct TORRENT_EXTRA_EXPORT partial_hash { partial_hash(): offset(0) {} // the number of bytes in the piece that has been hashed @@ -285,7 +285,7 @@ namespace libtorrent struct disk_io_thread; - class TORRENT_EXPORT piece_manager + class TORRENT_EXTRA_EXPORT piece_manager : public intrusive_ptr_base , boost::noncopyable { diff --git a/include/libtorrent/thread.hpp b/include/libtorrent/thread.hpp index c59d546e6..6aceef31a 100644 --- a/include/libtorrent/thread.hpp +++ b/include/libtorrent/thread.hpp @@ -58,7 +58,7 @@ namespace libtorrent TORRENT_EXPORT void sleep(int milliseconds); - struct TORRENT_EXPORT condition + struct TORRENT_EXTRA_EXPORT condition { condition(); ~condition(); diff --git a/include/libtorrent/timestamp_history.hpp b/include/libtorrent/timestamp_history.hpp index 9de53fc1e..a8b9ec277 100644 --- a/include/libtorrent/timestamp_history.hpp +++ b/include/libtorrent/timestamp_history.hpp @@ -41,7 +41,7 @@ namespace libtorrent { // timestamp history keeps a history of the lowest timestamps we've // seen in the last 20 minutes -struct TORRENT_EXPORT timestamp_history +struct TORRENT_EXTRA_EXPORT timestamp_history { enum { history_size = 20 }; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index ec8a222c3..74e736309 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -106,7 +106,7 @@ namespace libtorrent // a torrent is a class that holds information // for a specific download. It updates itself against // the tracker - class TORRENT_EXPORT torrent: public request_callback + class TORRENT_EXTRA_EXPORT torrent: public request_callback , public boost::enable_shared_from_this { public: diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 444378d97..1f9e4faff 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -76,9 +76,9 @@ namespace libtorrent namespace aux { struct session_impl; } // 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() : kind(announce_request) @@ -136,7 +136,7 @@ namespace libtorrent #endif }; - struct TORRENT_EXPORT request_callback + struct TORRENT_EXTRA_EXPORT request_callback { friend class tracker_manager; request_callback(): m_manager(0) {} @@ -174,7 +174,7 @@ namespace libtorrent tracker_manager* m_manager; }; - struct TORRENT_EXPORT timeout_handler + struct TORRENT_EXTRA_EXPORT timeout_handler : intrusive_ptr_base , boost::noncopyable { @@ -216,7 +216,7 @@ namespace libtorrent bool m_abort; }; - struct TORRENT_EXPORT tracker_connection + struct TORRENT_EXTRA_EXPORT tracker_connection : timeout_handler { tracker_connection(tracker_manager& man @@ -263,7 +263,7 @@ namespace libtorrent const tracker_request m_req; }; - class TORRENT_EXPORT tracker_manager: boost::noncopyable + class TORRENT_EXTRA_EXPORT tracker_manager: boost::noncopyable { public: diff --git a/include/libtorrent/udp_tracker_connection.hpp b/include/libtorrent/udp_tracker_connection.hpp index 45b6b3db1..cd19b669c 100644 --- a/include/libtorrent/udp_tracker_connection.hpp +++ b/include/libtorrent/udp_tracker_connection.hpp @@ -61,7 +61,7 @@ namespace libtorrent { 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; public: diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index 10726e703..d9f60ee15 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -166,7 +166,7 @@ int socket_impl_size(); // will keep the utp_stream object around for. // for more details, see utp_socket_impl, which is analogous // 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: diff --git a/include/libtorrent/web_connection_base.hpp b/include/libtorrent/web_connection_base.hpp index 2aa01c28c..3b5fb57a3 100644 --- a/include/libtorrent/web_connection_base.hpp +++ b/include/libtorrent/web_connection_base.hpp @@ -81,7 +81,7 @@ namespace libtorrent struct session_impl; } - class TORRENT_EXPORT web_connection_base + class TORRENT_EXTRA_EXPORT web_connection_base : public peer_connection { friend class invariant_access; diff --git a/include/libtorrent/web_peer_connection.hpp b/include/libtorrent/web_peer_connection.hpp index be7047f41..3ff731802 100644 --- a/include/libtorrent/web_peer_connection.hpp +++ b/include/libtorrent/web_peer_connection.hpp @@ -70,7 +70,7 @@ namespace libtorrent struct session_impl; } - class TORRENT_EXPORT web_peer_connection + class TORRENT_EXTRA_EXPORT web_peer_connection : public web_connection_base { friend class invariant_access; diff --git a/src/Makefile.am b/src/Makefile.am index 357077ac9..edbf569d8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,10 @@ if WITH_SHIPPED_GEOIP GEOIP_SOURCES = GeoIP.c endif +if WITH_OPENSSL +ASIO_OPENSSL_SOURCES = asio_ssl.cpp +endif + libtorrent_rasterbar_la_SOURCES = \ web_connection_base.cpp \ alert.cpp \ @@ -96,7 +100,8 @@ libtorrent_rasterbar_la_SOURCES = \ web_peer_connection.cpp \ \ $(KADEMLIA_SOURCES) \ - $(GEOIP_SOURCES) + $(GEOIP_SOURCES) \ + $(ASIO_OPENSSL_SOURCES) #libtorrent_rasterbar_la_LDFLAGS = $(LDFLAGS) -version-info $(INTERFACE_VERSION_INFO) libtorrent_rasterbar_la_LDFLAGS = -version-info $(INTERFACE_VERSION_INFO) diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 1b584e6ac..0d29a6e8f 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -102,6 +102,122 @@ namespace libtorrent #endif } + void add_files_impl(file_storage& fs, std::string const& p + , std::string const& l, boost::function 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 f + , error_code& ec) + { + file_pool fp; + boost::scoped_ptr st( + default_storage_constructor(const_cast(t.files()), 0, p, fp + , std::vector())); + + // 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) diff --git a/test/Jamfile b/test/Jamfile index 8bd898ef4..51777d6cc 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -9,7 +9,7 @@ explicit test_natpmp ; project : requirements - /torrent//torrent/shared/shared + /torrent//torrent/shared/shared/on main.cpp setup_transfer.cpp : default-build diff --git a/test/test_rss.cpp b/test/test_rss.cpp index bb732b8e7..3a1631f59 100644 --- a/test/test_rss.cpp +++ b/test/test_rss.cpp @@ -124,7 +124,9 @@ void test_feed(std::string const& filename, rss_expect const& expect) f->save_state(state); fprintf(stderr, "feed_state:\n"); +#ifdef TORRENT_DEBUG state.print(std::cerr); +#endif // TODO: verify some key state is saved in 'state' }