| bencode.hpp | | bencode.hpp | |
| | | | |
| skipping to change at line 60 | | skipping to change at line 60 | |
| * template<class InIt> | | * template<class InIt> | |
| * libtorrent::entry libtorrent::bdecode(InIt start, InIt end); | | * libtorrent::entry libtorrent::bdecode(InIt start, InIt end); | |
| * | | * | |
| * Decodes the buffer given by the start and end iterators | | * Decodes the buffer given by the start and end iterators | |
| * and returns the decoded entry. InIt must be an InputIterator | | * and returns the decoded entry. InIt must be an InputIterator | |
| * of type char. May throw libtorrent::invalid_encoding if | | * of type char. May throw libtorrent::invalid_encoding if | |
| * the string is not correctly bencoded. | | * the string is not correctly bencoded. | |
| * | | * | |
| */ | | */ | |
| | | | |
|
| #include <cstdlib> | | #include <stdlib.h> | |
| | | #include <string> | |
| | | #include <exception> | |
| | | #include <iterator> // for distance | |
| | | | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| #pragma warning(push, 1) | | #pragma warning(push, 1) | |
| #endif | | #endif | |
| | | | |
| #include <boost/static_assert.hpp> | | #include <boost/static_assert.hpp> | |
| | | | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| #pragma warning(pop) | | #pragma warning(pop) | |
| #endif | | #endif | |
| | | | |
| skipping to change at line 245 | | skipping to change at line 248 | |
| // integer | | // integer | |
| case 'i': | | case 'i': | |
| { | | { | |
| ++in; // 'i' | | ++in; // 'i' | |
| std::string val = read_until(in, end, 'e', e
rr); | | std::string val = read_until(in, end, 'e', e
rr); | |
| if (err) return; | | if (err) return; | |
| TORRENT_ASSERT(*in == 'e'); | | TORRENT_ASSERT(*in == 'e'); | |
| ++in; // 'e' | | ++in; // 'e' | |
| ret = entry(entry::int_t); | | ret = entry(entry::int_t); | |
| char* end_pointer; | | char* end_pointer; | |
|
| #if defined TORRENT_WINDOWS && !defined TORRENT_MINGW | | | |
| ret.integer() = _strtoi64(val.c_str(), &end_ | | | |
| pointer, 10); | | | |
| #else | | | |
| ret.integer() = strtoll(val.c_str(), &end_po
inter, 10); | | ret.integer() = strtoll(val.c_str(), &end_po
inter, 10); | |
|
| #endif | | | |
| #ifdef TORRENT_DEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| if (end_pointer == val.c_str()) | | if (end_pointer == val.c_str()) | |
| { | | { | |
| err = true; | | err = true; | |
| return; | | return; | |
| } | | } | |
| } break; | | } break; | |
| | | | |
| | | | |
| skipping to change at line 351 | | skipping to change at line 350 | |
| 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 == ':'); | |
| ++in; // ':' | | ++in; // ':' | |
|
| int len = std::atoi(len_s.c_str()); | | int len = atoi(len_s.c_str()); | |
| ret = entry(entry::string_t); | | ret = entry(entry::string_t); | |
| read_string(in, end, len, ret.string
(), err); | | read_string(in, end, len, ret.string
(), 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; | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 4 change blocks. |
| 7 lines changed or deleted | | 5 lines changed or added | |
|
| config.hpp | | config.hpp | |
| | | | |
| skipping to change at line 52 | | skipping to change at line 52 | |
| #error TORRENT_DEBUG_BUFFERS only works if you also disable pool allocators
with TORRENT_DISABLE_POOL_ALLOCATOR | | #error TORRENT_DEBUG_BUFFERS only works if you also disable pool allocators
with TORRENT_DISABLE_POOL_ALLOCATOR | |
| #endif | | #endif | |
| | | | |
| #if !defined BOOST_ASIO_SEPARATE_COMPILATION && !defined BOOST_ASIO_DYN_LIN
K | | #if !defined BOOST_ASIO_SEPARATE_COMPILATION && !defined BOOST_ASIO_DYN_LIN
K | |
| #error you must define either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO
_DYN_LINK in your project in \ | | #error you must define either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO
_DYN_LINK in your project in \ | |
| order for asio's declarations to be correct. If you're linking dynam
ically against libtorrent, define \ | | order for asio's declarations to be correct. If you're linking dynam
ically against libtorrent, define \ | |
| BOOST_ASIO_DYN_LINK otherwise BOOST_ASIO_SEPARATE_COMPILATION. You c
an also use pkg-config or boost \ | | BOOST_ASIO_DYN_LINK otherwise BOOST_ASIO_SEPARATE_COMPILATION. You c
an also use pkg-config or boost \ | |
| build, to automatically apply these defines | | build, to automatically apply these defines | |
| #endif | | #endif | |
| | | | |
|
| | | #if !defined _MSC_VER || _MSC_VER >= 1600 | |
| | | #ifndef __STDC_LIMIT_MACROS | |
| | | #define __STDC_LIMIT_MACROS 1 | |
| | | #endif | |
| | | #include <stdint.h> // for INT64_MAX | |
| | | #else | |
| | | #if !defined INT64_MAX | |
| | | #define INT64_MAX 0x7fffffffffffffffLL | |
| | | #endif | |
| | | #endif | |
| | | | |
| #ifndef _MSC_VER | | #ifndef _MSC_VER | |
|
| | | #ifndef __STDC_FORMAT_MACROS | |
| #define __STDC_FORMAT_MACROS 1 | | #define __STDC_FORMAT_MACROS 1 | |
|
| #define __STDC_LIMIT_MACROS 1 | | #endif | |
| #include <inttypes.h> // for PRId64 et.al. | | #include <inttypes.h> // for PRId64 et.al. | |
|
| #include <stdint.h> // for INT64_MAX | | | |
| #endif | | #endif | |
| | | | |
| #ifndef PRId64 | | #ifndef PRId64 | |
| // MinGW uses microsofts runtime | | // MinGW uses microsofts runtime | |
| #if defined _MSC_VER || defined __MINGW32__ | | #if defined _MSC_VER || defined __MINGW32__ | |
| #define PRId64 "I64d" | | #define PRId64 "I64d" | |
| #define PRIu64 "I64u" | | #define PRIu64 "I64u" | |
| #define PRIu32 "u" | | #define PRIu32 "u" | |
| #else | | #else | |
| #define PRId64 "lld" | | #define PRId64 "lld" | |
| #define PRIu64 "llu" | | #define PRIu64 "llu" | |
| #define PRIu32 "u" | | #define PRIu32 "u" | |
| #endif | | #endif | |
| #endif | | #endif | |
| | | | |
|
| #if !defined INT64_MAX | | | |
| #define INT64_MAX 0x7fffffffffffffffLL | | | |
| #endif | | | |
| | | | |
| // backwards compatibility with older versions of boost | | // backwards compatibility with older versions of boost | |
| #if !defined BOOST_SYMBOL_EXPORT && !defined BOOST_SYMBOL_IMPORT | | #if !defined BOOST_SYMBOL_EXPORT && !defined BOOST_SYMBOL_IMPORT | |
| # if defined _MSC_VER || defined __MINGW32__ | | # if defined _MSC_VER || defined __MINGW32__ | |
| # define BOOST_SYMBOL_EXPORT __declspec(dllexport) | | # define BOOST_SYMBOL_EXPORT __declspec(dllexport) | |
| # define BOOST_SYMBOL_IMPORT __declspec(dllimport) | | # define BOOST_SYMBOL_IMPORT __declspec(dllimport) | |
| # elif __GNU__ >= 4 | | # elif __GNU__ >= 4 | |
| # define BOOST_SYMBOL_EXPORT __attribute__((visibility("default"))) | | # define BOOST_SYMBOL_EXPORT __attribute__((visibility("default"))) | |
| # define BOOST_SYMBOL_IMPORT __attribute__((visibility("default"))) | | # define BOOST_SYMBOL_IMPORT __attribute__((visibility("default"))) | |
| # else | | # else | |
| # define BOOST_SYMBOL_EXPORT | | # define BOOST_SYMBOL_EXPORT | |
| | | | |
End of changes. 5 change blocks. |
| 6 lines changed or deleted | | 13 lines changed or added | |
|
| connection_queue.hpp | | connection_queue.hpp | |
| | | | |
| skipping to change at line 70 | | skipping to change at line 70 | |
| int free_slots() const; | | int free_slots() const; | |
| | | | |
| void enqueue(boost::function<void(int)> const& on_connect | | void enqueue(boost::function<void(int)> const& on_connect | |
| , boost::function<void()> const& on_timeout | | , boost::function<void()> const& on_timeout | |
| , time_duration timeout, int priority = 0); | | , time_duration timeout, int priority = 0); | |
| void done(int ticket); | | void done(int ticket); | |
| void limit(int limit); | | void limit(int limit); | |
| int limit() const; | | int limit() const; | |
| void close(); | | void close(); | |
| int size() const { return m_queue.size(); } | | int size() const { return m_queue.size(); } | |
|
| | | int num_connecting() const { return m_num_connecting; } | |
| | | #if defined TORRENT_ASIO_DEBUGGING | |
| | | float next_timeout() const { return total_milliseconds(m_timer.expir | |
| | | es_at() - time_now_hires()) / 1000.f; } | |
| | | float max_timeout() const | |
| | | { | |
| | | ptime max_timeout = min_time(); | |
| | | for (std::list<entry>::const_iterator i = m_queue.begin() | |
| | | , end(m_queue.end()); i != end; ++i) | |
| | | { | |
| | | if (!i->connecting) continue; | |
| | | if (i->expires > max_timeout) max_timeout = i->expir | |
| | | es; | |
| | | } | |
| | | if (max_timeout == min_time()) return 0.f; | |
| | | return total_milliseconds(max_timeout - time_now_hires()) / | |
| | | 1000.f; | |
| | | } | |
| | | #endif | |
| | | | |
| #ifdef TORRENT_DEBUG | | #ifdef TORRENT_DEBUG | |
| void check_invariant() const; | | void check_invariant() const; | |
| #endif | | #endif | |
| | | | |
| private: | | private: | |
| | | | |
| typedef mutex mutex_t; | | typedef mutex mutex_t; | |
| | | | |
| void try_connect(mutex_t::scoped_lock& l); | | void try_connect(mutex_t::scoped_lock& l); | |
| void on_timeout(error_code const& e); | | void on_timeout(error_code const& e); | |
| void on_try_connect(); | | void on_try_connect(); | |
| | | | |
| struct entry | | struct entry | |
| { | | { | |
| entry(): connecting(false), ticket(0), expires(max_time()),
priority(0) {} | | entry(): connecting(false), ticket(0), expires(max_time()),
priority(0) {} | |
| // called when the connection is initiated | | // called when the connection is initiated | |
| // this is when the timeout countdown starts | | // this is when the timeout countdown starts | |
|
| | | // TODO: if we don't actually need the connection queue | |
| | | // to hold ownership of objects, replace these boost functio | |
| | | ns | |
| | | // with pointer to a pure virtual interface class | |
| boost::function<void(int)> on_connect; | | boost::function<void(int)> on_connect; | |
| // called if done hasn't been called within the timeout | | // called if done hasn't been called within the timeout | |
| // or if the connection queue aborts. This means there | | // or if the connection queue aborts. This means there | |
| // are 3 different interleaves of these function calls: | | // are 3 different interleaves of these function calls: | |
| // 1. on_connect | | // 1. on_connect | |
| // 2. on_connect, on_timeout | | // 2. on_connect, on_timeout | |
| // 3. on_timeout | | // 3. on_timeout | |
| boost::function<void()> on_timeout; | | boost::function<void()> on_timeout; | |
| bool connecting; | | bool connecting; | |
| int ticket; | | int ticket; | |
| ptime expires; | | ptime expires; | |
| time_duration timeout; | | time_duration timeout; | |
| int priority; | | int priority; | |
| }; | | }; | |
| | | | |
|
| | | // TODO: split this into a queue and connecting map. The key for the | |
| | | map | |
| | | // is the ticket. Most field in entry would only be necessary for th | |
| | | e | |
| | | // connecting map. | |
| std::list<entry> m_queue; | | std::list<entry> m_queue; | |
| | | | |
| // the next ticket id a connection will be given | | // the next ticket id a connection will be given | |
| int m_next_ticket; | | int m_next_ticket; | |
| int m_num_connecting; | | int m_num_connecting; | |
| int m_half_open_limit; | | int m_half_open_limit; | |
| bool m_abort; | | bool m_abort; | |
| | | | |
|
| | | // the number of outstanding timers | |
| | | int m_num_timers; | |
| | | | |
| deadline_timer m_timer; | | deadline_timer m_timer; | |
| | | | |
| mutable mutex_t m_mutex; | | mutable mutex_t m_mutex; | |
| | | | |
| #ifdef TORRENT_DEBUG | | #ifdef TORRENT_DEBUG | |
| bool m_in_timeout_function; | | bool m_in_timeout_function; | |
| #endif | | #endif | |
| #ifdef TORRENT_CONNECTION_LOGGING | | #ifdef TORRENT_CONNECTION_LOGGING | |
| std::ofstream m_log; | | std::ofstream m_log; | |
| #endif | | #endif | |
| | | | |
End of changes. 4 change blocks. |
| 0 lines changed or deleted | | 31 lines changed or added | |
|
| disk_buffer_pool.hpp | | disk_buffer_pool.hpp | |
| | | | |
| skipping to change at line 62 | | skipping to change at line 62 | |
| | | | |
| namespace libtorrent | | namespace libtorrent | |
| { | | { | |
| struct TORRENT_EXTRA_EXPORT disk_buffer_pool : boost::noncopyable | | struct TORRENT_EXTRA_EXPORT disk_buffer_pool : boost::noncopyable | |
| { | | { | |
| disk_buffer_pool(int block_size); | | disk_buffer_pool(int block_size); | |
| #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS | | #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS | |
| ~disk_buffer_pool(); | | ~disk_buffer_pool(); | |
| #endif | | #endif | |
| | | | |
|
| #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS | | #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS || defined TORRENT_DIS
K_STATS | |
| bool is_disk_buffer(char* buffer | | bool is_disk_buffer(char* buffer | |
| , mutex::scoped_lock& l) const; | | , mutex::scoped_lock& l) const; | |
| bool is_disk_buffer(char* buffer) const; | | bool is_disk_buffer(char* buffer) const; | |
| #endif | | #endif | |
| | | | |
| char* allocate_buffer(char const* category); | | char* allocate_buffer(char const* category); | |
| void free_buffer(char* buf); | | void free_buffer(char* buf); | |
| void free_multiple_buffers(char** bufvec, int numbufs); | | void free_multiple_buffers(char** bufvec, int numbufs); | |
| | | | |
| int block_size() const { return m_block_size; } | | int block_size() const { return m_block_size; } | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| storage.hpp | | storage.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_STORAGE_HPP_INCLUDE | | #ifndef TORRENT_STORAGE_HPP_INCLUDE | |
| #define TORRENT_STORAGE_HPP_INCLUDE | | #define TORRENT_STORAGE_HPP_INCLUDE | |
| | | | |
| #include <vector> | | #include <vector> | |
| #include <sys/types.h> | | #include <sys/types.h> | |
|
| #include <sys/stat.h> | | | |
| | | | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| #pragma warning(push, 1) | | #pragma warning(push, 1) | |
| #endif | | #endif | |
| | | | |
| #include <boost/function/function2.hpp> | | #include <boost/function/function2.hpp> | |
| #include <boost/limits.hpp> | | #include <boost/limits.hpp> | |
| #include <boost/shared_ptr.hpp> | | #include <boost/shared_ptr.hpp> | |
| #include <boost/scoped_ptr.hpp> | | #include <boost/scoped_ptr.hpp> | |
| #include <boost/intrusive_ptr.hpp> | | #include <boost/intrusive_ptr.hpp> | |
| | | | |
End of changes. 1 change blocks. |
| 1 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 16 | | #define LIBTORRENT_VERSION_MINOR 16 | |
|
| #define LIBTORRENT_VERSION_TINY 2 | | #define LIBTORRENT_VERSION_TINY 3 | |
| | | | |
| // the format of this version is: MMmmtt | | // the format of this version is: MMmmtt | |
| // M = Major version, m = minor version, t = tiny version | | // M = Major version, m = minor version, t = tiny version | |
| #define LIBTORRENT_VERSION_NUM ((LIBTORRENT_VERSION_MAJOR * 10000) + (LIBTO
RRENT_VERSION_MINOR * 100) + LIBTORRENT_VERSION_TINY) | | #define LIBTORRENT_VERSION_NUM ((LIBTORRENT_VERSION_MAJOR * 10000) + (LIBTO
RRENT_VERSION_MINOR * 100) + LIBTORRENT_VERSION_TINY) | |
| | | | |
|
| #define LIBTORRENT_VERSION "0.16.2.0" | | #define LIBTORRENT_VERSION "0.16.3.0" | |
| #define LIBTORRENT_REVISION "$Rev: 7169 $" | | #define LIBTORRENT_REVISION "$Rev: 7334 $" | |
| | | | |
| #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 127 | | skipping to change at line 127 | |
| // this has one entry per http-request | | // this has one entry per http-request | |
| // (might be more than the bt requests) | | // (might be more than the bt requests) | |
| std::deque<int> m_file_requests; | | std::deque<int> m_file_requests; | |
| | | | |
| std::string m_url; | | std::string m_url; | |
| | | | |
| // this is used for intermediate storage of pieces | | // this is used for intermediate storage of pieces | |
| // that are received in more than one HTTP response | | // that are received in more than one HTTP response | |
| // TODO: if we make this be a disk_buffer_holder instead | | // TODO: if we make this be a disk_buffer_holder instead | |
| // we would save a copy sometimes | | // we would save a copy sometimes | |
|
| | | // use allocate_disk_receive_buffer and release_disk_receive
_buffer | |
| std::vector<char> m_piece; | | std::vector<char> m_piece; | |
| | | | |
| // the number of bytes received in the current HTTP | | // the number of bytes received in the current HTTP | |
| // response. used to know where in the buffer the | | // response. used to know where in the buffer the | |
| // next response starts | | // next response starts | |
| size_type m_received_body; | | size_type m_received_body; | |
| | | | |
| // position in the current range response | | // position in the current range response | |
| size_type m_range_pos; | | size_type m_range_pos; | |
| | | | |
| | | | |
End of changes. 1 change blocks. |
| 0 lines changed or deleted | | 1 lines changed or added | |
|