bitfield.hpp   bitfield.hpp 
skipping to change at line 39 skipping to change at line 39
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef TORRENT_BITFIELD_HPP_INCLUDED #ifndef TORRENT_BITFIELD_HPP_INCLUDED
#define TORRENT_BITFIELD_HPP_INCLUDED #define TORRENT_BITFIELD_HPP_INCLUDED
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include <cstring> // for memset and memcpy #include <cstring> // for memset and memcpy
#include <cstdlib> // for malloc, free and realloc
namespace libtorrent namespace libtorrent
{ {
struct TORRENT_EXPORT bitfield struct TORRENT_EXPORT bitfield
{ {
bitfield(): m_bytes(0), m_size(0), m_own(false) {} bitfield(): m_bytes(0), m_size(0), m_own(false) {}
bitfield(int bits): m_bytes(0), m_size(0) bitfield(int bits): m_bytes(0), m_size(0)
{ resize(bits); } { resize(bits); }
bitfield(int bits, bool val): m_bytes(0), m_size(0) bitfield(int bits, bool val): m_bytes(0), m_size(0)
{ resize(bits, val); } { resize(bits, val); }
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 broadcast_socket.hpp   broadcast_socket.hpp 
skipping to change at line 72 skipping to change at line 72
class TORRENT_EXPORT broadcast_socket class TORRENT_EXPORT broadcast_socket
{ {
public: public:
broadcast_socket(io_service& ios, udp::endpoint const& multi cast_endpoint broadcast_socket(io_service& ios, udp::endpoint const& multi cast_endpoint
, receive_handler_t const& handler, bool loopback = true); , receive_handler_t const& handler, bool loopback = true);
~broadcast_socket() { close(); } ~broadcast_socket() { close(); }
void send(char const* buffer, int size, error_code& ec); void send(char const* buffer, int size, error_code& ec);
void close(); void close();
int num_send_sockets() const { return m_unicast_sockets.size (); } int num_send_sockets() const { return m_unicast_sockets.size (); }
void enable_ip_broadcast(bool e);
private: private:
struct socket_entry struct socket_entry
{ {
socket_entry(boost::shared_ptr<datagram_socket> cons socket_entry(boost::shared_ptr<datagram_socket> cons
t& s): socket(s) {} t& s)
: socket(s) {}
socket_entry(boost::shared_ptr<datagram_socket> cons
t& s
, address_v4 const& mask): socket(s), netmas
k(mask) {}
boost::shared_ptr<datagram_socket> socket; boost::shared_ptr<datagram_socket> socket;
char buffer[1024]; char buffer[1024];
udp::endpoint remote; udp::endpoint remote;
address_v4 netmask;
void close() void close()
{ {
if (!socket) return; if (!socket) return;
error_code ec; error_code ec;
socket->close(ec); socket->close(ec);
} }
address_v4 broadcast_address() const
{
error_code ec;
return address_v4::broadcast(socket->local_e
ndpoint(ec).address().to_v4(), netmask);
}
}; };
void on_receive(socket_entry* s, error_code const& ec void on_receive(socket_entry* s, error_code const& ec
, std::size_t bytes_transferred); , std::size_t bytes_transferred);
void open_unicast_socket(io_service& ios, address const& add void open_unicast_socket(io_service& ios, address const& add
r); r
, address_v4 const& mask);
void open_multicast_socket(io_service& ios, address const& a ddr void open_multicast_socket(io_service& ios, address const& a ddr
, bool loopback, error_code& ec); , bool loopback, error_code& ec);
// these sockets are used to // these sockets are used to
// join the multicast group (on each interface) // join the multicast group (on each interface)
// and receive multicast messages // and receive multicast messages
std::list<socket_entry> m_sockets; std::list<socket_entry> m_sockets;
// these sockets are not bound to any // these sockets are not bound to any
// specific port and are used to // specific port and are used to
// send messages to the multicast group // send messages to the multicast group
// and receive unicast responses // and receive unicast responses
std::list<socket_entry> m_unicast_sockets; std::list<socket_entry> m_unicast_sockets;
udp::endpoint m_multicast_endpoint; udp::endpoint m_multicast_endpoint;
receive_handler_t m_on_receive; receive_handler_t m_on_receive;
// if set, use IP broadcast as well as IP multicast
// this is off by default because it's expensive in
// terms of bandwidth usage
bool m_ip_broadcast;
}; };
} }
#endif #endif
 End of changes. 6 change blocks. 
4 lines changed or deleted 23 lines changed or added


 bt_peer_connection.hpp   bt_peer_connection.hpp 
skipping to change at line 279 skipping to change at line 279
// stream key (info hash of attached torrent) // stream key (info hash of attached torrent)
// secret is the DH shared secret // secret is the DH shared secret
// initializes m_RC4_handler // initializes m_RC4_handler
void init_pe_RC4_handler(char const* secret, sha1_hash const & stream_key); void init_pe_RC4_handler(char const* secret, sha1_hash const & stream_key);
public: public:
// these functions encrypt the send buffer if m_rc4_encrypte d // these functions encrypt the send buffer if m_rc4_encrypte d
// is true, otherwise it passes the call to the // is true, otherwise it passes the call to the
// peer_connection functions of the same names // peer_connection functions of the same names
virtual void append_const_send_buffer(char const* buffer, in t size);
void send_buffer(char const* buf, int size, int flags = 0); void send_buffer(char const* buf, int size, int flags = 0);
buffer::interval allocate_send_buffer(int size); buffer::interval allocate_send_buffer(int size);
template <class Destructor> template <class Destructor>
void append_send_buffer(char* buffer, int size, Destructor c onst& destructor) void append_send_buffer(char* buffer, int size, Destructor c onst& destructor)
{ {
#ifndef TORRENT_DISABLE_ENCRYPTION #ifndef TORRENT_DISABLE_ENCRYPTION
if (m_rc4_encrypted) if (m_rc4_encrypted)
{ {
TORRENT_ASSERT(send_buffer_size() == m_encry pted_bytes); TORRENT_ASSERT(send_buffer_size() == m_encry pted_bytes);
m_RC4_handler->encrypt(buffer, size); m_RC4_handler->encrypt(buffer, size);
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 create_torrent.hpp   create_torrent.hpp 
skipping to change at line 194 skipping to change at line 194
std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem: :wpath const& p); std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem: :wpath const& p);
#endif #endif
fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem:: path const& p); fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem:: path const& p);
#if TORRENT_USE_WPATH #if TORRENT_USE_WPATH
fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem:: wpath const& p); fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem:: wpath const& p);
#endif #endif
template <class Pred, class Str, class PathTraits> template <class Pred, class Str, class PathTraits>
void add_files_impl(file_storage& fs, boost::filesystem::bas ic_path<Str, PathTraits> const& p void add_files_impl(file_storage& fs, boost::filesystem::bas ic_path<Str, PathTraits> const& p
, boost::filesystem::basic_path<Str, PathTraits> con st& l, Pred pred) , boost::filesystem::basic_path<Str, PathTraits> con st& l, Pred pred, boost::uint32_t flags)
{ {
using boost::filesystem::basic_path; using boost::filesystem::basic_path;
using boost::filesystem::basic_directory_iterator; using boost::filesystem::basic_directory_iterator;
basic_path<Str, PathTraits> f(p / l); basic_path<Str, PathTraits> f(p / l);
if (!pred(f)) return; if (!pred(f)) return;
if (is_directory(f))
bool recurse = is_directory(f);
// if the file is not a link or we're following link
s, and it's a directory
// only then should we recurse
if ((is_symlink(f)) && (flags & create_torrent::syml
inks))
recurse = false;
if (recurse)
{ {
for (basic_directory_iterator<basic_path<Str , PathTraits> > i(f), end; i != end; ++i) for (basic_directory_iterator<basic_path<Str , PathTraits> > i(f), end; i != end; ++i)
{ {
#if BOOST_VERSION < 103600 #if BOOST_VERSION < 103600
Str const& leaf = i->path().leaf(); Str const& leaf = i->path().leaf();
#else #else
Str const& leaf = i->path().filename (); Str const& leaf = i->path().filename ();
#endif #endif
if (ignore_subdir(leaf)) continue; if (ignore_subdir(leaf)) continue;
add_files_impl(fs, p, l / leaf, pred ); add_files_impl(fs, p, l / leaf, pred , flags);
} }
} }
else else
{ {
int file_flags = get_file_attributes(f); int file_flags = get_file_attributes(f);
std::time_t mtime = get_file_mtime(f); std::time_t mtime = get_file_mtime(f);
//Masking all bits to check if the file is a symlink //Masking all bits to check if the file is a symlink
if(file_flags & file_storage::attribute_syml if ((file_flags & file_storage::attribute_sy
ink) mlink)
&& (flags & create_torrent::symlinks
))
{ {
fs::path sym_path = get_symlink_path (f); fs::path sym_path = get_symlink_path (f);
fs.add_file(l, 0 ,file_flags, mtime, sym_path); fs.add_file(l, 0 ,file_flags, mtime, sym_path);
} }
else else
{ {
fs.add_file(l, file_size(f), file_fl ags, mtime); fs.add_file(l, file_size(f), file_fl ags, mtime);
} }
} }
} }
} }
// path versions // path versions
template <class Pred> template <class Pred>
void add_files(file_storage& fs, boost::filesystem::path const& file void add_files(file_storage& fs, boost::filesystem::path const& file
, Pred p) , Pred p
, boost::uint32_t flags = 0)
{ {
using boost::filesystem::path; using boost::filesystem::path;
boost::filesystem::path f = file; boost::filesystem::path f = file;
#if BOOST_VERSION < 103600 #if BOOST_VERSION < 103600
if (f.leaf() == ".") f = f.branch_path(); if (f.leaf() == ".") f = f.branch_path();
detail::add_files_impl(fs, complete(f).branch_path(), path(f .leaf()), p); detail::add_files_impl(fs, complete(f).branch_path(), path(f .leaf()), p, flags);
#else #else
if (f.filename() == ".") f = f.parent_path(); if (f.filename() == ".") f = f.parent_path();
detail::add_files_impl(fs, complete(f).parent_path(), path(f .filename()), p); detail::add_files_impl(fs, complete(f).parent_path(), path(f .filename()), p, flags);
#endif #endif
} }
inline void add_files(file_storage& fs, boost::filesystem::path cons inline void add_files(file_storage& fs, boost::filesystem::path cons
t& file) t& file
, boost::uint32_t flags = 0)
{ {
using boost::filesystem::path; using boost::filesystem::path;
boost::filesystem::path f = file; boost::filesystem::path f = file;
#if BOOST_VERSION < 103600 #if BOOST_VERSION < 103600
if (f.leaf() == ".") f = f.branch_path(); if (f.leaf() == ".") f = f.branch_path();
detail::add_files_impl(fs, complete(f).branch_path(), path(f detail::add_files_impl(fs, complete(f).branch_path(), path(f
.leaf()), detail::default_pred); .leaf())
, detail::default_pred, flags);
#else #else
if (f.filename() == ".") f = f.parent_path(); if (f.filename() == ".") f = f.parent_path();
detail::add_files_impl(fs, complete(f).parent_path(), path(f detail::add_files_impl(fs, complete(f).parent_path(), path(f
.filename()), detail::default_pred); .filename())
, detail::default_pred, flags);
#endif #endif
} }
struct piece_holder struct piece_holder
{ {
piece_holder(int bytes): m_piece(page_aligned_allocator::mal loc(bytes)) {} piece_holder(int bytes): m_piece(page_aligned_allocator::mal loc(bytes)) {}
~piece_holder() { page_aligned_allocator::free(m_piece); } ~piece_holder() { page_aligned_allocator::free(m_piece); }
char* bytes() { return m_piece; } char* bytes() { return m_piece; }
private: private:
char* m_piece; char* m_piece;
skipping to change at line 322 skipping to change at line 334
inline void set_piece_hashes(create_torrent& t, boost::filesystem::p ath const& p, error_code& ec) inline void set_piece_hashes(create_torrent& t, boost::filesystem::p ath const& p, error_code& ec)
{ {
set_piece_hashes(t, p, detail::nop, ec); set_piece_hashes(t, p, detail::nop, ec);
} }
#if TORRENT_USE_WPATH #if TORRENT_USE_WPATH
// wpath versions // wpath versions
template <class Pred> template <class Pred>
void add_files(file_storage& fs, boost::filesystem::wpath const& fil void add_files(file_storage& fs, boost::filesystem::wpath const& fil
e, Pred p) e, Pred p
, boost::uint32_t flags = 0)
{ {
using boost::filesystem::wpath; using boost::filesystem::wpath;
wpath f = file; wpath f = file;
#if BOOST_VERSION < 103600 #if BOOST_VERSION < 103600
if (f.leaf() == L".") f = f.branch_path(); if (f.leaf() == L".") f = f.branch_path();
detail::add_files_impl(fs, complete(f).branch_path(), wpath( f.leaf()), p); detail::add_files_impl(fs, complete(f).branch_path(), wpath( f.leaf()), p, flags);
#else #else
if (f.filename() == L".") f = f.parent_path(); if (f.filename() == L".") f = f.parent_path();
detail::add_files_impl(fs, complete(f).parent_path(), wpath( f.filename()), p); detail::add_files_impl(fs, complete(f).parent_path(), wpath( f.filename()), p, flags);
#endif #endif
} }
inline void add_files(file_storage& fs, boost::filesystem::wpath con inline void add_files(file_storage& fs, boost::filesystem::wpath con
st& file) st& file
, boost::uint32_t flags = 0)
{ {
using boost::filesystem::wpath; using boost::filesystem::wpath;
wpath f = file; wpath f = file;
#if BOOST_VERSION < 103600 #if BOOST_VERSION < 103600
if (f.leaf() == L".") f = f.branch_path(); if (f.leaf() == L".") f = f.branch_path();
detail::add_files_impl(fs, complete(f).branch_path(), wpath( detail::add_files_impl(fs, complete(f).branch_path(), wpath(
f.leaf()), detail::wdefault_pred); f.leaf()), detail::wdefault_pred
, flags);
#else #else
if (f.filename() == L".") f = f.parent_path(); if (f.filename() == L".") f = f.parent_path();
detail::add_files_impl(fs, complete(f).parent_path(), wpath( detail::add_files_impl(fs, complete(f).parent_path(), wpath(
f.filename()), detail::wdefault_pred); f.filename())
, detail::wdefault_pred, flags);
#endif #endif
} }
template <class Fun> template <class Fun>
void set_piece_hashes(create_torrent& t, boost::filesystem::wpath co nst& p, Fun f void set_piece_hashes(create_torrent& t, boost::filesystem::wpath co nst& p, Fun f
, error_code& ec) , error_code& ec)
{ {
file_pool fp; file_pool fp;
std::string utf8; std::string utf8;
wchar_utf8(p.string(), utf8); wchar_utf8(p.string(), utf8);
 End of changes. 16 change blocks. 
25 lines changed or deleted 44 lines changed or added


 entry.hpp   entry.hpp 
skipping to change at line 190 skipping to change at line 190
#endif #endif
protected: protected:
void construct(data_type t); void construct(data_type t);
void copy(const entry& e); void copy(const entry& e);
void destruct(); void destruct();
private: private:
#ifndef TORRENT_DEBUG
data_type m_type; data_type m_type;
#if (defined(_MSC_VER) && _MSC_VER < 1310) || TORRENT_COMPLETE_TYPES_REQUIR
ED
// workaround for msvc-bug.
// assumes sizeof(map<string, char>) == sizeof(map<string, e
ntry>)
// and sizeof(list<char>) == sizeof(list<entry>)
union
{
char data[
detail::max4<sizeof(std::list<char>)
, sizeof(std::map<std::string, char>)
, sizeof(string_type)
, sizeof(integer_type)>::value];
integer_type dummy_aligner;
};
#else #else
union // the bitfield is used so that the m_type_queried
{ // field still fits, so that the ABI is the same for
char data[detail::max4<sizeof(list_type) // debug builds and release builds. It appears to be
, sizeof(dictionary_type) // very hard to match debug builds with debug versions
, sizeof(string_type) // of libtorrent
, sizeof(integer_type)>::value]; data_type m_type:31;
integer_type dummy_aligner;
};
#endif
#ifdef TORRENT_DEBUG
public: public:
// in debug mode this is set to false by bdecode // in debug mode this is set to false by bdecode
// to indicate that the program has not yet queried // to indicate that the program has not yet queried
// the type of this entry, and sould not assume // the type of this entry, and sould not assume
// that it has a certain type. This is asserted in // that it has a certain type. This is asserted in
// the accessor functions. This does not apply if // the accessor functions. This does not apply if
// exceptions are used. // exceptions are used.
mutable bool m_type_queried; mutable bool m_type_queried:1;
protected:
#endif // TORRENT_DEBUG
#if (defined(_MSC_VER) && _MSC_VER < 1310) || TORRENT_COMPLETE_TYPES_REQUIR
ED
// workaround for msvc-bug.
// assumes sizeof(map<string, char>) == sizeof(map<string, e
ntry>)
// and sizeof(list<char>) == sizeof(list<entry>)
enum { union_size
= detail::max4<sizeof(std::list<char>)
, sizeof(std::map<std::string, char>)
, sizeof(string_type)
, sizeof(integer_type)>::value
};
#else
enum { union_size
= detail::max4<sizeof(list_type)
, sizeof(dictionary_type)
, sizeof(string_type)
, sizeof(integer_type)>::value
};
#endif #endif
integer_type data[(union_size + sizeof(integer_type) - 1)
/ sizeof(integer_type)];
}; };
#if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM #if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM
inline std::ostream& operator<<(std::ostream& os, const entry& e) inline std::ostream& operator<<(std::ostream& os, const entry& e)
{ {
e.print(os, 0); e.print(os, 0);
return os; return os;
} }
#endif #endif
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
inline void throw_type_error() inline void throw_type_error()
{ {
throw libtorrent_exception(error_code(errors::invalid_entry_ type throw libtorrent_exception(error_code(errors::invalid_entry_ type
, get_libtorrent_category())); , get_libtorrent_category()));
} }
#endif #endif
inline entry::data_type entry::type() const
{
#ifdef TORRENT_DEBUG
m_type_queried = true;
#endif
return m_type;
}
inline entry::~entry() { destruct(); }
inline void entry::operator=(const entry& e)
{
destruct();
copy(e);
}
inline entry::integer_type& entry::integer()
{
if (m_type == undefined_t) construct(int_t);
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != int_t) throw_type_error();
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == int_t);
return *reinterpret_cast<integer_type*>(data);
}
inline entry::integer_type const& entry::integer() const
{
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != int_t) throw_type_error();
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == int_t);
return *reinterpret_cast<const integer_type*>(data);
}
inline entry::string_type& entry::string()
{
if (m_type == undefined_t) construct(string_t);
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != string_t) throw_type_error();
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == string_t);
return *reinterpret_cast<string_type*>(data);
}
inline entry::string_type const& entry::string() const
{
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != string_t) throw_type_error();
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == string_t);
return *reinterpret_cast<const string_type*>(data);
}
inline entry::list_type& entry::list()
{
if (m_type == undefined_t) construct(list_t);
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != list_t) throw_type_error();
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == list_t);
return *reinterpret_cast<list_type*>(data);
}
inline entry::list_type const& entry::list() const
{
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != list_t) throw_type_error();
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == list_t);
return *reinterpret_cast<const list_type*>(data);
}
inline entry::dictionary_type& entry::dict()
{
if (m_type == undefined_t) construct(dictionary_t);
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != dictionary_t) throw_type_error();
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == dictionary_t);
return *reinterpret_cast<dictionary_type*>(data);
}
inline entry::dictionary_type const& entry::dict() const
{
#ifndef BOOST_NO_EXCEPTIONS
if (m_type != dictionary_t) throw_type_error();
#elif defined TORRENT_DEBUG
TORRENT_ASSERT(m_type_queried);
#endif
TORRENT_ASSERT(m_type == dictionary_t);
return *reinterpret_cast<const dictionary_type*>(data);
}
} }
#endif // TORRENT_ENTRY_HPP_INCLUDED #endif // TORRENT_ENTRY_HPP_INCLUDED
 End of changes. 7 change blocks. 
