fixed windows build
This commit is contained in:
parent
b38df8941d
commit
e750910798
|
@ -39,6 +39,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define Protocol Protocol_
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
||||
// asio assumes that the windows error codes are defined already
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#if BOOST_VERSION < 103500
|
||||
#include <asio/ip/address.hpp>
|
||||
#else
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace libtorrent
|
|||
#if BOOST_VERSION < 103500
|
||||
namespace error = asio::error;
|
||||
#else
|
||||
namespace error = boost::asio::error;
|
||||
namespace error = boost::asio::error;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
||||
// asio assumes that the windows error codes are defined already
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#if BOOST_VERSION < 103500
|
||||
#include <asio/io_service.hpp>
|
||||
#else
|
||||
|
|
|
@ -65,6 +65,8 @@ namespace libtorrent
|
|||
}
|
||||
};
|
||||
|
||||
struct lazy_dict_entry;
|
||||
|
||||
struct TORRENT_EXPORT lazy_entry
|
||||
{
|
||||
enum entry_type_t
|
||||
|
@ -151,13 +153,7 @@ namespace libtorrent
|
|||
lazy_entry const* dict_find_list(char const* name) const;
|
||||
lazy_entry const* dict_find_string(char const* name) const;
|
||||
|
||||
std::pair<std::string, lazy_entry const*> dict_at(int i) const
|
||||
{
|
||||
TORRENT_ASSERT(m_type == dict_t);
|
||||
TORRENT_ASSERT(i < m_size);
|
||||
std::pair<char const*, lazy_entry> const& e = m_data.dict[i];
|
||||
return std::make_pair(std::string(e.first, e.second.m_begin - e.first), &e.second);
|
||||
}
|
||||
std::pair<std::string, lazy_entry const*> dict_at(int i) const;
|
||||
|
||||
int dict_size() const
|
||||
{
|
||||
|
@ -238,10 +234,11 @@ namespace libtorrent
|
|||
entry_type_t m_type;
|
||||
union data_t
|
||||
{
|
||||
std::pair<char const*, lazy_entry>* dict;
|
||||
lazy_dict_entry* dict;
|
||||
lazy_entry* list;
|
||||
char const* start;
|
||||
} m_data;
|
||||
|
||||
int m_size; // if list or dictionary, the number of items
|
||||
int m_capacity; // if list or dictionary, allocated number of items
|
||||
// used for dictionaries and lists to record the range
|
||||
|
@ -254,6 +251,12 @@ namespace libtorrent
|
|||
lazy_entry const& operator=(lazy_entry const&);
|
||||
};
|
||||
|
||||
struct lazy_dict_entry
|
||||
{
|
||||
char const* name;
|
||||
lazy_entry val;
|
||||
};
|
||||
|
||||
TORRENT_EXPORT std::string print_entry(lazy_entry const& e, bool single_line = false);
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
TORRENT_EXPORT std::ostream& operator<<(std::ostream& os, lazy_entry const& e);
|
||||
|
|
|
@ -45,6 +45,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define Protocol Protocol_
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
||||
// asio assumes that the windows error codes are defined already
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#if BOOST_VERSION < 103500
|
||||
|
|
|
@ -34,6 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_THREAD_HPP_INCLUDED
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
||||
// asio assumes that the windows error codes are defined already
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <boost/asio/detail/thread.hpp>
|
||||
#include <boost/asio/detail/mutex.hpp>
|
||||
#include <boost/asio/detail/event.hpp>
|
||||
|
|
|
@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/io_service.hpp"
|
||||
#include "libtorrent/socket_io.hpp"
|
||||
#include "libtorrent/time.hpp"
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
namespace libtorrent {
|
||||
|
|
|
@ -32,6 +32,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/enum_net.hpp"
|
||||
#include "libtorrent/broadcast_socket.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
||||
#if BOOST_VERSION < 103500
|
||||
#include <asio/ip/host_name.hpp>
|
||||
#include <asio/ip/multicast.hpp>
|
||||
|
@ -40,13 +47,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/asio/ip/multicast.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/enum_net.hpp"
|
||||
#include "libtorrent/broadcast_socket.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
bool is_local(address const& a)
|
||||
|
|
|
@ -191,26 +191,26 @@ namespace libtorrent
|
|||
if (m_capacity == 0)
|
||||
{
|
||||
int capacity = lazy_entry_dict_init;
|
||||
m_data.dict = new (std::nothrow) std::pair<char const*, lazy_entry>[capacity];
|
||||
m_data.dict = new (std::nothrow) lazy_dict_entry[capacity];
|
||||
if (m_data.dict == 0) return 0;
|
||||
m_capacity = capacity;
|
||||
}
|
||||
else if (m_size == m_capacity)
|
||||
{
|
||||
int capacity = m_capacity * lazy_entry_grow_factor;
|
||||
std::pair<char const*, lazy_entry>* tmp = new (std::nothrow) std::pair<char const*, lazy_entry>[capacity];
|
||||
lazy_dict_entry* tmp = new (std::nothrow) lazy_dict_entry[capacity];
|
||||
if (tmp == 0) return 0;
|
||||
std::memcpy(tmp, m_data.dict, sizeof(std::pair<char const*, lazy_entry>) * m_size);
|
||||
for (int i = 0; i < m_size; ++i) m_data.dict[i].second.release();
|
||||
std::memcpy(tmp, m_data.dict, sizeof(lazy_dict_entry) * m_size);
|
||||
for (int i = 0; i < m_size; ++i) m_data.dict[i].val.release();
|
||||
delete[] m_data.dict;
|
||||
m_data.dict = tmp;
|
||||
m_capacity = capacity;
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(m_size < m_capacity);
|
||||
std::pair<char const*, lazy_entry>& ret = m_data.dict[m_size++];
|
||||
ret.first = name;
|
||||
return &ret.second;
|
||||
lazy_dict_entry& ret = m_data.dict[m_size++];
|
||||
ret.name = name;
|
||||
return &ret.val;
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -257,6 +257,14 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<std::string, lazy_entry const*> lazy_entry::dict_at(int i) const
|
||||
{
|
||||
TORRENT_ASSERT(m_type == dict_t);
|
||||
TORRENT_ASSERT(i < m_size);
|
||||
lazy_dict_entry const& e = m_data.dict[i];
|
||||
return std::make_pair(std::string(e.name, e.val.m_begin - e.name), &e.val);
|
||||
}
|
||||
|
||||
std::string lazy_entry::dict_find_string_value(char const* name) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
|
@ -304,9 +312,9 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_type == dict_t);
|
||||
for (int i = 0; i < m_size; ++i)
|
||||
{
|
||||
std::pair<char const*, lazy_entry> const& e = m_data.dict[i];
|
||||
if (string_equal(name, e.first, e.second.m_begin - e.first))
|
||||
return &m_data.dict[i].second;
|
||||
lazy_dict_entry& e = m_data.dict[i];
|
||||
if (string_equal(name, e.name, e.val.m_begin - e.name))
|
||||
return &e.val;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -35,12 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/version.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#if BOOST_VERSION < 103500
|
||||
#include <asio/ip/host_name.hpp>
|
||||
#else
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
#endif
|
||||
|
||||
#include "libtorrent/natpmp.hpp"
|
||||
#include "libtorrent/io.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
|
@ -48,6 +42,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/socket_io.hpp"
|
||||
#include "libtorrent/io_service.hpp"
|
||||
|
||||
#if BOOST_VERSION < 103500
|
||||
#include <asio/ip/host_name.hpp>
|
||||
#else
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
#endif
|
||||
|
||||
using boost::bind;
|
||||
using namespace libtorrent;
|
||||
|
||||
|
|
Loading…
Reference in New Issue