GeoIP.h   GeoIP.h 
skipping to change at line 71 skipping to change at line 71
typedef struct GeoIPRegionTag { typedef struct GeoIPRegionTag {
char country_code[3]; char country_code[3];
char region[3]; char region[3];
} GeoIPRegion; } GeoIPRegion;
typedef enum { typedef enum {
GEOIP_STANDARD = 0, GEOIP_STANDARD = 0,
GEOIP_MEMORY_CACHE = 1, GEOIP_MEMORY_CACHE = 1,
GEOIP_CHECK_CACHE = 2, GEOIP_CHECK_CACHE = 2,
GEOIP_INDEX_CACHE = 4, GEOIP_INDEX_CACHE = 4,
GEOIP_MMAP_CACHE = 8, GEOIP_MMAP_CACHE = 8
} GeoIPOptions; } GeoIPOptions;
typedef enum { typedef enum {
GEOIP_COUNTRY_EDITION = 1, GEOIP_COUNTRY_EDITION = 1,
GEOIP_REGION_EDITION_REV0 = 7, GEOIP_REGION_EDITION_REV0 = 7,
GEOIP_CITY_EDITION_REV0 = 6, GEOIP_CITY_EDITION_REV0 = 6,
GEOIP_ORG_EDITION = 5, GEOIP_ORG_EDITION = 5,
GEOIP_ISP_EDITION = 4, GEOIP_ISP_EDITION = 4,
GEOIP_CITY_EDITION_REV1 = 2, GEOIP_CITY_EDITION_REV1 = 2,
GEOIP_REGION_EDITION_REV1 = 3, GEOIP_REGION_EDITION_REV1 = 3,
GEOIP_PROXY_EDITION = 8, GEOIP_PROXY_EDITION = 8,
GEOIP_ASNUM_EDITION = 9, GEOIP_ASNUM_EDITION = 9,
GEOIP_NETSPEED_EDITION = 10, GEOIP_NETSPEED_EDITION = 10,
GEOIP_DOMAIN_EDITION = 11 GEOIP_DOMAIN_EDITION = 11
} GeoIPDBTypes; } GeoIPDBTypes;
typedef enum { typedef enum {
GEOIP_ANON_PROXY = 1, GEOIP_ANON_PROXY = 1,
GEOIP_HTTP_X_FORWARDED_FOR_PROXY = 2, GEOIP_HTTP_X_FORWARDED_FOR_PROXY = 2,
GEOIP_HTTP_CLIENT_IP_PROXY = 3, GEOIP_HTTP_CLIENT_IP_PROXY = 3
} GeoIPProxyTypes; } GeoIPProxyTypes;
typedef enum { typedef enum {
GEOIP_UNKNOWN_SPEED = 0, GEOIP_UNKNOWN_SPEED = 0,
GEOIP_DIALUP_SPEED = 1, GEOIP_DIALUP_SPEED = 1,
GEOIP_CABLEDSL_SPEED = 2, GEOIP_CABLEDSL_SPEED = 2,
GEOIP_CORPORATE_SPEED = 3, GEOIP_CORPORATE_SPEED = 3
} GeoIPNetspeedValues; } GeoIPNetspeedValues;
extern char **GeoIPDBFileName; extern char **GeoIPDBFileName;
extern const char * GeoIPDBDescription[NUM_DB_TYPES]; extern const char * GeoIPDBDescription[NUM_DB_TYPES];
extern const char *GeoIPCountryDBFileName; extern const char *GeoIPCountryDBFileName;
extern const char *GeoIPRegionDBFileName; extern const char *GeoIPRegionDBFileName;
extern const char *GeoIPCityDBFileName; extern const char *GeoIPCityDBFileName;
extern const char *GeoIPOrgDBFileName; extern const char *GeoIPOrgDBFileName;
extern const char *GeoIPISPDBFileName; extern const char *GeoIPISPDBFileName;
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 alert_types.hpp   alert_types.hpp 
skipping to change at line 208 skipping to change at line 208
{} {}
virtual std::auto_ptr<alert> clone() const virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new state_changed_alert(*this) ); } { return std::auto_ptr<alert>(new state_changed_alert(*this) ); }
virtual char const* what() const { return "torrent state cha nged"; } virtual char const* what() const { return "torrent state cha nged"; }
virtual std::string message() const virtual std::string message() const
{ {
static char const* state_str[] = static char const* state_str[] =
{"checking (q)", "checking", "dl metadata" {"checking (q)", "checking", "dl metadata"
, "downloading", "finished", "seeding", "all , "downloading", "finished", "seeding", "all
ocating"}; ocating"
, "checking (r)"};
return torrent_alert::message() + ": state changed t o: " return torrent_alert::message() + ": state changed t o: "
+ state_str[state]; + state_str[state];
} }
const static int static_category = alert::status_notificatio n; const static int static_category = alert::status_notificatio n;
virtual int category() const { return static_category; } virtual int category() const { return static_category; }
torrent_status::state_t state; torrent_status::state_t state;
}; };
struct TORRENT_EXPORT tracker_error_alert: tracker_alert struct TORRENT_EXPORT tracker_error_alert: tracker_alert
{ {
tracker_error_alert(torrent_handle const& h tracker_error_alert(torrent_handle const& h
, int times , int times
, int status , int status
, std::string const& url , std::string const& url_
, std::string const& msg_) , std::string const& msg_)
: tracker_alert(h, url) : tracker_alert(h, url_)
, times_in_row(times) , times_in_row(times)
, status_code(status) , status_code(status)
, msg(msg_) , msg(msg_)
{ TORRENT_ASSERT(!url.empty()); } { TORRENT_ASSERT(!url.empty()); }
virtual std::auto_ptr<alert> clone() const virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_error_alert(*this) ); } { return std::auto_ptr<alert>(new tracker_error_alert(*this) ); }
const static int static_category = alert::tracker_notificati on | alert::error_notification; const static int static_category = alert::tracker_notificati on | alert::error_notification;
virtual int category() const { return static_category; } virtual int category() const { return static_category; }
virtual char const* what() const { return "tracker error"; } virtual char const* what() const { return "tracker error"; }
skipping to change at line 254 skipping to change at line 255
} }
int times_in_row; int times_in_row;
int status_code; int status_code;
std::string msg; std::string msg;
}; };
struct TORRENT_EXPORT tracker_warning_alert: tracker_alert struct TORRENT_EXPORT tracker_warning_alert: tracker_alert
{ {
tracker_warning_alert(torrent_handle const& h tracker_warning_alert(torrent_handle const& h
, std::string const& url , std::string const& url_
, std::string const& msg_) , std::string const& msg_)
: tracker_alert(h, url) : tracker_alert(h, url_)
, msg(msg_) , msg(msg_)
{ TORRENT_ASSERT(!url.empty()); } { TORRENT_ASSERT(!url.empty()); }
std::string msg; std::string msg;
virtual std::auto_ptr<alert> clone() const virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_warning_alert(*thi s)); } { return std::auto_ptr<alert>(new tracker_warning_alert(*thi s)); }
const static int static_category = alert::tracker_notificati on | alert::error_notification; const static int static_category = alert::tracker_notificati on | alert::error_notification;
virtual int category() const { return static_category; } virtual int category() const { return static_category; }
virtual char const* what() const { return "tracker warning"; } virtual char const* what() const { return "tracker warning"; }
skipping to change at line 278 skipping to change at line 279
{ {
return tracker_alert::message() + " warning: " + msg ; return tracker_alert::message() + " warning: " + msg ;
} }
}; };
struct TORRENT_EXPORT scrape_reply_alert: tracker_alert struct TORRENT_EXPORT scrape_reply_alert: tracker_alert
{ {
scrape_reply_alert(torrent_handle const& h scrape_reply_alert(torrent_handle const& h
, int incomplete_ , int incomplete_
, int complete_ , int complete_
, std::string const& url) , std::string const& url_)
: tracker_alert(h, url) : tracker_alert(h, url_)
, incomplete(incomplete_) , incomplete(incomplete_)
, complete(complete_) , complete(complete_)
{ TORRENT_ASSERT(!url.empty()); } { TORRENT_ASSERT(!url.empty()); }
int incomplete; int incomplete;
int complete; int complete;
virtual std::auto_ptr<alert> clone() const virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new scrape_reply_alert(*this)) ; } { return std::auto_ptr<alert>(new scrape_reply_alert(*this)) ; }
virtual char const* what() const { return "tracker scrape re ply"; } virtual char const* what() const { return "tracker scrape re ply"; }
skipping to change at line 302 skipping to change at line 303
std::stringstream ret; std::stringstream ret;
ret << tracker_alert::message() << " scrape reply: " << incomplete ret << tracker_alert::message() << " scrape reply: " << incomplete
<< " " << complete; << " " << complete;
return ret.str(); return ret.str();
} }
}; };
struct TORRENT_EXPORT scrape_failed_alert: tracker_alert struct TORRENT_EXPORT scrape_failed_alert: tracker_alert
{ {
scrape_failed_alert(torrent_handle const& h scrape_failed_alert(torrent_handle const& h
, std::string const& url , std::string const& url_
, std::string const& msg_) , std::string const& msg_)
: tracker_alert(h, url) : tracker_alert(h, url_)
, msg(msg_) , msg(msg_)
{ TORRENT_ASSERT(!url.empty()); } { TORRENT_ASSERT(!url.empty()); }
std::string msg; std::string msg;
virtual std::auto_ptr<alert> clone() const virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new scrape_failed_alert(*this) ); } { return std::auto_ptr<alert>(new scrape_failed_alert(*this) ); }
const static int static_category = alert::tracker_notificati on | alert::error_notification; const static int static_category = alert::tracker_notificati on | alert::error_notification;
virtual int category() const { return static_category; } virtual int category() const { return static_category; }
virtual char const* what() const { return "tracker scrape fa iled"; } virtual char const* what() const { return "tracker scrape fa iled"; }
virtual std::string message() const virtual std::string message() const
{ {
return tracker_alert::message() + " scrape failed: " + msg; return tracker_alert::message() + " scrape failed: " + msg;
} }
}; };
struct TORRENT_EXPORT tracker_reply_alert: tracker_alert struct TORRENT_EXPORT tracker_reply_alert: tracker_alert
{ {
tracker_reply_alert(torrent_handle const& h tracker_reply_alert(torrent_handle const& h
, int np , int np
, std::string const& url) , std::string const& url_)
: tracker_alert(h, url) : tracker_alert(h, url_)
, num_peers(np) , num_peers(np)
{ TORRENT_ASSERT(!url.empty()); } { TORRENT_ASSERT(!url.empty()); }
int num_peers; int num_peers;
virtual std::auto_ptr<alert> clone() const virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_reply_alert(*this) ); } { return std::auto_ptr<alert>(new tracker_reply_alert(*this) ); }
virtual char const* what() const { return "tracker reply"; } virtual char const* what() const { return "tracker reply"; }
virtual std::string message() const virtual std::string message() const
{ {
skipping to change at line 369 skipping to change at line 370
std::stringstream ret; std::stringstream ret;
ret << torrent_alert::message() << " received DHT pe ers: " ret << torrent_alert::message() << " received DHT pe ers: "
<< num_peers; << num_peers;
return ret.str(); return ret.str();
} }
}; };
struct TORRENT_EXPORT tracker_announce_alert: tracker_alert struct TORRENT_EXPORT tracker_announce_alert: tracker_alert
{ {
tracker_announce_alert(torrent_handle const& h tracker_announce_alert(torrent_handle const& h
, std::string const& url, int event_) , std::string const& url_, int event_)
: tracker_alert(h, url) : tracker_alert(h, url_)
, event(event_) , event(event_)
{ TORRENT_ASSERT(!url.empty()); } { TORRENT_ASSERT(!url.empty()); }
int event; int event;
virtual std::auto_ptr<alert> clone() const virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new tracker_announce_alert(*th is)); } { return std::auto_ptr<alert>(new tracker_announce_alert(*th is)); }
virtual char const* what() const { return "tracker announce sent"; } virtual char const* what() const { return "tracker announce sent"; }
virtual std::string message() const virtual std::string message() const
{ {
 End of changes. 10 change blocks. 
14 lines changed or deleted 15 lines changed or added


 bandwidth_manager.hpp   bandwidth_manager.hpp 
skipping to change at line 271 skipping to change at line 271
<< " used: " << std::setw(7) << m_current_quota << " used: " << std::setw(7) << m_current_quota
<< " limit: " << std::setw(7) << m_limit << " limit: " << std::setw(7) << m_limit
<< " history: " << std::setw(3) << m_history.size() << " history: " << std::setw(3) << m_history.size()
<< std::endl; << std::endl;
#endif #endif
if (m_history.size() > 1) return; if (m_history.size() > 1) return;
if (m_abort) return; if (m_abort) return;
error_code ec; error_code ec;
TORRENT_ASSERT(e.expires_at > time_now()); // TORRENT_ASSERT(e.expires_at > time_now());
m_history_timer.expires_at(e.expires_at, ec); m_history_timer.expires_at(e.expires_at, ec);
m_history_timer.async_wait(bind(&bandwidth_manager::on_histo ry_expire, this, _1)); m_history_timer.async_wait(bind(&bandwidth_manager::on_histo ry_expire, this, _1));
} }
void on_history_expire(error_code const& e) void on_history_expire(error_code const& e)
{ {
if (e) return; if (e) return;
mutex_t::scoped_lock l(m_mutex); mutex_t::scoped_lock l(m_mutex);
INVARIANT_CHECK; INVARIANT_CHECK;
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 bencode.hpp   bencode.hpp 
skipping to change at line 77 skipping to change at line 77
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/escape_string.hpp"
#if defined(_MSC_VER)
namespace std
{
using ::isdigit;
using ::atoi;
};
#define for if (false) {} else for
#endif
namespace libtorrent namespace libtorrent
{ {
struct TORRENT_EXPORT invalid_encoding: std::exception struct TORRENT_EXPORT invalid_encoding: std::exception
{ {
virtual const char* what() const throw() { return "invalid b encoding"; } virtual const char* what() const throw() { return "invalid b encoding"; }
}; };
namespace detail namespace detail
skipping to change at line 337 skipping to change at line 328
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
TORRENT_ASSERT(*in == 'e'); TORRENT_ASSERT(*in == 'e');
++in; // 'e' ++in; // 'e'
} break; } break;
// ---------------------------------------------- // ----------------------------------------------
// string // string
default: default:
if (isdigit((unsigned char)*in)) if (is_digit((unsigned char)*in))
{ {
std::string len_s = read_until(in, e nd, ':', err); std::string len_s = read_until(in, e nd, ':', err);
if (err) if (err)
{ {
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
} }
TORRENT_ASSERT(*in == ':'); TORRENT_ASSERT(*in == ':');
 End of changes. 2 change blocks. 
11 lines changed or deleted 2 lines changed or added


 bitfield.hpp   bitfield.hpp 
skipping to change at line 63 skipping to change at line 63
void borrow_bytes(char* bytes, int bits) void borrow_bytes(char* bytes, int bits)
{ {
dealloc(); dealloc();
m_bytes = (unsigned char*)bytes; m_bytes = (unsigned char*)bytes;
m_size = bits; m_size = bits;
m_own = false; m_own = false;
} }
~bitfield() { dealloc(); } ~bitfield() { dealloc(); }
void assign(char const* bytes, int bits) void assign(char const* bytes, int bits)
{ resize(bits); memcpy(m_bytes, bytes, (bits + 7) / 8); } { resize(bits); std::memcpy(m_bytes, bytes, (bits + 7) / 8); clear_trailing_bits(); }
bool operator[](int index) const bool operator[](int index) const
{ return get_bit(index); } { return get_bit(index); }
bool get_bit(int index) const bool get_bit(int index) const
{ {
TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < m_size); TORRENT_ASSERT(index < m_size);
return m_bytes[index / 8] & (0x80 >> (index & 7)); return m_bytes[index / 8] & (0x80 >> (index & 7));
} }
skipping to change at line 200 skipping to change at line 200
int s = m_size; int s = m_size;
int b = m_size & 7; int b = m_size & 7;
resize(bits); resize(bits);
if (s >= m_size) return; if (s >= m_size) return;
int old_size_bytes = (s + 7) / 8; int old_size_bytes = (s + 7) / 8;
int new_size_bytes = (m_size + 7) / 8; int new_size_bytes = (m_size + 7) / 8;
if (val) if (val)
{ {
if (old_size_bytes && b) m_bytes[old_size_by tes - 1] |= (0xff >> b); if (old_size_bytes && b) m_bytes[old_size_by tes - 1] |= (0xff >> b);
if (old_size_bytes < new_size_bytes) if (old_size_bytes < new_size_bytes)
memset(m_bytes + old_size_bytes, 0xf std::memset(m_bytes + old_size_bytes
f, new_size_bytes - old_size_bytes); , 0xff, new_size_bytes - old_size_bytes);
clear_trailing_bits();
} }
else else
{ {
if (old_size_bytes < new_size_bytes) if (old_size_bytes < new_size_bytes)
memset(m_bytes + old_size_bytes, 0x0 0, new_size_bytes - old_size_bytes); std::memset(m_bytes + old_size_bytes , 0x00, new_size_bytes - old_size_bytes);
} }
} }
void set_all() void set_all()
{ {
memset(m_bytes, 0xff, (m_size + 7) / 8); std::memset(m_bytes, 0xff, (m_size + 7) / 8);
clear_trailing_bits();
} }
void clear_all() void clear_all()
{ {
memset(m_bytes, 0x00, (m_size + 7) / 8); std::memset(m_bytes, 0x00, (m_size + 7) / 8);
} }
void resize(int bits) void resize(int bits)
{ {
const int bytes = (bits + 7) / 8; const int bytes = (bits + 7) / 8;
if (m_bytes) if (m_bytes)
{ {
if (m_own) if (m_own)
{ {
m_bytes = (unsigned char*)realloc(m_ bytes, bytes); m_bytes = (unsigned char*)std::reall oc(m_bytes, bytes);
m_own = true; m_own = true;
} }
else if (bits > m_size) else if (bits > m_size)
{ {
unsigned char* tmp = (unsigned char* unsigned char* tmp = (unsigned char*
)malloc(bytes); )std::malloc(bytes);
memcpy(tmp, m_bytes, (std::min)((m_s std::memcpy(tmp, m_bytes, (std::min)
ize + 7)/ 8, bytes)); ((m_size + 7)/ 8, bytes));
m_bytes = tmp; m_bytes = tmp;
m_own = true; m_own = true;
} }
} }
else else
{ {
m_bytes = (unsigned char*)malloc(bytes); m_bytes = (unsigned char*)std::malloc(bytes) ;
m_own = true; m_own = true;
} }
m_size = bits; m_size = bits;
// clear the tail bits in the last byte clear_trailing_bits();
if (m_size && (bits & 7)) m_bytes[(m_size + 7) / 8 -
1] &= 0xff << (7 - (bits & 7));
} }
private: private:
void dealloc() { if (m_own) free(m_bytes); m_bytes = 0; } void clear_trailing_bits()
{
// clear the tail bits in the last byte
if (m_size & 7) m_bytes[(m_size + 7) / 8 - 1] &= 0xf
f << (8 - (m_size & 7));
}
void dealloc() { if (m_own) std::free(m_bytes); m_bytes = 0;
}
unsigned char* m_bytes; unsigned char* m_bytes;
int m_size; // in bits int m_size; // in bits
bool m_own; bool m_own;
}; };
} }
#endif // TORRENT_BITFIELD_HPP_INCLUDED #endif // TORRENT_BITFIELD_HPP_INCLUDED
 End of changes. 10 change blocks. 