135 lines changed or deleted 33 lines changed or added


 escape_string.hpp   escape_string.hpp 
skipping to change at line 73 skipping to change at line 73
TORRENT_EXPORT bool need_encoding(char const* str, int len); TORRENT_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_EXPORT std::string base64encode(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_EXPORT std::string base32encode(std::string const& s);
TORRENT_EXPORT std::string base32decode(std::string const& s); TORRENT_EXPORT std::string base32decode(std::string const& s);
TORRENT_EXPORT boost::optional<std::string> url_has_argument( TORRENT_EXPORT boost::optional<std::string> url_has_argument(
std::string const& url, std::string argument, int* out_pos = 0); std::string const& url, std::string argument, size_t* out_po s = 0);
TORRENT_EXPORT std::string read_until(char const*& str, char delim, char const* end); 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 std::string to_hex(std::string const& s);
TORRENT_EXPORT bool is_hex(char const *in, int len); TORRENT_EXPORT bool is_hex(char const *in, int len);
TORRENT_EXPORT void to_hex(char const *in, int len, char* out); 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_EXPORT bool from_hex(char const *in, int len, char* out);
#if TORRENT_USE_WPATH #if TORRENT_USE_WPATH
TORRENT_EXPORT std::wstring convert_to_wstring(std::string const& s) ; TORRENT_EXPORT std::wstring convert_to_wstring(std::string const& s) ;
#endif #endif
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 file_storage.hpp   file_storage.hpp 
skipping to change at line 144 skipping to change at line 144
} }
size_type total_size() const { return m_total_size; } size_type total_size() const { return m_total_size; }
void set_num_pieces(int n) { m_num_pieces = n; } void set_num_pieces(int n) { m_num_pieces = n; }
int num_pieces() const { TORRENT_ASSERT(m_piece_length > 0); return m_num_pieces; } int num_pieces() const { TORRENT_ASSERT(m_piece_length > 0); return m_num_pieces; }
void set_piece_length(int l) { m_piece_length = l; } void set_piece_length(int l) { m_piece_length = l; }
int piece_length() const { TORRENT_ASSERT(m_piece_length > 0 ); return m_piece_length; } int piece_length() const { TORRENT_ASSERT(m_piece_length > 0 ); return m_piece_length; }
int piece_size(int index) const; int piece_size(int index) const;
void set_name(std::string const& n) { m_name = n; } void set_name(std::string const& n) { m_name = n; }
const std::string& name() const { TORRENT_ASSERT(m_piece_len gth > 0); return m_name; } const std::string& name() const { return m_name; }
void swap(file_storage& ti) void swap(file_storage& ti)
{ {
using std::swap; using std::swap;
swap(ti.m_piece_length, m_piece_length); swap(ti.m_piece_length, m_piece_length);
swap(ti.m_files, m_files); swap(ti.m_files, m_files);
swap(ti.m_total_size, m_total_size); swap(ti.m_total_size, m_total_size);
swap(ti.m_num_pieces, m_num_pieces); swap(ti.m_num_pieces, m_num_pieces);
swap(ti.m_name, m_name); swap(ti.m_name, m_name);
} }
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 lsd.hpp   lsd.hpp 
skipping to change at line 68 skipping to change at line 68
public: public:
lsd(io_service& ios, address const& listen_interface lsd(io_service& ios, address const& listen_interface
, peer_callback_t const& cb); , peer_callback_t const& cb);
~lsd(); ~lsd();
// void rebind(address const& listen_interface); // void rebind(address const& listen_interface);
void announce(sha1_hash const& ih, int listen_port); void announce(sha1_hash const& ih, int listen_port);
void close(); void close();
void use_broadcast(bool b);
private: private:
void resend_announce(error_code const& e, std::string msg); void resend_announce(error_code const& e, std::string msg);
void on_announce(udp::endpoint const& from, char* buffer void on_announce(udp::endpoint const& from, char* buffer
, std::size_t bytes_transferred); , std::size_t bytes_transferred);
// void setup_receive(); // void setup_receive();
peer_callback_t m_callback; peer_callback_t m_callback;
// current retry count // current retry count
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 natpmp.hpp   natpmp.hpp 
skipping to change at line 79 skipping to change at line 79
private: private:
typedef boost::mutex mutex_t; typedef boost::mutex mutex_t;
void update_mapping(int i, mutex_t::scoped_lock& l); void update_mapping(int i, mutex_t::scoped_lock& l);
void send_map_request(int i, mutex_t::scoped_lock& l); void send_map_request(int i, mutex_t::scoped_lock& l);
void resend_request(int i, error_code const& e); void resend_request(int i, error_code const& e);
void on_reply(error_code const& e void on_reply(error_code const& e
, std::size_t bytes_transferred); , std::size_t bytes_transferred);
void try_next_mapping(int i, mutex_t::scoped_lock& l); void try_next_mapping(int i, mutex_t::scoped_lock& l);
void update_expiration_timer(); void update_expiration_timer(boost::mutex::scoped_lock& l);
void mapping_expired(error_code const& e, int i); void mapping_expired(error_code const& e, int i);
void close_impl(mutex_t::scoped_lock& l); void close_impl(mutex_t::scoped_lock& l);
void log(char const* msg, mutex_t::scoped_lock& l); void log(char const* msg, mutex_t::scoped_lock& l);
void disable(error_code const& ec, mutex_t::scoped_lock& l); void disable(error_code const& ec, mutex_t::scoped_lock& l);
struct mapping_t struct mapping_t
{ {
enum action_t { action_none, action_add, action_delete }; enum action_t { action_none, action_add, action_delete };
mapping_t() mapping_t()
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 peer_connection.hpp   peer_connection.hpp 
skipping to change at line 320 skipping to change at line 320
bitfield const& get_bitfield() const; bitfield const& get_bitfield() const;
std::vector<int> const& allowed_fast(); std::vector<int> const& allowed_fast();
std::vector<int> const& suggested_pieces() const { return m_ suggested_pieces; } std::vector<int> const& suggested_pieces() const { return m_ suggested_pieces; }
ptime connected_time() const { return m_connect; } ptime connected_time() const { return m_connect; }
ptime last_received() const { return m_last_receive; } ptime last_received() const { return m_last_receive; }
void on_timeout(); void on_timeout();
// this will cause this peer_connection to be disconnected. // this will cause this peer_connection to be disconnected.
void disconnect(error_code const& ec, int error = 0); virtual void disconnect(error_code const& ec, int error = 0) ;
bool is_disconnecting() const { return m_disconnecting; } bool is_disconnecting() const { return m_disconnecting; }
// this is called when the connection attempt has succeeded // this is called when the connection attempt has succeeded
// and the peer_connection is supposed to set m_connecting // and the peer_connection is supposed to set m_connecting
// to false, and stop monitor writability // to false, and stop monitor writability
void on_connection_complete(error_code const& e); void on_connection_complete(error_code const& e);
// returns true if this connection is still waiting to // returns true if this connection is still waiting to
// finish the connection attempt // finish the connection attempt
bool is_connecting() const { return m_connecting; } bool is_connecting() const { return m_connecting; }
skipping to change at line 502 skipping to change at line 502
if (m_ses.m_disk_thread.is_disk_buffer(buffer)) if (m_ses.m_disk_thread.is_disk_buffer(buffer))
m_ses.m_disk_thread.rename_buffer(buffer, "q ueued send buffer"); m_ses.m_disk_thread.rename_buffer(buffer, "q ueued send buffer");
#endif #endif
m_send_buffer.append_buffer(buffer, size, size, dest ructor); m_send_buffer.append_buffer(buffer, size, size, dest ructor);
#if defined TORRENT_STATS && defined TORRENT_DISK_STATS #if defined TORRENT_STATS && defined TORRENT_DISK_STATS
m_ses.m_buffer_usage_logger << log_time() << " appen d_send_buffer: " << size << std::endl; m_ses.m_buffer_usage_logger << log_time() << " appen d_send_buffer: " << size << std::endl;
m_ses.log_buffer_usage(); m_ses.log_buffer_usage();
#endif #endif
} }
virtual void append_const_send_buffer(char const* buffer, in
t size);
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
void set_country(char const* c) void set_country(char const* c)
{ {
TORRENT_ASSERT(strlen(c) == 2); TORRENT_ASSERT(strlen(c) == 2);
m_country[0] = c[0]; m_country[0] = c[0];
m_country[1] = c[1]; m_country[1] = c[1];
} }
bool has_country() const { return m_country[0] != 0; } bool has_country() const { return m_country[0] != 0; }
#endif #endif
skipping to change at line 541 skipping to change at line 543
size_type uploaded_since_unchoke() const size_type uploaded_since_unchoke() const
{ return m_statistics.total_payload_upload() - m_uploaded_at _last_unchoke; } { return m_statistics.total_payload_upload() - m_uploaded_at _last_unchoke; }
size_type downloaded_since_unchoke() const size_type downloaded_since_unchoke() const
{ return m_statistics.total_payload_download() - m_downloade d_at_last_unchoke; } { return m_statistics.total_payload_download() - m_downloade d_at_last_unchoke; }
void setup_receive(); void setup_receive();
protected: protected:
enum sync_t { read_async, read_sync };
size_t try_read(sync_t s, error_code& ec);
virtual void get_specific_peer_info(peer_info& p) const = 0; virtual void get_specific_peer_info(peer_info& p) const = 0;
virtual void write_choke() = 0; virtual void write_choke() = 0;
virtual void write_unchoke() = 0; virtual void write_unchoke() = 0;
virtual void write_interested() = 0; virtual void write_interested() = 0;
virtual void write_not_interested() = 0; virtual void write_not_interested() = 0;
virtual void write_request(peer_request const& r) = 0; virtual void write_request(peer_request const& r) = 0;
virtual void write_cancel(peer_request const& r) = 0; virtual void write_cancel(peer_request const& r) = 0;
virtual void write_have(int index) = 0; virtual void write_have(int index) = 0;
virtual void write_keepalive() = 0; virtual void write_keepalive() = 0;
skipping to change at line 617 skipping to change at line 622
// a back reference to the session // a back reference to the session
// the peer belongs to. // the peer belongs to.
aux::session_impl& m_ses; aux::session_impl& m_ses;
// called from the main loop when this connection has any // called from the main loop when this connection has any
// work to do. // work to do.
void on_send_data(error_code const& error void on_send_data(error_code const& error
, std::size_t bytes_transferred); , std::size_t bytes_transferred);
void on_receive_data(error_code const& error void on_receive_data(error_code const& error
, std::size_t bytes_transferred); , std::size_t bytes_transferred);
void on_receive_data_nolock(error_code const& error
, std::size_t bytes_transferred);
// this is the limit on the number of outstanding requests // this is the limit on the number of outstanding requests
// we have to this peer. This is initialized to the settings // we have to this peer. This is initialized to the settings
// in the session_settings structure. But it may be lowered // in the session_settings structure. But it may be lowered
// if the peer is known to require a smaller limit (like Bit Comet). // if the peer is known to require a smaller limit (like Bit Comet).
// or if the extended handshake sets a limit. // or if the extended handshake sets a limit.
// web seeds also has a limit on the queue size. // web seeds also has a limit on the queue size.
int m_max_out_request_queue; int m_max_out_request_queue;
void set_timeout(int s) { m_timeout = s; } void set_timeout(int s) { m_timeout = s; }
 End of changes. 4 change blocks. 
1 lines changed or deleted 9 lines changed or added


 piece_picker.hpp   piece_picker.hpp 
skipping to change at line 279 skipping to change at line 279
// or if it already has been successfully downloaded // or if it already has been successfully downloaded
bool is_requested(piece_block block) const; bool is_requested(piece_block block) const;
// returns true if the block has been downloaded // returns true if the block has been downloaded
bool is_downloaded(piece_block block) const; bool is_downloaded(piece_block block) const;
// returns true if the block has been downloaded and written to disk // returns true if the block has been downloaded and written to disk
bool is_finished(piece_block block) const; bool is_finished(piece_block block) const;
// marks this piece-block as queued for downloading // marks this piece-block as queued for downloading
bool mark_as_downloading(piece_block block, void* peer bool mark_as_downloading(piece_block block, void* peer
, piece_state_t s); , piece_state_t s);
void mark_as_writing(piece_block block, void* peer); // returns true if the block was marked as writing,
// and false if the block is already finished or writing
bool mark_as_writing(piece_block block, void* peer);
void mark_as_finished(piece_block block, void* peer); void mark_as_finished(piece_block block, void* peer);
void write_failed(piece_block block); void write_failed(piece_block block);
int num_peers(piece_block block) const; int num_peers(piece_block block) const;
ptime last_request(int piece) const; ptime last_request(int piece) const;
// returns information about the given piece // returns information about the given piece
void piece_info(int index, piece_picker::downloading_piece& st) const; void piece_info(int index, piece_picker::downloading_piece& st) const;
// if a piece had a hash-failure, it must be restored and // if a piece had a hash-failure, it must be restored and
// made available for redownloading // made available for redownloading
 End of changes. 1 change blocks. 
