forked from premiere/premiere-libtorrent
fix build and some warnings
This commit is contained in:
parent
820fde5066
commit
4fd230dbe5
|
@ -103,10 +103,6 @@ namespace libtorrent
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
// this is used in the template, so it must be available to the client
|
|
||||||
TORRENT_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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -363,6 +363,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TORRENT_UNUSED(x) (void)(x)
|
||||||
|
|
||||||
#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW
|
#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
|
@ -296,6 +296,12 @@ namespace libtorrent
|
||||||
mutable boost::uint8_t m_type_queried:1;
|
mutable boost::uint8_t m_type_queried:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
TORRENT_EXPORT char const* integer_to_str(char* buf, int size
|
||||||
|
, entry::integer_type val);
|
||||||
|
}
|
||||||
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
#if TORRENT_USE_IOSTREAM
|
||||||
// prints the bencoded structure to the ostream as a JSON-style structure.
|
// prints the bencoded structure to the ostream as a JSON-style structure.
|
||||||
inline std::ostream& operator<<(std::ostream& os, const entry& e)
|
inline std::ostream& operator<<(std::ostream& os, const entry& e)
|
||||||
|
|
|
@ -392,8 +392,10 @@ namespace libtorrent
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_suggest);
|
stats_counters().inc_stats_counter(counters::num_outgoing_suggest);
|
||||||
}
|
}
|
||||||
|
|
||||||
char random_byte()
|
namespace {
|
||||||
{ return random() & 0xff; }
|
char random_byte()
|
||||||
|
{ return random() & 0xff; }
|
||||||
|
}
|
||||||
|
|
||||||
void bt_peer_connection::get_specific_peer_info(peer_info& p) const
|
void bt_peer_connection::get_specific_peer_info(peer_info& p) const
|
||||||
{
|
{
|
||||||
|
@ -715,10 +717,12 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif // #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#endif // #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
||||||
|
|
||||||
void regular_c_free(char* buf, void* /* userdata */
|
namespace {
|
||||||
, block_cache_reference /* ref */)
|
void regular_c_free(char* buf, void* /* userdata */
|
||||||
{
|
, block_cache_reference /* ref */)
|
||||||
::free(buf);
|
{
|
||||||
|
::free(buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::append_const_send_buffer(char const* buffer, int size
|
void bt_peer_connection::append_const_send_buffer(char const* buffer, int size
|
||||||
|
@ -2426,6 +2430,8 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
void buffer_reclaim_block(char* /* buffer */, void* userdata
|
void buffer_reclaim_block(char* /* buffer */, void* userdata
|
||||||
, block_cache_reference ref)
|
, block_cache_reference ref)
|
||||||
{
|
{
|
||||||
|
@ -2440,6 +2446,8 @@ namespace libtorrent
|
||||||
buf->free_disk_buffer(buffer);
|
buf->free_disk_buffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
void bt_peer_connection::write_piece(peer_request const& r, disk_buffer_holder& buffer)
|
void bt_peer_connection::write_piece(peer_request const& r, disk_buffer_holder& buffer)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sse42_support = supports_sse42();
|
bool sse42_support = supports_sse42();
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
|
@ -436,6 +436,8 @@ namespace libtorrent
|
||||||
check_buffer_level(l);
|
check_buffer_level(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
boost::uint64_t physical_ram()
|
boost::uint64_t physical_ram()
|
||||||
{
|
{
|
||||||
boost::uint64_t ret = 0;
|
boost::uint64_t ret = 0;
|
||||||
|
@ -483,6 +485,8 @@ namespace libtorrent
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
void disk_buffer_pool::set_settings(aux::session_settings const& sett
|
void disk_buffer_pool::set_settings(aux::session_settings const& sett
|
||||||
, error_code& ec)
|
, error_code& ec)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,17 +30,24 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include "libtorrent/config.hpp"
|
||||||
|
|
||||||
|
#include "aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
#if TORRENT_USE_IOSTREAM
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
#include <algorithm>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
#include "aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
#include "libtorrent/entry.hpp"
|
#include "libtorrent/entry.hpp"
|
||||||
#include "libtorrent/config.hpp"
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
#include "libtorrent/lazy_entry.hpp"
|
#include "libtorrent/lazy_entry.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include "libtorrent/bdecode.hpp"
|
#include "libtorrent/bdecode.hpp"
|
||||||
|
#include "libtorrent/entry.hpp"
|
||||||
#include "libtorrent/hex.hpp"
|
#include "libtorrent/hex.hpp"
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
@ -61,7 +68,8 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
TORRENT_EXPORT char const* integer_to_str(char* buf, int size, entry::integer_type val)
|
TORRENT_EXPORT char const* integer_to_str(char* buf, int size
|
||||||
|
, entry::integer_type val)
|
||||||
{
|
{
|
||||||
int sign = 0;
|
int sign = 0;
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
|
|
|
@ -475,6 +475,8 @@ namespace libtorrent
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: 3 move the hex coding to its own .cpp file corresponding
|
||||||
|
// to the functions exported by hex.hpp
|
||||||
TORRENT_EXTRA_EXPORT int hex_to_int(char in)
|
TORRENT_EXTRA_EXPORT int hex_to_int(char in)
|
||||||
{
|
{
|
||||||
if (in >= '0' && in <= '9') return int(in) - '0';
|
if (in >= '0' && in <= '9') return int(in) - '0';
|
||||||
|
|
|
@ -123,6 +123,18 @@ namespace libtorrent
|
||||||
if (str2.size() != len) return false;
|
if (str2.size() != len) return false;
|
||||||
return memcmp(str2.c_str(), str, len) == 0;
|
return memcmp(str2.c_str(), str, len) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool compare_file_entry_size(internal_file_entry const& fe1
|
||||||
|
, internal_file_entry const& fe2)
|
||||||
|
{
|
||||||
|
return fe1.size < fe2.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool compare_file_offset(internal_file_entry const& lhs
|
||||||
|
, internal_file_entry const& rhs)
|
||||||
|
{
|
||||||
|
return lhs.offset < rhs.offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// path is not supposed to include the name of the torrent itself.
|
// path is not supposed to include the name of the torrent itself.
|
||||||
|
@ -352,14 +364,6 @@ namespace libtorrent
|
||||||
update_path_index(m_files[index], new_filename);
|
update_path_index(m_files[index], new_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
bool compare_file_offset(internal_file_entry const& lhs, internal_file_entry const& rhs)
|
|
||||||
{
|
|
||||||
return lhs.offset < rhs.offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
file_storage::iterator file_storage::file_at_offset_deprecated(boost::int64_t offset) const
|
file_storage::iterator file_storage::file_at_offset_deprecated(boost::int64_t offset) const
|
||||||
{
|
{
|
||||||
|
@ -889,9 +893,6 @@ namespace libtorrent
|
||||||
{ return at(i - m_files.begin()); }
|
{ return at(i - m_files.begin()); }
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
#endif // TORRENT_NO_DEPRECATE
|
||||||
|
|
||||||
bool compare_file_entry_size(internal_file_entry const& fe1, internal_file_entry const& fe2)
|
|
||||||
{ return fe1.size < fe2.size; }
|
|
||||||
|
|
||||||
void file_storage::reorder_file(int index, int dst)
|
void file_storage::reorder_file(int index, int dst)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(index < int(m_files.size()));
|
TORRENT_ASSERT(index < int(m_files.size()));
|
||||||
|
|
|
@ -109,6 +109,8 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
// 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
|
||||||
int gzip_header(const char* buf, int size)
|
int gzip_header(const char* buf, int size)
|
||||||
{
|
{
|
||||||
|
@ -182,6 +184,7 @@ namespace libtorrent
|
||||||
|
|
||||||
return total_size - size;
|
return total_size - size;
|
||||||
}
|
}
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT void inflate_gzip(
|
TORRENT_EXTRA_EXPORT void inflate_gzip(
|
||||||
char const* in
|
char const* in
|
||||||
|
|
|
@ -67,11 +67,10 @@ namespace libtorrent
|
||||||
if (error_pos) *error_pos = start - orig_start;
|
if (error_pos) *error_pos = start - orig_start;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#define TORRENT_FAIL_BDECODE(code) do { ec = make_error_code(code); return fail(error_pos, stack, start, orig_start); } while (false)
|
#define TORRENT_FAIL_BDECODE(code) do { ec = make_error_code(code); return fail(error_pos, stack, start, orig_start); } while (false)
|
||||||
|
|
||||||
namespace { bool numeric(char c) { return c >= '0' && c <= '9'; } }
|
bool numeric(char c) { return c >= '0' && c <= '9'; }
|
||||||
|
|
||||||
char const* find_char(char const* start, char const* end, char delimiter)
|
char const* find_char(char const* start, char const* end, char delimiter)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +78,8 @@ namespace libtorrent
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
int lazy_bdecode(char const* start, char const* end
|
int lazy_bdecode(char const* start, char const* end
|
||||||
, lazy_entry& ret, int depth_limit, int item_limit)
|
, lazy_entry& ret, int depth_limit, int item_limit)
|
||||||
|
@ -170,10 +171,10 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
case 'd':
|
case 'd':
|
||||||
top->construct_dict(start - 1);
|
top->construct_dict(start - 1);
|
||||||
continue;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
top->construct_list(start - 1);
|
top->construct_list(start - 1);
|
||||||
continue;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
char const* int_start = start;
|
char const* int_start = start;
|
||||||
|
@ -183,7 +184,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(*start == 'e');
|
TORRENT_ASSERT(*start == 'e');
|
||||||
++start;
|
++start;
|
||||||
stack.pop_back();
|
stack.pop_back();
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
@ -204,10 +205,9 @@ namespace libtorrent
|
||||||
top->construct_string(start, int(len));
|
top->construct_string(start, int(len));
|
||||||
stack.pop_back();
|
stack.pop_back();
|
||||||
start += len;
|
start += len;
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -477,6 +477,8 @@ namespace libtorrent
|
||||||
return return_t(m_begin, m_len);
|
return return_t(m_begin, m_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
int line_longer_than(lazy_entry const& e, int limit)
|
int line_longer_than(lazy_entry const& e, int limit)
|
||||||
{
|
{
|
||||||
int line_len = 0;
|
int line_len = 0;
|
||||||
|
@ -580,6 +582,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
ret += "'";
|
ret += "'";
|
||||||
}
|
}
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
std::string print_entry(lazy_entry const& e, bool single_line, int indent)
|
std::string print_entry(lazy_entry const& e, bool single_line, int indent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,11 +97,15 @@ namespace libtorrent
|
||||||
min_request_queue = 2,
|
min_request_queue = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
bool pending_block_in_buffer(pending_block const& pb)
|
bool pending_block_in_buffer(pending_block const& pb)
|
||||||
{
|
{
|
||||||
return pb.send_buffer_offset != pending_block::not_in_buffer;
|
return pb.send_buffer_offset != pending_block::not_in_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#if defined TORRENT_REQUEST_LOGGING
|
#if defined TORRENT_REQUEST_LOGGING
|
||||||
void write_request_log(FILE* f, sha1_hash const& ih
|
void write_request_log(FILE* f, sha1_hash const& ih
|
||||||
, peer_connection* p, peer_request const& r)
|
, peer_connection* p, peer_request const& r)
|
||||||
|
@ -1398,6 +1402,8 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
bool match_request(peer_request const& r, piece_block const& b, int block_size)
|
bool match_request(peer_request const& r, piece_block const& b, int block_size)
|
||||||
{
|
{
|
||||||
if (int(b.piece_index) != r.piece) return false;
|
if (int(b.piece_index) != r.piece) return false;
|
||||||
|
@ -1405,6 +1411,7 @@ namespace libtorrent
|
||||||
if (r.start % block_size != 0) return false;
|
if (r.start % block_size != 0) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// -------- REJECT PIECE -------
|
// -------- REJECT PIECE -------
|
||||||
|
@ -5673,11 +5680,13 @@ namespace libtorrent
|
||||||
, userdata, ref);
|
, userdata, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
void session_free_buffer(char* buffer, void* userdata, block_cache_reference)
|
void session_free_buffer(char* buffer, void* userdata, block_cache_reference)
|
||||||
{
|
{
|
||||||
aux::session_interface* ses = (aux::session_interface*)userdata;
|
aux::session_interface* ses = (aux::session_interface*)userdata;
|
||||||
ses->free_buffer(buffer);
|
ses->free_buffer(buffer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void peer_connection::send_buffer(char const* buf, int size, int flags)
|
void peer_connection::send_buffer(char const* buf, int size, int flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,10 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
int round_up8(int v)
|
namespace {
|
||||||
{
|
int round_up8(int v)
|
||||||
return ((v & 7) == 0) ? v : v + (8 - (v & 7));
|
{
|
||||||
}
|
return ((v & 7) == 0) ? v : v + (8 - (v & 7));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int receive_buffer::max_receive()
|
int receive_buffer::max_receive()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3219,6 +3219,7 @@ retry:
|
||||||
// m_peer_pool.release_memory();
|
// m_peer_pool.release_memory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
// returns the index of the first set bit.
|
// returns the index of the first set bit.
|
||||||
int log2(boost::uint32_t v)
|
int log2(boost::uint32_t v)
|
||||||
{
|
{
|
||||||
|
@ -3238,6 +3239,8 @@ retry:
|
||||||
return MultiplyDeBruijnBitPosition[boost::uint32_t(v * 0x07C4ACDDU) >> 27];
|
return MultiplyDeBruijnBitPosition[boost::uint32_t(v * 0x07C4ACDDU) >> 27];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
void session_impl::received_buffer(int s)
|
void session_impl::received_buffer(int s)
|
||||||
{
|
{
|
||||||
int index = (std::min)(log2(s >> 3), 17);
|
int index = (std::min)(log2(s >> 3), 17);
|
||||||
|
@ -5376,10 +5379,13 @@ retry:
|
||||||
void session_impl::start_dht()
|
void session_impl::start_dht()
|
||||||
{ start_dht(m_dht_state); }
|
{ start_dht(m_dht_state); }
|
||||||
|
|
||||||
void on_bootstrap(alert_manager& alerts)
|
namespace {
|
||||||
{
|
|
||||||
if (alerts.should_post<dht_bootstrap_alert>())
|
void on_bootstrap(alert_manager& alerts)
|
||||||
alerts.emplace_alert<dht_bootstrap_alert>();
|
{
|
||||||
|
if (alerts.should_post<dht_bootstrap_alert>())
|
||||||
|
alerts.emplace_alert<dht_bootstrap_alert>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::start_dht(entry const& startup_state)
|
void session_impl::start_dht(entry const& startup_state)
|
||||||
|
@ -5496,11 +5502,31 @@ retry:
|
||||||
, this, _1), salt);
|
, this, _1), salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_dht_put(alert_manager& alerts, sha1_hash target)
|
namespace {
|
||||||
{
|
|
||||||
if (alerts.should_post<dht_put_alert>())
|
void on_dht_put(alert_manager& alerts, sha1_hash target)
|
||||||
alerts.emplace_alert<dht_put_alert>(target);
|
{
|
||||||
}
|
if (alerts.should_post<dht_put_alert>())
|
||||||
|
alerts.emplace_alert<dht_put_alert>(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
void put_mutable_callback(alert_manager& alerts, dht::item& i
|
||||||
|
, boost::function<void(entry&, boost::array<char,64>&
|
||||||
|
, boost::uint64_t&, std::string const&)> cb)
|
||||||
|
{
|
||||||
|
entry value = i.value();
|
||||||
|
boost::array<char, 64> sig = i.sig();
|
||||||
|
boost::array<char, 32> pk = i.pk();
|
||||||
|
boost::uint64_t seq = i.seq();
|
||||||
|
std::string salt = i.salt();
|
||||||
|
cb(value, sig, seq, salt);
|
||||||
|
i.assign(value, salt, seq, pk.data(), sig.data());
|
||||||
|
|
||||||
|
if (alerts.should_post<dht_put_alert>())
|
||||||
|
alerts.emplace_alert<dht_put_alert>(pk, sig, salt, seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
void session_impl::dht_put_item(entry data, sha1_hash target)
|
void session_impl::dht_put_item(entry data, sha1_hash target)
|
||||||
{
|
{
|
||||||
|
@ -5509,22 +5535,6 @@ retry:
|
||||||
, target));
|
, target));
|
||||||
}
|
}
|
||||||
|
|
||||||
void put_mutable_callback(alert_manager& alerts, dht::item& i
|
|
||||||
, boost::function<void(entry&, boost::array<char,64>&
|
|
||||||
, boost::uint64_t&, std::string const&)> cb)
|
|
||||||
{
|
|
||||||
entry value = i.value();
|
|
||||||
boost::array<char, 64> sig = i.sig();
|
|
||||||
boost::array<char, 32> pk = i.pk();
|
|
||||||
boost::uint64_t seq = i.seq();
|
|
||||||
std::string salt = i.salt();
|
|
||||||
cb(value, sig, seq, salt);
|
|
||||||
i.assign(value, salt, seq, pk.data(), sig.data());
|
|
||||||
|
|
||||||
if (alerts.should_post<dht_put_alert>())
|
|
||||||
alerts.emplace_alert<dht_put_alert>(pk, sig, salt, seq);
|
|
||||||
}
|
|
||||||
|
|
||||||
void session_impl::dht_put_mutable_item(boost::array<char, 32> key
|
void session_impl::dht_put_mutable_item(boost::array<char, 32> key
|
||||||
, boost::function<void(entry&, boost::array<char,64>&
|
, boost::function<void(entry&, boost::array<char,64>&
|
||||||
, boost::uint64_t&, std::string const&)> cb
|
, boost::uint64_t&, std::string const&)> cb
|
||||||
|
|
|
@ -64,6 +64,7 @@ namespace libtorrent
|
||||||
};
|
};
|
||||||
#undef CASE
|
#undef CASE
|
||||||
#else
|
#else
|
||||||
|
TORRENT_UNUSED(s);
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -94,7 +95,8 @@ namespace libtorrent
|
||||||
// for SSL connections, make sure to authenticate the hostname
|
// for SSL connections, make sure to authenticate the hostname
|
||||||
// of the certificate
|
// of the certificate
|
||||||
#define CASE(t) case socket_type_int_impl<ssl_stream<t> >::value: \
|
#define CASE(t) case socket_type_int_impl<ssl_stream<t> >::value: \
|
||||||
s.get<ssl_stream<t> >()->set_verify_callback(asio::ssl::rfc2818_verification(hostname), ec); \
|
s.get<ssl_stream<t> >()->set_verify_callback( \
|
||||||
|
asio::ssl::rfc2818_verification(hostname), ec); \
|
||||||
ctx = SSL_get_SSL_CTX(s.get<ssl_stream<t> >()->native_handle()); \
|
ctx = SSL_get_SSL_CTX(s.get<ssl_stream<t> >()->native_handle()); \
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -116,11 +118,16 @@ namespace libtorrent
|
||||||
SSL_CTX_set_tlsext_servername_arg(ctx, 0);
|
SSL_CTX_set_tlsext_servername_arg(ctx, 0);
|
||||||
}
|
}
|
||||||
#endif // OPENSSL_VERSION_NUMBER
|
#endif // OPENSSL_VERSION_NUMBER
|
||||||
|
#else
|
||||||
|
TORRENT_UNUSED(ec);
|
||||||
|
TORRENT_UNUSED(hostname);
|
||||||
|
TORRENT_UNUSED(s);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_close_socket(socket_type* s, boost::shared_ptr<void> holder)
|
namespace {
|
||||||
|
|
||||||
|
void on_close_socket(socket_type* s, boost::shared_ptr<void>)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
#if defined TORRENT_ASIO_DEBUGGING
|
||||||
complete_async("on_close_socket");
|
complete_async("on_close_socket");
|
||||||
|
@ -129,6 +136,8 @@ namespace libtorrent
|
||||||
s->close(ec);
|
s->close(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
// the second argument is a shared pointer to an object that
|
// the second argument is a shared pointer to an object that
|
||||||
// will keep the socket (s) alive for the duration of the async operation
|
// will keep the socket (s) alive for the duration of the async operation
|
||||||
void async_shutdown(socket_type& s, boost::shared_ptr<void> holder)
|
void async_shutdown(socket_type& s, boost::shared_ptr<void> holder)
|
||||||
|
@ -158,6 +167,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#undef CASE
|
#undef CASE
|
||||||
#else
|
#else
|
||||||
|
TORRENT_UNUSED(holder);
|
||||||
s.close(e);
|
s.close(e);
|
||||||
#endif // TORRENT_USE_OPENSSL
|
#endif // TORRENT_USE_OPENSSL
|
||||||
}
|
}
|
||||||
|
@ -247,6 +257,8 @@ namespace libtorrent
|
||||||
new ((ssl_stream<utp_stream>*)m_data) ssl_stream<utp_stream>(m_io_service
|
new ((ssl_stream<utp_stream>*)m_data) ssl_stream<utp_stream>(m_io_service
|
||||||
, *((boost::asio::ssl::context*)userdata));
|
, *((boost::asio::ssl::context*)userdata));
|
||||||
break;
|
break;
|
||||||
|
#else
|
||||||
|
TORRENT_UNUSED(userdata);
|
||||||
#endif
|
#endif
|
||||||
default: TORRENT_ASSERT(false);
|
default: TORRENT_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/time.hpp"
|
||||||
|
#include "libtorrent/aux_/time.hpp"
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -80,6 +80,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
bool valid_path_character(char c)
|
bool valid_path_character(char c)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_WINDOWS
|
#ifdef TORRENT_WINDOWS
|
||||||
|
@ -91,6 +93,8 @@ namespace libtorrent
|
||||||
return std::strchr(invalid_chars, c) == 0;
|
return std::strchr(invalid_chars, c) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
// fixes invalid UTF-8 sequences and
|
// fixes invalid UTF-8 sequences and
|
||||||
// replaces characters that are invalid
|
// replaces characters that are invalid
|
||||||
// in paths
|
// in paths
|
||||||
|
@ -360,6 +364,8 @@ namespace libtorrent
|
||||||
if (path.empty()) path = "_";
|
if (path.empty()) path = "_";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
// 'top_level' is extracting the file for a single-file torrent. The
|
// 'top_level' is extracting the file for a single-file torrent. The
|
||||||
// distinction is that the filename is found in "name" rather than
|
// distinction is that the filename is found in "name" rather than
|
||||||
// "path"
|
// "path"
|
||||||
|
@ -572,6 +578,32 @@ namespace libtorrent
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int load_file(std::string const& filename, std::vector<char>& v
|
||||||
|
, error_code& ec, int limit = 8000000)
|
||||||
|
{
|
||||||
|
ec.clear();
|
||||||
|
file f;
|
||||||
|
if (!f.open(filename, file::read_only, ec)) return -1;
|
||||||
|
boost::int64_t s = f.get_size(ec);
|
||||||
|
if (ec) return -1;
|
||||||
|
if (s > limit)
|
||||||
|
{
|
||||||
|
ec = errors::metadata_too_large;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
v.resize((unsigned int)s);
|
||||||
|
if (s == 0) return 0;
|
||||||
|
file::iovec_t b = {&v[0], size_t(s) };
|
||||||
|
boost::int64_t read = f.readv(0, &b, 1, ec);
|
||||||
|
if (read != s) return -3;
|
||||||
|
if (ec) return -3;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
// TODO: 3 move the merkle functions out into its own file
|
||||||
|
// and header file
|
||||||
int merkle_get_parent(int tree_node)
|
int merkle_get_parent(int tree_node)
|
||||||
{
|
{
|
||||||
// node 0 doesn't have a parent
|
// node 0 doesn't have a parent
|
||||||
|
@ -603,27 +635,6 @@ namespace libtorrent
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_file(std::string const& filename, std::vector<char>& v, error_code& ec, int limit = 8000000)
|
|
||||||
{
|
|
||||||
ec.clear();
|
|
||||||
file f;
|
|
||||||
if (!f.open(filename, file::read_only, ec)) return -1;
|
|
||||||
boost::int64_t s = f.get_size(ec);
|
|
||||||
if (ec) return -1;
|
|
||||||
if (s > limit)
|
|
||||||
{
|
|
||||||
ec = errors::metadata_too_large;
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
v.resize((unsigned int)s);
|
|
||||||
if (s == 0) return 0;
|
|
||||||
file::iovec_t b = {&v[0], size_t(s) };
|
|
||||||
boost::int64_t read = f.readv(0, &b, 1, ec);
|
|
||||||
if (read != s) return -3;
|
|
||||||
if (ec) return -3;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
announce_entry::announce_entry(std::string const& u)
|
announce_entry::announce_entry(std::string const& u)
|
||||||
: url(u)
|
: url(u)
|
||||||
, next_announce(min_time())
|
, next_announce(min_time())
|
||||||
|
@ -1470,6 +1481,9 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
|
|
||||||
|
// TODO: 3 this function is used in other translation units. Make sure
|
||||||
|
// it's declared in an appropriate header.
|
||||||
bool is_i2p_url(std::string const& url)
|
bool is_i2p_url(std::string const& url)
|
||||||
{
|
{
|
||||||
using boost::tuples::ignore;
|
using boost::tuples::ignore;
|
||||||
|
@ -1480,6 +1494,7 @@ namespace libtorrent
|
||||||
char const* top_domain = strrchr(hostname.c_str(), '.');
|
char const* top_domain = strrchr(hostname.c_str(), '.');
|
||||||
return top_domain && strcmp(top_domain, ".i2p") == 0;
|
return top_domain && strcmp(top_domain, ".i2p") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool torrent_info::parse_torrent_file(bdecode_node const& torrent_file
|
bool torrent_info::parse_torrent_file(bdecode_node const& torrent_file
|
||||||
|
|
|
@ -39,13 +39,16 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
void apply_mask(boost::uint8_t* b, boost::uint8_t const* mask, int size)
|
namespace {
|
||||||
{
|
|
||||||
for (int i = 0; i < size; ++i)
|
void apply_mask(boost::uint8_t* b, boost::uint8_t const* mask, int size)
|
||||||
{
|
{
|
||||||
*b &= *mask;
|
for (int i = 0; i < size; ++i)
|
||||||
++b;
|
{
|
||||||
++mask;
|
*b &= *mask;
|
||||||
|
++b;
|
||||||
|
++mask;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue