introduce lt namespace alias

This commit is contained in:
arvidn 2017-04-12 14:05:53 -04:00 committed by Arvid Norberg
parent e4dbd28920
commit d138f02424
189 changed files with 516 additions and 583 deletions

View File

@ -1,3 +1,4 @@
* introduce "lt" namespace alias
* need_save_resume_data() will no longer return true every 15 minutes
* make the file_status interface explicitly public types
* added resolver_cache_timeout setting for internal host name resolver

View File

@ -11,7 +11,7 @@
#include "bytes.hpp"
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
#ifdef _MSC_VER
#pragma warning(push)
@ -143,7 +143,7 @@ namespace boost
// types are indeed polymorphic, no need to derive from
// them.
#define POLY(x) template<> \
struct is_polymorphic<libtorrent:: x > : boost::mpl::true_ {};
struct is_polymorphic<lt:: x > : boost::mpl::true_ {};
POLY(torrent_alert)
POLY(tracker_alert)

View File

@ -15,7 +15,6 @@
using namespace boost::python;
namespace bp = boost::python;
namespace lt = libtorrent;
template<class T>
struct endpoint_to_tuple
@ -73,9 +72,9 @@ struct pair_to_tuple
struct address_to_tuple
{
static PyObject* convert(libtorrent::address const& addr)
static PyObject* convert(lt::address const& addr)
{
libtorrent::error_code ec;
lt::error_code ec;
return incref(bp::object(addr.to_string(ec)).ptr());
}
};

View File

@ -10,7 +10,7 @@
#include "bytes.hpp"
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
#ifdef _MSC_VER
#pragma warning(push)
@ -65,16 +65,16 @@ namespace
struct FileIter
{
typedef libtorrent::file_entry value_type;
typedef libtorrent::file_entry reference;
typedef libtorrent::file_entry* pointer;
typedef lt::file_entry value_type;
typedef lt::file_entry reference;
typedef lt::file_entry* pointer;
typedef int difference_type;
typedef std::forward_iterator_tag iterator_category;
FileIter(file_storage const& fs, file_index_t i) : m_fs(&fs), m_i(i) {}
FileIter(FileIter const&) = default;
FileIter() : m_fs(nullptr), m_i(0) {}
libtorrent::file_entry operator*() const
lt::file_entry operator*() const
{ return m_fs->at(m_i); }
FileIter operator++() { m_i++; return *this; }
@ -200,7 +200,7 @@ void bind_create_torrent()
.def(init<file_storage&>())
.def(init<torrent_info const&>(arg("ti")))
.def(init<file_storage&, int, int, int>((arg("storage"), arg("piece_size") = 0
, arg("pad_file_limit") = -1, arg("flags") = int(libtorrent::create_torrent::optimize_alignment))))
, arg("pad_file_limit") = -1, arg("flags") = int(lt::create_torrent::optimize_alignment))))
.def("generate", &create_torrent::generate)

View File

@ -10,7 +10,6 @@
#include <ctime>
using namespace boost::python;
namespace lt = libtorrent;
#if BOOST_VERSION < 103400

View File