16 lines changed or deleted 24 lines changed or added


 bt_peer_connection.hpp   bt_peer_connection.hpp 
skipping to change at line 265 skipping to change at line 265
// 1. a -> b dhkey, pad // 1. a -> b dhkey, pad
// 2. b -> a dhkey, pad // 2. b -> a dhkey, pad
// 3. a -> b sync, payload // 3. a -> b sync, payload
// 4. b -> a sync, payload // 4. b -> a sync, payload
// 5. a -> b payload // 5. a -> b payload
void write_pe1_2_dhkey(); void write_pe1_2_dhkey();
void write_pe3_sync(); void write_pe3_sync();
void write_pe4_sync(int crypto_select); void write_pe4_sync(int crypto_select);
void write_pe_vc_cryptofield(buffer::interval& write_buf, void write_pe_vc_cryptofield(buffer::interval& write_buf
int , int crypto_field, int pad_size);
crypto_field, int pad_size);
// 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
void send_buffer(char* 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);
m_RC4_handler->encrypt(buffer, size); m_RC4_handler->encrypt(buffer, size);
#ifdef TORRENT_DEBUG
m_encrypted_bytes += size;
TORRENT_ASSERT(m_encrypted_bytes == send_buf
fer_size() + size);
#endif
}
#endif #endif
peer_connection::append_send_buffer(buffer, size, de structor); peer_connection::append_send_buffer(buffer, size, de structor);
} }
void setup_send(); void setup_send();
private: private:
void encrypt_pending_buffer();
// Returns offset at which bytestream (src, src + src_size) // Returns offset at which bytestream (src, src + src_size)
// matches bytestream(target, target + target_size). // matches bytestream(target, target + target_size).
// If no sync found, return -1 // If no sync found, return -1
int get_syncoffset(char const* src, int src_size, int get_syncoffset(char const* src, int src_size
char const* target, int t , char const* target, int target_size) const;
arget_size) const;
#endif #endif
enum state enum state
{ {
#ifndef TORRENT_DISABLE_ENCRYPTION #ifndef TORRENT_DISABLE_ENCRYPTION
read_pe_dhkey = 0, read_pe_dhkey = 0,
read_pe_syncvc, read_pe_syncvc,
read_pe_synchash, read_pe_synchash,
read_pe_skey_vc, read_pe_skey_vc,
read_pe_cryptofield, read_pe_cryptofield,
skipping to change at line 336 skipping to change at line 345
handshake_len = 68, handshake_len = 68,
dh_key_len = 96 dh_key_len = 96
}; };
#endif #endif
std::string m_client_version; std::string m_client_version;
// state of on_receive // state of on_receive
state m_state; state m_state;
// the timeout in seconds
int m_timeout;
static const message_handler m_message_handler[num_supported _messages]; static const message_handler m_message_handler[num_supported _messages];
// this is a queue of ranges that describes // this is a queue of ranges that describes
// where in the send buffer actual payload // where in the send buffer actual payload
// data is located. This is currently // data is located. This is currently
// only used to be able to gather statistics // only used to be able to gather statistics
// seperately on payload and protocol data. // seperately on payload and protocol data.
struct range struct range
{ {
range(int s, int l) range(int s, int l)
skipping to change at line 418 skipping to change at line 424
#endif // #ifndef TORRENT_DISABLE_ENCRYPTION #endif // #ifndef TORRENT_DISABLE_ENCRYPTION
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
// this is set to true when the client's // this is set to true when the client's
// bitfield is sent to this peer // bitfield is sent to this peer
bool m_sent_bitfield; bool m_sent_bitfield;
bool m_in_constructor; bool m_in_constructor;
bool m_sent_handshake; bool m_sent_handshake;
// the number of bytes in the send buffer
// that have been encrypted (only used for
// encrypted connections)
int m_encrypted_bytes;
#endif #endif
}; };
} }
#endif // TORRENT_BT_PEER_CONNECTION_HPP_INCLUDED #endif // TORRENT_BT_PEER_CONNECTION_HPP_INCLUDED
 End of changes. 8 change blocks. 
