low level network primitives should not be exported. Moved enum_if into tests (since it uses internal functions)

This commit is contained in:
Arvid Norberg
2013-07-20 01:02:15 +00:00
parent 6e28e33b32
commit bbe62564ad
8 changed files with 41 additions and 34 deletions

View File

@@ -59,7 +59,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/magnet_uri.hpp"
#include "libtorrent/bitfield.hpp"
#include "libtorrent/peer_info.hpp"
#include "libtorrent/socket_io.hpp" // print_address
#include "libtorrent/time.hpp"
#include "libtorrent/create_torrent.hpp"
@@ -264,6 +263,21 @@ bool is_hex(char const *in, int len)
return true;
}
std::string print_endpoint(libtorrent::tcp::endpoint const& ep)
{
using namespace libtorrent;
error_code ec;
char buf[200];
address const& addr = ep.address();
#if TORRENT_USE_IPV6
if (addr.is_v6())
snprintf(buf, sizeof(buf), "[%s]:%d", addr.to_string(ec).c_str(), ep.port());
else
#endif
snprintf(buf, sizeof(buf), "%s:%d", addr.to_string(ec).c_str(), ep.port());
return buf;
}
enum {
torrents_all,
torrents_downloading,
@@ -571,9 +585,9 @@ void print_peer_info(std::string& out, std::vector<libtorrent::peer_info> const&
if (print_ip)
{
snprintf(str, sizeof(str), "%-30s %-22s", (print_endpoint(i->ip) +
snprintf(str, sizeof(str), "%-30s %-22s", (::print_endpoint(i->ip) +
(i->connection_type == peer_info::bittorrent_utp ? " [uTP]" : "")).c_str()
, print_endpoint(i->local_endpoint).c_str());
, ::print_endpoint(i->local_endpoint).c_str());
out += str;
}