move some internal headers to aux_ to fix documentation

This commit is contained in:
arvidn 2015-09-07 17:00:27 -04:00
parent 5c614be0ce
commit ee3cb6cf86
11 changed files with 47 additions and 33 deletions

View File

@ -23,7 +23,6 @@ nobase_include_HEADERS = \
bt_peer_connection.hpp \
buffer.hpp \
build_config.hpp \
byteswap.hpp \
chained_buffer.hpp \
choker.hpp \
close_reason.hpp \
@ -78,7 +77,6 @@ nobase_include_HEADERS = \
max.hpp \
natpmp.hpp \
network_thread_pool.hpp \
openssl.hpp \
operations.hpp \
packet_buffer.hpp \
parse_url.hpp \
@ -172,6 +170,8 @@ nobase_include_HEADERS = \
aux_/session_interface.hpp \
aux_/time.hpp \
aux_/file_progress.hpp \
aux_/openssl.hpp \
aux_/byteswap.hpp \
\
extensions/lt_trackers.hpp \
extensions/metadata_transfer.hpp \

View File

@ -60,8 +60,10 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0);
// declarations of the two functions
// internal
TORRENT_EXPORT void assert_print(char const* fmt, ...) TORRENT_FORMAT(1,2);
// internal
#if (TORRENT_USE_ASSERTS || defined TORRENT_ASIO_DEBUGGING) \
&& !defined TORRENT_PRODUCTION_ASSERTS
TORRENT_NO_RETURN

View File

@ -50,6 +50,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <arpa/inet.h>
#endif
namespace libtorrent {
namespace aux {
// these need to be within the disabled warnings because on OSX
// the htonl and ntohl macros cause lots of old-style case warnings
inline boost::uint32_t host_to_network(boost::uint32_t x)
@ -64,6 +67,9 @@ inline boost::uint16_t host_to_network(boost::uint16_t x)
inline boost::uint16_t network_to_host(boost::uint16_t x)
{ return ntohs(x); }
}
}
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#endif // TORRENT_BYTESWAP_HPP_INCLUDED

View File

@ -47,6 +47,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <openssl/safestack.h> // for sk_GENERAL_NAME_value
#include <openssl/x509v3.h> // for GENERAL_NAME
namespace libtorrent {
namespace aux {
inline void openssl_set_tlsext_hostname(SSL* s, char const* name)
{
#if OPENSSL_VERSION_NUMBER >= 0x90812f
@ -81,6 +84,9 @@ inline GENERAL_NAME* openssl_general_name_value(GENERAL_NAMES* gens, int i)
#endif // OPENSSL_VERSION_NUMBER
#endif // BOOST_VERSION
}
}
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#endif // TORRENT_USE_OPENSSL

View File

@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/byteswap.hpp"
#include "libtorrent/aux_/byteswap.hpp"
#include "libtorrent/aux_/cpuid.hpp"
#include <cstring> // for memset and memcpy
@ -98,7 +98,7 @@ namespace libtorrent
{
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < size());
return (m_buf[index / 32] & host_to_network((0x80000000 >> (index & 31)))) != 0;
return (m_buf[index / 32] & aux::host_to_network((0x80000000 >> (index & 31)))) != 0;
}
// set bit at ``index`` to 0 (clear_bit) or 1 (set_bit).
@ -106,13 +106,13 @@ namespace libtorrent
{
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < size());
m_buf[index / 32] &= host_to_network(~(0x80000000 >> (index & 31)));
m_buf[index / 32] &= aux::host_to_network(~(0x80000000 >> (index & 31)));
}
void set_bit(int index)
{
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < size());
m_buf[index / 32] |= host_to_network((0x80000000 >> (index & 31)));
m_buf[index / 32] |= aux::host_to_network((0x80000000 >> (index & 31)));
}
// returns true if all bits in the bitfield are set
@ -126,7 +126,7 @@ namespace libtorrent
int rest = size() & 31;
if (rest > 0)
{
boost::uint32_t mask = host_to_network(0xffffffff << (32-rest));
boost::uint32_t mask = aux::host_to_network(0xffffffff << (32-rest));
if ((m_buf[words] & mask) != mask) return false;
}
return true;
@ -223,7 +223,7 @@ namespace libtorrent
typedef bool& reference;
typedef std::forward_iterator_tag iterator_category;
bool operator*() { return (*buf & host_to_network(bit)) != 0; }
bool operator*() { return (*buf & aux::host_to_network(bit)) != 0; }
const_iterator& operator++() { inc(); return *this; }
const_iterator operator++(int)
{ const_iterator ret(*this); inc(); return ret; }
@ -289,7 +289,7 @@ namespace libtorrent
int new_size_words = num_words();
if (val)
{
if (old_size_words && b) m_buf[old_size_words - 1] |= host_to_network((0xffffffff >> b));
if (old_size_words && b) m_buf[old_size_words - 1] |= aux::host_to_network((0xffffffff >> b));
if (old_size_words < new_size_words)
std::memset(m_buf + old_size_words, 0xff
, size_t((new_size_words - old_size_words) * 4));
@ -357,7 +357,7 @@ namespace libtorrent
void clear_trailing_bits()
{
// clear the tail bits in the last byte
if (size() & 31) m_buf[num_words() - 1] &= host_to_network(0xffffffff << (32 - (size() & 31)));
if (size() & 31) m_buf[num_words() - 1] &= aux::host_to_network(0xffffffff << (32 - (size() & 31)));
}
void dealloc()

View File

@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/byteswap.hpp"
#include "libtorrent/aux_/byteswap.hpp"
#if TORRENT_USE_IOSTREAM
#include "libtorrent/hex.hpp" // to_hex, from_hex
@ -157,16 +157,16 @@ namespace libtorrent
// byte order, so they have to be byteswapped before
// applying the shift operations, and then byteswapped
// back again.
m_number[0] = network_to_host(m_number[0]);
m_number[0] = aux::network_to_host(m_number[0]);
for (int i = 0; i < number_size - 1; ++i)
{
m_number[i] <<= n;
m_number[i+1] = network_to_host(m_number[i+1]);
m_number[i+1] = aux::network_to_host(m_number[i+1]);
m_number[i] |= m_number[i+1] >> (32 - n);
m_number[i] = host_to_network(m_number[i]);
m_number[i] = aux::host_to_network(m_number[i]);
}
m_number[number_size-1] <<= n;
m_number[number_size-1] = host_to_network(m_number[number_size-1]);
m_number[number_size-1] = aux::host_to_network(m_number[number_size-1]);
}
return *this;
}
@ -194,17 +194,17 @@ namespace libtorrent
// byte order, so they have to be byteswapped before
// applying the shift operations, and then byteswapped
// back again.
m_number[number_size-1] = network_to_host(m_number[number_size-1]);
m_number[number_size-1] = aux::network_to_host(m_number[number_size-1]);
for (int i = number_size - 1; i > 0; --i)
{
m_number[i] >>= n;
m_number[i-1] = network_to_host(m_number[i-1]);
m_number[i-1] = aux::network_to_host(m_number[i-1]);
m_number[i] |= (m_number[i-1] << (32 - n)) & 0xffffffff;
m_number[i] = host_to_network(m_number[i]);
m_number[i] = aux::host_to_network(m_number[i]);
}
m_number[0] >>= n;
m_number[0] = host_to_network(m_number[0]);
m_number[0] = aux::host_to_network(m_number[0]);
}
return *this;
}
@ -222,8 +222,8 @@ namespace libtorrent
{
for (int i = 0; i < number_size; ++i)
{
boost::uint32_t lhs = network_to_host(m_number[i]);
boost::uint32_t rhs = network_to_host(n.m_number[i]);
boost::uint32_t lhs = aux::network_to_host(m_number[i]);
boost::uint32_t rhs = aux::network_to_host(n.m_number[i]);
if (lhs < rhs) return true;
if (lhs > rhs) return false;
}

View File

@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/io_service.hpp"
#include "libtorrent/openssl.hpp"
#include "libtorrent/aux_/openssl.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
@ -88,7 +88,7 @@ public:
void set_host_name(std::string name)
{
openssl_set_tlsext_hostname(m_sock.native_handle(), name.c_str());
aux::openssl_set_tlsext_hostname(m_sock.native_handle(), name.c_str());
}
template <class T>

View File

@ -76,7 +76,7 @@ const rlim_t rlim_infinity = RLIM_INFINITY;
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/openssl.hpp"
#include "libtorrent/aux_/openssl.hpp"
#include "libtorrent/peer_id.hpp"
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/tracker_manager.hpp"
@ -468,9 +468,9 @@ namespace aux {
m_ssl_ctx.set_verify_mode(boost::asio::ssl::context::verify_none, ec);
#if BOOST_VERSION >= 104700
#if OPENSSL_VERSION_NUMBER >= 0x90812f
openssl_set_tlsext_servername_callback(m_ssl_ctx.native_handle()
aux::openssl_set_tlsext_servername_callback(m_ssl_ctx.native_handle()
, servername_callback);
openssl_set_tlsext_servername_arg(m_ssl_ctx.native_handle(), this);
aux::openssl_set_tlsext_servername_arg(m_ssl_ctx.native_handle(), this);
#endif // OPENSSL_VERSION_NUMBER
#endif // BOOST_VERSION
#endif

View File

@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/socket_type.hpp"
#include "libtorrent/openssl.hpp"
#include "libtorrent/aux_/openssl.hpp"
#ifdef TORRENT_USE_OPENSSL
#include <boost/asio/ssl/context.hpp>
@ -115,8 +115,8 @@ namespace libtorrent
#if OPENSSL_VERSION_NUMBER >= 0x90812f
if (ctx)
{
openssl_set_tlsext_servername_callback(ctx, 0);
openssl_set_tlsext_servername_arg(ctx, 0);
aux::openssl_set_tlsext_servername_callback(ctx, 0);
aux::openssl_set_tlsext_servername_arg(ctx, 0);
}
#endif // OPENSSL_VERSION_NUMBER
#else

View File

@ -1558,9 +1558,9 @@ namespace libtorrent
std::string names;
bool match = false;
#endif
for (int i = 0; i < openssl_num_general_names(gens); ++i)
for (int i = 0; i < aux::openssl_num_general_names(gens); ++i)
{
GENERAL_NAME* gen = openssl_general_name_value(gens, i);
GENERAL_NAME* gen = aux::openssl_general_name_value(gens, i);
if (gen->type != GEN_DNS) continue;
ASN1_IA5STRING* domain = gen->d.dNSName;
if (domain->type != V_ASN1_IA5STRING || !domain->data || !domain->length) continue;

View File

@ -82,8 +82,8 @@ namespace libtorrent
if (e1.port() > e2.port())
swap(e1, e2);
boost::uint32_t p;
reinterpret_cast<boost::uint16_t*>(&p)[0] = host_to_network(e1.port());
reinterpret_cast<boost::uint16_t*>(&p)[1] = host_to_network(e2.port());
reinterpret_cast<boost::uint16_t*>(&p)[0] = aux::host_to_network(e1.port());
reinterpret_cast<boost::uint16_t*>(&p)[1] = aux::host_to_network(e2.port());
ret = crc32c_32(p);
}
#if TORRENT_USE_IPV6