10 lines changed or deleted 21 lines changed or added


 config.hpp   config.hpp 
skipping to change at line 80 skipping to change at line 80
// set up defines for target environments // set up defines for target environments
#if (defined __APPLE__ && __MACH__) || defined __FreeBSD__ || defined __Net BSD__ \ #if (defined __APPLE__ && __MACH__) || defined __FreeBSD__ || defined __Net BSD__ \
|| defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__ \ || defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__ \
|| defined __FreeBSD_kernel__ || defined __FreeBSD_kernel__
#define TORRENT_BSD #define TORRENT_BSD
#elif defined __linux__ #elif defined __linux__
#define TORRENT_LINUX #define TORRENT_LINUX
#elif defined WIN32 #elif defined WIN32
#define TORRENT_WINDOWS #define TORRENT_WINDOWS
#elif defined sun || defined __sun
#define TORRENT_SOLARIS
#else #else
#warning unkown OS, assuming BSD #warning unkown OS, assuming BSD
#define TORRENT_BSD #define TORRENT_BSD
#endif #endif
// should wpath or path be used? // should wpath or path be used?
#if defined UNICODE && !defined BOOST_FILESYSTEM_NARROW_ONLY \ #if defined UNICODE && !defined BOOST_FILESYSTEM_NARROW_ONLY \
&& BOOST_VERSION >= 103400 && defined WIN32 && BOOST_VERSION >= 103400 && defined WIN32
#define TORRENT_USE_WPATH 1 #define TORRENT_USE_WPATH 1
#else #else
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 disk_io_thread.hpp   disk_io_thread.hpp 
skipping to change at line 268 skipping to change at line 268
// write cache // write cache
cache_t m_pieces; cache_t m_pieces;
// read cache // read cache
cache_t m_read_pieces; cache_t m_read_pieces;
// total number of blocks in use by both the read // total number of blocks in use by both the read
// and the write cache. This is not supposed to // and the write cache. This is not supposed to
// exceed m_cache_size // exceed m_cache_size
cache_status m_cache_stats; cache_status m_cache_stats;
int m_num_cached_blocks;
// in (16kB) blocks // in (16kB) blocks
int m_cache_size; int m_cache_size;
// expiration time of cache entries in seconds // expiration time of cache entries in seconds
int m_cache_expiry; int m_cache_expiry;
// if set to true, each piece flush will allocate // if set to true, each piece flush will allocate
// one piece worth of temporary memory on the heap // one piece worth of temporary memory on the heap
// and copy the block data into it, and then perform // and copy the block data into it, and then perform
 End of changes. 1 change blocks. 