1 lines changed or deleted 4 lines changed or added


 session_impl.hpp   session_impl.hpp 
skipping to change at line 339 skipping to change at line 339
bool load_country_db(char const* file); bool load_country_db(char const* file);
bool has_country_db() const { return m_country_db; } bool has_country_db() const { return m_country_db; }
char const* country_for_ip(address const& a); char const* country_for_ip(address const& a);
#ifndef BOOST_FILESYSTEM_NARROW_ONLY #ifndef BOOST_FILESYSTEM_NARROW_ONLY
bool load_asnum_db(wchar_t const* file); bool load_asnum_db(wchar_t const* file);
bool load_country_db(wchar_t const* file); bool load_country_db(wchar_t const* file);
#endif #endif
#endif #endif
void load_state(entry const& ses_state);
entry state() const;
void start_lsd(); void start_lsd();
void start_natpmp(natpmp* n); void start_natpmp(natpmp* n);
void start_upnp(upnp* u); void start_upnp(upnp* u);
void stop_lsd(); void stop_lsd();
void stop_natpmp(); void stop_natpmp();
void stop_upnp(); void stop_upnp();
int next_port(); int next_port();
skipping to change at line 575 skipping to change at line 572
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
proxy_settings m_dht_proxy; proxy_settings m_dht_proxy;
#endif #endif
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
entry m_dht_state; entry m_dht_state;
#endif #endif
// set to true when the session object // set to true when the session object
// is being destructed and the thread // is being destructed and the thread
// should exit // should exit
volatile bool m_abort; bool m_abort;
// is true if the session is paused // is true if the session is paused
bool m_paused; bool m_paused;
// the max number of unchoked peers as set by the us er // the max number of unchoked peers as set by the us er
int m_max_uploads; int m_max_uploads;
// the number of unchoked peers as set by the auto-u nchoker // the number of unchoked peers as set by the auto-u nchoker
// this should always be >= m_max_uploads // this should always be >= m_max_uploads
int m_allowed_upload_slots; int m_allowed_upload_slots;
 End of changes. 2 change blocks. 