@ -7,7 +7,7 @@
#include "bytes.hpp"
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
struct entry_to_python
{
@ -172,7 +172,7 @@ struct entry_from_python
void bind_entry()
{
to_python_converter<std::shared_ptr<libtorrent::entry>, entry_to_python>();
to_python_converter<std::shared_ptr<lt::entry>, entry_to_python>();
to_python_converter<entry, entry_to_python>();
entry_from_python();
}

View File

@ -52,7 +52,7 @@ namespace boost
#include "boost_python.hpp"
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
using boost::system::error_category;
namespace {
@ -86,17 +86,17 @@ namespace {
int const value = extract<int>(state[0]);
std::string const category = extract<std::string>(state[1]);
if (category == "system")
ec.assign(value, libtorrent::system_category());
ec.assign(value, lt::system_category());
else if (category == "generic")
ec.assign(value, libtorrent::generic_category());
ec.assign(value, lt::generic_category());
else if (category == "libtorrent")
ec.assign(value, libtorrent::libtorrent_category());
ec.assign(value, lt::libtorrent_category());
else if (category == "http error")
ec.assign(value, libtorrent::http_category());
ec.assign(value, lt::http_category());
else if (category == "UPnP error")
ec.assign(value, libtorrent::upnp_category());
ec.assign(value, lt::upnp_category());
else if (category == "bdecode error")
ec.assign(value, libtorrent::bdecode_category());
ec.assign(value, lt::bdecode_category());
else if (category == "asio.netdb")
ec.assign(value, boost::asio::error::get_netdb_category());
else if (category == "asio.addinfo")

View File

@ -8,7 +8,7 @@
void bind_fingerprint()
{
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
def("generate_fingerprint", &generate_fingerprint);

View File

@ -7,7 +7,7 @@
#include "gil.hpp"
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
namespace
{

View File

@ -11,8 +11,7 @@
#include "bytes.hpp"
using namespace boost::python;
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
extern void dict_to_add_torrent_params(dict params, add_torrent_params& p);

View File

@ -8,7 +8,7 @@
#include <boost/python/iterator.hpp>
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
std::int64_t get_last_active(peer_info const& pi)
{

View File

@ -27,8 +27,8 @@
namespace boost
{
// this fixes mysterious link error on msvc
libtorrent::alert const volatile*
get_pointer(libtorrent::alert const volatile* p)
lt::alert const volatile*
get_pointer(lt::alert const volatile* p)
{
return p;
}
@ -45,8 +45,7 @@ namespace boost
#endif
using namespace boost::python;
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
namespace
{
@ -523,7 +522,7 @@ namespace
, std::string const& salt, std::string pk, std::string sk
, std::string data)
{
using libtorrent::dht::sign_mutable_item;
using lt::dht::sign_mutable_item;
e = data;
std::vector<char> buf;

View File

@ -6,7 +6,7 @@
#include <libtorrent/session.hpp>
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
void bind_session_settings()
{

View File

@ -14,7 +14,7 @@ long get_hash(boost::python::object o)
return long(PyObject_Hash(str(o).ptr()));
}
using namespace libtorrent;
using namespace lt;
bytes sha1_hash_bytes(const sha1_hash& bn) {
return bytes(bn.to_string());
@ -23,7 +23,7 @@ bytes sha1_hash_bytes(const sha1_hash& bn) {
void bind_sha1_hash()
{
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
class_<sha1_hash>("sha1_hash")
.def(self == self)

View File

@ -17,7 +17,7 @@
#include "gil.hpp"
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
#ifdef _MSC_VER
#pragma warning(push)

View File

@ -19,8 +19,7 @@
#endif
using namespace boost::python;
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
namespace
{

View File

@ -8,7 +8,7 @@
#include <libtorrent/bitfield.hpp>
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
object bitfield_to_list(bitfield const& bf)
{

View File

@ -8,7 +8,7 @@
#include "bytes.hpp"
using namespace boost::python;
using namespace libtorrent;
using namespace lt;
#ifdef _MSC_VER
#pragma warning(push)
@ -91,7 +91,7 @@ void bind_utility()
bytes_from_python();
#ifndef TORRENT_NO_DEPRECATE
def("identify_client", &libtorrent::identify_client);
def("identify_client", &lt::identify_client);
def("client_fingerprint", &client_fingerprint_);
#endif
def("bdecode", &bdecode_);

View File

@ -6,7 +6,7 @@
#include "boost_python.hpp"
using namespace boost::python;
using libtorrent::version;
using lt::version;
void bind_version()
{

View File

@ -129,7 +129,7 @@ for system errors. That is, errors that belong to the generic or system category
Errors that belong to the libtorrent error category are not localized however, they
are only available in english. In order to translate libtorrent errors, compare the
error category of the ``error_code`` object against ``libtorrent::libtorrent_category()``,
error category of the ``error_code`` object against ``lt::libtorrent_category()``,
and if matches, you know the error code refers to the list above. You can provide
your own mapping from error code to string, which is localized. In this case, you
cannot rely on ``error_code::message()`` to generate your strings.
@ -143,7 +143,7 @@ Here's a simple example of how to translate error codes:
std::string error_code_to_string(boost::system::error_code const& ec)
{
if (ec.category() != libtorrent::libtorrent_category())
if (ec.category() != lt::libtorrent_category())
{
return ec.message();
}

View File

@ -83,7 +83,7 @@ asio::tcp::endpoint
The endpoint type is represented as a tuple of a string (as the address) and an int for
the port number. E.g. ``('127.0.0.1', 6881)`` represents the localhost port 6881.
libtorrent::time_duration
lt::time_duration
The time duration is represented as a number of seconds in a regular integer.
The following functions takes a reference to a container that is filled with

View File

@ -31,7 +31,6 @@ For example:
#include <libtorrent/torrent_handle.hpp>
#include <libtorrent/magnet_uri.hpp>
namespace lt = libtorrent;
int main(int argc, char const* argv[])
{
if (argc != 2) {

View File

@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/alert_types.hpp>
#include <libtorrent/magnet_uri.hpp>
namespace lt = libtorrent;
int main(int argc, char const* argv[])
{
if (argc != 2) {

View File

@ -46,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/error_code.hpp>
#include <libtorrent/magnet_uri.hpp>
namespace lt = libtorrent;
using clk = std::chrono::steady_clock;
// return the name of a torrent status enum

View File

@ -72,7 +72,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "session_view.hpp"
#include "print.hpp"
using libtorrent::total_milliseconds;
using lt::total_milliseconds;
#ifdef _WIN32
@ -131,7 +131,7 @@ private:
bool sleep_and_input(int* c, int sleep)
{
libtorrent::time_point const start = libtorrent::clock_type::now();
lt::time_point const start = lt::clock_type::now();
int ret = 0;
retry:
fd_set set;
@ -146,7 +146,7 @@ retry:
}
if (errno == EINTR)
{
if (total_milliseconds(libtorrent::clock_type::now() - start) < sleep)
if (total_milliseconds(lt::clock_type::now() - start) < sleep)
goto retry;
return false;
}
@ -185,8 +185,8 @@ bool print_disk_stats = false;
int num_outstanding_resume_data = 0;
#ifndef TORRENT_DISABLE_DHT
std::vector<libtorrent::dht_lookup> dht_active_requests;
std::vector<libtorrent::dht_routing_bucket> dht_routing_table;
std::vector<lt::dht_lookup> dht_active_requests;
std::vector<lt::dht_routing_bucket> dht_routing_table;
#endif
std::string to_hex(lt::sha1_hash const& s)
@ -197,7 +197,7 @@ std::string to_hex(lt::sha1_hash const& s)
}
int load_file(std::string const& filename, std::vector<char>& v
, libtorrent::error_code& ec, int limit = 8000000)
, lt::error_code& ec, int limit = 8000000)
{
ec.clear();
FILE* f = std::fopen(filename.c_str(), "rb");
@ -309,9 +309,9 @@ std::string make_absolute_path(std::string const& p)
return ret;
}
std::string print_endpoint(libtorrent::tcp::endpoint const& ep)
std::string print_endpoint(lt::tcp::endpoint const& ep)
{
using namespace libtorrent;
using namespace lt;
error_code ec;
char buf[200];
address const& addr = ep.address();
@ -324,13 +324,13 @@ std::string print_endpoint(libtorrent::tcp::endpoint const& ep)
return buf;
}
using libtorrent::torrent_status;
using lt::torrent_status;
FILE* g_log_file = nullptr;
int peer_index(libtorrent::tcp::endpoint addr, std::vector<libtorrent::peer_info> const& peers)
int peer_index(lt::tcp::endpoint addr, std::vector<lt::peer_info> const& peers)
{
using namespace libtorrent;
using namespace lt;
std::vector<peer_info>::const_iterator i = std::find_if(peers.begin(), peers.end()
, [&addr](peer_info const& pi) { return pi.ip == addr; });
if (i == peers.end()) return -1;
@ -340,9 +340,9 @@ int peer_index(libtorrent::tcp::endpoint addr, std::vector<libtorrent::peer_info
// returns the number of lines printed
int print_peer_info(std::string& out
, std::vector<libtorrent::peer_info> const& peers, int max_lines)
, std::vector<lt::peer_info> const& peers, int max_lines)
{
using namespace libtorrent;
using namespace lt;
int pos = 0;
if (print_ip) out += "IP ";
out += "progress down (total | peak ) up (total | peak ) sent-req tmo bsy rcv flags dn up source ";
@ -508,7 +508,7 @@ int print_peer_info(std::string& out
return pos;
}
int allocation_mode = libtorrent::storage_mode_sparse;
int allocation_mode = lt::storage_mode_sparse;
std::string save_path(".");
int torrent_upload_limit = 0;
int torrent_download_limit = 0;
@ -537,7 +537,7 @@ void print_settings(int const start, int const num
{
for (int i = start; i < start + num; ++i)
{
char const* name = libtorrent::name_for_setting(i);
char const* name = lt::name_for_setting(i);
if (!name || name[0] == '\0') continue;
std::printf(fmt, name);
}
@ -588,9 +588,9 @@ void add_magnet(lt::session& ses, lt::string_view uri)
}
// return false on failure
bool add_torrent(libtorrent::session& ses, std::string torrent)
bool add_torrent(lt::session& ses, std::string torrent)
{
using namespace libtorrent;
using namespace lt;
static int counter = 0;
std::printf("[%d] %s\n", counter++, torrent.c_str());
@ -634,7 +634,7 @@ bool add_torrent(libtorrent::session& ses, std::string torrent)
std::vector<std::string> list_dir(std::string path
, bool (*filter_fun)(lt::string_view)
, libtorrent::error_code& ec)
, lt::error_code& ec)
{
std::vector<std::string> ret;
#ifdef TORRENT_WINDOWS
@ -684,9 +684,9 @@ std::vector<std::string> list_dir(std::string path
return ret;
}
void scan_dir(std::string const& dir_path, libtorrent::session& ses)
void scan_dir(std::string const& dir_path, lt::session& ses)
{
using namespace libtorrent;
using namespace lt;
error_code ec;
std::vector<std::string> ents = list_dir(dir_path
@ -723,9 +723,9 @@ char const* timestamp()
return str;
}
void print_alert(libtorrent::alert const* a, std::string& str)
void print_alert(lt::alert const* a, std::string& str)
{
using namespace libtorrent;
using namespace lt;
if (a->category() & alert::error_notification)
{
@ -762,9 +762,9 @@ int save_file(std::string const& filename, std::vector<char> const& v)
// returns true if the alert was handled (and should not be printed to the log)
// returns false if the alert was not handled
bool handle_alert(torrent_view& view, session_view& ses_view
, libtorrent::session& ses, libtorrent::alert* a)
, lt::session& ses, lt::alert* a)
{
using namespace libtorrent;
using namespace lt;
if (session_stats_alert* s = alert_cast<session_stats_alert>(a))
{
@ -936,7 +936,7 @@ bool handle_alert(torrent_view& view, session_view& ses_view
}
void pop_alerts(torrent_view& view, session_view& ses_view
, libtorrent::session& ses, std::deque<std::string>& events)
, lt::session& ses, std::deque<std::string>& events)
{
std::vector<lt::alert*> alerts;
ses.pop_alerts(&alerts);
@ -952,12 +952,12 @@ void pop_alerts(torrent_view& view, session_view& ses_view
}
}
void print_piece(libtorrent::partial_piece_info const* pp
, libtorrent::cached_piece_info const* cs
, std::vector<libtorrent::peer_info> const& peers
void print_piece(lt::partial_piece_info const* pp
, lt::cached_piece_info const* cs
, std::vector<lt::peer_info> const& peers
, std::string& out)
{
using namespace libtorrent;
using namespace lt;
char str[1024];
assert(pp == nullptr || cs == nullptr || cs->piece == pp->piece_index);
@ -1073,8 +1073,7 @@ MAGNETURL is a magnet link
return 0;
}
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
torrent_view view;
session_view ses_view;
@ -1175,8 +1174,8 @@ MAGNETURL is a magnet link
case 't': poll_interval = atoi(arg); break;
case 'F': refresh_delay = atoi(arg); break;
case 'a': allocation_mode = (arg == std::string("sparse"))
? libtorrent::storage_mode_sparse
: libtorrent::storage_mode_allocate;
? lt::storage_mode_sparse
: lt::storage_mode_allocate;
break;
case 'x':
{
@ -1234,7 +1233,7 @@ MAGNETURL is a magnet link
+ alert::picker_log_notification
));
libtorrent::session ses(settings);
lt::session ses(settings);
if (rate_limit_locals)
{

View File

@ -58,8 +58,8 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#endif
using namespace libtorrent;
using namespace libtorrent::detail; // for write_* and read_*
using namespace lt;
using namespace lt::detail; // for write_* and read_*
using namespace std::placeholders;
@ -770,7 +770,7 @@ void print_usage()
exit(1);
}
void hasher_thread(libtorrent::create_torrent* t, piece_index_t const start_piece
void hasher_thread(lt::create_torrent* t, piece_index_t const start_piece
, piece_index_t const end_piece, int piece_size, bool print)
{
if (print) std::fprintf(stderr, "\n");
@ -817,7 +817,7 @@ void generate_torrent(std::vector<char>& buf, int size, int num_files
file_size += 200;
}
libtorrent::create_torrent t(fs, piece_size);
lt::create_torrent t(fs, piece_size);
int const num_threads = std::thread::hardware_concurrency()
? std::thread::hardware_concurrency() : 4;
@ -1003,7 +1003,7 @@ int main(int argc, char* argv[])
}
// 1 MiB piece size
const int piece_size = 1024 * 1024;
libtorrent::create_torrent t(fs, piece_size);
lt::create_torrent t(fs, piece_size);
sha1_hash zero(nullptr);
for (piece_index_t k(0); k < fs.end_piece(); ++k)
t.set_hash(k, zero);

View File

@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/magnet_uri.hpp"
int load_file(std::string const& filename, std::vector<char>& v
, libtorrent::error_code& ec, int limit = 8000000)
, lt::error_code& ec, int limit = 8000000)
{
ec.clear();
FILE* f = std::fopen(filename.c_str(), "rb");
@ -104,7 +104,7 @@ int load_file(std::string const& filename, std::vector<char>& v
int main(int argc, char* argv[])
{
using namespace libtorrent;
using namespace lt;
if (argc < 2 || argc > 4)
{

View File

@ -48,7 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <direct.h> // for _getcwd
#endif
using namespace libtorrent;
using namespace lt;
using namespace std::placeholders;
std::vector<char> load_file(std::string const& filename)
@ -162,7 +162,7 @@ void print_usage()
int main(int argc, char* argv[])
{
using namespace libtorrent;
using namespace lt;
std::string creator_str = "libtorrent";
std::string comment_str;

View File

@ -128,13 +128,13 @@ std::string const& progress_bar(int progress, int width, color_code c
return bar;
}
int get_piece(libtorrent::bitfield const& p, int index)
int get_piece(lt::bitfield const& p, int index)
{
if (index < 0 || index >= p.size()) return 0;
return p.get_bit(index) ? 1 : 0;
}
std::string const& piece_bar(libtorrent::bitfield const& p, int width)
std::string const& piece_bar(lt::bitfield const& p, int width)
{
#ifdef _WIN32
int const table_size = 5;
@ -207,7 +207,7 @@ std::string const& piece_bar(libtorrent::bitfield const& p, int width)
// this function uses the block characters that splits up the glyph in 4
// segments and provide all combinations of a segment lit or not. This allows us
// to print 4 pieces per character.
std::string piece_matrix(libtorrent::bitfield const& p, int width, int* height)
std::string piece_matrix(lt::bitfield const& p, int width, int* height)
{
// print two rows of pieces at a time
int piece = 0;
@ -257,7 +257,7 @@ std::string piece_matrix(libtorrent::bitfield const& p, int width, int* height)
#else
// on MS-DOS terminals, we only have block characters for upper half and lower
// half. This lets us print two pieces per character.
std::string piece_matrix(libtorrent::bitfield const& p, int width, int* height)
std::string piece_matrix(lt::bitfield const& p, int width, int* height)
{
// print two rows of pieces at a time
int piece = 0;

View File

@ -36,7 +36,7 @@ enum { progress_invert = 1};
std::string const& progress_bar(int progress, int width, color_code c = col_green
, char fill = '#', char bg = '-', std::string caption = "", int flags = 0);
std::string const& piece_bar(libtorrent::bitfield const& p, int width);
std::string const& piece_bar(lt::bitfield const& p, int width);
void set_cursor_pos(int x, int y);
@ -45,7 +45,7 @@ void clear_screen();
void clear_rows(int y1, int y2);
void terminal_size(int* terminal_width, int* terminal_height);
std::string piece_matrix(libtorrent::bitfield const& p, int width, int* height);
std::string piece_matrix(lt::bitfield const& p, int width, int* height);
void print(char const* str);

View File

@ -37,13 +37,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm> // for std::max
namespace lt = libtorrent;
session_view::session_view()
: m_position(0)
, m_print_utp_stats(false)
{
using libtorrent::find_metric_idx;
using lt::find_metric_idx;
m_width = 128;

View File

@ -38,8 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
int main(int argc, char* argv[])
{
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
if (argc != 2)
{

View File

@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cstdio> // for snprintf
#include <cinttypes> // for PRId64 et.al.
using namespace libtorrent;
using namespace lt;
int main()
{

View File

@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/fwd.hpp"
#include "libtorrent/torrent_status.hpp"
namespace lt = libtorrent;
struct torrent_view
{

View File

@ -43,9 +43,9 @@ char const* timestamp()
return str;
}
void print_alert(libtorrent::alert const* a)
void print_alert(lt::alert const* a)
{
using namespace libtorrent;
using namespace lt;
if (alert_cast<portmap_error_alert>(a))
{
@ -62,8 +62,7 @@ void print_alert(libtorrent::alert const* a)
int main(int argc, char* argv[])
{
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
if (argc != 1)
{

View File

@ -634,4 +634,9 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#endif // TORRENT_HAS_ARM_CRC32
namespace libtorrent {}
// create alias
namespace lt = libtorrent;
#endif // TORRENT_CONFIG_HPP_INCLUDED

View File

@ -54,4 +54,6 @@ namespace libtorrent {
}
namespace lt = libtorrent;
#endif

View File

@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/path.hpp"
#include <fstream>
namespace lt = libtorrent;
std::string save_path(int idx)
{

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/add_torrent_params.hpp"
std::string save_path(int idx);
libtorrent::add_torrent_params create_torrent(int idx, bool seed = true
lt::add_torrent_params create_torrent(int idx, bool seed = true
, int num_pieces = 9);
#endif

View File

@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace sim;
namespace lt = libtorrent;
struct fake_peer
{

@ -1 +1 @@
Subproject commit c1537196d68a6950e00995d5594dcbce4485effd
Subproject commit 60d786b8fa6ddaacdc98bdf691220660bc194494

View File

@ -35,10 +35,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/proxy_settings.hpp"
inline libtorrent::aux::proxy_settings make_proxy_settings(
libtorrent::settings_pack::proxy_type_t const proxy_type)
inline lt::aux::proxy_settings make_proxy_settings(
lt::settings_pack::proxy_type_t const proxy_type)
{
using namespace libtorrent;
using namespace lt;
aux::proxy_settings ps;
ps.type = std::uint8_t(proxy_type);

View File

@ -48,9 +48,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "setup_dht.hpp"
namespace lt = libtorrent;
using namespace sim;
using namespace libtorrent;
using namespace lt;
#ifndef TORRENT_DISABLE_DHT
@ -150,8 +149,8 @@ struct dht_node final : lt::dht::socket_manager, lt::aux::session_listen_socket
{
if (ec) return;
using libtorrent::entry;
using libtorrent::bdecode;
using lt::entry;
using lt::bdecode;
int pos;
error_code err;
@ -164,7 +163,7 @@ struct dht_node final : lt::dht::socket_manager, lt::aux::session_listen_socket
if (msg.type() != bdecode_node::dict_t) return;
libtorrent::dht::msg m(msg, m_ep);
lt::dht::msg m(msg, m_ep);
dht().incoming(m);
sock().async_receive_from(asio::mutable_buffers_1(m_buffer, sizeof(m_buffer))

View File

@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_settings.hpp" // for dht_settings
#include "libtorrent/performance_counters.hpp" // for counters
namespace lt = libtorrent;
namespace sim
{

View File

@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "utils.hpp"
#include "simulator/queue.hpp"
namespace lt = libtorrent;
using namespace sim;
namespace {
@ -159,7 +158,7 @@ int completed_pieces(lt::session& ses)
namespace {
bool should_print(lt::alert* a)
{
using namespace libtorrent;
using namespace lt;
#ifndef TORRENT_DISABLE_LOGGING
if (auto pla = alert_cast<peer_log_alert>(a))
@ -182,7 +181,7 @@ bool should_print(lt::alert* a)
void utp_only(lt::settings_pack& p)
{
using namespace libtorrent;
using namespace lt;
p.set_bool(settings_pack::enable_outgoing_tcp, false);
p.set_bool(settings_pack::enable_incoming_tcp, false);
p.set_bool(settings_pack::enable_outgoing_utp, true);
@ -191,7 +190,7 @@ void utp_only(lt::settings_pack& p)
void enable_enc(lt::settings_pack& p)
{
using namespace libtorrent;
using namespace lt;
p.set_bool(settings_pack::prefer_rc4, true);
p.set_int(settings_pack::in_enc_policy, settings_pack::pe_forced);
p.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced);

View File

@ -47,7 +47,6 @@ namespace libtorrent
struct torrent_status;
}
namespace lt = libtorrent;
enum class swarm_test { download, upload };

View File

@ -43,10 +43,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
using namespace sim;
using namespace libtorrent;
using namespace lt;
const int num_torrents = 10;
namespace lt = libtorrent;
using sim::asio::ip::address_v4;

View File

@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/bencode.hpp"
#include "libtorrent/kademlia/item.hpp"
namespace lt = libtorrent;
#ifndef TORRENT_DISABLE_DHT
void bootstrap_session(std::vector<dht_network*> networks, lt::session& ses)

View File

@ -39,7 +39,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/deadline_timer.hpp"
#include "setup_transfer.hpp" // for addr()
namespace lt = libtorrent;
using namespace sim;
struct sim_config : sim::default_config

View File

@ -48,8 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cstdarg>
#include <cmath>
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
using namespace sim;
using namespace std::placeholders;

View File

@ -47,8 +47,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <functional>
#include <sstream>
using namespace libtorrent;
using namespace libtorrent::dht;
using namespace lt;
using namespace lt::dht;
using namespace sim;
using namespace sim::chrono;
using namespace sim::asio;
@ -83,7 +83,7 @@ void timer_tick(dht_storage_interface* s
, dht_storage_counters const& c
, boost::system::error_code const&)
{
libtorrent::aux::update_time_now();
lt::aux::update_time_now();
s->tick();
TEST_EQUAL(s->counters().peers, c.peers);
@ -199,7 +199,7 @@ TORRENT_TEST(dht_storage_infohashes_sample)
timer.expires_from_now(hours(1)); // expiration of torrents
timer.async_wait([&s](boost::system::error_code const& ec)
{
libtorrent::aux::update_time_now();
lt::aux::update_time_now();
// tick here to trigger the torrents expiration
s->tick();

View File

@ -50,7 +50,6 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace sim;
namespace lt = libtorrent;
std::string make_ep_string(char const* address, bool const is_v6
, char const* port)
@ -67,7 +66,7 @@ std::string make_ep_string(char const* address, bool const is_v6
template <typename HandleAlerts, typename Test>
void run_test(HandleAlerts const& on_alert, Test const& test)
{
using namespace libtorrent;
using namespace lt;
using asio::ip::address;
address const peer0 = addr("50.0.0.1");
@ -165,7 +164,7 @@ TORRENT_TEST(no_proxy_tcp)
try
{
g_alloc_counter = 100 + i;
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session&, lt::alert const*) {},
[](std::shared_ptr<lt::session> ses[2]) {}

View File

@ -43,8 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "simulator/utils.hpp"
#include "libtorrent/string_view.hpp"
using namespace libtorrent::literals;
namespace lt = libtorrent;
using namespace lt::literals;
template <typename Sett, typename Alert>
void run_fake_peer_test(

View File

@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_stats.hpp"
#include "libtorrent/torrent_info.hpp"
using namespace libtorrent;
using namespace lt;
// the disk I/O thread is not simulated with high enough fidelity for this to
// work

View File

@ -50,9 +50,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/crc.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
using namespace libtorrent;
using namespace lt;
using namespace sim;
namespace lt = libtorrent;
namespace io = lt::detail;
using chrono::duration_cast;

View File

@ -46,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace sim;
namespace lt = libtorrent;
template <typename Setup, typename HandleAlerts, typename Test>
void run_test(Setup const& setup

View File

@ -42,8 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/magnet_uri.hpp"
#include "libtorrent/extensions/ut_metadata.hpp"
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
enum flags_t
{

View File

@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <memory>
using namespace libtorrent;
using namespace lt;
struct choke_state
{
@ -63,7 +63,7 @@ TORRENT_TEST(optimistic_unchoke)
{
int const num_nodes = 20;
lt::time_duration const test_duration
= libtorrent::seconds(num_nodes * 90);
= lt::seconds(num_nodes * 90);
dsl_config network_cfg;
sim::simulation sim{network_cfg};
@ -71,7 +71,7 @@ TORRENT_TEST(optimistic_unchoke)
io_service ios(sim, addr("50.1.0.0"));
lt::time_point start_time(lt::clock_type::now());
libtorrent::add_torrent_params atp = create_torrent(0);
lt::add_torrent_params atp = create_torrent(0);
atp.flags &= ~add_torrent_params::flag_auto_managed;
atp.flags &= ~add_torrent_params::flag_paused;

View File

@ -44,9 +44,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
using namespace sim;
using namespace libtorrent;
using namespace lt;
namespace lt = libtorrent;
using sim::asio::ip::address_v4;

View File

@ -43,8 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
char const* pe_policy(std::uint8_t policy)
{
@ -54,7 +53,7 @@ char const* pe_policy(std::uint8_t policy)
return "unknown";
}
void display_pe_settings(libtorrent::settings_pack const& s)
void display_pe_settings(lt::settings_pack const& s)
{
std::printf("out_enc_policy - %s\tin_enc_policy - %s\n"
, pe_policy(s.get_int(settings_pack::out_enc_policy))

View File

@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/write_resume_data.hpp"
#include "settings.hpp"
using namespace libtorrent;
using namespace lt;
TORRENT_TEST(seed_and_suggest_mode)
{

View File

@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "settings.hpp"
#include "create_torrent.hpp"
using namespace libtorrent;
using namespace lt;
TORRENT_TEST(seed_mode)
{

View File

@ -48,9 +48,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
using namespace sim;
using namespace libtorrent;
using namespace lt;
namespace lt = libtorrent;
// this is the general template for these tests. create the session with custom
// settings (Settings), set up the test, by adding torrents with certain
@ -103,7 +102,7 @@ void run_test(Setup const& setup
TORRENT_TEST(socks5_tcp_announce)
{
using namespace libtorrent;
using namespace lt;
int tracker_port = -1;
int alert_port = -1;
run_test(
@ -162,7 +161,7 @@ TORRENT_TEST(socks5_tcp_announce)
TORRENT_TEST(udp_tracker)
{
using namespace libtorrent;
using namespace lt;
bool tracker_alert = false;
bool connected = false;
bool announced = false;
@ -194,7 +193,7 @@ TORRENT_TEST(udp_tracker)
udp_server tracker(sim, "2.2.2.2", 8080,
[&](char const* msg, int size)
{
using namespace libtorrent::detail;
using namespace lt::detail;
std::vector<char> ret;
TEST_CHECK(size >= 16);

View File

@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/settings_pack.hpp"
#include "test.hpp"
using namespace libtorrent;
using namespace lt;
TORRENT_TEST(super_seeding)
{

View File

@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/torrent_info.hpp"
#include "settings.hpp"
using namespace libtorrent;
using namespace lt;
TORRENT_TEST(seed_mode)
{

View File

@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/disk_io_thread_pool.hpp"
#include <condition_variable>
namespace lt = libtorrent;
struct test_threads : lt::pool_thread_interface
{

View File

@ -36,9 +36,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alert_types.hpp"
#include "libtorrent/settings_pack.hpp"
using namespace libtorrent;
using namespace lt;
using namespace sim;
namespace lt = libtorrent;
time_point32 time_now()
{

View File

@ -43,9 +43,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/file_storage.hpp"
#include "libtorrent/torrent_info.hpp"
using namespace libtorrent;
using namespace lt;
using namespace sim;
namespace lt = libtorrent;
using chrono::duration_cast;

View File

@ -50,7 +50,6 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace sim;
namespace lt = libtorrent;
std::string make_ep_string(char const* address, bool const is_v6
, char const* port)
@ -71,7 +70,7 @@ void run_test(
, Test const& test
, int flags = 0)
{
using namespace libtorrent;
using namespace lt;
const bool use_ipv6 = flags & ipv6;
@ -159,7 +158,7 @@ void run_test(
TORRENT_TEST(socks4_tcp)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session& ses0, lt::session& ses1)
{
@ -175,7 +174,7 @@ TORRENT_TEST(socks4_tcp)
TORRENT_TEST(socks5_tcp_connect)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session& ses0, lt::session& ses1)
{
@ -191,7 +190,7 @@ TORRENT_TEST(socks5_tcp_connect)
TORRENT_TEST(encryption_tcp)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session& ses0, lt::session& ses1)
{ enable_enc(ses0); enable_enc(ses1); },
@ -204,7 +203,7 @@ TORRENT_TEST(encryption_tcp)
TORRENT_TEST(no_proxy_tcp_ipv6)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session&, lt::session&) {},
[](lt::session&, lt::alert const*) {},
@ -217,7 +216,7 @@ TORRENT_TEST(no_proxy_tcp_ipv6)
TORRENT_TEST(no_proxy_utp_ipv6)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session&, lt::session&) {},
[](lt::session&, lt::alert const*) {},
@ -232,7 +231,7 @@ TORRENT_TEST(no_proxy_utp_ipv6)
/*
TORRENT_TEST(socks5_tcp_ipv6)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session& ses0, lt::session& ses1)
{
@ -250,7 +249,7 @@ TORRENT_TEST(socks5_tcp_ipv6)
TORRENT_TEST(no_proxy_tcp)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session&, lt::session&) {},
[](lt::session&, lt::alert const*) {},
@ -262,7 +261,7 @@ TORRENT_TEST(no_proxy_tcp)
TORRENT_TEST(no_proxy_utp)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session&, lt::session&) {},
[](lt::session&, lt::alert const*) {},
@ -275,7 +274,7 @@ TORRENT_TEST(no_proxy_utp)
// TOD: 3 figure out why this test is failing
TORRENT_TEST(encryption_utp)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session& ses0, lt::session& ses1)
{ enable_enc(ses0); enable_enc(ses1); utp_only(ses0); },
@ -291,7 +290,7 @@ TORRENT_TEST(encryption_utp)
/*
TORRENT_TEST(socks5_utp)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session& ses0, lt::session& ses1)
{
@ -312,7 +311,7 @@ TORRENT_TEST(socks5_utp)
// directly to each other, all other tests in here may be broken.
TORRENT_TEST(no_proxy_tcp_banned)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session&, lt::session& ses1) { filter_ips(ses1); },
[](lt::session&, lt::alert const*) {},
@ -324,7 +323,7 @@ TORRENT_TEST(no_proxy_tcp_banned)
TORRENT_TEST(no_proxy_utp_banned)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session&, lt::session& ses1) { filter_ips(ses1); },
[](lt::session&, lt::alert const*) {},
@ -336,7 +335,7 @@ TORRENT_TEST(no_proxy_utp_banned)
TORRENT_TEST(auto_disk_cache_size)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session& ses0, lt::session&) { set_cache_size(ses0, -1); },
[](lt::session&, lt::alert const*) {},
@ -353,7 +352,7 @@ TORRENT_TEST(auto_disk_cache_size)
TORRENT_TEST(disable_disk_cache)
{
using namespace libtorrent;
using namespace lt;
run_test(
[](lt::session& ses0, lt::session&) { set_cache_size(ses0, 0); },
[](lt::session&, lt::alert const*) {},

View File

@ -41,8 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <fstream>
#include <iostream>
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
TORRENT_TEST(utp)
{

View File

@ -49,15 +49,14 @@ POSSIBILITY OF SUCH DAMAGE.
#include <numeric>
using namespace sim;
using namespace libtorrent;
using namespace lt;
namespace lt = libtorrent;
int const piece_size = 0x4000;
add_torrent_params create_torrent(file_storage& fs, bool const pad_files = false)
{
libtorrent::create_torrent t(fs, piece_size
lt::create_torrent t(fs, piece_size
, pad_files ? piece_size : -1
, pad_files ? create_torrent::optimize_alignment : 0);
@ -143,7 +142,7 @@ void run_test(Setup const& setup
TORRENT_TEST(single_file)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
fs.add_file("abc'abc", 0x8000); // this filename will have to be escaped
@ -181,7 +180,7 @@ TORRENT_TEST(single_file)
TORRENT_TEST(multi_file)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
fs.add_file(combine_path("foo", "abc'abc"), 0x8000); // this filename will have to be escaped
fs.add_file(combine_path("foo", "bar"), 0x3000);
@ -247,7 +246,7 @@ void serve_content_for(sim::http_server& http, std::string const& path
// second redirect is added to the same web-seed entry as the first one
TORRENT_TEST(unaligned_file_redirect)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
fs.add_file(combine_path("foo", "1"), 0xc030);
fs.add_file(combine_path("foo", "2"), 0xc030);
@ -291,7 +290,7 @@ TORRENT_TEST(unaligned_file_redirect)
// test redirecting *unaligned* but padded files to separate servers
TORRENT_TEST(multi_file_redirect_pad_files)
{
using namespace libtorrent;
using namespace lt;
file_storage fs_;
fs_.add_file(combine_path("foo", "1"), 0xc030);
fs_.add_file(combine_path("foo", "2"), 0xc030);
@ -344,7 +343,7 @@ TORRENT_TEST(multi_file_redirect_pad_files)
// they are piece aligned)
TORRENT_TEST(multi_file_redirect)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
fs.add_file(combine_path("foo", "1"), 0xc000);
fs.add_file(combine_path("foo", "2"), 0xc030);
@ -392,7 +391,7 @@ TORRENT_TEST(multi_file_redirect)
// test web_seed redirect through proxy
TORRENT_TEST(multi_file_redirect_through_proxy)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
fs.add_file(combine_path("foo", "1"), 0xc000);
fs.add_file(combine_path("foo", "2"), 0xc030);
@ -455,7 +454,7 @@ TORRENT_TEST(multi_file_redirect_through_proxy)
// separate servers, without pad files
TORRENT_TEST(multi_file_unaligned_redirect)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
fs.add_file(combine_path("foo", "1"), 0xc030);
fs.add_file(combine_path("foo", "2"), 0xc030);
@ -534,7 +533,7 @@ TORRENT_TEST(urlseed_timeout)
// may be closed in such manner.
TORRENT_TEST(no_close_redudant_webseed)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
fs.add_file("file1", 1);
@ -579,7 +578,7 @@ TORRENT_TEST(no_close_redudant_webseed)
// make sure the max_web_seed_connections limit is honored
TORRENT_TEST(web_seed_connection_limit)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
fs.add_file("file1", 1);

View File

@ -42,7 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io_service.hpp"
#include "setup_swarm.hpp"
using namespace libtorrent;
using namespace lt;
void utp_only(lt::session& ses)
{

View File

@ -40,8 +40,6 @@ namespace libtorrent
class alert;
}
namespace lt = libtorrent;
void utp_only(lt::session& ses);
void enable_enc(lt::session& ses);
void filter_ips(lt::session& ses);

View File

@ -44,7 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <functional>
#include <utility>
using namespace libtorrent;
using namespace lt;
using namespace std::placeholders;
peer_conn::peer_conn(io_service& ios
@ -130,7 +130,7 @@ void peer_conn::on_handshake2(error_code const& ec, size_t)
void peer_conn::write_have_all()
{
using namespace libtorrent::detail;
using namespace lt::detail;
if (fast_extension)
{
@ -180,7 +180,7 @@ void peer_conn::on_have_all_sent(error_code const& ec, size_t)
bool peer_conn::write_request()
{
using namespace libtorrent::detail;
using namespace lt::detail;
// if we're choked (and there are no allowed-fast pieces left)
if (choked && allowed_fast.empty() && !m_current_piece_is_allowed) return false;
@ -309,7 +309,7 @@ void peer_conn::work_download()
void peer_conn::on_msg_length(error_code const& ec, size_t)
{
using namespace libtorrent::detail;
using namespace lt::detail;
if ((ec == boost::asio::error::operation_aborted || ec == boost::asio::error::bad_descriptor)
&& restarting)
@ -346,7 +346,7 @@ void peer_conn::on_msg_length(error_code const& ec, size_t)
void peer_conn::on_message(error_code const& ec, size_t bytes_transferred)
{
using namespace libtorrent::detail;
using namespace lt::detail;
if ((ec == boost::asio::error::operation_aborted || ec == boost::asio::error::bad_descriptor)
&& restarting)
@ -405,7 +405,7 @@ void peer_conn::on_message(error_code const& ec, size_t bytes_transferred)
{
int piece = detail::read_int32(ptr);
if (pieces.empty()) pieces.push_back(piece);
else pieces.insert(pieces.begin() + static_cast<int>(libtorrent::random(static_cast<std::uint32_t>(pieces.size()))), piece);
else pieces.insert(pieces.begin() + static_cast<int>(lt::random(static_cast<std::uint32_t>(pieces.size()))), piece);
}
else if (msg == 5) // bitfield
{
@ -528,7 +528,7 @@ bool peer_conn::verify_piece(int piece, int start, char const* ptr, int size)
*/
void peer_conn::write_piece(int piece, int start, int length)
{
using namespace libtorrent::detail;
using namespace lt::detail;
// generate_block(write_buffer, piece, start, length);
@ -547,7 +547,7 @@ void peer_conn::write_piece(int piece, int start, int length)
void peer_conn::write_have(int piece)
{
using namespace libtorrent::detail;
using namespace lt::detail;
char* ptr = write_buf_proto.data();
write_uint32(5, ptr);

View File

@ -48,25 +48,25 @@ struct EXPORT peer_conn
enum class peer_mode_t
{ uploader, downloader, idle };
peer_conn(libtorrent::io_service& ios
peer_conn(lt::io_service& ios
, std::function<void(int, char const*, int)> on_msg
, libtorrent::torrent_info const& ti
, libtorrent::tcp::endpoint const& ep
, lt::torrent_info const& ti
, lt::tcp::endpoint const& ep
, peer_mode_t mode);
void start_conn();
void on_connect(libtorrent::error_code const& ec);
void on_handshake(char* h, libtorrent::error_code const& ec, size_t bytes_transferred);
void on_handshake2(libtorrent::error_code const& ec, size_t bytes_transferred);
void on_connect(lt::error_code const& ec);
void on_handshake(char* h, lt::error_code const& ec, size_t bytes_transferred);
void on_handshake2(lt::error_code const& ec, size_t bytes_transferred);
void write_have_all();
void on_have_all_sent(libtorrent::error_code const& ec, size_t bytes_transferred);
void on_have_all_sent(lt::error_code const& ec, size_t bytes_transferred);
bool write_request();
void on_req_sent(char* m, libtorrent::error_code const& ec, size_t bytes_transferred);
void close(char const* fmt, libtorrent::error_code const& ec);
void on_req_sent(char* m, lt::error_code const& ec, size_t bytes_transferred);
void close(char const* fmt, lt::error_code const& ec);
void work_download();
void on_msg_length(libtorrent::error_code const& ec, size_t bytes_transferred);
void on_message(libtorrent::error_code const& ec, size_t bytes_transferred);
void on_msg_length(lt::error_code const& ec, size_t bytes_transferred);
void on_message(lt::error_code const& ec, size_t bytes_transferred);
bool verify_piece(int piece, int start, char const* ptr, int size);
void write_piece(int piece, int start, int length);
void write_have(int piece);
@ -75,13 +75,13 @@ struct EXPORT peer_conn
private:
libtorrent::tcp::socket s;
lt::tcp::socket s;
std::array<char, 100> write_buf_proto;
std::array<std::uint32_t, 17 * 1024 / 4> write_buffer;
std::array<char, 17 * 1024> buffer;
peer_mode_t const m_mode;
libtorrent::torrent_info const& m_ti;
lt::torrent_info const& m_ti;
int read_pos = 0;
@ -100,9 +100,9 @@ private:
bool fast_extension = false;
int blocks_received = 0;
int blocks_sent = 0;
libtorrent::time_point start_time = libtorrent::clock_type::now();
libtorrent::time_point end_time;
libtorrent::tcp::endpoint endpoint;
lt::time_point start_time = lt::clock_type::now();
lt::time_point end_time;
lt::tcp::endpoint endpoint;
bool restarting = false;
};

View File

@ -49,13 +49,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include <functional>
#include <memory>
using namespace libtorrent;
using namespace lt;
using namespace std::placeholders;
struct dht_server
{
libtorrent::io_service m_ios;
lt::io_service m_ios;
std::atomic<int> m_dht_requests;
udp::socket m_socket;
int m_port;

View File

@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/socket.hpp>
#include <libtorrent/broadcast_socket.hpp>
using namespace libtorrent;
using namespace lt;
int main()
{

View File

@ -65,7 +65,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
using namespace libtorrent;
using namespace lt;
namespace {
@ -366,7 +366,7 @@ EXPORT int main(int argc, char const* argv[])
std::string const root_dir = current_working_directory();
std::string const unit_dir_prefix = combine_path(root_dir, "test_tmp_" + std::to_string(process_id) + "_");
std::printf("test: %s\ncwd_prefix = \"%s\"\nrnd = %x\n"
, executable, unit_dir_prefix.c_str(), libtorrent::random(0xffffffff));
, executable, unit_dir_prefix.c_str(), lt::random(0xffffffff));
if (_g_num_unit_tests == 0)
{

View File

@ -40,9 +40,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/file_pool.hpp"
#include "libtorrent/storage_defs.hpp"
using namespace libtorrent;
using namespace lt;
std::shared_ptr<libtorrent::torrent_info> make_test_torrent(
std::shared_ptr<lt::torrent_info> make_test_torrent(
torrent_args const& args)
{
entry e;
@ -165,7 +165,7 @@ std::shared_ptr<libtorrent::torrent_info> make_test_torrent(
return std::make_shared<torrent_info>(&tmp[0], int(tmp.size()));
}
void generate_files(libtorrent::torrent_info const& ti, std::string const& path
void generate_files(lt::torrent_info const& ti, std::string const& path
, bool alternate_data)
{
file_pool fp;

View File

@ -59,9 +59,9 @@ struct torrent_args
std::string m_http_seed;
};
EXPORT std::shared_ptr<libtorrent::torrent_info>
EXPORT std::shared_ptr<lt::torrent_info>
make_test_torrent(torrent_args const& args);
EXPORT void generate_files(libtorrent::torrent_info const& ti, std::string const& path, bool random = false);
EXPORT void generate_files(lt::torrent_info const& ti, std::string const& path, bool random = false);
#endif

View File

@ -47,12 +47,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include <condition_variable>
#include <memory>
using namespace libtorrent;
using namespace lt;
using namespace std::placeholders;
struct peer_server
{
libtorrent::io_service m_ios;
lt::io_service m_ios;
std::atomic<int> m_peer_requests{0};
tcp::acceptor m_acceptor{m_ios};
int m_port = 0;

View File

@ -36,10 +36,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alert_types.hpp"
#include "print_alerts.hpp"
void print_alerts(libtorrent::session* ses, libtorrent::time_point start_time)
void print_alerts(lt::session* ses, lt::time_point start_time)
{
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
if (ses == nullptr) return;

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session.hpp"
#include "test.hpp" // for EXPORT
EXPORT void print_alerts(libtorrent::session* ses, libtorrent::time_point start_time);
EXPORT void print_alerts(lt::session* ses, lt::time_point start_time);
#endif

View File

@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alert.hpp"
#include "settings.hpp"
using namespace libtorrent;
using namespace lt;
libtorrent::settings_pack settings()
lt::settings_pack settings()
{
const int mask = alert::all_categories
& ~(alert::progress_notification

View File

@ -33,5 +33,5 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/settings_pack.hpp"
#include "test.hpp"
libtorrent::settings_pack EXPORT settings();
lt::settings_pack EXPORT settings();

View File

@ -67,8 +67,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <csignal>
#endif
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
#if defined TORRENT_WINDOWS
#include <conio.h>
@ -121,22 +120,22 @@ address rand_v6()
static std::uint16_t g_port = 0;
tcp::endpoint rand_tcp_ep(libtorrent::address(&rand_addr)())
tcp::endpoint rand_tcp_ep(lt::address(&rand_addr)())
{
// make sure we don't produce the same "random" port twice
g_port = (g_port + 1) % 14038;
return tcp::endpoint(rand_addr(), g_port + 1024);
}
udp::endpoint rand_udp_ep(libtorrent::address(&rand_addr)())
udp::endpoint rand_udp_ep(lt::address(&rand_addr)())
{
g_port = (g_port + 1) % 14037;
return udp::endpoint(rand_addr(), g_port + 1024);
}
std::map<std::string, std::int64_t> get_counters(libtorrent::session& s)
std::map<std::string, std::int64_t> get_counters(lt::session& s)
{
using namespace libtorrent;
using namespace lt;
s.post_session_stats();
std::map<std::string, std::int64_t> ret;
@ -177,7 +176,7 @@ bool should_print(lt::alert* a)
}
alert const* wait_for_alert(lt::session& ses, int type, char const* name, int num)
{
time_point end_time = libtorrent::clock_type::now() + seconds(10);
time_point end_time = lt::clock_type::now() + seconds(10);
while (true)
{
time_point now = clock_type::now();
@ -206,7 +205,7 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name, int nu
}
int load_file(std::string const& filename, std::vector<char>& v
, libtorrent::error_code& ec, int limit)
, lt::error_code& ec, int limit)
{
ec.clear();
FILE* f = fopen(filename.c_str(), "rb");
@ -269,7 +268,7 @@ int load_file(std::string const& filename, std::vector<char>& v
bool print_alerts(lt::session& ses, char const* name
, bool allow_no_torrents, bool allow_failed_fastresume
, std::function<bool(libtorrent::alert const*)> predicate, bool no_output)
, std::function<bool(lt::alert const*)> predicate, bool no_output)
{
bool ret = false;
std::vector<torrent_handle> handles = ses.get_torrents();
@ -309,7 +308,7 @@ void wait_for_listen(lt::session& ses, char const* name)
alert const* a = nullptr;
do
{
print_alerts(ses, name, true, true, [&listen_done](libtorrent::alert const* al)
print_alerts(ses, name, true, true, [&listen_done](lt::alert const* al)
{
if (alert_cast<listen_failed_alert>(al)
|| alert_cast<listen_succeeded_alert>(al))
@ -332,7 +331,7 @@ void wait_for_downloading(lt::session& ses, char const* name)
alert const* a = nullptr;
do
{
print_alerts(ses, name, true, true, [&downloading_done](libtorrent::alert const* al)
print_alerts(ses, name, true, true, [&downloading_done](lt::alert const* al)
{
state_changed_alert const* sc = alert_cast<state_changed_alert>(al);
if (sc && sc->state == torrent_status::downloading)
@ -352,9 +351,9 @@ void wait_for_downloading(lt::session& ses, char const* name)
}
void print_ses_rate(float const time
, libtorrent::torrent_status const* st1
, libtorrent::torrent_status const* st2
, libtorrent::torrent_status const* st3)
, lt::torrent_status const* st1
, lt::torrent_status const* st2
, lt::torrent_status const* st3)
{
if (st1)
{
@ -493,7 +492,7 @@ void stop_all_proxies()
// returns a port on success and -1 on failure
int start_proxy(int proxy_type)
{
using namespace libtorrent;
using namespace lt;
std::map<int, proxy_t> :: iterator i = running_proxies.begin();
for (; i != running_proxies.end(); ++i)
@ -560,7 +559,7 @@ int start_proxy(int proxy_type)
return port;
}
using namespace libtorrent;
using namespace lt;
template <class T>
std::shared_ptr<T> clone_ptr(std::shared_ptr<T> const& ptr)
@ -573,7 +572,7 @@ std::uint8_t random_byte()
std::vector<char> generate_piece(piece_index_t const idx, int const piece_size)
{
using namespace libtorrent;
using namespace lt;
std::vector<char> ret(static_cast<std::size_t>(piece_size));
std::mt19937 rng(static_cast<std::uint32_t>(static_cast<int>(idx)));
@ -588,7 +587,7 @@ std::vector<char> generate_piece(piece_index_t const idx, int const piece_size)
lt::file_storage make_file_storage(const int file_sizes[], int num_files
, int const piece_size, std::string base_name)
{
using namespace libtorrent;
using namespace lt;
file_storage fs;
for (int i = 0; i != num_files; ++i)
{
@ -611,11 +610,11 @@ lt::file_storage make_file_storage(const int file_sizes[], int num_files
std::shared_ptr<lt::torrent_info> make_torrent(const int file_sizes[]
, int const num_files, int const piece_size)
{
using namespace libtorrent;
using namespace lt;
file_storage fs = make_file_storage(file_sizes, num_files, piece_size);
libtorrent::create_torrent ct(fs, piece_size, 0x4000
, libtorrent::create_torrent::optimize_alignment);
lt::create_torrent ct(fs, piece_size, 0x4000
, lt::create_torrent::optimize_alignment);
for (piece_index_t i(0); i < fs.end_piece(); ++i)
{
@ -674,7 +673,7 @@ std::shared_ptr<torrent_info> create_torrent(std::ostream* file
file_storage fs;
int total_size = piece_size * num_pieces;
fs.add_file(name, total_size);
libtorrent::create_torrent t(fs, piece_size);
lt::create_torrent t(fs, piece_size);
if (add_tracker)
{
t.add_tracker(invalid_tracker_url);
@ -977,7 +976,7 @@ udp::endpoint uep(char const* ip, int port)
return ret;
}
libtorrent::address addr(char const* ip)
lt::address addr(char const* ip)
{
lt::error_code ec;
auto ret = lt::address::from_string(ip, ec);
@ -985,7 +984,7 @@ libtorrent::address addr(char const* ip)
return ret;
}
libtorrent::address_v4 addr4(char const* ip)
lt::address_v4 addr4(char const* ip)
{
lt::error_code ec;
auto ret = lt::address_v4::from_string(ip, ec);
@ -994,7 +993,7 @@ libtorrent::address_v4 addr4(char const* ip)
}
#if TORRENT_USE_IPV6
libtorrent::address_v6 addr6(char const* ip)
lt::address_v6 addr6(char const* ip)
{
lt::error_code ec;
auto ret = lt::address_v6::from_string(ip, ec);

View File

@ -45,62 +45,62 @@ EXPORT int print_failures();
EXPORT unsigned char random_byte();
EXPORT int load_file(std::string const& filename, std::vector<char>& v
, libtorrent::error_code& ec, int limit = 8000000);
, lt::error_code& ec, int limit = 8000000);
EXPORT void report_failure(char const* err, char const* file, int line);
EXPORT void init_rand_address();
EXPORT libtorrent::address rand_v4();
EXPORT lt::address rand_v4();
#if TORRENT_USE_IPV6
EXPORT libtorrent::address rand_v6();
EXPORT lt::address rand_v6();
#endif
EXPORT libtorrent::tcp::endpoint rand_tcp_ep(libtorrent::address(&rand_addr)() = rand_v4);
EXPORT libtorrent::udp::endpoint rand_udp_ep(libtorrent::address(&rand_addr)() = rand_v4);
EXPORT lt::tcp::endpoint rand_tcp_ep(lt::address(&rand_addr)() = rand_v4);
EXPORT lt::udp::endpoint rand_udp_ep(lt::address(&rand_addr)() = rand_v4);
EXPORT libtorrent::sha1_hash rand_hash();
EXPORT libtorrent::sha1_hash to_hash(char const* s);
EXPORT lt::sha1_hash rand_hash();
EXPORT lt::sha1_hash to_hash(char const* s);
EXPORT std::map<std::string, std::int64_t> get_counters(libtorrent::session& s);
EXPORT std::map<std::string, std::int64_t> get_counters(lt::session& s);
EXPORT libtorrent::alert const* wait_for_alert(
libtorrent::session& ses, int type, char const* name = "", int num = 1);
EXPORT lt::alert const* wait_for_alert(
lt::session& ses, int type, char const* name = "", int num = 1);
EXPORT void print_ses_rate(float time
, libtorrent::torrent_status const* st1
, libtorrent::torrent_status const* st2
, libtorrent::torrent_status const* st3 = NULL);
, lt::torrent_status const* st1
, lt::torrent_status const* st2
, lt::torrent_status const* st3 = NULL);
EXPORT bool print_alerts(libtorrent::session& ses, char const* name
EXPORT bool print_alerts(lt::session& ses, char const* name
, bool allow_no_torrents = false
, bool allow_failed_fastresume = false
, std::function<bool(libtorrent::alert const*)> predicate
= std::function<bool(libtorrent::alert const*)>()
, std::function<bool(lt::alert const*)> predicate
= std::function<bool(lt::alert const*)>()
, bool no_output = false);
EXPORT void wait_for_listen(libtorrent::session& ses, char const* name);
EXPORT void wait_for_downloading(libtorrent::session& ses, char const* name);
EXPORT void wait_for_listen(lt::session& ses, char const* name);
EXPORT void wait_for_downloading(lt::session& ses, char const* name);
EXPORT std::vector<char> generate_piece(libtorrent::piece_index_t idx, int piece_size = 0x4000);
EXPORT libtorrent::file_storage make_file_storage(const int file_sizes[], int num_files
EXPORT std::vector<char> generate_piece(lt::piece_index_t idx, int piece_size = 0x4000);
EXPORT lt::file_storage make_file_storage(const int file_sizes[], int num_files
, int const piece_size, std::string base_name = "test_dir-");
EXPORT std::shared_ptr<libtorrent::torrent_info> make_torrent(const int file_sizes[]
EXPORT std::shared_ptr<lt::torrent_info> make_torrent(const int file_sizes[]
, int num_files, int piece_size);
EXPORT void create_random_files(std::string const& path, const int file_sizes[]
, int num_files);
EXPORT std::shared_ptr<libtorrent::torrent_info> create_torrent(std::ostream* file = 0
EXPORT std::shared_ptr<lt::torrent_info> create_torrent(std::ostream* file = 0
, char const* name = "temporary", int piece_size = 16 * 1024, int num_pieces = 13
, bool add_tracker = true, std::string ssl_certificate = "");
EXPORT std::tuple<libtorrent::torrent_handle
, libtorrent::torrent_handle
, libtorrent::torrent_handle>
setup_transfer(libtorrent::session* ses1, libtorrent::session* ses2
, libtorrent::session* ses3, bool clear_files, bool use_metadata_transfer = true
EXPORT std::tuple<lt::torrent_handle
, lt::torrent_handle
, lt::torrent_handle>
setup_transfer(lt::session* ses1, lt::session* ses2
, lt::session* ses3, bool clear_files, bool use_metadata_transfer = true
, bool connect = true, std::string suffix = "", int piece_size = 16 * 1024
, std::shared_ptr<libtorrent::torrent_info>* torrent = 0, bool super_seeding = false
, libtorrent::add_torrent_params const* p = 0, bool stop_lsd = true, bool use_ssl_ports = false
, std::shared_ptr<libtorrent::torrent_info>* torrent2 = 0);
, std::shared_ptr<lt::torrent_info>* torrent = 0, bool super_seeding = false
, lt::add_torrent_params const* p = 0, bool stop_lsd = true, bool use_ssl_ports = false
, std::shared_ptr<lt::torrent_info>* torrent2 = 0);
EXPORT int start_web_server(bool ssl = false, bool chunked = false
, bool keepalive = true);
@ -110,12 +110,12 @@ EXPORT int start_proxy(int type);
EXPORT void stop_proxy(int port);
EXPORT void stop_all_proxies();
EXPORT libtorrent::tcp::endpoint ep(char const* ip, int port);
EXPORT libtorrent::udp::endpoint uep(char const* ip, int port);
EXPORT libtorrent::address addr(char const* ip);
EXPORT libtorrent::address_v4 addr4(char const* ip);
EXPORT lt::tcp::endpoint ep(char const* ip, int port);
EXPORT lt::udp::endpoint uep(char const* ip, int port);
EXPORT lt::address addr(char const* ip);
EXPORT lt::address_v4 addr4(char const* ip);
#if TORRENT_USE_IPV6
EXPORT libtorrent::address_v6 addr6(char const* ip);
EXPORT lt::address_v6 addr6(char const* ip);
#endif
#endif

View File

@ -52,8 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
void test_swarm(int flags)
{
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
std::printf("\n\n ==== TEST SWARM === %s%s%s%s%s ===\n\n\n"
, (flags & super_seeding) ? "super-seeding ": ""

View File

@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <functional>
#include <thread>
namespace lt = libtorrent;
using namespace libtorrent;
using namespace lt;
TORRENT_TEST(limit)
{
@ -151,7 +150,7 @@ TORRENT_TEST(notify_function)
#ifndef TORRENT_DISABLE_EXTENSIONS
int plugin_alerts[3] = { 0, 0, 0 };
struct test_plugin : libtorrent::plugin
struct test_plugin : lt::plugin
{
explicit test_plugin(int index) : m_index(index) {}
void on_alert(alert const* a) override

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm>
using namespace libtorrent;
using namespace lt;
TORRENT_TEST(alerts_types)
{

View File

@ -44,8 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
void test_swarm()
{
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
// these are declared before the session objects
// so that they are destructed last. This enables
@ -136,7 +135,7 @@ void test_swarm()
TORRENT_TEST(auto_unchoke)
{
using namespace libtorrent;
using namespace lt;
// in case the previous run was t r catch (std::exception&) {}erminated
error_code ec;

View File

@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
struct torrent;
struct peer_connection;
using namespace libtorrent;
using namespace lt;
using namespace std::placeholders;
const float sample_time = 20.f; // seconds
@ -156,7 +156,7 @@ void run_test(connections_t& v
std::for_each(v.begin(), v.end()
, std::bind(&peer_connection::start, _1));
libtorrent::aux::session_settings s;
lt::aux::session_settings s;
int tick_interval = s.get_int(settings_pack::tick_interval);
for (int i = 0; i < int(sample_time * 1000 / tick_interval); ++i)

View File

@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/bdecode.hpp"
#include "libtorrent/entry.hpp"
using namespace libtorrent;
using namespace lt;
// test integer
TORRENT_TEST(integer)

View File

@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "test.hpp"
using namespace libtorrent;
using namespace lt;
// test vectors from bittorrent protocol description
// http://www.bittorrent.com/protocol.html

View File

@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/cpuid.hpp"
#include <cstdlib>
using namespace libtorrent;
using namespace lt;
void print_bitfield(bitfield const& b)
{

View File

@ -42,7 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <functional>
#include <memory>
using namespace libtorrent;
using namespace lt;
struct test_storage_impl : storage_interface
{

View File

@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/sha1_hash.hpp"
#include <cstdint>
using namespace libtorrent;
using namespace lt;
void test_set_and_get()
{

View File

@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "test.hpp"
using namespace libtorrent;
using namespace lt;
// -- test buffer --

View File

@ -60,8 +60,7 @@ enum
void test_checking(int flags = read_only_files)
{
using namespace libtorrent;
namespace lt = libtorrent;
using namespace lt;
std::printf("\n==== TEST CHECKING %s%s%s=====\n\n"
, (flags & read_only_files) ? "read-only-files ":""
@ -105,8 +104,8 @@ void test_checking(int flags = read_only_files)
, file_sizes, num_files);
add_files(fs, combine_path("tmp1_checking", "test_torrent_dir"));
libtorrent::create_torrent t(fs, piece_size, 0x4000
, libtorrent::create_torrent::optimize_alignment);
lt::create_torrent t(fs, piece_size, 0x4000
, lt::create_torrent::optimize_alignment);
// calculate the hash for all pieces
set_piece_hashes(t, "tmp1_checking", ec);

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
TORRENT_TEST(crc32)
{
using namespace libtorrent;
using namespace lt;
std::uint32_t out;

Some files were not shown because too many files have changed in this diff Show More