1 lines changed or deleted 0 lines changed or added


 escape_string.hpp   escape_string.hpp 
skipping to change at line 37 skipping to change at line 37
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
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_ESCAPE_STRING_HPP_INCLUDED #ifndef TORRENT_ESCAPE_STRING_HPP_INCLUDED
#define TORRENT_ESCAPE_STRING_HPP_INCLUDED #define TORRENT_ESCAPE_STRING_HPP_INCLUDED
#include <string> #include <string>
#include <limits>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/array.hpp>
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/size_type.hpp"
namespace libtorrent namespace libtorrent
{ {
boost::array<char, 3 + std::numeric_limits<size_type>::digits10> TOR
RENT_EXPORT to_string(size_type n);
bool TORRENT_EXPORT is_digit(char c);
bool TORRENT_EXPORT isprint(char c);
std::string TORRENT_EXPORT unescape_string(std::string const& s); std::string TORRENT_EXPORT unescape_string(std::string const& s);
std::string TORRENT_EXPORT escape_string(const char* str, int len); std::string TORRENT_EXPORT escape_string(const char* str, int len);
std::string TORRENT_EXPORT escape_path(const char* str, int len); std::string TORRENT_EXPORT escape_path(const char* 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);
 End of changes. 4 change blocks. 
0 lines changed or deleted 8 lines changed or added


 lazy_entry.hpp   lazy_entry.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_LAZY_ENTRY_HPP_INCLUDED #ifndef TORRENT_LAZY_ENTRY_HPP_INCLUDED
#define TORRENT_LAZY_ENTRY_HPP_INCLUDED #define TORRENT_LAZY_ENTRY_HPP_INCLUDED
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "libtorrent/assert.hpp"
#include "libtorrent/size_type.hpp"
#include <iosfwd> #include <iosfwd>
#include <string> #include <string>
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/size_type.hpp"
namespace libtorrent namespace libtorrent
{ {
struct lazy_entry; struct lazy_entry;
char const* parse_int(char const* start, char const* end, char delim TORRENT_EXPORT char const* parse_int(char const* start, char const*
iter, boost::int64_t& val); end
, char delimiter, boost::int64_t& val);
// return 0 = success // return 0 = success
int lazy_bdecode(char const* start, char const* end, lazy_entry& ret , int depth_limit = 1000); TORRENT_EXPORT int lazy_bdecode(char const* start, char const* end, lazy_entry& ret, int depth_limit = 1000);
struct lazy_entry struct TORRENT_EXPORT lazy_entry
{ {
enum entry_type_t enum entry_type_t
{ {
none_t, dict_t, list_t, string_t, int_t none_t, dict_t, list_t, string_t, int_t
}; };
lazy_entry() : m_type(none_t), m_begin(0), m_end(0) lazy_entry() : m_type(none_t), m_begin(0), m_end(0)
{ m_data.start = 0; } { m_data.start = 0; }
entry_type_t type() const { return m_type; } entry_type_t type() const { return m_type; }
skipping to change at line 228 skipping to change at line 230
char const* start; char const* start;
} m_data; } m_data;
int m_size; // if list or dictionary, the number of items int m_size; // if list or dictionary, the number of items
int m_capacity; // if list or dictionary, allocated number o f items int m_capacity; // if list or dictionary, allocated number o f items
// used for dictionaries and lists to record the range // used for dictionaries and lists to record the range
// in the original buffer they are based on // in the original buffer they are based on
char const* m_begin; char const* m_begin;
char const* m_end; char const* m_end;
}; };
std::ostream& operator<<(std::ostream& os, lazy_entry const& e); TORRENT_EXPORT std::ostream& operator<<(std::ostream& os, lazy_entry const& e);
} }
#endif #endif
 End of changes. 6 change blocks. 
7 lines changed or deleted 9 lines changed or added


 pe_crypto.hpp   pe_crypto.hpp 
skipping to change at line 84 skipping to change at line 84
char m_dh_local_key[96]; char m_dh_local_key[96];
char m_dh_secret[96]; char m_dh_secret[96];
sha1_hash m_xor_mask; sha1_hash m_xor_mask;
}; };
class RC4_handler // Non copyable class RC4_handler // Non copyable
{ {
public: public:
// Input longkeys must be 20 bytes // Input longkeys must be 20 bytes
RC4_handler(const sha1_hash& rc4_local_longkey, RC4_handler(const sha1_hash& rc4_local_longkey,
const sha1_hash& rc4_remote_longkey const sha1_hash& rc4_remote_longkey)
)
{ {
RC4_set_key(&m_local_key, 20, RC4_set_key(&m_local_key, 20,
reinterpret_cast<unsigned c har const*>(rc4_local_longkey.begin())); reinterpret_cast<unsigned char const*>(rc4_l ocal_longkey.begin()));
RC4_set_key(&m_remote_key, 20, RC4_set_key(&m_remote_key, 20,
reinterpret_cast<unsigned c har const*>(rc4_remote_longkey.begin())); reinterpret_cast<unsigned char const*>(rc4_r emote_longkey.begin()));
// Discard first 1024 bytes // Discard first 1024 bytes
char buf[1024]; char buf[1024];
encrypt(buf, 1024); encrypt(buf, 1024);
decrypt(buf, 1024); decrypt(buf, 1024);
}; };
~RC4_handler() {}; ~RC4_handler() {};
void encrypt(char* pos, int len) void encrypt(char* pos, int len)
{ {
TORRENT_ASSERT(len >= 0); TORRENT_ASSERT(len >= 0);
TORRENT_ASSERT(pos); TORRENT_ASSERT(pos);
RC4 (&m_local_key, len, reinterpret_cast<unsigned ch RC4(&m_local_key, len, reinterpret_cast<unsigned cha
ar const*>(pos), r const*>(pos),
reinterpret_cast<unsigned char*>(pos)); reinterpret_cast<unsigned char*>(pos));
} }
void decrypt(char* pos, int len) void decrypt(char* pos, int len)
{ {
TORRENT_ASSERT(len >= 0); TORRENT_ASSERT(len >= 0);
TORRENT_ASSERT(pos); TORRENT_ASSERT(pos);
RC4 (&m_remote_key, len, reinterpret_cast<unsigned c RC4(&m_remote_key, len, reinterpret_cast<unsigned ch
har const*>(pos), ar const*>(pos),
reinterpret_cast<unsigned char*>(pos)); reinterpret_cast<unsigned char*>(pos));
} }
private: private:
RC4_KEY m_local_key; // Key to encrypt outgoing data RC4_KEY m_local_key; // Key to encrypt outgoing data
RC4_KEY m_remote_key; // Key to decrypt incoming data RC4_KEY m_remote_key; // Key to decrypt incoming data
}; };
} // namespace libtorrent } // namespace libtorrent
#endif // TORRENT_PE_CRYPTO_HPP_INCLUDED #endif // TORRENT_PE_CRYPTO_HPP_INCLUDED
 End of changes. 5 change blocks. 
11 lines changed or deleted 9 lines changed or added


 peer_connection.hpp   peer_connection.hpp 
