diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 40d224c26..baff6124c 100755 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -67,6 +67,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "libtorrent/size_type.hpp" + namespace libtorrent { @@ -109,8 +111,7 @@ namespace libtorrent typedef std::map dictionary_type; typedef std::string string_type; typedef std::vector list_type; - - typedef boost::int64_t integer_type; + typedef size_type integer_type; enum data_type { diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index fd130efa2..4fd823e6f 100755 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -38,7 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include + +#include "libtorrent/size_type.hpp" namespace libtorrent { @@ -52,8 +53,6 @@ namespace libtorrent { public: - typedef boost::int64_t size_type; - class seek_mode { friend class file; diff --git a/include/libtorrent/policy.hpp b/include/libtorrent/policy.hpp index b1085db57..7c24ff920 100755 --- a/include/libtorrent/policy.hpp +++ b/include/libtorrent/policy.hpp @@ -105,7 +105,7 @@ namespace libtorrent { enum connection_type { connectable, not_connectable }; - peer(const address& ip, peer::connection_type t); + peer(const address& ip, connection_type t); int total_download() const; int total_upload() const; diff --git a/include/libtorrent/size_type.hpp b/include/libtorrent/size_type.hpp new file mode 100755 index 000000000..3050b46a3 --- /dev/null +++ b/include/libtorrent/size_type.hpp @@ -0,0 +1,48 @@ +/* + +Copyright (c) 2003, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +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 +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef TORRENT_SIZE_TYPE_HPP_INCLUDED +#define TORRENT_SIZE_TYPE_HPP_INCLUDED + +#include + +namespace libtorrent +{ +#if defined(_MSC_VER) && _MSC_VER < 1300 + typedef int size_type; +#else + typedef boost::int64_t size_type; +#endif +} + + +#endif diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index e8a6adc77..56df65cf5 100755 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -38,6 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "libtorrent/size_type.hpp" + namespace libtorrent { @@ -46,9 +48,6 @@ namespace libtorrent enum { history = 10 }; public: - typedef boost::int64_t size_type; - - stat() : m_downloaded_payload(0) , m_uploaded_payload(0) diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 9a1569038..4f1940f37 100755 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -52,8 +52,6 @@ namespace libtorrent class session; - typedef boost::int64_t size_type; - std::vector get_filesizes( const torrent_info& t , const boost::filesystem::path& p); @@ -80,8 +78,6 @@ namespace libtorrent void swap(storage&); - typedef boost::int64_t size_type; - size_type read(char* buf, int slot, size_type offset, size_type size); void write(const char* buf, int slot, size_type offset, size_type size); @@ -93,7 +89,6 @@ namespace libtorrent class piece_manager : boost::noncopyable { public: - typedef boost::int64_t size_type; piece_manager( const torrent_info& info diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index cfce7c3ad..99c349100 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -107,8 +107,6 @@ namespace libtorrent { public: - typedef boost::int64_t size_type; - torrent( detail::session_impl& ses , const torrent_info& torrent_file diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index f57b35204..2e298d752 100755 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -64,8 +64,6 @@ namespace libtorrent struct torrent_status { - typedef boost::int64_t size_type; - torrent_status() : state(queued_for_checking) , progress(0.f) diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 189802943..c1406998a 100755 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -82,8 +82,6 @@ namespace libtorrent { public: - typedef boost::int64_t size_type; - torrent_info(const entry& torrent_file) : m_creation_date(boost::gregorian::date(1970 , boost::gregorian::Jan diff --git a/src/file.cpp b/src/file.cpp index 1f2a5adb0..78618c83c 100755 --- a/src/file.cpp +++ b/src/file.cpp @@ -167,22 +167,22 @@ namespace libtorrent m_impl->close(); } - file::size_type file::write(const char* buf, file::size_type num_bytes) + size_type file::write(const char* buf, size_type num_bytes) { return m_impl->write(buf, num_bytes); } - file::size_type file::read(char* buf, file::size_type num_bytes) + size_type file::read(char* buf, size_type num_bytes) { return m_impl->read(buf, num_bytes); } - void file::seek(file::size_type pos, file::seek_mode m) + void file::seek(size_type pos, file::seek_mode m) { m_impl->seek(pos, m.m_val); } - file::size_type file::tell() + size_type file::tell() { return m_impl->tell(); } diff --git a/src/session.cpp b/src/session.cpp index 103f36869..dad23eb80 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -932,7 +932,7 @@ namespace libtorrent // verify info_hash const std::string &hash = rd.dict()["info-hash"].string(); - std::string real_hash(info.info_hash().begin(), info.info_hash().end()); + std::string real_hash((char*)info.info_hash().begin(), (char*)info.info_hash().end()); if (hash != real_hash) return; @@ -1013,12 +1013,23 @@ namespace libtorrent std::vector file_sizes; entry::list_type& l = rd.dict()["file sizes"].list(); + +#if defined(_MSC_VER) && _MSC_VER < 1300 + for (entry::list_type::iterator i = l.begin(); + i != l.end(); + ++i) + { + file_sizes.push_back(i->integer()); + } +#else +// typedef entry::integer_type (entry::*mem_fun_type)() const; + std::transform( l.begin() , l.end() , std::back_inserter(file_sizes) , boost::bind(&entry::integer, _1)); - +#endif if (!match_filesizes(info, save_path, file_sizes)) return; diff --git a/src/storage.cpp b/src/storage.cpp index 7401b7cae..a0290e8d7 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -197,7 +197,7 @@ namespace libtorrent m_pimpl.swap(other.m_pimpl); } - storage::size_type storage::read( + size_type storage::read( char* buf , int slot , size_type offset @@ -396,7 +396,6 @@ namespace libtorrent class piece_manager::impl { public: - typedef boost::int64_t size_type; impl( const torrent_info& info @@ -555,22 +554,22 @@ namespace libtorrent } - piece_manager::size_type piece_manager::impl::read( + size_type piece_manager::impl::read( char* buf , int piece_index - , piece_manager::size_type offset - , piece_manager::size_type size) + , size_type offset + , size_type size) { assert(m_piece_to_slot[piece_index] >= 0); int slot = m_piece_to_slot[piece_index]; return m_storage.read(buf, slot, offset, size); } - piece_manager::size_type piece_manager::read( + size_type piece_manager::read( char* buf , int piece_index - , piece_manager::size_type offset - , piece_manager::size_type size) + , size_type offset + , size_type size) { return m_pimpl->read(buf, piece_index, offset, size); } @@ -578,8 +577,8 @@ namespace libtorrent void piece_manager::impl::write( const char* buf , int piece_index - , piece_manager::size_type offset - , piece_manager::size_type size) + , size_type offset + , size_type size) { int slot = slot_for_piece(piece_index); m_storage.write(buf, slot, offset, size); @@ -588,8 +587,8 @@ namespace libtorrent void piece_manager::write( const char* buf , int piece_index - , piece_manager::size_type offset - , piece_manager::size_type size) + , size_type offset + , size_type size) { m_pimpl->write(buf, piece_index, offset, size); } diff --git a/src/torrent.cpp b/src/torrent.cpp index 8e13eaf69..29268188e 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -345,16 +345,16 @@ namespace libtorrent } */ - torrent::size_type torrent::bytes_left() const + size_type torrent::bytes_left() const { return m_torrent_file.total_size() - bytes_done(); } - torrent::size_type torrent::bytes_done() const + size_type torrent::bytes_done() const { const int last_piece = m_torrent_file.num_pieces()-1; - torrent::size_type total_done + size_type total_done = m_num_pieces * m_torrent_file.piece_length(); // if we have the last piece, we have to correct diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index eb44743b4..65264ddeb 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -183,7 +183,7 @@ namespace libtorrent ret.dict()["file-version"] = 1; const sha1_hash& info_hash = t->torrent_file().info_hash(); - ret.dict()["info-hash"] = std::string(info_hash.begin(), info_hash.end()); + ret.dict()["info-hash"] = std::string((char*)info_hash.begin(), (char*)info_hash.end()); ret.dict()["slots"] = entry(entry::list_t); entry::list_type& slots = ret.dict()["slots"].list(); @@ -222,7 +222,7 @@ namespace libtorrent unsigned char v = 0; for (int k = 0; k < 8; ++k) v |= i->finished_blocks[j*8+k]?(1 << k):0; - bitmask.push_back(v); + bitmask.insert(bitmask.end(), v); } piece_struct["bitmask"] = bitmask;