4 lines changed or deleted 1 lines changed or added


 session_settings.hpp   session_settings.hpp 
skipping to change at line 187 skipping to change at line 187
, optimistic_disk_retry(10 * 60) , optimistic_disk_retry(10 * 60)
, disable_hash_checks(false) , disable_hash_checks(false)
, allow_reordered_disk_operations(true) , allow_reordered_disk_operations(true)
, max_suggest_pieces(10) , max_suggest_pieces(10)
, drop_skipped_requests(false) , drop_skipped_requests(false)
, low_prio_disk(true) , low_prio_disk(true)
, local_service_announce_interval(5 * 60) , local_service_announce_interval(5 * 60)
, udp_tracker_token_expiry(60) , udp_tracker_token_expiry(60)
, report_true_downloaded(false) , report_true_downloaded(false)
, strict_end_game_mode(true) , strict_end_game_mode(true)
, broadcast_lsd(false)
{} {}
// this is the user agent that will be sent to the tracker // this is the user agent that will be sent to the tracker
// when doing requests. It is used to identify the client. // when doing requests. It is used to identify the client.
// It cannot contain \r or \n // It cannot contain \r or \n
std::string user_agent; std::string user_agent;
// the number of seconds to wait until giving up on a // the number of seconds to wait until giving up on a
// tracker request if it hasn't finished // tracker request if it hasn't finished
int tracker_completion_timeout; int tracker_completion_timeout;
skipping to change at line 680 skipping to change at line 681
// when set to true, the downloaded counter sent to trackers // when set to true, the downloaded counter sent to trackers
// will include the actual number of payload bytes donwnload ed // will include the actual number of payload bytes donwnload ed
// including redundant bytes. If set to false, it will not i nclude // including redundant bytes. If set to false, it will not i nclude
// any redundany bytes // any redundany bytes
bool report_true_downloaded; bool report_true_downloaded;
// if set to true, libtorrent won't request a piece multiple times // if set to true, libtorrent won't request a piece multiple times
// until every piece is requested // until every piece is requested
bool strict_end_game_mode; bool strict_end_game_mode;
// if this is true, the broadcast socket will not only use I
P multicast
// but also send the messages on the broadcast address. This
is false by
// default in order to avoid flooding networks for no good r
eason. If
// a network is known not to support multicast, this can be
enabled
bool broadcast_lsd;
}; };
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
struct dht_settings struct dht_settings
{ {
dht_settings() dht_settings()
: max_peers_reply(100) : max_peers_reply(100)
, search_branching(5) , search_branching(5)
, service_port(0) , service_port(0)
, max_fail_count(20) , max_fail_count(20)
 End of changes. 2 change blocks. 
0 lines changed or deleted 11 lines changed or added


 socket.hpp   socket.hpp 
skipping to change at line 167 skipping to change at line 167
{ {
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
if (a.is_v4()) if (a.is_v4())
{ {
#endif #endif
write_uint32(a.to_v4().to_ulong(), out); write_uint32(a.to_v4().to_ulong(), out);
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
} }
else if (a.is_v6()) else if (a.is_v6())
{ {
address_v6::bytes_type bytes typedef address_v6::bytes_type bytes_t;
= a.to_v6().to_bytes(); bytes_t bytes = a.to_v6().to_bytes();
std::copy(bytes.begin(), bytes.end(), out); for (bytes_t::iterator i = bytes.begin()
, end(bytes.end()); i != end; ++i)
write_uint8(*i, out);
} }
#endif #endif
} }
template<class InIt> template<class InIt>
address read_v4_address(InIt& in) address read_v4_address(InIt& in)
{ {
unsigned long ip = read_uint32(in); unsigned long ip = read_uint32(in);
return address_v4(ip); return address_v4(ip);
} }
 End of changes. 1 change blocks. 
3 lines changed or deleted 5 lines changed or added


 torrent.hpp   torrent.hpp 
skipping to change at line 850 skipping to change at line 850
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
// this announce timer is used both // this announce timer is used both
// by Local service discovery and // by Local service discovery and
// by the DHT. // by the DHT.
deadline_timer m_dht_announce_timer; deadline_timer m_dht_announce_timer;
#endif #endif
// used for tracker announces // used for tracker announces
deadline_timer m_tracker_timer; deadline_timer m_tracker_timer;
void update_tracker_timer(); void update_tracker_timer(ptime now);
static void on_tracker_announce_disp(boost::weak_ptr<torrent > p static void on_tracker_announce_disp(boost::weak_ptr<torrent > p
, error_code const& e); , error_code const& e);
void on_tracker_announce(); void on_tracker_announce();
void dht_announce(); void dht_announce();
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
static void on_dht_announce_response_disp(boost::weak_ptr<to rrent> t static void on_dht_announce_response_disp(boost::weak_ptr<to rrent> t
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 torrent_info.hpp   torrent_info.hpp 
skipping to change at line 156 skipping to change at line 156
void failed(int retry_interval = 0) void failed(int retry_interval = 0)
{ {
++fails; ++fails;
int delay = (std::min)(tracker_retry_delay_min + int (fails) * int(fails) int delay = (std::min)(tracker_retry_delay_min + int (fails) * int(fails)
* tracker_retry_delay_min, int(tracker_retry _delay_max)); * tracker_retry_delay_min, int(tracker_retry _delay_max));
delay = (std::max)(delay, retry_interval); delay = (std::max)(delay, retry_interval);
next_announce = time_now() + seconds(delay); next_announce = time_now() + seconds(delay);
updating = false; updating = false;
} }
bool will_announce(ptime now) const
{
return now <= next_announce
&& (fails < fail_limit || fail_limit == 0)
&& !updating;
}
bool can_announce(ptime now) const bool can_announce(ptime now) const
{ {
return now >= next_announce return now >= next_announce
&& now >= min_announce && now >= min_announce
&& (fails < fail_limit || fail_limit == 0) && (fails < fail_limit || fail_limit == 0)
&& !updating; && !updating;
} }
bool is_working() const bool is_working() const
{ {
 End of changes. 1 change blocks. 
0 lines changed or deleted 7 lines changed or added


 traversal_algorithm.hpp   traversal_algorithm.hpp 
skipping to change at line 135 skipping to change at line 135
, InIt start // <- nodes to initiate traversal with , InIt start // <- nodes to initiate traversal with
, InIt end) , InIt end)
: m_ref_count(0) : m_ref_count(0)
, m_node(node) , m_node(node)
, m_target(target) , m_target(target)
, m_invoke_count(0) , m_invoke_count(0)
, m_branch_factor(3) , m_branch_factor(3)
, m_responses(0) , m_responses(0)
, m_timeouts(0) , m_timeouts(0)
{ {
using boost::bind;
for (InIt i = start; i != end; ++i) for (InIt i = start; i != end; ++i)
{ {
add_entry(i->id, udp::endpoint(i->addr, i->port), result::in itial); add_entry(i->id, udp::endpoint(i->addr, i->port), result::in itial);
} }
// in case the routing table is empty, use the // in case the routing table is empty, use the
// router nodes in the table // router nodes in the table
if (start == end) add_router_entries(); if (start == end) add_router_entries();
init(); init();
} }
 End of changes. 1 change blocks. 
2 lines changed or deleted 0 lines changed or added


 version.hpp   version.hpp 
skipping to change at line 38 skipping to change at line 38
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef TORRENT_VERSION_HPP_INCLUDED #ifndef TORRENT_VERSION_HPP_INCLUDED
#define TORRENT_VERSION_HPP_INCLUDED #define TORRENT_VERSION_HPP_INCLUDED
#define LIBTORRENT_VERSION_MAJOR 0 #define LIBTORRENT_VERSION_MAJOR 0
#define LIBTORRENT_VERSION_MINOR 15 #define LIBTORRENT_VERSION_MINOR 15
#define LIBTORRENT_VERSION_TINY 0 #define LIBTORRENT_VERSION_TINY 1
#define LIBTORRENT_VERSION "0.15.0.0" #define LIBTORRENT_VERSION "0.15.1.0"
#define LIBTORRENT_REVISION "$Rev: 3323 $" #define LIBTORRENT_REVISION "$Rev: 4658 $"
#endif #endif
 End of changes. 2 change blocks. 
3 lines changed or deleted 3 lines changed or added


 web_peer_connection.hpp   web_peer_connection.hpp 
skipping to change at line 111 skipping to change at line 111
~web_peer_connection(); ~web_peer_connection();
// called from the main loop when this connection has any // called from the main loop when this connection has any
// work to do. // work to do.
void on_sent(error_code const& error void on_sent(error_code const& error
, std::size_t bytes_transferred); , std::size_t bytes_transferred);
void on_receive(error_code const& error void on_receive(error_code const& error
, std::size_t bytes_transferred); , std::size_t bytes_transferred);
virtual void disconnect(error_code const& ec, int error = 0)
;
std::string const& url() const { return m_original_url; } std::string const& url() const { return m_original_url; }
virtual void get_specific_peer_info(peer_info& p) const; virtual void get_specific_peer_info(peer_info& p) const;
virtual bool in_handshake() const; virtual bool in_handshake() const;
// the following functions appends messages // the following functions appends messages
// to the send buffer // to the send buffer
void write_choke() {} void write_choke() {}
void write_unchoke() {} void write_unchoke() {}
void write_interested() {} void write_interested() {}
 End of changes. 1 change blocks. 
0 lines changed or deleted 3 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/