skipping to change at line 81 skipping to change at line 81
#include "libtorrent/session.hpp" #include "libtorrent/session.hpp"
#include "libtorrent/bandwidth_limit.hpp" #include "libtorrent/bandwidth_limit.hpp"
#include "libtorrent/policy.hpp" #include "libtorrent/policy.hpp"
#include "libtorrent/socket_type.hpp" #include "libtorrent/socket_type.hpp"
#include "libtorrent/intrusive_ptr_base.hpp" #include "libtorrent/intrusive_ptr_base.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/chained_buffer.hpp" #include "libtorrent/chained_buffer.hpp"
#include "libtorrent/disk_buffer_holder.hpp" #include "libtorrent/disk_buffer_holder.hpp"
#include "libtorrent/bitfield.hpp" #include "libtorrent/bitfield.hpp"
#ifdef TORRENT_STATS
#include "libtorrent/aux_/session_impl.hpp"
#endif
namespace libtorrent namespace libtorrent
{ {
class torrent; class torrent;
struct peer_plugin; struct peer_plugin;
namespace detail namespace detail
{ {
struct session_impl; struct session_impl;
} }
 End of changes. 1 change blocks. 
0 lines changed or deleted 4 lines changed or added


 peer_id.hpp   peer_id.hpp 
skipping to change at line 45 skipping to change at line 45
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <cctype> #include <cctype>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <cstring> #include <cstring>
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/escape_string.hpp"
namespace libtorrent namespace libtorrent
{ {
class TORRENT_EXPORT big_number class TORRENT_EXPORT big_number
{ {
// the number of bytes of the number // the number of bytes of the number
enum { number_size = 20 }; enum { number_size = 20 };
public: public:
enum { size = number_size }; enum { size = number_size };
skipping to change at line 171 skipping to change at line 172
{ {
os << std::hex << std::setw(2) << std::setfill('0') os << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<unsigned int>(*i); << static_cast<unsigned int>(*i);
} }
os << std::dec << std::setfill(' '); os << std::dec << std::setfill(' ');
return os; return os;
} }
inline std::istream& operator>>(std::istream& is, big_number& peer) inline std::istream& operator>>(std::istream& is, big_number& peer)
{ {
using namespace std;
for (big_number::iterator i = peer.begin(); for (big_number::iterator i = peer.begin();
i != peer.end(); ++i) i != peer.end(); ++i)
{ {
char c[2]; char c[2];
is >> c[0] >> c[1]; is >> c[0] >> c[1];
c[0] = tolower(c[0]); c[0] = tolower(c[0]);
c[1] = tolower(c[1]); c[1] = tolower(c[1]);
if ( if (
((c[0] < '0' || c[0] > '9') && (c[0] < 'a' | | c[0] > 'f')) ((c[0] < '0' || c[0] > '9') && (c[0] < 'a' | | c[0] > 'f'))
|| ((c[1] < '0' || c[1] > '9') && (c[1] < 'a ' || c[1] > 'f')) || ((c[1] < '0' || c[1] > '9') && (c[1] < 'a ' || c[1] > 'f'))
|| is.fail()) || is.fail())
{ {
is.setstate(ios_base::failbit); is.setstate(std::ios_base::failbit);
return is; return is;
} }
*i = ((isdigit(c[0])?c[0]-'0':c[0]-'a'+10) << 4) *i = ((is_digit(c[0])?c[0]-'0':c[0]-'a'+10) << 4)
+ (isdigit(c[1])?c[1]-'0':c[1]-'a'+10); + (is_digit(c[1])?c[1]-'0':c[1]-'a'+10);
} }
return is; return is;
} }
} }
#endif // TORRENT_PEER_ID_HPP_INCLUDED #endif // TORRENT_PEER_ID_HPP_INCLUDED
 End of changes. 4 change blocks. 
5 lines changed or deleted 4 lines changed or added


 session_impl.hpp   session_impl.hpp 
skipping to change at line 56 skipping to change at line 56
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push, 1) #pragma warning(push, 1)
#endif #endif
#include <boost/limits.hpp> #include <boost/limits.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/thread/recursive_mutex.hpp> #include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/condition.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#include "libtorrent/torrent_handle.hpp" #include "libtorrent/torrent_handle.hpp"
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/socket.hpp" #include "libtorrent/socket.hpp"
#include "libtorrent/peer_connection.hpp"
#include "libtorrent/peer_id.hpp" #include "libtorrent/peer_id.hpp"
#include "libtorrent/policy.hpp"
#include "libtorrent/tracker_manager.hpp" #include "libtorrent/tracker_manager.hpp"
#include "libtorrent/peer_info.hpp"
#include "libtorrent/alert.hpp" #include "libtorrent/alert.hpp"
#include "libtorrent/fingerprint.hpp"
#include "libtorrent/debug.hpp" #include "libtorrent/debug.hpp"
#include "libtorrent/peer_request.hpp"
#include "libtorrent/piece_block_progress.hpp" #include "libtorrent/piece_block_progress.hpp"
#include "libtorrent/ip_filter.hpp" #include "libtorrent/ip_filter.hpp"
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/session_settings.hpp" #include "libtorrent/session_settings.hpp"
#include "libtorrent/kademlia/dht_tracker.hpp" #include "libtorrent/kademlia/dht_tracker.hpp"
#include "libtorrent/session_status.hpp" #include "libtorrent/session_status.hpp"
#include "libtorrent/session.hpp" #include "libtorrent/session.hpp"
#include "libtorrent/stat.hpp" #include "libtorrent/stat.hpp"
#include "libtorrent/file_pool.hpp" #include "libtorrent/file_pool.hpp"
#include "libtorrent/bandwidth_manager.hpp" #include "libtorrent/bandwidth_manager.hpp"
#include "libtorrent/natpmp.hpp"
#include "libtorrent/upnp.hpp"
#include "libtorrent/lsd.hpp"
#include "libtorrent/socket_type.hpp" #include "libtorrent/socket_type.hpp"
#include "libtorrent/connection_queue.hpp" #include "libtorrent/connection_queue.hpp"
#include "libtorrent/disk_io_thread.hpp" #include "libtorrent/disk_io_thread.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
namespace libtorrent namespace libtorrent
{ {
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
class peer_connection;
class upnp;
class natpmp;
class lsd;
class fingerprint;
namespace dht
{
class dht_tracker;
};
namespace aux namespace aux
{ {
struct session_impl; struct session_impl;
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined T ORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined T ORRENT_ERROR_LOGGING
struct tracker_logger; struct tracker_logger;
#endif #endif
// this is the link between the main thread and the // this is the link between the main thread and the
skipping to change at line 237 skipping to change at line 240
void set_max_uploads(int limit); void set_max_uploads(int limit);
int max_connections() const { return m_max_connectio ns; } int max_connections() const { return m_max_connectio ns; }
int max_uploads() const { return m_max_uploads; } int max_uploads() const { return m_max_uploads; }
int max_half_open_connections() const { return m_hal f_open.limit(); } int max_half_open_connections() const { return m_hal f_open.limit(); }
int num_uploads() const { return m_num_unchoked; } int num_uploads() const { return m_num_unchoked; }
int num_connections() const int num_connections() const
{ return m_connections.size(); } { return m_connections.size(); }
void unchoke_peer(peer_connection& c) void unchoke_peer(peer_connection& c);
{
torrent* t = c.associated_torrent().lock().g
et();
TORRENT_ASSERT(t);
if (t->unchoke_peer(c))
++m_num_unchoked;
}
session_status status() const; session_status status() const;
void set_peer_id(peer_id const& id); void set_peer_id(peer_id const& id);
void set_key(int key); void set_key(int key);
unsigned short listen_port() const; unsigned short listen_port() const;
void abort(); void abort();
torrent_handle find_torrent_handle(sha1_hash const& info_hash); torrent_handle find_torrent_handle(sha1_hash const& info_hash);
skipping to change at line 295 skipping to change at line 292
bool has_asnum_db() const { return m_asnum_db; } bool has_asnum_db() const { return m_asnum_db; }
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);
#endif #endif
void load_state(entry const& ses_state); void load_state(entry const& ses_state);
entry state() const; entry state() const;
#ifdef TORRENT_STATS
void log_buffer_usage()
{
int send_buffer_capacity = 0;
int used_send_buffer = 0;
for (connection_map::const_iterator i = m_co
nnections.begin()
, end(m_connections.end()); i != end
; ++i)
{
send_buffer_capacity += (*i)->send_b
uffer_capacity();
used_send_buffer += (*i)->send_buffe
r_size();
}
TORRENT_ASSERT(send_buffer_capacity >= used_
send_buffer);
m_buffer_usage_logger << log_time() << " sen
d_buffer_size: " << send_buffer_capacity << std::endl;
m_buffer_usage_logger << log_time() << " use
d_send_buffer: " << used_send_buffer << std::endl;
m_buffer_usage_logger << log_time() << " sen
d_buffer_utilization: "
<< (used_send_buffer * 100.f / send_
buffer_capacity) << std::endl;
}
#endif
void start_lsd(); void start_lsd();
natpmp* start_natpmp(); natpmp* start_natpmp();
upnp* start_upnp(); upnp* start_upnp();
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 349 skipping to change at line 328
void free_buffer(char* buf, int size); void free_buffer(char* buf, int size);
char* allocate_disk_buffer(); char* allocate_disk_buffer();
void free_disk_buffer(char* buf); void free_disk_buffer(char* buf);
void set_external_address(address const& ip); void set_external_address(address const& ip);
address const& external_address() const { return m_e xternal_address; } address const& external_address() const { return m_e xternal_address; }
// private: // private:
void dht_state_callback(boost::condition& c
, entry& e, bool& done) const;
void on_lsd_peer(tcp::endpoint peer, sha1_hash const & ih); void on_lsd_peer(tcp::endpoint peer, sha1_hash const & ih);
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR #ifndef TORRENT_DISABLE_POOL_ALLOCATOR
// this pool is used to allocate and recycle send // this pool is used to allocate and recycle send
// buffers from. // buffers from.
boost::pool<> m_send_buffers; boost::pool<> m_send_buffers;
#endif #endif
boost::mutex m_send_buffer_mutex; boost::mutex m_send_buffer_mutex;
// the file pool that all storages in this session's // the file pool that all storages in this session's
// torrents uses. It sets a limit on the number of // torrents uses. It sets a limit on the number of
// open files by this session. // open files by this session.
// file pool must be destructed after the torrents // file pool must be destructed after the torrents
// since they will still have references to it // since they will still have references to it
// when they are destructed. // when they are destructed.
file_pool m_files; file_pool m_files;
// this is where all active sockets are stored. // this is where all active sockets are stored.
// the selector can sleep while there's no activity on // the selector can sleep while there's no activity on
// them // them
io_service m_io_service; mutable io_service m_io_service;
// handles disk io requests asynchronously // handles disk io requests asynchronously
// peers have pointers into the disk buffer // peers have pointers into the disk buffer
// pool, and must be destructed before this // pool, and must be destructed before this
// object. The disk thread relies on the file // object. The disk thread relies on the file
// pool object, and must be destructed before // pool object, and must be destructed before
// m_files. The disk io thread posts completion // m_files. The disk io thread posts completion
// events to the io service, and needs to be // events to the io service, and needs to be
// constructed after it. // constructed after it.
disk_io_thread m_disk_thread; disk_io_thread m_disk_thread;
skipping to change at line 585 skipping to change at line 566
// the index of the torrent that will be offered to // the index of the torrent that will be offered to
// connect to a peer next time second_tick is called . // connect to a peer next time second_tick is called .
// This implements a round robin. // This implements a round robin.
int m_next_connect_torrent; int m_next_connect_torrent;
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
void check_invariant() const; void check_invariant() const;
#endif #endif
#ifdef TORRENT_STATS #ifdef TORRENT_STATS
void log_buffer_usage();
// logger used to write bandwidth usage statistics // logger used to write bandwidth usage statistics
std::ofstream m_stats_logger; std::ofstream m_stats_logger;
int m_second_counter; int m_second_counter;
// used to log send buffer usage statistics // used to log send buffer usage statistics
std::ofstream m_buffer_usage_logger; std::ofstream m_buffer_usage_logger;
// the number of send buffers that are allocated // the number of send buffers that are allocated
int m_buffer_allocations; int m_buffer_allocations;
#endif #endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined T ORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined T ORRENT_ERROR_LOGGING
boost::shared_ptr<logger> create_log(std::string con st& name boost::shared_ptr<logger> create_log(std::string con st& name
 End of changes. 14 change blocks. 
45 lines changed or deleted 17 lines changed or added


 size_type.hpp   size_type.hpp 
skipping to change at line 49 skipping to change at line 49
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
#endif #endif
namespace libtorrent namespace libtorrent
{ {
typedef boost::int64_t size_type; typedef boost::int64_t size_type;
typedef boost::uint64_t unsigned_size_type;
} }
#endif #endif
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 socket.hpp   socket.hpp 
skipping to change at line 216 skipping to change at line 216
int level(Protocol const&) const { return IPPROTO_IPV6; } int level(Protocol const&) const { return IPPROTO_IPV6; }
template<class Protocol> template<class Protocol>
int name(Protocol const&) const { return IPV6_V6ONLY; } int name(Protocol const&) const { return IPV6_V6ONLY; }
template<class Protocol> template<class Protocol>
int const* data(Protocol const&) const { return &m_value; } int const* data(Protocol const&) const { return &m_value; }
template<class Protocol> template<class Protocol>
size_t size(Protocol const&) const { return sizeof(m_value); } size_t size(Protocol const&) const { return sizeof(m_value); }
int m_value; int m_value;
}; };
#ifdef TORRENT_WINDOWS
struct v6_protection_level
{
v6_protection_level(int level): m_value(level) {}
template<class Protocol>
int level(Protocol const&) const { return IPPROTO_IPV6; }
template<class Protocol>
int name(Protocol const&) const { return IPV6_PROTECTION_LEV
EL; }
template<class Protocol>
int const* data(Protocol const&) const { return &m_value; }
template<class Protocol>
size_t size(Protocol const&) const { return sizeof(m_value);
}
int m_value;
};
#endif
struct type_of_service struct type_of_service
{ {
type_of_service(char val): m_value(val) {} type_of_service(char val): m_value(val) {}
template<class Protocol> template<class Protocol>
int level(Protocol const&) const { return IPPROTO_IP; } int level(Protocol const&) const { return IPPROTO_IP; }
template<class Protocol> template<class Protocol>
int name(Protocol const&) const { return IP_TOS; } int name(Protocol const&) const { return IP_TOS; }
template<class Protocol> template<class Protocol>
char const* data(Protocol const&) const { return &m_value; } char const* data(Protocol const&) const { return &m_value; }
template<class Protocol> template<class Protocol>
 End of changes. 1 change blocks. 
0 lines changed or deleted 18 lines changed or added


 storage.hpp   storage.hpp 
skipping to change at line 82 skipping to change at line 82
struct disk_io_job; struct disk_io_job;
struct disk_buffer_holder; struct disk_buffer_holder;
enum storage_mode_t enum storage_mode_t
{ {
storage_mode_allocate = 0, storage_mode_allocate = 0,
storage_mode_sparse, storage_mode_sparse,
storage_mode_compact storage_mode_compact
}; };
#if defined(_WIN32) && defined(UNICODE) #if TORRENT_USE_WPATH
TORRENT_EXPORT std::wstring safe_convert(std::string const& s); TORRENT_EXPORT std::wstring safe_convert(std::string const& s);
#endif #endif
TORRENT_EXPORT std::vector<std::pair<size_type, std::time_t> > get_f ilesizes( TORRENT_EXPORT std::vector<std::pair<size_type, std::time_t> > get_f ilesizes(
file_storage const& t file_storage const& t
, fs::path p); , fs::path p);
TORRENT_EXPORT bool match_filesizes( TORRENT_EXPORT bool match_filesizes(
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 torrent.hpp   torrent.hpp 
skipping to change at line 215 skipping to change at line 215
std::string name() const; std::string name() const;
stat statistics() const { return m_stat; } stat statistics() const { return m_stat; }
void add_stats(stat const& s) { m_stat += s; } void add_stats(stat const& s) { m_stat += s; }
size_type bytes_left() const; size_type bytes_left() const;
boost::tuples::tuple<size_type, size_type> bytes_done() cons t; boost::tuples::tuple<size_type, size_type> bytes_done() cons t;
size_type quantized_bytes_done() const; size_type quantized_bytes_done() const;
void ip_filter_updated() { m_policy.ip_filter_updated(); } void ip_filter_updated() { m_policy.ip_filter_updated(); }
void set_error(std::string const& msg) { m_error = msg; } void set_error(std::string const& msg);
bool has_error() const { return !m_error.empty(); } bool has_error() const { return !m_error.empty(); }
void pause(); void pause();
void resume(); void resume();
ptime started() const { return m_started; } ptime started() const { return m_started; }
void do_pause(); void do_pause();
void do_resume(); void do_resume();
bool is_paused() const; bool is_paused() const;
bool is_torrent_paused() const { return m_paused; } bool is_torrent_paused() const { return m_paused; }
void force_recheck(); void force_recheck();
void save_resume_data(); void save_resume_data();
bool is_auto_managed() const { return m_auto_managed; } bool is_auto_managed() const { return m_auto_managed; }
void auto_managed(bool a); void auto_managed(bool a);
bool should_check_files() const;
void delete_files(); void delete_files();
// ============ start deprecation ============= // ============ start deprecation =============
void filter_piece(int index, bool filter); void filter_piece(int index, bool filter);
void filter_pieces(std::vector<bool> const& bitmask); void filter_pieces(std::vector<bool> const& bitmask);
bool is_piece_filtered(int index) const; bool is_piece_filtered(int index) const;
void filtered_pieces(std::vector<bool>& bitmask) const; void filtered_pieces(std::vector<bool>& bitmask) const;
void filter_files(std::vector<bool> const& files); void filter_files(std::vector<bool> const& files);
void file_progress(std::vector<float>& fp) const; void file_progress(std::vector<float>& fp) const;
// ============ end deprecation ============= // ============ end deprecation =============
skipping to change at line 664 skipping to change at line 666
, boost::function<void(int)> f); , boost::function<void(int)> f);
void try_next_tracker(tracker_request const& req); void try_next_tracker(tracker_request const& req);
int prioritize_tracker(int tracker_index); int prioritize_tracker(int tracker_index);
void on_country_lookup(error_code const& error, tcp::resolve r::iterator i void on_country_lookup(error_code const& error, tcp::resolve r::iterator i
, boost::intrusive_ptr<peer_connection> p) const; , boost::intrusive_ptr<peer_connection> p) const;
bool request_bandwidth_from_session(int channel) const; bool request_bandwidth_from_session(int channel) const;
void update_peer_interest(bool was_finished); void update_peer_interest(bool was_finished);
void queue_torrent_check();
void dequeue_torrent_check();
policy m_policy; policy m_policy;
// total time we've been available on this torrent // total time we've been available on this torrent
// does not count when the torrent is stopped or paused // does not count when the torrent is stopped or paused
time_duration m_active_time; time_duration m_active_time;
// total time we've been available as a seed on this torrent // total time we've been available as a seed on this torrent
// does not count when the torrent is stopped or paused // does not count when the torrent is stopped or paused
time_duration m_seeding_time; time_duration m_seeding_time;
skipping to change at line 976 skipping to change at line 981
// is set to true every time there is an incoming // is set to true every time there is an incoming
// connection to this torrent // connection to this torrent
bool m_has_incoming:1; bool m_has_incoming:1;
// this is set to true when the files are checked // this is set to true when the files are checked
// before the files are checked, we don't try to // before the files are checked, we don't try to
// connect to peers // connect to peers
bool m_files_checked:1; bool m_files_checked:1;
// this is true if the torrent has been added to
// checking queue in the session
bool m_queued_for_checking:1;
// this is true while tracker announcing is enabled // this is true while tracker announcing is enabled
// is is disabled while paused and checking files // is is disabled while paused and checking files
bool m_announcing:1; bool m_announcing:1;
// this is true if event start has been sent to the tracker // this is true if event start has been sent to the tracker
bool m_start_sent:1; bool m_start_sent:1;
// this is true if event completed has been sent to the trac ker // this is true if event completed has been sent to the trac ker
bool m_complete_sent:1; bool m_complete_sent:1;
}; };
 End of changes. 4 change blocks. 
1 lines changed or deleted 10 lines changed or added


 torrent_handle.hpp   torrent_handle.hpp 
skipping to change at line 84 skipping to change at line 84
struct TORRENT_EXPORT invalid_handle: std::exception struct TORRENT_EXPORT invalid_handle: std::exception
{ {
virtual const char* what() const throw() virtual const char* what() const throw()
{ return "invalid torrent handle used"; } { return "invalid torrent handle used"; }
}; };
struct TORRENT_EXPORT torrent_status struct TORRENT_EXPORT torrent_status
{ {
torrent_status() torrent_status()
: state(queued_for_checking) : state(checking_resume_data)
, paused(false) , paused(false)
, progress(0.f) , progress(0.f)
, total_download(0) , total_download(0)
, total_upload(0) , total_upload(0)
, total_payload_download(0) , total_payload_download(0)
, total_payload_upload(0) , total_payload_upload(0)
, total_failed_bytes(0) , total_failed_bytes(0)
, total_redundant_bytes(0) , total_redundant_bytes(0)
, download_rate(0) , download_rate(0)
, upload_rate(0) , upload_rate(0)
skipping to change at line 133 skipping to change at line 133
{} {}
enum state_t enum state_t
{ {
queued_for_checking, queued_for_checking,
checking_files, checking_files,
downloading_metadata, downloading_metadata,
downloading, downloading,
finished, finished,
seeding, seeding,
allocating allocating,
checking_resume_data
}; };
state_t state; state_t state;
bool paused; bool paused;
float progress; float progress;
std::string error; std::string error;
boost::posix_time::time_duration next_announce; boost::posix_time::time_duration next_announce;
boost::posix_time::time_duration announce_interval; boost::posix_time::time_duration announce_interval;
 End of changes. 2 change blocks. 
2 lines changed or deleted 3 lines changed or added


 torrent_info.hpp   torrent_info.hpp 
skipping to change at line 96 skipping to change at line 96
{ {
public: public:
torrent_info(sha1_hash const& info_hash); torrent_info(sha1_hash const& info_hash);
torrent_info(lazy_entry const& torrent_file); torrent_info(lazy_entry const& torrent_file);
torrent_info(char const* buffer, int size); torrent_info(char const* buffer, int size);
torrent_info(fs::path const& filename); torrent_info(fs::path const& filename);
~torrent_info(); ~torrent_info();
file_storage const& files() const { return m_files; } file_storage const& files() const { return m_files; }
file_storage& files() { return m_files; } file_storage const& orig_files() const { return m_orig_files
? *m_orig_files : m_files; }
void rename_file(int index, std::string const& new_filename)
{
copy_on_write();
m_files.rename_file(index, new_filename);
}
void add_tracker(std::string const& url, int tier = 0); void add_tracker(std::string const& url, int tier = 0);
std::vector<announce_entry> const& trackers() const { return m_urls; } std::vector<announce_entry> const& trackers() const { return m_urls; }
std::vector<std::string> const& url_seeds() const std::vector<std::string> const& url_seeds() const
{ return m_url_seeds; } { return m_url_seeds; }
void add_url_seed(std::string const& url) void add_url_seed(std::string const& url)
{ m_url_seeds.push_back(url); } { m_url_seeds.push_back(url); }
size_type total_size() const { return m_files.total_size(); } size_type total_size() const { return m_files.total_size(); }
skipping to change at line 134 skipping to change at line 140
std::vector<file_slice> map_block(int piece, size_type offse t, int size) const std::vector<file_slice> map_block(int piece, size_type offse t, int size) const
{ return m_files.map_block(piece, offset, size); } { return m_files.map_block(piece, offset, size); }
peer_request map_file(int file, size_type offset, int size) const peer_request map_file(int file, size_type offset, int size) const
{ return m_files.map_file(file, offset, size); } { return m_files.map_file(file, offset, size); }
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
// ------- start deprecation ------- // ------- start deprecation -------
// these functions will be removed in a future version // these functions will be removed in a future version
torrent_info(entry const& torrent_file) TORRENT_DEPRECATED; torrent_info(entry const& torrent_file) TORRENT_DEPRECATED;
void print(std::ostream& os) const TORRENT_DEPRECATED; void print(std::ostream& os) const TORRENT_DEPRECATED;
file_storage& files() TORRENT_DEPRECATED { return m_files; }
// ------- end deprecation ------- // ------- end deprecation -------
#endif #endif
bool is_valid() const { return m_files.is_valid(); } bool is_valid() const { return m_files.is_valid(); }
bool priv() const { return m_private; } bool priv() const { return m_private; }
int piece_size(int index) const { return m_files.piece_size( index); } int piece_size(int index) const { return m_files.piece_size( index); }
sha1_hash hash_for_piece(int index) const sha1_hash hash_for_piece(int index) const
skipping to change at line 191 skipping to change at line 198
void swap(torrent_info& ti); void swap(torrent_info& ti);
boost::shared_array<char> metadata() const boost::shared_array<char> metadata() const
{ return m_info_section; } { return m_info_section; }
int metadata_size() const { return m_info_section_size; } int metadata_size() const { return m_info_section_size; }
private: private:
void copy_on_write();
bool parse_torrent_file(lazy_entry const& libtorrent, std::s tring& error); bool parse_torrent_file(lazy_entry const& libtorrent, std::s tring& error);
file_storage m_files; file_storage m_files;
// if m_files is modified, it is first copied into
// m_orig_files so that the original name and
// filenames are preserved.
boost::shared_ptr<const file_storage> m_orig_files;
// the urls to the trackers // the urls to the trackers
std::vector<announce_entry> m_urls; std::vector<announce_entry> m_urls;
std::vector<std::string> m_url_seeds; std::vector<std::string> m_url_seeds;
nodes_t m_nodes; nodes_t m_nodes;
// the hash that identifies this torrent // the hash that identifies this torrent
sha1_hash m_info_hash; sha1_hash m_info_hash;
// if a creation date is found in the torrent file // if a creation date is found in the torrent file
// this will be set to that, otherwise it'll be // this will be set to that, otherwise it'll be
 End of changes. 4 change blocks. 
1 lines changed or deleted 15 lines changed or added


 udp_socket.hpp   udp_socket.hpp 
skipping to change at line 54 skipping to change at line 54
{ {
class connection_queue; class connection_queue;
class udp_socket class udp_socket
{ {
public: public:
typedef boost::function<void(error_code const& ec typedef boost::function<void(error_code const& ec
, udp::endpoint const&, char const* buf, int size)> callback_t; , udp::endpoint const&, char const* buf, int size)> callback_t;
udp_socket(io_service& ios, callback_t const& c, connection_ queue& cc); udp_socket(io_service& ios, callback_t const& c, connection_ queue& cc);
~udp_socket();
bool is_open() const { return m_ipv4_sock.is_open() || m_ipv 6_sock.is_open(); } bool is_open() const { return m_ipv4_sock.is_open() || m_ipv 6_sock.is_open(); }
io_service& get_io_service() { return m_ipv4_sock.get_io_ser vice(); } io_service& get_io_service() { return m_ipv4_sock.get_io_ser vice(); }
void send(udp::endpoint const& ep, char const* p, int len, e rror_code& ec); void send(udp::endpoint const& ep, char const* p, int len, e rror_code& ec);
void bind(udp::endpoint const& ep, error_code& ec); void bind(udp::endpoint const& ep, error_code& ec);
void bind(int port); void bind(int port);
void close(); void close();
int local_port() const { return m_bind_port; } int local_port() const { return m_bind_port; }
void set_proxy_settings(proxy_settings const& ps); void set_proxy_settings(proxy_settings const& ps);
proxy_settings const& get_proxy_settings() { return m_proxy_ settings; } proxy_settings const& get_proxy_settings() { return m_proxy_ settings; }
#ifdef TORRENT_DEBUG
~udp_socket() { m_magic = 0; }
#endif
private: private:
callback_t m_callback; callback_t m_callback;
void on_read(udp::socket* sock, error_code const& e, std::si ze_t bytes_transferred); void on_read(udp::socket* sock, error_code const& e, std::si ze_t bytes_transferred);
void on_name_lookup(error_code const& e, tcp::resolver::iter ator i); void on_name_lookup(error_code const& e, tcp::resolver::iter ator i);
void on_timeout(); void on_timeout();
void on_connect(int ticket); void on_connect(int ticket);
void on_connected(error_code const& ec); void on_connected(error_code const& ec);
void handshake1(error_code const& e); void handshake1(error_code const& e);
skipping to change at line 110 skipping to change at line 107
int m_bind_port; int m_bind_port;
char m_outstanding; char m_outstanding;
tcp::socket m_socks5_sock; tcp::socket m_socks5_sock;
int m_connection_ticket; int m_connection_ticket;
proxy_settings m_proxy_settings; proxy_settings m_proxy_settings;
connection_queue& m_cc; connection_queue& m_cc;
tcp::resolver m_resolver; tcp::resolver m_resolver;
char m_tmp_buf[100]; char m_tmp_buf[100];
bool m_tunnel_packets; bool m_tunnel_packets;
bool m_abort;
udp::endpoint m_proxy_addr; udp::endpoint m_proxy_addr;
#ifdef TORRENT_DEBUG #ifdef TORRENT_DEBUG
int m_magic; int m_magic;
#endif #endif
}; };
} }
#endif #endif
 End of changes. 3 change blocks. 
4 lines changed or deleted 2 lines changed or added


 version.hpp   version.hpp 
skipping to change at line 39 skipping to change at line 39
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 14 #define LIBTORRENT_VERSION_MINOR 14
#define LIBTORRENT_VERSION "0.14.1.0" #define LIBTORRENT_VERSION "0.14.2.0"
#define LIBTORRENT_REVISION "$Rev: 3169 $"
#endif #endif
 End of changes. 1 change blocks. 
1 lines changed or deleted 2 lines changed or added


 xml_parse.hpp   xml_parse.hpp 
skipping to change at line 37 skipping to change at line 37
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
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_XML_PARSE_HPP #ifndef TORRENT_XML_PARSE_HPP
#define TORRENT_XML_PARSE_HPP #define TORRENT_XML_PARSE_HPP
#include <cctype> #include <cctype>
#include <cstring>
namespace libtorrent namespace libtorrent
{ {
enum enum
{ {
xml_start_tag, xml_start_tag,
xml_end_tag, xml_end_tag,
xml_empty_tag, xml_empty_tag,
xml_declaration_tag, xml_declaration_tag,
xml_string, xml_string,
xml_attribute, xml_attribute,
xml_comment, xml_comment,
xml_parse_error xml_parse_error
}; };
inline bool isspace(char c)
{
const static char* ws = " \t\n\r\f\v";
return std::strchr(ws, c);
}
// callback(int type, char const* name, char const* val) // callback(int type, char const* name, char const* val)
// str2 is only used for attributes. name is element or attribute // str2 is only used for attributes. name is element or attribute
// name and val is attribute value // name and val is attribute value
template <class CallbackType> template <class CallbackType>
void xml_parse(char* p, char* end, CallbackType callback) void xml_parse(char* p, char* end, CallbackType callback)
{ {
for(;p != end; ++p) for(;p != end; ++p)
{ {
char const* start = p; char const* start = p;
skipping to change at line 85 skipping to change at line 92
callback(token, start, val_start); callback(token, start, val_start);
if (p != end) *p = '<'; if (p != end) *p = '<';
} }
if (p == end) break; if (p == end) break;
// skip '<' // skip '<'
++p; ++p;
// parse the name of the tag. // parse the name of the tag.
for (start = p; p != end && *p != '>' && !std::isspa ce(*p); ++p); for (start = p; p != end && *p != '>' && !isspace(*p ); ++p);
char* tag_name_end = p; char* tag_name_end = p;
// skip the attributes for now // skip the attributes for now
for (; p != end && *p != '>'; ++p); for (; p != end && *p != '>'; ++p);
// parse error // parse error
if (p == end) if (p == end)
{ {
token = xml_parse_error; token = xml_parse_error;
skipping to change at line 131 skipping to change at line 138
} }
else if (*start == '?' && *(p-1) == '?') else if (*start == '?' && *(p-1) == '?')
{ {
*(p-1) = 0; *(p-1) = 0;
++start; ++start;
token = xml_declaration_tag; token = xml_declaration_tag;
callback(token, start, val_start); callback(token, start, val_start);
*(p-1) = '?'; *(p-1) = '?';
tag_end = p - 1; tag_end = p - 1;
} }
else if (start + 5 < p && memcmp(start, "!--", 3) == 0 && memcmp(p-2, "--", 2) == 0) else if (start + 5 < p && std::memcmp(start, "!--", 3) == 0 && std::memcmp(p-2, "--", 2) == 0)
{ {
start += 3; start += 3;
*(p-2) = 0; *(p-2) = 0;
token = xml_comment; token = xml_comment;
callback(token, start, val_start); callback(token, start, val_start);
*(p-2) = '-'; *(p-2) = '-';
tag_end = p - 2; tag_end = p - 2;
} }
else else
{ {
token = xml_start_tag; token = xml_start_tag;
callback(token, start, val_start); callback(token, start, val_start);
} }
*tag_name_end = save; *tag_name_end = save;
// parse attributes // parse attributes
for (char* i = tag_name_end; i < tag_end; ++i) for (char* i = tag_name_end; i < tag_end; ++i)
{ {
// find start of attribute name // find start of attribute name
for (; i != tag_end && std::isspace(*i); ++i ); for (; i != tag_end && isspace(*i); ++i);
if (i == tag_end) break; if (i == tag_end) break;
start = i; start = i;
// find end of attribute name // find end of attribute name
for (; i != tag_end && *i != '=' && !std::is space(*i); ++i); for (; i != tag_end && *i != '=' && !isspace (*i); ++i);
char* name_end = i; char* name_end = i;
// look for equality sign // look for equality sign
for (; i != tag_end && *i != '='; ++i); for (; i != tag_end && *i != '='; ++i);
if (i == tag_end) if (i == tag_end)
{ {
token = xml_parse_error; token = xml_parse_error;
val_start = 0; val_start = 0;
start = "garbage inside element brac kets"; start = "garbage inside element brac kets";
callback(token, start, val_start); callback(token, start, val_start);
break; break;
} }
++i; ++i;
for (; i != tag_end && std::isspace(*i); ++i ); for (; i != tag_end && isspace(*i); ++i);
// check for parse error (values must be quo ted) // check for parse error (values must be quo ted)
if (i == tag_end || (*i != '\'' && *i != '\" ')) if (i == tag_end || (*i != '\'' && *i != '\" '))
{ {
token = xml_parse_error; token = xml_parse_error;
val_start = 0; val_start = 0;
start = "unquoted attribute value"; start = "unquoted attribute value";
callback(token, start, val_start); callback(token, start, val_start);
break; break;
} }
char quote = *i; char quote = *i;
 End of changes. 7 change blocks. 
5 lines changed or deleted 12 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/