diff --git a/ChangeLog b/ChangeLog index 20cfd8001..6ef9f5f6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index 0c01dc895..bf2df6414 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -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 : boost::mpl::true_ {}; + struct is_polymorphic : boost::mpl::true_ {}; POLY(torrent_alert) POLY(tracker_alert) diff --git a/bindings/python/src/converters.cpp b/bindings/python/src/converters.cpp index ee6edc40c..cf6f04b60 100644 --- a/bindings/python/src/converters.cpp +++ b/bindings/python/src/converters.cpp @@ -15,7 +15,6 @@ using namespace boost::python; namespace bp = boost::python; -namespace lt = libtorrent; template 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()); } }; diff --git a/bindings/python/src/create_torrent.cpp b/bindings/python/src/create_torrent.cpp index 17a9d06c7..7358f311f 100644 --- a/bindings/python/src/create_torrent.cpp +++ b/bindings/python/src/create_torrent.cpp @@ -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()) .def(init(arg("ti"))) .def(init((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) diff --git a/bindings/python/src/datetime.cpp b/bindings/python/src/datetime.cpp index beead26cb..62f269350 100644 --- a/bindings/python/src/datetime.cpp +++ b/bindings/python/src/datetime.cpp @@ -10,7 +10,6 @@ #include using namespace boost::python; -namespace lt = libtorrent; #if BOOST_VERSION < 103400 diff --git a/bindings/python/src/entry.cpp b/bindings/python/src/entry.cpp index db3179256..e97baf0d9 100644 --- a/bindings/python/src/entry.cpp +++ b/bindings/python/src/entry.cpp @@ -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, entry_to_python>(); + to_python_converter, entry_to_python>(); to_python_converter(); entry_from_python(); } diff --git a/bindings/python/src/error_code.cpp b/bindings/python/src/error_code.cpp index 4defb501d..dbd21c212 100644 --- a/bindings/python/src/error_code.cpp +++ b/bindings/python/src/error_code.cpp @@ -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(state[0]); std::string const category = extract(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") diff --git a/bindings/python/src/fingerprint.cpp b/bindings/python/src/fingerprint.cpp index a4bcf391a..2431f6d7a 100644 --- a/bindings/python/src/fingerprint.cpp +++ b/bindings/python/src/fingerprint.cpp @@ -8,7 +8,7 @@ void bind_fingerprint() { using namespace boost::python; - using namespace libtorrent; + using namespace lt; def("generate_fingerprint", &generate_fingerprint); diff --git a/bindings/python/src/ip_filter.cpp b/bindings/python/src/ip_filter.cpp index 8fea1888b..83c2685f8 100644 --- a/bindings/python/src/ip_filter.cpp +++ b/bindings/python/src/ip_filter.cpp @@ -7,7 +7,7 @@ #include "gil.hpp" using namespace boost::python; -using namespace libtorrent; +using namespace lt; namespace { diff --git a/bindings/python/src/magnet_uri.cpp b/bindings/python/src/magnet_uri.cpp index ed99771e6..a7bab94ee 100644 --- a/bindings/python/src/magnet_uri.cpp +++ b/bindings/python/src/magnet_uri.cpp @@ -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); diff --git a/bindings/python/src/peer_info.cpp b/bindings/python/src/peer_info.cpp index f1bc9e763..cf37d4b28 100644 --- a/bindings/python/src/peer_info.cpp +++ b/bindings/python/src/peer_info.cpp @@ -8,7 +8,7 @@ #include using namespace boost::python; -using namespace libtorrent; +using namespace lt; std::int64_t get_last_active(peer_info const& pi) { diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 8a7d86583..69f29eff8 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -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 buf; diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index 96fa8d4b2..40cab5964 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -6,7 +6,7 @@ #include using namespace boost::python; -using namespace libtorrent; +using namespace lt; void bind_session_settings() { diff --git a/bindings/python/src/sha1_hash.cpp b/bindings/python/src/sha1_hash.cpp index 47f26d0b2..f81192704 100644 --- a/bindings/python/src/sha1_hash.cpp +++ b/bindings/python/src/sha1_hash.cpp @@ -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") .def(self == self) diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index aaa5dbcb3..e73b323c9 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -17,7 +17,7 @@ #include "gil.hpp" using namespace boost::python; -using namespace libtorrent; +using namespace lt; #ifdef _MSC_VER #pragma warning(push) diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index bda8077f4..c53623088 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -19,8 +19,7 @@ #endif using namespace boost::python; -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; namespace { diff --git a/bindings/python/src/torrent_status.cpp b/bindings/python/src/torrent_status.cpp index 8ef757e90..080eb4acc 100644 --- a/bindings/python/src/torrent_status.cpp +++ b/bindings/python/src/torrent_status.cpp @@ -8,7 +8,7 @@ #include using namespace boost::python; -using namespace libtorrent; +using namespace lt; object bitfield_to_list(bitfield const& bf) { diff --git a/bindings/python/src/utility.cpp b/bindings/python/src/utility.cpp index 600f4726f..7f7dd53e4 100644 --- a/bindings/python/src/utility.cpp +++ b/bindings/python/src/utility.cpp @@ -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", <::identify_client); def("client_fingerprint", &client_fingerprint_); #endif def("bdecode", &bdecode_); diff --git a/bindings/python/src/version.cpp b/bindings/python/src/version.cpp index e6234cb0e..42c377e3b 100644 --- a/bindings/python/src/version.cpp +++ b/bindings/python/src/version.cpp @@ -6,7 +6,7 @@ #include "boost_python.hpp" using namespace boost::python; -using libtorrent::version; +using lt::version; void bind_version() { diff --git a/docs/manual.rst b/docs/manual.rst index 6f7f2e19a..1b4b716ba 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -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(); } diff --git a/docs/python_binding.rst b/docs/python_binding.rst index e6539984f..8f5725d05 100644 --- a/docs/python_binding.rst +++ b/docs/python_binding.rst @@ -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 diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 57b00f3ef..ee4c1a307 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -31,7 +31,6 @@ For example: #include #include - namespace lt = libtorrent; int main(int argc, char const* argv[]) { if (argc != 2) { diff --git a/examples/bt-get.cpp b/examples/bt-get.cpp index ff3b90b1e..4827fd44a 100644 --- a/examples/bt-get.cpp +++ b/examples/bt-get.cpp @@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace lt = libtorrent; int main(int argc, char const* argv[]) { if (argc != 2) { diff --git a/examples/bt-get2.cpp b/examples/bt-get2.cpp index 527a24b8b..9e8161547 100644 --- a/examples/bt-get2.cpp +++ b/examples/bt-get2.cpp @@ -46,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace lt = libtorrent; using clk = std::chrono::steady_clock; // return the name of a torrent status enum diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 51433a10b..4323faa4a 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -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 dht_active_requests; -std::vector dht_routing_table; +std::vector dht_active_requests; +std::vector 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& 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 const& peers) +int peer_index(lt::tcp::endpoint addr, std::vector const& peers) { - using namespace libtorrent; + using namespace lt; std::vector::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 const& peers, int max_lines) + , std::vector 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 list_dir(std::string path , bool (*filter_fun)(lt::string_view) - , libtorrent::error_code& ec) + , lt::error_code& ec) { std::vector ret; #ifdef TORRENT_WINDOWS @@ -684,9 +684,9 @@ std::vector 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 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 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(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& events) + , lt::session& ses, std::deque& events) { std::vector 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 const& peers +void print_piece(lt::partial_piece_info const* pp + , lt::cached_piece_info const* cs + , std::vector 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) { diff --git a/examples/connection_tester.cpp b/examples/connection_tester.cpp index cfce0ef7a..469a1bf0e 100644 --- a/examples/connection_tester.cpp +++ b/examples/connection_tester.cpp @@ -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& 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); diff --git a/examples/dump_torrent.cpp b/examples/dump_torrent.cpp index fdb2b6209..d8a6fec84 100644 --- a/examples/dump_torrent.cpp +++ b/examples/dump_torrent.cpp @@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/magnet_uri.hpp" int load_file(std::string const& filename, std::vector& 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& v int main(int argc, char* argv[]) { - using namespace libtorrent; + using namespace lt; if (argc < 2 || argc > 4) { diff --git a/examples/make_torrent.cpp b/examples/make_torrent.cpp index c0aec0b4f..1bbcf5b19 100644 --- a/examples/make_torrent.cpp +++ b/examples/make_torrent.cpp @@ -48,7 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for _getcwd #endif -using namespace libtorrent; +using namespace lt; using namespace std::placeholders; std::vector 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; diff --git a/examples/print.cpp b/examples/print.cpp index a37ac9764..7b2bfb71b 100644 --- a/examples/print.cpp +++ b/examples/print.cpp @@ -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; diff --git a/examples/print.hpp b/examples/print.hpp index 0d322d0e7..a2104a7e6 100644 --- a/examples/print.hpp +++ b/examples/print.hpp @@ -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); diff --git a/examples/session_view.cpp b/examples/session_view.cpp index 6586a6649..aebcab500 100644 --- a/examples/session_view.cpp +++ b/examples/session_view.cpp @@ -37,13 +37,11 @@ POSSIBILITY OF SUCH DAMAGE. #include // 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; diff --git a/examples/simple_client.cpp b/examples/simple_client.cpp index 5a157150a..d182365b1 100644 --- a/examples/simple_client.cpp +++ b/examples/simple_client.cpp @@ -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) { diff --git a/examples/stats_counters.cpp b/examples/stats_counters.cpp index 509d7db2e..4b570d334 100644 --- a/examples/stats_counters.cpp +++ b/examples/stats_counters.cpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for snprintf #include // for PRId64 et.al. -using namespace libtorrent; +using namespace lt; int main() { diff --git a/examples/torrent_view.hpp b/examples/torrent_view.hpp index 32771988c..14a60242e 100644 --- a/examples/torrent_view.hpp +++ b/examples/torrent_view.hpp @@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/fwd.hpp" #include "libtorrent/torrent_status.hpp" -namespace lt = libtorrent; struct torrent_view { diff --git a/examples/upnp_test.cpp b/examples/upnp_test.cpp index 450aeaa6b..0f6a1681a 100644 --- a/examples/upnp_test.cpp +++ b/examples/upnp_test.cpp @@ -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(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) { diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 9625d5049..bd459ea73 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -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 diff --git a/include/libtorrent/version.hpp b/include/libtorrent/version.hpp index f63e91974..3def1fb5e 100644 --- a/include/libtorrent/version.hpp +++ b/include/libtorrent/version.hpp @@ -54,4 +54,6 @@ namespace libtorrent { } +namespace lt = libtorrent; + #endif diff --git a/simulation/create_torrent.cpp b/simulation/create_torrent.cpp index 2dce61fc5..0c1f37cb6 100644 --- a/simulation/create_torrent.cpp +++ b/simulation/create_torrent.cpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/path.hpp" #include -namespace lt = libtorrent; std::string save_path(int idx) { diff --git a/simulation/create_torrent.hpp b/simulation/create_torrent.hpp index e8785f0db..f3c289d3a 100644 --- a/simulation/create_torrent.hpp +++ b/simulation/create_torrent.hpp @@ -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 diff --git a/simulation/fake_peer.hpp b/simulation/fake_peer.hpp index e3c6206cb..9470a4d7c 100644 --- a/simulation/fake_peer.hpp +++ b/simulation/fake_peer.hpp @@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE. using namespace sim; -namespace lt = libtorrent; struct fake_peer { diff --git a/simulation/libsimulator b/simulation/libsimulator index c1537196d..60d786b8f 160000 --- a/simulation/libsimulator +++ b/simulation/libsimulator @@ -1 +1 @@ -Subproject commit c1537196d68a6950e00995d5594dcbce4485effd +Subproject commit 60d786b8fa6ddaacdc98bdf691220660bc194494 diff --git a/simulation/make_proxy_settings.hpp b/simulation/make_proxy_settings.hpp index bb71f8726..57c79ec8e 100644 --- a/simulation/make_proxy_settings.hpp +++ b/simulation/make_proxy_settings.hpp @@ -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); diff --git a/simulation/setup_dht.cpp b/simulation/setup_dht.cpp index 5c74a74ec..0bf8f61ee 100644 --- a/simulation/setup_dht.cpp +++ b/simulation/setup_dht.cpp @@ -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)) diff --git a/simulation/setup_dht.hpp b/simulation/setup_dht.hpp index 92adfa045..903af8d92 100644 --- a/simulation/setup_dht.hpp +++ b/simulation/setup_dht.hpp @@ -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 { diff --git a/simulation/setup_swarm.cpp b/simulation/setup_swarm.cpp index fa36185c1..47a64ac71 100644 --- a/simulation/setup_swarm.cpp +++ b/simulation/setup_swarm.cpp @@ -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(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); diff --git a/simulation/setup_swarm.hpp b/simulation/setup_swarm.hpp index a3da0046e..495b0bb5e 100644 --- a/simulation/setup_swarm.hpp +++ b/simulation/setup_swarm.hpp @@ -47,7 +47,6 @@ namespace libtorrent struct torrent_status; } -namespace lt = libtorrent; enum class swarm_test { download, upload }; diff --git a/simulation/test_auto_manage.cpp b/simulation/test_auto_manage.cpp index 035ab615b..2ec906ffb 100644 --- a/simulation/test_auto_manage.cpp +++ b/simulation/test_auto_manage.cpp @@ -43,10 +43,9 @@ POSSIBILITY OF SUCH DAMAGE. #include using namespace sim; -using namespace libtorrent; +using namespace lt; const int num_torrents = 10; -namespace lt = libtorrent; using sim::asio::ip::address_v4; diff --git a/simulation/test_dht.cpp b/simulation/test_dht.cpp index 20a0b57df..2d4eca859 100644 --- a/simulation/test_dht.cpp +++ b/simulation/test_dht.cpp @@ -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 networks, lt::session& ses) diff --git a/simulation/test_dht_bootstrap.cpp b/simulation/test_dht_bootstrap.cpp index 6b0e80a56..de650fa8f 100644 --- a/simulation/test_dht_bootstrap.cpp +++ b/simulation/test_dht_bootstrap.cpp @@ -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 diff --git a/simulation/test_dht_rate_limit.cpp b/simulation/test_dht_rate_limit.cpp index 4c352eb6b..2b5f99a36 100644 --- a/simulation/test_dht_rate_limit.cpp +++ b/simulation/test_dht_rate_limit.cpp @@ -48,8 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; using namespace sim; using namespace std::placeholders; diff --git a/simulation/test_dht_storage.cpp b/simulation/test_dht_storage.cpp index 6e91ffd0c..bb3e203da 100644 --- a/simulation/test_dht_storage.cpp +++ b/simulation/test_dht_storage.cpp @@ -47,8 +47,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -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(); diff --git a/simulation/test_error_handling.cpp b/simulation/test_error_handling.cpp index 226c78928..6c500f18b 100644 --- a/simulation/test_error_handling.cpp +++ b/simulation/test_error_handling.cpp @@ -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 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 ses[2]) {} diff --git a/simulation/test_fast_extensions.cpp b/simulation/test_fast_extensions.cpp index efcf2f079..9fe23e86c 100644 --- a/simulation/test_fast_extensions.cpp +++ b/simulation/test_fast_extensions.cpp @@ -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 void run_fake_peer_test( diff --git a/simulation/test_file_pool.cpp b/simulation/test_file_pool.cpp index aff3c67c1..7aec5386f 100644 --- a/simulation/test_file_pool.cpp +++ b/simulation/test_file_pool.cpp @@ -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 diff --git a/simulation/test_http_connection.cpp b/simulation/test_http_connection.cpp index 85525c21e..364486a2a 100644 --- a/simulation/test_http_connection.cpp +++ b/simulation/test_http_connection.cpp @@ -50,9 +50,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #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; diff --git a/simulation/test_ip_filter.cpp b/simulation/test_ip_filter.cpp index d20cf681f..c73d3bfb5 100644 --- a/simulation/test_ip_filter.cpp +++ b/simulation/test_ip_filter.cpp @@ -46,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE. using namespace sim; -namespace lt = libtorrent; template void run_test(Setup const& setup diff --git a/simulation/test_metadata_extension.cpp b/simulation/test_metadata_extension.cpp index ccffe5b2f..987f854b6 100644 --- a/simulation/test_metadata_extension.cpp +++ b/simulation/test_metadata_extension.cpp @@ -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 { diff --git a/simulation/test_optimistic_unchoke.cpp b/simulation/test_optimistic_unchoke.cpp index 1d1956e6c..97d868674 100644 --- a/simulation/test_optimistic_unchoke.cpp +++ b/simulation/test_optimistic_unchoke.cpp @@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -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; diff --git a/simulation/test_pause.cpp b/simulation/test_pause.cpp index 37dc65071..955d4637e 100644 --- a/simulation/test_pause.cpp +++ b/simulation/test_pause.cpp @@ -44,9 +44,8 @@ POSSIBILITY OF SUCH DAMAGE. #include using namespace sim; -using namespace libtorrent; +using namespace lt; -namespace lt = libtorrent; using sim::asio::ip::address_v4; diff --git a/simulation/test_pe_crypto.cpp b/simulation/test_pe_crypto.cpp index 9528cfc8e..495955dba 100644 --- a/simulation/test_pe_crypto.cpp +++ b/simulation/test_pe_crypto.cpp @@ -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)) diff --git a/simulation/test_save_resume.cpp b/simulation/test_save_resume.cpp index 026a3c4c7..b6fdcfcdc 100644 --- a/simulation/test_save_resume.cpp +++ b/simulation/test_save_resume.cpp @@ -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) { diff --git a/simulation/test_session.cpp b/simulation/test_session.cpp index 7c889687c..4ab478f6b 100644 --- a/simulation/test_session.cpp +++ b/simulation/test_session.cpp @@ -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) { diff --git a/simulation/test_socks5.cpp b/simulation/test_socks5.cpp index 94c6a1bf4..a80c332a6 100644 --- a/simulation/test_socks5.cpp +++ b/simulation/test_socks5.cpp @@ -48,9 +48,8 @@ POSSIBILITY OF SUCH DAMAGE. #include 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 ret; TEST_CHECK(size >= 16); diff --git a/simulation/test_super_seeding.cpp b/simulation/test_super_seeding.cpp index 4cf1f4394..b7c3f1420 100644 --- a/simulation/test_super_seeding.cpp +++ b/simulation/test_super_seeding.cpp @@ -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) { diff --git a/simulation/test_swarm.cpp b/simulation/test_swarm.cpp index 9637dfafd..3d287caf3 100644 --- a/simulation/test_swarm.cpp +++ b/simulation/test_swarm.cpp @@ -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) { diff --git a/simulation/test_thread_pool.cpp b/simulation/test_thread_pool.cpp index b93712ff4..b90d32693 100644 --- a/simulation/test_thread_pool.cpp +++ b/simulation/test_thread_pool.cpp @@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/disk_io_thread_pool.hpp" #include -namespace lt = libtorrent; struct test_threads : lt::pool_thread_interface { diff --git a/simulation/test_torrent_status.cpp b/simulation/test_torrent_status.cpp index 2448166e1..2510d33a1 100644 --- a/simulation/test_torrent_status.cpp +++ b/simulation/test_torrent_status.cpp @@ -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() { diff --git a/simulation/test_tracker.cpp b/simulation/test_tracker.cpp index 9e94bf5d8..47120d2f2 100644 --- a/simulation/test_tracker.cpp +++ b/simulation/test_tracker.cpp @@ -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; diff --git a/simulation/test_transfer.cpp b/simulation/test_transfer.cpp index 3ac53ec2e..246199a22 100644 --- a/simulation/test_transfer.cpp +++ b/simulation/test_transfer.cpp @@ -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*) {}, diff --git a/simulation/test_utp.cpp b/simulation/test_utp.cpp index eb79c7371..0247e4899 100644 --- a/simulation/test_utp.cpp +++ b/simulation/test_utp.cpp @@ -41,8 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; TORRENT_TEST(utp) { diff --git a/simulation/test_web_seed.cpp b/simulation/test_web_seed.cpp index 8867f9bcf..e6cf8d3ee 100644 --- a/simulation/test_web_seed.cpp +++ b/simulation/test_web_seed.cpp @@ -49,15 +49,14 @@ POSSIBILITY OF SUCH DAMAGE. #include 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); diff --git a/simulation/utils.cpp b/simulation/utils.cpp index d838c8814..2b8563fe5 100644 --- a/simulation/utils.cpp +++ b/simulation/utils.cpp @@ -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) { diff --git a/simulation/utils.hpp b/simulation/utils.hpp index d42c212b1..0128483ef 100644 --- a/simulation/utils.hpp +++ b/simulation/utils.hpp @@ -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); diff --git a/test/bittorrent_peer.cpp b/test/bittorrent_peer.cpp index d5f3e33fa..a8d6cac02 100644 --- a/test/bittorrent_peer.cpp +++ b/test/bittorrent_peer.cpp @@ -44,7 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -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(libtorrent::random(static_cast(pieces.size()))), piece); + else pieces.insert(pieces.begin() + static_cast(lt::random(static_cast(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); diff --git a/test/bittorrent_peer.hpp b/test/bittorrent_peer.hpp index bc4e1d374..793819576 100644 --- a/test/bittorrent_peer.hpp +++ b/test/bittorrent_peer.hpp @@ -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 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 write_buf_proto; std::array write_buffer; std::array 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; }; diff --git a/test/dht_server.cpp b/test/dht_server.cpp index 0becb5c0e..ec4166b55 100644 --- a/test/dht_server.cpp +++ b/test/dht_server.cpp @@ -49,13 +49,13 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -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 m_dht_requests; udp::socket m_socket; int m_port; diff --git a/test/enum_if.cpp b/test/enum_if.cpp index 9b5c3cfc2..855c25c8e 100644 --- a/test/enum_if.cpp +++ b/test/enum_if.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; +using namespace lt; int main() { diff --git a/test/main.cpp b/test/main.cpp index f30817d47..45d9e8048 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -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) { diff --git a/test/make_torrent.cpp b/test/make_torrent.cpp index 5bc1bb2bb..30aedc78e 100644 --- a/test/make_torrent.cpp +++ b/test/make_torrent.cpp @@ -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 make_test_torrent( +std::shared_ptr make_test_torrent( torrent_args const& args) { entry e; @@ -165,7 +165,7 @@ std::shared_ptr make_test_torrent( return std::make_shared(&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; diff --git a/test/make_torrent.hpp b/test/make_torrent.hpp index 3dadf28eb..85111abeb 100644 --- a/test/make_torrent.hpp +++ b/test/make_torrent.hpp @@ -59,9 +59,9 @@ struct torrent_args std::string m_http_seed; }; -EXPORT std::shared_ptr +EXPORT std::shared_ptr 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 diff --git a/test/peer_server.cpp b/test/peer_server.cpp index 1ac07533f..0f8a6f0e1 100644 --- a/test/peer_server.cpp +++ b/test/peer_server.cpp @@ -47,12 +47,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -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 m_peer_requests{0}; tcp::acceptor m_acceptor{m_ios}; int m_port = 0; diff --git a/test/print_alerts.cpp b/test/print_alerts.cpp index fc01bc245..34973edb1 100644 --- a/test/print_alerts.cpp +++ b/test/print_alerts.cpp @@ -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; diff --git a/test/print_alerts.hpp b/test/print_alerts.hpp index e5ecff382..5bbd4284d 100644 --- a/test/print_alerts.hpp +++ b/test/print_alerts.hpp @@ -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 diff --git a/test/settings.cpp b/test/settings.cpp index 614c732fd..ab08feba8 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -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 diff --git a/test/settings.hpp b/test/settings.hpp index 4390f60ea..fae29b8b7 100644 --- a/test/settings.hpp +++ b/test/settings.hpp @@ -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(); diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 1298be3e1..5ef45cd53 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -67,8 +67,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; #if defined TORRENT_WINDOWS #include @@ -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 get_counters(libtorrent::session& s) +std::map get_counters(lt::session& s) { - using namespace libtorrent; + using namespace lt; s.post_session_stats(); std::map 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& 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& v bool print_alerts(lt::session& ses, char const* name , bool allow_no_torrents, bool allow_failed_fastresume - , std::function predicate, bool no_output) + , std::function predicate, bool no_output) { bool ret = false; std::vector 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(al) || alert_cast(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(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 :: 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 std::shared_ptr clone_ptr(std::shared_ptr const& ptr) @@ -573,7 +572,7 @@ std::uint8_t random_byte() std::vector generate_piece(piece_index_t const idx, int const piece_size) { - using namespace libtorrent; + using namespace lt; std::vector ret(static_cast(piece_size)); std::mt19937 rng(static_cast(static_cast(idx))); @@ -588,7 +587,7 @@ std::vector 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 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 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); diff --git a/test/setup_transfer.hpp b/test/setup_transfer.hpp index 903552ca5..070366079 100644 --- a/test/setup_transfer.hpp +++ b/test/setup_transfer.hpp @@ -45,62 +45,62 @@ EXPORT int print_failures(); EXPORT unsigned char random_byte(); EXPORT int load_file(std::string const& filename, std::vector& 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 get_counters(libtorrent::session& s); +EXPORT std::map 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 predicate - = std::function() + , std::function predicate + = std::function() , 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 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 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 make_torrent(const int file_sizes[] +EXPORT std::shared_ptr 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 create_torrent(std::ostream* file = 0 +EXPORT std::shared_ptr 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 -setup_transfer(libtorrent::session* ses1, libtorrent::session* ses2 - , libtorrent::session* ses3, bool clear_files, bool use_metadata_transfer = true +EXPORT std::tuple +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* 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* torrent2 = 0); + , std::shared_ptr* 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* 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 diff --git a/test/swarm_suite.cpp b/test/swarm_suite.cpp index 386d323df..6d6e5f73b 100644 --- a/test/swarm_suite.cpp +++ b/test/swarm_suite.cpp @@ -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 ": "" diff --git a/test/test_alert_manager.cpp b/test/test_alert_manager.cpp index 797fcd9c3..fc070a20d 100644 --- a/test/test_alert_manager.cpp +++ b/test/test_alert_manager.cpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -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 diff --git a/test/test_alert_types.cpp b/test/test_alert_types.cpp index a23f3da42..9c3438a89 100644 --- a/test/test_alert_types.cpp +++ b/test/test_alert_types.cpp @@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; +using namespace lt; TORRENT_TEST(alerts_types) { diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp index 799084cf2..cfe338066 100644 --- a/test/test_auto_unchoke.cpp +++ b/test/test_auto_unchoke.cpp @@ -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; diff --git a/test/test_bandwidth_limiter.cpp b/test/test_bandwidth_limiter.cpp index efa882e71..3a6321fb0 100644 --- a/test/test_bandwidth_limiter.cpp +++ b/test/test_bandwidth_limiter.cpp @@ -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) diff --git a/test/test_bdecode.cpp b/test/test_bdecode.cpp index 4ff13df0d..54ee5a8ac 100644 --- a/test/test_bdecode.cpp +++ b/test/test_bdecode.cpp @@ -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) diff --git a/test/test_bencoding.cpp b/test/test_bencoding.cpp index 6286f92a8..1ef5edf13 100644 --- a/test/test_bencoding.cpp +++ b/test/test_bencoding.cpp @@ -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 diff --git a/test/test_bitfield.cpp b/test/test_bitfield.cpp index a90c1ebac..987cb1218 100644 --- a/test/test_bitfield.cpp +++ b/test/test_bitfield.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/cpuid.hpp" #include -using namespace libtorrent; +using namespace lt; void print_bitfield(bitfield const& b) { diff --git a/test/test_block_cache.cpp b/test/test_block_cache.cpp index 7dcc7dfbb..979bb643a 100644 --- a/test/test_block_cache.cpp +++ b/test/test_block_cache.cpp @@ -42,7 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; +using namespace lt; struct test_storage_impl : storage_interface { diff --git a/test/test_bloom_filter.cpp b/test/test_bloom_filter.cpp index 195cd0be7..b034b9716 100644 --- a/test/test_bloom_filter.cpp +++ b/test/test_bloom_filter.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/sha1_hash.hpp" #include -using namespace libtorrent; +using namespace lt; void test_set_and_get() { diff --git a/test/test_buffer.cpp b/test/test_buffer.cpp index e53261f38..f6c8e9fa6 100644 --- a/test/test_buffer.cpp +++ b/test/test_buffer.cpp @@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" -using namespace libtorrent; +using namespace lt; // -- test buffer -- diff --git a/test/test_checking.cpp b/test/test_checking.cpp index a5a73dd05..84d632ac7 100644 --- a/test/test_checking.cpp +++ b/test/test_checking.cpp @@ -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); diff --git a/test/test_crc32.cpp b/test/test_crc32.cpp index 3ef3115ea..3f0c58871 100644 --- a/test/test_crc32.cpp +++ b/test/test_crc32.cpp @@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. TORRENT_TEST(crc32) { - using namespace libtorrent; + using namespace lt; std::uint32_t out; diff --git a/test/test_create_torrent.cpp b/test/test_create_torrent.cpp index 999db92c8..c402a2216 100644 --- a/test/test_create_torrent.cpp +++ b/test/test_create_torrent.cpp @@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE. #include -namespace lt = libtorrent; // make sure creating a torrent from an existing handle preserves the // info-dictionary verbatim, so as to not alter the info-hash diff --git a/test/test_dht.cpp b/test/test_dht.cpp index 0062f71fb..3a5880a37 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -64,8 +64,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" -using namespace libtorrent; -using namespace libtorrent::dht; +using namespace lt; +using namespace lt::dht; using namespace std::placeholders; namespace { @@ -179,7 +179,7 @@ entry write_peers(std::set const& peers) { std::string endpoint(18, '\0'); std::string::iterator out = endpoint.begin(); - libtorrent::detail::write_endpoint(p, out); + lt::detail::write_endpoint(p, out); endpoint.resize(out - endpoint.begin()); pe.push_back(entry(endpoint)); } diff --git a/test/test_dht_storage.cpp b/test/test_dht_storage.cpp index 688067602..7607a46d1 100644 --- a/test/test_dht_storage.cpp +++ b/test/test_dht_storage.cpp @@ -53,9 +53,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" -using namespace libtorrent; -using namespace libtorrent::dht; -namespace lt = libtorrent; +using namespace lt; +using namespace lt::dht; namespace { diff --git a/test/test_direct_dht.cpp b/test/test_direct_dht.cpp index 6f0f410e9..d13c9cfec 100644 --- a/test/test_direct_dht.cpp +++ b/test/test_direct_dht.cpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alert_types.hpp" #include "libtorrent/bdecode.hpp" -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; namespace { diff --git a/test/test_dos_blocker.cpp b/test/test_dos_blocker.cpp index 050b07ee2..f0fb17be1 100644 --- a/test/test_dos_blocker.cpp +++ b/test/test_dos_blocker.cpp @@ -40,10 +40,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_io.hpp" // for print_endpoint #include -using namespace libtorrent; +using namespace lt; #ifndef TORRENT_DISABLE_LOGGING -struct log_t : libtorrent::dht::dht_logger +struct log_t : lt::dht::dht_logger { bool should_log(module_t) const override { return true; } @@ -59,8 +59,8 @@ struct log_t : libtorrent::dht::dht_logger void log_packet(message_direction_t dir, span pkt , udp::endpoint const& node) override { - libtorrent::bdecode_node print; - libtorrent::error_code ec; + lt::bdecode_node print; + lt::error_code ec; int ret = bdecode(pkt.data(), pkt.data() + int(pkt.size()), print, ec, nullptr, 100, 100); TEST_EQUAL(ret, 0); @@ -78,7 +78,7 @@ TORRENT_TEST(dos_blocker) { #ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_DHT - using namespace libtorrent::dht; + using namespace lt::dht; log_t l; dos_blocker b; diff --git a/test/test_ed25519.cpp b/test/test_ed25519.cpp index 971e51304..026f1ed0a 100644 --- a/test/test_ed25519.cpp +++ b/test/test_ed25519.cpp @@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/ed25519.hpp" #include "libtorrent/hex.hpp" -using namespace libtorrent; -using namespace libtorrent::dht; +using namespace lt; +using namespace lt::dht; namespace { diff --git a/test/test_enum_net.cpp b/test/test_enum_net.cpp index 06a78b259..f291c4e37 100644 --- a/test/test_enum_net.cpp +++ b/test/test_enum_net.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" #include "libtorrent/error_code.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(is_local) { diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index a6547028e..4e4f62a7f 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -51,9 +51,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include // for vsnprintf -using namespace libtorrent; +using namespace lt; using namespace std::placeholders; -namespace lt = libtorrent; void log(char const* fmt, ...) { @@ -75,7 +74,7 @@ void print_session_log(lt::session& ses) int read_message(tcp::socket& s, char* buffer, int max_size) { - using namespace libtorrent::detail; + using namespace lt::detail; error_code ec; boost::asio::read(s, boost::asio::buffer(buffer, 4) , boost::asio::transfer_all(), ec); @@ -155,7 +154,7 @@ void print_message(char const* buffer, int len) void send_allow_fast(tcp::socket& s, int piece) { log("==> allow fast: %d", piece); - using namespace libtorrent::detail; + using namespace lt::detail; char msg[] = "\0\0\0\x05\x11\0\0\0\0"; char* ptr = msg + 5; write_int32(piece, ptr); @@ -168,7 +167,7 @@ void send_allow_fast(tcp::socket& s, int piece) void send_suggest_piece(tcp::socket& s, int piece) { log("==> suggest piece: %d", piece); - using namespace libtorrent::detail; + using namespace lt::detail; char msg[] = "\0\0\0\x05\x0d\0\0\0\0"; char* ptr = msg + 5; write_int32(piece, ptr); @@ -220,7 +219,7 @@ void send_have_none(tcp::socket& s) void send_bitfield(tcp::socket& s, char const* bits) { - using namespace libtorrent::detail; + using namespace lt::detail; int num_pieces = int(strlen(bits)); int packet_size = (num_pieces+7)/8 + 5; @@ -304,7 +303,7 @@ void send_extension_handshake(tcp::socket& s, entry const& e) bencode(std::back_inserter(buf), e); - using namespace libtorrent::detail; + using namespace lt::detail; char* ptr = &buf[0]; write_uint32(int(buf.size()) - 4, ptr); @@ -319,7 +318,7 @@ void send_extension_handshake(tcp::socket& s, entry const& e) void send_request(tcp::socket& s, peer_request req) { - using namespace libtorrent::detail; + using namespace lt::detail; log("==> request %d (%d,%d)", static_cast(req.piece), req.start, req.length); char msg[] = "\0\0\0\x0d\x06 "; // have_none @@ -370,7 +369,7 @@ void send_ut_metadata_msg(tcp::socket& s, int ut_metadata_msg, int type, int pie e["piece"] = piece; bencode(std::back_inserter(buf), e); - using namespace libtorrent::detail; + using namespace lt::detail; char* ptr = &buf[0]; write_uint32(int(buf.size()) - 4, ptr); @@ -506,7 +505,7 @@ TORRENT_TEST(reject_fast) int msg = recv_buffer[0]; if (msg != 0x6) continue; - using namespace libtorrent::detail; + using namespace lt::detail; char* ptr = recv_buffer + 1; int piece = read_int32(ptr); @@ -623,7 +622,7 @@ TORRENT_TEST(reject_suggest) fail_counter--; if (msg != 0x6) continue; - using namespace libtorrent::detail; + using namespace lt::detail; char* ptr = recv_buffer + 1; int const piece = read_int32(ptr); @@ -701,7 +700,7 @@ TORRENT_TEST(suggest_order) // we're just interested in requests if (msg != 0x6) continue; - using namespace libtorrent::detail; + using namespace lt::detail; char* ptr = recv_buffer + 1; int const piece = read_int32(ptr); @@ -787,7 +786,7 @@ TORRENT_TEST(multiple_have_all) // makes sure that pieces that are lost are not requested TORRENT_TEST(dont_have) { - using namespace libtorrent::detail; + using namespace lt::detail; std::cout << "\n === test dont_have ===\n" << std::endl; @@ -890,7 +889,7 @@ TORRENT_TEST(dont_have) // pos TORRENT_TEST(invalid_metadata_request) { - using namespace libtorrent::detail; + using namespace lt::detail; std::cout << "\n === test invalid metadata ===\n" << std::endl; diff --git a/test/test_fence.cpp b/test/test_fence.cpp index e78f085af..3476f3b22 100644 --- a/test/test_fence.cpp +++ b/test/test_fence.cpp @@ -37,9 +37,9 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; +using namespace lt; -using libtorrent::aux::disk_job_fence; +using lt::aux::disk_job_fence; TORRENT_TEST(empty_fence) { diff --git a/test/test_ffs.cpp b/test/test_ffs.cpp index bf0d85489..9eeb9a279 100644 --- a/test/test_ffs.cpp +++ b/test/test_ffs.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/ffs.hpp" #include "libtorrent/aux_/byteswap.hpp" -using namespace libtorrent; +using namespace lt; static void to_binary(char const* s, std::uint32_t* buf) { diff --git a/test/test_file.cpp b/test/test_file.cpp index ff721b213..4ac5051cf 100644 --- a/test/test_file.cpp +++ b/test/test_file.cpp @@ -39,12 +39,11 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace lt = libtorrent; -using namespace libtorrent; +using namespace lt; int touch_file(std::string const& filename, int size) { - using namespace libtorrent; + using namespace lt; std::vector v; v.resize(size); diff --git a/test/test_file_progress.cpp b/test/test_file_progress.cpp index 224b6e7d9..c24739086 100644 --- a/test/test_file_progress.cpp +++ b/test/test_file_progress.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/file_storage.hpp" #include "libtorrent/piece_picker.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(init) { diff --git a/test/test_file_storage.cpp b/test/test_file_storage.cpp index 3da4000d3..9aca89e92 100644 --- a/test/test_file_storage.cpp +++ b/test/test_file_storage.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/file_storage.hpp" #include "libtorrent/aux_/path.hpp" -using namespace libtorrent; +using namespace lt; void setup_test_storage(file_storage& st) { diff --git a/test/test_gzip.cpp b/test/test_gzip.cpp index a38353304..291dc5407 100644 --- a/test/test_gzip.cpp +++ b/test/test_gzip.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" // for load_file #include "libtorrent/aux_/path.hpp" // for combine_path -using namespace libtorrent; +using namespace lt; TORRENT_TEST(zeroes) { diff --git a/test/test_hasher.cpp b/test/test_hasher.cpp index 744043b76..55997d7e2 100644 --- a/test/test_hasher.cpp +++ b/test/test_hasher.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" -using namespace libtorrent; +using namespace lt; namespace { diff --git a/test/test_hasher512.cpp b/test/test_hasher512.cpp index d0b82801a..6bbe820e3 100644 --- a/test/test_hasher512.cpp +++ b/test/test_hasher512.cpp @@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" -using namespace libtorrent; +using namespace lt; namespace { diff --git a/test/test_heterogeneous_queue.cpp b/test/test_heterogeneous_queue.cpp index e6f001550..2b28602a6 100644 --- a/test/test_heterogeneous_queue.cpp +++ b/test/test_heterogeneous_queue.cpp @@ -147,7 +147,7 @@ struct G : A // and retrieval of their pointers TORRENT_TEST(emplace_back) { - using namespace libtorrent; + using namespace lt; heterogeneous_queue q; q.emplace_back(0, 1); @@ -195,7 +195,7 @@ TORRENT_TEST(emplace_back) TORRENT_TEST(emplace_back_over_aligned) { - using namespace libtorrent; + using namespace lt; heterogeneous_queue q; q.emplace_back(1, 2); @@ -221,7 +221,7 @@ TORRENT_TEST(emplace_back_over_aligned) // test swap TORRENT_TEST(swap) { - using namespace libtorrent; + using namespace lt; heterogeneous_queue q1; heterogeneous_queue q2; @@ -270,7 +270,7 @@ TORRENT_TEST(swap) // test destruction TORRENT_TEST(destruction) { - using namespace libtorrent; + using namespace lt; heterogeneous_queue q; TEST_EQUAL(D::instances, 0); @@ -292,7 +292,7 @@ TORRENT_TEST(destruction) // test copy/move TORRENT_TEST(copy_move) { - using namespace libtorrent; + using namespace lt; heterogeneous_queue q; @@ -318,7 +318,7 @@ TORRENT_TEST(copy_move) TORRENT_TEST(nontrivial) { - using namespace libtorrent; + using namespace lt; heterogeneous_queue q; for (int i = 0; i < 10000; ++i) diff --git a/test/test_http_connection.cpp b/test/test_http_connection.cpp index 97dddbca8..4d89de8c1 100644 --- a/test/test_http_connection.cpp +++ b/test/test_http_connection.cpp @@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; +using namespace lt; io_service ios; resolver res(ios); diff --git a/test/test_http_parser.cpp b/test/test_http_parser.cpp index 8e260b4e1..37b5d0424 100644 --- a/test/test_http_parser.cpp +++ b/test/test_http_parser.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; +using namespace lt; // TODO: 3 use span here instead of zero-terminated string std::tuple feed_bytes(http_parser& parser, char const* str) diff --git a/test/test_identify_client.cpp b/test/test_identify_client.cpp index 2683fca04..ccc269c35 100644 --- a/test/test_identify_client.cpp +++ b/test/test_identify_client.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/identify_client.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(identify_client) { diff --git a/test/test_ip_filter.cpp b/test/test_ip_filter.cpp index 681a30ce9..c80307e4d 100644 --- a/test/test_ip_filter.cpp +++ b/test/test_ip_filter.cpp @@ -49,7 +49,7 @@ also works for IPv6. */ -using namespace libtorrent; +using namespace lt; template bool compare(ip_range const& lhs @@ -90,7 +90,7 @@ void test_rules_invariant(std::vector> const& r, ip_filter const& f) TORRENT_TEST(session_get_ip_filter) { - using namespace libtorrent; + using namespace lt; session ses(settings()); ip_filter const& ipf = ses.get_ip_filter(); #if TORRENT_USE_IPV6 @@ -102,7 +102,7 @@ TORRENT_TEST(session_get_ip_filter) TORRENT_TEST(ip_filter) { - using namespace libtorrent; + using namespace lt; std::vector> range; error_code ec; diff --git a/test/test_ip_voter.cpp b/test/test_ip_voter.cpp index 92d2ad7d7..93aba3c0e 100644 --- a/test/test_ip_voter.cpp +++ b/test/test_ip_voter.cpp @@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/broadcast_socket.hpp" // for supports_ipv6() #include "setup_transfer.hpp" // for rand_v4 -using namespace libtorrent; +using namespace lt; bool cast_vote(ip_voter& ipv, address ext_ip, address voter) { diff --git a/test/test_linked_list.cpp b/test/test_linked_list.cpp index 0e182da06..2b94fd2ea 100644 --- a/test/test_linked_list.cpp +++ b/test/test_linked_list.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/linked_list.hpp" -using namespace libtorrent; +using namespace lt; struct test_node : list_node { diff --git a/test/test_listen_socket.cpp b/test/test_listen_socket.cpp index c6d68317a..82ca8680f 100644 --- a/test/test_listen_socket.cpp +++ b/test/test_listen_socket.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/aux_/session_impl.hpp" -using namespace libtorrent; +using namespace lt; namespace { diff --git a/test/test_lsd.cpp b/test/test_lsd.cpp index 1ecb59d8f..ddca0f2be 100644 --- a/test/test_lsd.cpp +++ b/test/test_lsd.cpp @@ -43,8 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. void test_lsd() { - using namespace libtorrent; - namespace lt = libtorrent; + using namespace lt; // these are declared before the session objects // so that they are destructed last. This enables @@ -97,7 +96,7 @@ void test_lsd() TORRENT_TEST(lsd) { - using namespace libtorrent; + using namespace lt; // in case the previous run was terminated error_code ec; diff --git a/test/test_magnet.cpp b/test/test_magnet.cpp index c4bf69191..f4494a0b2 100644 --- a/test/test_magnet.cpp +++ b/test/test_magnet.cpp @@ -41,8 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hex.hpp" // to_hex #include "settings.hpp" -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; #ifndef TORRENT_NO_DEPRECATE void test_remove_url(std::string url) diff --git a/test/test_merkle.cpp b/test/test_merkle.cpp index 1b0d7e074..1b635ed52 100644 --- a/test/test_merkle.cpp +++ b/test/test_merkle.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. TORRENT_TEST(merkle) { - using namespace libtorrent; + using namespace lt; // test merkle_*() functions diff --git a/test/test_natpmp.cpp b/test/test_natpmp.cpp index 32060ae48..75205a715 100644 --- a/test/test_natpmp.cpp +++ b/test/test_natpmp.cpp @@ -37,9 +37,9 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; +using namespace lt; -using libtorrent::aux::portmap_protocol; +using lt::aux::portmap_protocol; namespace { diff --git a/test/test_packet_buffer.cpp b/test/test_packet_buffer.cpp index 25250dc13..5f01321e9 100644 --- a/test/test_packet_buffer.cpp +++ b/test/test_packet_buffer.cpp @@ -34,10 +34,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/packet_buffer.hpp" #include "libtorrent/packet_pool.hpp" -using libtorrent::packet_buffer; -using libtorrent::packet_ptr; -using libtorrent::packet_pool; -using libtorrent::packet; +using lt::packet_buffer; +using lt::packet_ptr; +using lt::packet_pool; +using lt::packet; packet_ptr make_pkt(packet_pool& pool, int const val) { diff --git a/test/test_part_file.cpp b/test/test_part_file.cpp index 2f06f67c3..009db820e 100644 --- a/test/test_part_file.cpp +++ b/test/test_part_file.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/path.hpp" #include "libtorrent/error_code.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(part_file) { diff --git a/test/test_pe_crypto.cpp b/test/test_pe_crypto.cpp index 52c9b17f7..73de20dc0 100644 --- a/test/test_pe_crypto.cpp +++ b/test/test_pe_crypto.cpp @@ -45,9 +45,8 @@ POSSIBILITY OF SUCH DAMAGE. #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) -namespace lt = libtorrent; -void test_enc_handler(libtorrent::crypto_plugin& a, libtorrent::crypto_plugin& b) +void test_enc_handler(lt::crypto_plugin& a, lt::crypto_plugin& b) { int const repcount = 128; for (int rep = 0; rep < repcount; ++rep) @@ -59,7 +58,7 @@ void test_enc_handler(libtorrent::crypto_plugin& a, libtorrent::crypto_plugin& b std::generate(buf.begin(), buf.end(), &std::rand); std::copy(buf.begin(), buf.end(), cmp_buf.begin()); - using namespace libtorrent::aux; + using namespace lt::aux; { lt::span iovec(&buf[0], buf_len); @@ -107,7 +106,7 @@ void test_enc_handler(libtorrent::crypto_plugin& a, libtorrent::crypto_plugin& b TORRENT_TEST(diffie_hellman) { - using namespace libtorrent; + using namespace lt; const int repcount = 128; @@ -138,7 +137,7 @@ TORRENT_TEST(diffie_hellman) TORRENT_TEST(rc4) { - using namespace libtorrent; + using namespace lt; sha1_hash test1_key = hasher("test1_key",8).final(); sha1_hash test2_key = hasher("test2_key",8).final(); diff --git a/test/test_peer_classes.cpp b/test/test_peer_classes.cpp index 17c5a2959..430fabbf5 100644 --- a/test/test_peer_classes.cpp +++ b/test/test_peer_classes.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_class_type_filter.hpp" #include "libtorrent/aux_/path.hpp" -using namespace libtorrent; +using namespace lt; std::string class_name(peer_class_t id, peer_class_pool const& p) { @@ -90,24 +90,24 @@ TORRENT_TEST(peer_class) for (int i = 0; i < 5; ++i) { - TEST_CHECK(filter.apply((libtorrent::peer_class_type_filter::socket_type_t)i + TEST_CHECK(filter.apply((lt::peer_class_type_filter::socket_type_t)i , 0xffffffff) == 0xffffffff); } - filter.disallow((libtorrent::peer_class_type_filter::socket_type_t)0, peer_class_t{0}); - TEST_CHECK(filter.apply((libtorrent::peer_class_type_filter::socket_type_t)0 + filter.disallow((lt::peer_class_type_filter::socket_type_t)0, peer_class_t{0}); + TEST_CHECK(filter.apply((lt::peer_class_type_filter::socket_type_t)0 , 0xffffffff) == 0xfffffffe); - TEST_CHECK(filter.apply((libtorrent::peer_class_type_filter::socket_type_t)1 + TEST_CHECK(filter.apply((lt::peer_class_type_filter::socket_type_t)1 , 0xffffffff) == 0xffffffff); - filter.allow((libtorrent::peer_class_type_filter::socket_type_t)0, peer_class_t{0}); - TEST_CHECK(filter.apply((libtorrent::peer_class_type_filter::socket_type_t)0 + filter.allow((lt::peer_class_type_filter::socket_type_t)0, peer_class_t{0}); + TEST_CHECK(filter.apply((lt::peer_class_type_filter::socket_type_t)0 , 0xffffffff) == 0xffffffff); - TEST_CHECK(filter.apply((libtorrent::peer_class_type_filter::socket_type_t)0, 0) == 0); - filter.add((libtorrent::peer_class_type_filter::socket_type_t)0, peer_class_t{0}); - TEST_CHECK(filter.apply((libtorrent::peer_class_type_filter::socket_type_t)0, 0) == 1); - filter.remove((libtorrent::peer_class_type_filter::socket_type_t)0, peer_class_t{0}); - TEST_CHECK(filter.apply((libtorrent::peer_class_type_filter::socket_type_t)0, 0) == 0); + TEST_CHECK(filter.apply((lt::peer_class_type_filter::socket_type_t)0, 0) == 0); + filter.add((lt::peer_class_type_filter::socket_type_t)0, peer_class_t{0}); + TEST_CHECK(filter.apply((lt::peer_class_type_filter::socket_type_t)0, 0) == 1); + filter.remove((lt::peer_class_type_filter::socket_type_t)0, peer_class_t{0}); + TEST_CHECK(filter.apply((lt::peer_class_type_filter::socket_type_t)0, 0) == 0); pool.decref(id2); pool.decref(id1); diff --git a/test/test_peer_list.cpp b/test/test_peer_list.cpp index 8ef3d6f45..ba6f3ec08 100644 --- a/test/test_peer_list.cpp +++ b/test/test_peer_list.cpp @@ -47,7 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for shared_ptr #include -using namespace libtorrent; +using namespace lt; struct mock_torrent; @@ -86,7 +86,7 @@ struct mock_peer_connection bool was_disconnected() const { return m_disconnect_called; } void set_local_ep(tcp::endpoint const& ep) { m_local = ep; } - libtorrent::stat m_stat; + lt::stat m_stat; bool m_choked; bool m_outgoing; torrent_peer* m_tp; @@ -111,7 +111,7 @@ struct mock_peer_connection bool fast_reconnect() const override { return true; } bool is_choked() const override { return m_choked; } bool failed() const override { return false; } - libtorrent::stat const& statistics() const override { return m_stat; } + lt::stat const& statistics() const override { return m_stat; } }; struct mock_torrent @@ -372,7 +372,7 @@ TORRENT_TEST(update_peer_port_collide) st.erased.clear(); } -std::shared_ptr shared_from_this(libtorrent::peer_connection_interface* p) +std::shared_ptr shared_from_this(lt::peer_connection_interface* p) { return std::static_pointer_cast( static_cast(p)->shared_from_this()); diff --git a/test/test_peer_priority.cpp b/test/test_peer_priority.cpp index a1850c60f..fab99c5fd 100644 --- a/test/test_peer_priority.cpp +++ b/test/test_peer_priority.cpp @@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" -using namespace libtorrent; +using namespace lt; std::uint32_t hash_buffer(char const* buf, int len) { diff --git a/test/test_pex.cpp b/test/test_pex.cpp index 230d9e1ce..7e255dd42 100644 --- a/test/test_pex.cpp +++ b/test/test_pex.cpp @@ -48,8 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. void test_pex() { - using namespace libtorrent; - namespace lt = libtorrent; + using namespace lt; // these are declared before the session objects // so that they are destructed last. This enables @@ -151,7 +150,7 @@ void test_pex() TORRENT_TEST(pex) { #ifndef TORRENT_DISABLE_EXTENSIONS - using namespace libtorrent; + using namespace lt; // in case the previous run was terminated error_code ec; diff --git a/test/test_piece_picker.cpp b/test/test_piece_picker.cpp index 03423ab31..15ee713cc 100644 --- a/test/test_piece_picker.cpp +++ b/test/test_piece_picker.cpp @@ -47,7 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" -using namespace libtorrent; +using namespace lt; using namespace std::placeholders; const int blocks_per_piece = 4; diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index a3140f74e..f7296b21f 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -40,11 +40,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(primitives) { - using namespace libtorrent; + using namespace lt; error_code ec; // make sure the retry interval keeps growing diff --git a/test/test_priority.cpp b/test/test_priority.cpp index 06b54ea77..cdb743658 100644 --- a/test/test_priority.cpp +++ b/test/test_priority.cpp @@ -48,8 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; using std::ignore; const int mask = alert::all_categories & ~(alert::performance_warning | alert::stats_notification); @@ -381,7 +380,7 @@ done: TORRENT_TEST(priority) { - using namespace libtorrent; + using namespace lt; settings_pack p = settings(); test_transfer(p); cleanup(); @@ -390,7 +389,7 @@ TORRENT_TEST(priority) #ifndef TORRENT_NO_DEPRECATE TORRENT_TEST(priority_deprecated) { - using namespace libtorrent; + using namespace lt; settings_pack p; test_transfer(p, true); cleanup(); diff --git a/test/test_privacy.cpp b/test/test_privacy.cpp index 84f382117..eefb8de7b 100644 --- a/test/test_privacy.cpp +++ b/test/test_privacy.cpp @@ -46,8 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; char const* proxy_name[] = { "none", @@ -61,7 +60,7 @@ char const* proxy_name[] = { std::vector rejected_trackers; -bool alert_predicate(libtorrent::alert const* a) +bool alert_predicate(lt::alert const* a) { anonymous_mode_alert const* am = alert_cast(a); if (am == nullptr) return false; @@ -119,10 +118,10 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags) // since multiple sessions may exist simultaneously (because of the // pipelining of the tests) they actually need to use different ports - static int listen_port = 10000 + libtorrent::random(50000); + static int listen_port = 10000 + lt::random(50000); char iface[200]; std::snprintf(iface, sizeof(iface), "127.0.0.1:%d", listen_port); - listen_port += libtorrent::random(10) + 1; + listen_port += lt::random(10) + 1; sett.set_str(settings_pack::listen_interfaces, iface); // if we don't do this, the peer connection test diff --git a/test/test_random.cpp b/test/test_random.cpp index d31668a0d..7c3a124ff 100644 --- a/test/test_random.cpp +++ b/test/test_random.cpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "libtorrent/random.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(random) { @@ -48,7 +48,7 @@ TORRENT_TEST(random) for (int i = 0; i < repetitions; ++i) { - std::uint32_t val = libtorrent::random(0xffffffff); + std::uint32_t val = lt::random(0xffffffff); val >>= byte * 8; ++buckets[val & 0xff]; } diff --git a/test/test_read_piece.cpp b/test/test_read_piece.cpp index 70c5844bf..4d41d5da2 100644 --- a/test/test_read_piece.cpp +++ b/test/test_read_piece.cpp @@ -47,8 +47,7 @@ enum flags_t void test_read_piece(int flags) { - using namespace libtorrent; - namespace lt = libtorrent; + using namespace lt; std::printf("==== TEST READ PIECE =====\n"); @@ -76,7 +75,7 @@ void test_read_piece(int flags) , file_sizes, 2); add_files(fs, combine_path("tmp1_read_piece", "test_torrent")); - libtorrent::create_torrent t(fs, piece_size, 0x4000); + lt::create_torrent t(fs, piece_size, 0x4000); // calculate the hash for all pieces set_piece_hashes(t, "tmp1_read_piece", ec); diff --git a/test/test_read_resume.cpp b/test/test_read_resume.cpp index 841955557..4b2dc5073 100644 --- a/test/test_read_resume.cpp +++ b/test/test_read_resume.cpp @@ -42,8 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/add_torrent_params.hpp" #include "libtorrent/read_resume_data.hpp" -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; TORRENT_TEST(read_resume) { diff --git a/test/test_receive_buffer.cpp b/test/test_receive_buffer.cpp index a1b45955e..ba5f9d56e 100644 --- a/test/test_receive_buffer.cpp +++ b/test/test_receive_buffer.cpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/receive_buffer.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(recv_buffer_init) { diff --git a/test/test_recheck.cpp b/test/test_recheck.cpp index 153c50cfc..612efef1b 100644 --- a/test/test_recheck.cpp +++ b/test/test_recheck.cpp @@ -47,8 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; const int mask = alert::all_categories & ~(alert::performance_warning | alert::stats_notification); diff --git a/test/test_remap_files.cpp b/test/test_remap_files.cpp index 9fbac0637..ae1af8e3b 100644 --- a/test/test_remap_files.cpp +++ b/test/test_remap_files.cpp @@ -44,8 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; using std::ignore; bool all_of(std::vector const& v) @@ -55,7 +54,7 @@ bool all_of(std::vector const& v) void test_remap_files(storage_mode_t storage_mode = storage_mode_sparse) { - using namespace libtorrent; + using namespace lt; // in case the previous run was terminated error_code ec; diff --git a/test/test_resolve_links.cpp b/test/test_resolve_links.cpp index b9fb74644..f819fb1cd 100644 --- a/test/test_resolve_links.cpp +++ b/test/test_resolve_links.cpp @@ -42,7 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; +using namespace lt; using namespace std::placeholders; struct test_torrent_t @@ -148,8 +148,8 @@ TORRENT_TEST(range_lookup_duplicated_files) fs2.add_file("test_resolve_links_dir/tmp1", 1024); fs2.add_file("test_resolve_links_dir/tmp2", 1024); - libtorrent::create_torrent t1(fs1, 1024); - libtorrent::create_torrent t2(fs2, 1024); + lt::create_torrent t1(fs1, 1024); + lt::create_torrent t2(fs2, 1024); t1.set_hash(piece_index_t{0}, sha1_hash::max()); diff --git a/test/test_resume.cpp b/test/test_resume.cpp index 8203accfe..d7dc640d3 100644 --- a/test/test_resume.cpp +++ b/test/test_resume.cpp @@ -46,8 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "settings.hpp" -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; std::shared_ptr generate_torrent() { diff --git a/test/test_session.cpp b/test/test_session.cpp index 96a919117..9b52be68c 100644 --- a/test/test_session.cpp +++ b/test/test_session.cpp @@ -46,8 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include using namespace std::placeholders; -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; TORRENT_TEST(session) { diff --git a/test/test_session_params.cpp b/test/test_session_params.cpp index f77c30777..7102919df 100644 --- a/test/test_session_params.cpp +++ b/test/test_session_params.cpp @@ -41,9 +41,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" -using namespace libtorrent; -using namespace libtorrent::dht; -namespace lt = libtorrent; +using namespace lt; +using namespace lt::dht; namespace { diff --git a/test/test_settings_pack.cpp b/test/test_settings_pack.cpp index 61c6ba7b0..4a9672eb3 100644 --- a/test/test_settings_pack.cpp +++ b/test/test_settings_pack.cpp @@ -38,8 +38,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bdecode.hpp" #include -using namespace libtorrent; -using namespace libtorrent::aux; +using namespace lt; +using namespace lt::aux; TORRENT_TEST(default_settings) { diff --git a/test/test_sha1_hash.cpp b/test/test_sha1_hash.cpp index 7c519e398..c6b4a427e 100644 --- a/test/test_sha1_hash.cpp +++ b/test/test_sha1_hash.cpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/sha1_hash.hpp" #include "libtorrent/hex.hpp" // from_hex -using namespace libtorrent; +using namespace lt; static sha1_hash to_hash(char const* s) { diff --git a/test/test_sliding_average.cpp b/test/test_sliding_average.cpp index 348e28653..08174e7cc 100644 --- a/test/test_sliding_average.cpp +++ b/test/test_sliding_average.cpp @@ -44,7 +44,7 @@ int samples[] = { 67, 51, 66, 52, 48, 57, 30, 51, 72, 65, 78, 56, 74, 68, 49, 66, 63, 57, 61, 62, 64, 62, 61, 52, 67, 64, 59, 61, 69, 60, 54, 69 }; -using namespace libtorrent; +using namespace lt; // make sure we react quickly for the first few samples TORRENT_TEST(reaction_time) diff --git a/test/test_socket_io.cpp b/test/test_socket_io.cpp index 5e1b221a6..aac0b747b 100644 --- a/test/test_socket_io.cpp +++ b/test/test_socket_io.cpp @@ -37,8 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; -using namespace libtorrent::detail; +using namespace lt; +using namespace lt::detail; TORRENT_TEST(address_to_bytes) { diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index b1a217465..54c15533e 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -57,9 +57,8 @@ POSSIBILITY OF SUCH DAMAGE. #include using namespace std::placeholders; -using namespace libtorrent; +using namespace lt; using std::ignore; -namespace lt = libtorrent; int const alert_mask = alert::all_categories & ~alert::progress_notification @@ -160,7 +159,7 @@ void test_ssl(int test_idx, bool use_utp) // if a peer fails once, don't try it again sett.set_int(settings_pack::max_failcount, 1); - libtorrent::session ses1(sett, 0); + lt::session ses1(sett, 0); // this +20 is here to use a different port as ses1 port += 20; @@ -173,7 +172,7 @@ void test_ssl(int test_idx, bool use_utp) sett.set_str(settings_pack::listen_interfaces, listen_iface); - libtorrent::session ses2(sett, 0); + lt::session ses2(sett, 0); wait_for_listen(ses1, "ses1"); wait_for_listen(ses2, "ses2"); @@ -345,7 +344,7 @@ attack_t attacks[] = const int num_attacks = sizeof(attacks)/sizeof(attacks[0]); -bool try_connect(libtorrent::session& ses1, int port +bool try_connect(lt::session& ses1, int port , std::shared_ptr const& t, std::uint32_t flags) { using boost::asio::ssl::context; @@ -560,7 +559,7 @@ void test_malicious_peer() sett.set_bool(settings_pack::enable_upnp, false); sett.set_bool(settings_pack::enable_natpmp, false); - libtorrent::session ses1(sett, 0); + lt::session ses1(sett, 0); wait_for_listen(ses1, "ses1"); // create torrent diff --git a/test/test_stack_allocator.cpp b/test/test_stack_allocator.cpp index 9f31b50d7..8d7ccbd77 100644 --- a/test/test_stack_allocator.cpp +++ b/test/test_stack_allocator.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/stack_allocator.hpp" #include "libtorrent/string_view.hpp" -using libtorrent::aux::stack_allocator; -using libtorrent::aux::allocation_slot; -using namespace libtorrent::literals; +using lt::aux::stack_allocator; +using lt::aux::allocation_slot; +using namespace lt::literals; TORRENT_TEST(copy_string) { @@ -55,7 +55,7 @@ TORRENT_TEST(copy_string) TORRENT_TEST(copy_buffer) { stack_allocator a; - allocation_slot const idx1 = a.copy_buffer(libtorrent::span("testing")); + allocation_slot const idx1 = a.copy_buffer(lt::span("testing")); // attempt to trigger a reallocation a.allocate(100000); diff --git a/test/test_stat_cache.cpp b/test/test_stat_cache.cpp index fa45b14f5..2b6d4f682 100644 --- a/test/test_stat_cache.cpp +++ b/test/test_stat_cache.cpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "test.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(stat_cache) { diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 6c51435e4..218e1b376 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -53,8 +53,7 @@ POSSIBILITY OF SUCH DAMAGE. #include using namespace std::placeholders; -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; const int piece_size = 16 * 1024 * 16; const int half = piece_size / 2; @@ -130,7 +129,7 @@ std::shared_ptr setup_torrent_info(file_storage& fs fs.add_file(combine_path("temp_storage", combine_path("folder2", "test3.tmp")), 0); fs.add_file(combine_path("temp_storage", combine_path("_folder3", "test4.tmp")), 0); fs.add_file(combine_path("temp_storage", combine_path("_folder3", combine_path("subfolder", "test5.tmp"))), 8); - libtorrent::create_torrent t(fs, 4, -1, 0); + lt::create_torrent t(fs, 4, -1, 0); char buf_[4] = {0, 0, 0, 0}; sha1_hash h = hasher(buf_).final(); @@ -189,7 +188,7 @@ std::vector new_piece(int size) void run_storage_tests(std::shared_ptr info , file_storage& fs , std::string const& test_path - , libtorrent::storage_mode_t storage_mode + , lt::storage_mode_t storage_mode , bool unbuffered) { TORRENT_ASSERT(fs.num_files() > 0); @@ -419,7 +418,7 @@ void test_rename(std::string const& test_path) } void test_check_files(std::string const& test_path - , libtorrent::storage_mode_t storage_mode + , lt::storage_mode_t storage_mode , bool unbuffered) { std::shared_ptr info; @@ -438,7 +437,7 @@ void test_check_files(std::string const& test_path std::vector piece0 = new_piece(piece_size); std::vector piece2 = new_piece(piece_size); - libtorrent::create_torrent t(fs, piece_size, -1, 0); + lt::create_torrent t(fs, piece_size, -1, 0); t.set_hash(piece_index_t(0), hasher(piece0).final()); t.set_hash(piece_index_t(1), sha1_hash(nullptr)); t.set_hash(piece_index_t(2), sha1_hash(nullptr)); @@ -528,7 +527,7 @@ void run_test(bool unbuffered) // | | | | | // | piece 0 | piece 1 | piece 2 | piece 3 | - libtorrent::create_torrent t(fs, piece_size, -1, 0); + lt::create_torrent t(fs, piece_size, -1, 0); TEST_CHECK(t.num_pieces() == 4); t.set_hash(piece_index_t(0), hasher(piece0).final()); t.set_hash(piece_index_t(1), hasher(piece1).final()); @@ -573,7 +572,7 @@ void run_test(bool unbuffered) error_code ec; file_storage fs; fs.add_file(combine_path("temp_storage", "test1.tmp"), 3 * piece_size); - libtorrent::create_torrent t(fs, piece_size, -1, 0); + lt::create_torrent t(fs, piece_size, -1, 0); TEST_CHECK(fs.file_path(file_index_t(0)) == combine_path("temp_storage", "test1.tmp")); t.set_hash(piece_index_t(0), hasher(piece0).final()); t.set_hash(piece_index_t(1), hasher(piece1).final()); @@ -748,8 +747,8 @@ TORRENT_TEST(fastresume_deprecated) bool got_file_rename_alert(alert const* a) { - return alert_cast(a) - || alert_cast(a); + return alert_cast(a) + || alert_cast(a); } TORRENT_TEST(rename_file) diff --git a/test/test_string.cpp b/test/test_string.cpp index ef3ac97b3..95caddf52 100644 --- a/test/test_string.cpp +++ b/test/test_string.cpp @@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include // for strcmp #include "libtorrent/aux_/escape_string.hpp" // for trim -using namespace libtorrent; +using namespace lt; TORRENT_TEST(maybe_url_encode) { diff --git a/test/test_tailqueue.cpp b/test/test_tailqueue.cpp index fa3f009f9..e12efa597 100644 --- a/test/test_tailqueue.cpp +++ b/test/test_tailqueue.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/tailqueue.hpp" -using namespace libtorrent; +using namespace lt; struct test_node : tailqueue_node { diff --git a/test/test_threads.cpp b/test/test_threads.cpp index f6642567c..0baa05918 100644 --- a/test/test_threads.cpp +++ b/test/test_threads.cpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/time.hpp" -namespace lt = libtorrent; -using namespace libtorrent; +using namespace lt; void fun(std::condition_variable* s, std::mutex* m, int* waiting, int i) { diff --git a/test/test_time.cpp b/test/test_time.cpp index 4f8cbc9d9..10932df81 100644 --- a/test/test_time.cpp +++ b/test/test_time.cpp @@ -39,8 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace lt = libtorrent; -using namespace libtorrent; +using namespace lt; void check_timer_loop(std::mutex& m, time_point& last, std::condition_variable& cv) { diff --git a/test/test_timestamp_history.cpp b/test/test_timestamp_history.cpp index 6dcf86842..9daebc807 100644 --- a/test/test_timestamp_history.cpp +++ b/test/test_timestamp_history.cpp @@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. TORRENT_TEST(timestamp_history) { - using namespace libtorrent; + using namespace lt; timestamp_history h; TEST_EQUAL(h.add_sample(0x32, false), 0); diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 326008db8..357d342e0 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -48,8 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; void test_running_torrent(std::shared_ptr info, std::int64_t file_size) { @@ -186,7 +185,7 @@ TORRENT_TEST(total_wanted) fs.add_file("test_torrent_dir4/tmp3", 1024); fs.add_file("test_torrent_dir4/tmp4", 1024); - libtorrent::create_torrent t(fs, 1024); + lt::create_torrent t(fs, 1024); std::vector tmp; bencode(std::back_inserter(tmp), t.generate()); error_code ec; @@ -224,7 +223,7 @@ TORRENT_TEST(added_peers) fs.add_file("test_torrent_dir4/tmp1", 1024); - libtorrent::create_torrent t(fs, 1024); + lt::create_torrent t(fs, 1024); std::vector tmp; bencode(std::back_inserter(tmp), t.generate()); error_code ec; @@ -261,7 +260,7 @@ TORRENT_TEST(torrent) fs.add_file("test_torrent_dir2/tmp1", file_size); fs.add_file("test_torrent_dir2/tmp2", file_size); fs.add_file("test_torrent_dir2/tmp3", file_size); - libtorrent::create_torrent t(fs, 128 * 1024); + lt::create_torrent t(fs, 128 * 1024); t.add_tracker("http://non-existing.com/announce"); std::vector piece(128 * 1024); @@ -289,7 +288,7 @@ TORRENT_TEST(torrent) file_storage fs; fs.add_file("test_torrent_dir2/tmp1", 1024); - libtorrent::create_torrent t(fs, 128 * 1024, 6); + lt::create_torrent t(fs, 128 * 1024, 6); std::vector piece(128 * 1024); for (int i = 0; i < int(piece.size()); ++i) @@ -311,13 +310,13 @@ TORRENT_TEST(torrent) } #ifndef TORRENT_DISABLE_EXTENSIONS -struct test_plugin : libtorrent::torrent_plugin {}; +struct test_plugin : lt::torrent_plugin {}; struct plugin_creator { explicit plugin_creator(int& c) : m_called(c) {} - std::shared_ptr + std::shared_ptr operator()(torrent_handle const&, void*) { ++m_called; @@ -332,7 +331,7 @@ TORRENT_TEST(duplicate_is_not_error) file_storage fs; fs.add_file("test_torrent_dir2/tmp1", 1024); - libtorrent::create_torrent t(fs, 128 * 1024, 6); + lt::create_torrent t(fs, 128 * 1024, 6); std::vector piece(128 * 1024); for (int i = 0; i < int(piece.size()); ++i) @@ -381,7 +380,7 @@ TORRENT_TEST(torrent_total_size_zero) TEST_CHECK(fs.total_size() == 0); ec.clear(); - libtorrent::create_torrent t1(fs); + lt::create_torrent t1(fs); set_piece_hashes(t1, ".", ec); TEST_CHECK(ec); @@ -390,7 +389,7 @@ TORRENT_TEST(torrent_total_size_zero) TEST_CHECK(fs.total_size() == 0); ec.clear(); - libtorrent::create_torrent t2(fs); + lt::create_torrent t2(fs); set_piece_hashes(t2, ".", ec); TEST_CHECK(ec); } @@ -401,7 +400,7 @@ TORRENT_TEST(rename_file) fs.add_file("test3/tmp1", 20); fs.add_file("test3/tmp2", 20); - libtorrent::create_torrent t(fs, 128 * 1024, 6); + lt::create_torrent t(fs, 128 * 1024, 6); std::vector tmp; std::back_insert_iterator> out(tmp); @@ -466,7 +465,7 @@ TORRENT_TEST(queue) std::stringstream file_path; file_path << "test_torrent_dir4/queue" << i; fs.add_file(file_path.str(), 1024); - libtorrent::create_torrent t(fs, 128 * 1024, 6); + lt::create_torrent t(fs, 128 * 1024, 6); std::vector buf; bencode(std::back_inserter(buf), t.generate()); diff --git a/test/test_torrent_info.cpp b/test/test_torrent_info.cpp index e376ea534..d06b05b3d 100644 --- a/test/test_torrent_info.cpp +++ b/test/test_torrent_info.cpp @@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; +using namespace lt; #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS TORRENT_TEST(mutable_torrents) @@ -50,7 +50,7 @@ TORRENT_TEST(mutable_torrents) fs.add_file("test/temporary.txt", 0x4000); - libtorrent::create_torrent t(fs, 0x4000); + lt::create_torrent t(fs, 0x4000); // calculate the hash for all pieces sha1_hash ph; @@ -89,7 +89,7 @@ struct test_torrent_t char const* file; }; -using namespace libtorrent; +using namespace lt; static test_torrent_t test_torrents[] = { @@ -799,7 +799,7 @@ void test_resolve_duplicates(int test_case) break; } - libtorrent::create_torrent t(fs, 0x4000); + lt::create_torrent t(fs, 0x4000); // calculate the hash for all pieces sha1_hash ph; @@ -883,7 +883,7 @@ TORRENT_TEST(empty_file2) TORRENT_TEST(copy) { - using namespace libtorrent; + using namespace lt; std::shared_ptr a = std::make_shared( combine_path(parent_path(current_working_directory()) diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index 8e9ed21e3..24591859c 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -49,8 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; // TODO: test scrape requests // TODO: test parse peers6 @@ -321,7 +320,7 @@ TORRENT_TEST(extract_peer_missing_port) , errors::invalid_tracker_response, false); } -bool connect_alert(libtorrent::alert const* a, tcp::endpoint& ep) +bool connect_alert(lt::alert const* a, tcp::endpoint& ep) { if (peer_connect_alert const* pc = alert_cast(a)) ep = pc->endpoint; @@ -456,7 +455,7 @@ TORRENT_TEST(http_peers) addp.save_path = "tmp2_tracker"; torrent_handle h = s->add_torrent(addp); - libtorrent::torrent_status status = h.status(); + lt::torrent_status status = h.status(); TEST_CHECK(status.current_tracker.empty()); // wait to hit the tracker @@ -529,7 +528,7 @@ TORRENT_TEST(current_tracker) addp.save_path = "tmp3_tracker"; torrent_handle h = s->add_torrent(addp); - libtorrent::torrent_status status = h.status(); + lt::torrent_status status = h.status(); TEST_CHECK(status.current_tracker.empty()); // wait to hit the tracker announce diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index 74e116aac..6824e760c 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -49,8 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; using std::ignore; @@ -358,7 +357,7 @@ void cleanup() #ifndef TORRENT_NO_DEPRECATE TORRENT_TEST(no_contiguous_buffers) { - using namespace libtorrent; + using namespace lt; // test no contiguous_recv_buffers settings_pack p; @@ -372,28 +371,28 @@ TORRENT_TEST(no_contiguous_buffers) // test with all kinds of proxies TORRENT_TEST(socks5_pw) { - using namespace libtorrent; + using namespace lt; test_transfer(settings_pack::socks5_pw, settings_pack()); cleanup(); } TORRENT_TEST(http) { - using namespace libtorrent; + using namespace lt; test_transfer(settings_pack::http, settings_pack()); cleanup(); } TORRENT_TEST(http_pw) { - using namespace libtorrent; + using namespace lt; test_transfer(settings_pack::http_pw, settings_pack()); cleanup(); } /* TORRENT_TEST(i2p) { - using namespace libtorrent; + using namespace lt; test_transfer(settings_pack::i2p_proxy, settings_pack()); cleanup(); } @@ -401,7 +400,7 @@ TORRENT_TEST(i2p) // this test is too flaky. Move it to a sim TORRENT_TEST(disk_full) { - using namespace libtorrent; + using namespace lt; // test with a (simulated) full disk test_transfer(0, settings_pack(), true); @@ -411,7 +410,7 @@ TORRENT_TEST(disk_full) TORRENT_TEST(allow_fast) { - using namespace libtorrent; + using namespace lt; // test allowed fast settings_pack p; p.set_int(settings_pack::allowed_fast_set_size, 2000); @@ -422,7 +421,7 @@ TORRENT_TEST(allow_fast) TORRENT_TEST(coalesce_reads) { - using namespace libtorrent; + using namespace lt; // test allowed fast settings_pack p; p.set_int(settings_pack::read_cache_line_size, 16); @@ -434,7 +433,7 @@ TORRENT_TEST(coalesce_reads) TORRENT_TEST(coalesce_writes) { - using namespace libtorrent; + using namespace lt; // test allowed fast settings_pack p; p.set_bool(settings_pack::coalesce_writes, true); @@ -446,7 +445,7 @@ TORRENT_TEST(coalesce_writes) TORRENT_TEST(allocate) { - using namespace libtorrent; + using namespace lt; // test storage_mode_allocate std::printf("full allocation mode\n"); test_transfer(0, settings_pack(), false, storage_mode_allocate); diff --git a/test/test_upnp.cpp b/test/test_upnp.cpp index 0ba3ee987..039283093 100644 --- a/test/test_upnp.cpp +++ b/test/test_upnp.cpp @@ -41,10 +41,9 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -namespace lt = libtorrent; -using namespace libtorrent; +using namespace lt; -using libtorrent::aux::portmap_protocol; +using lt::aux::portmap_protocol; broadcast_socket* sock = nullptr; int g_port = 0; @@ -147,7 +146,7 @@ namespace void run_upnp_test(char const* root_filename, char const* router_model, char const* control_name, int igd_version) { - libtorrent::io_service ios; + lt::io_service ios; g_port = start_web_server(); diff --git a/test/test_url_seed.cpp b/test/test_url_seed.cpp index 21c34406e..a4567cfbe 100644 --- a/test/test_url_seed.cpp +++ b/test/test_url_seed.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::none; +const int proxy = lt::settings_pack::none; #ifdef TORRENT_USE_OPENSSL TORRENT_TEST(url_seed_ssl_keepalive) diff --git a/test/test_utf8.cpp b/test/test_utf8.cpp index 8e6a01a7b..f8014d5ac 100644 --- a/test/test_utf8.cpp +++ b/test/test_utf8.cpp @@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; +using namespace lt; void verify_transforms(char const* utf8_source, int utf8_source_len = -1) { diff --git a/test/test_utp.cpp b/test/test_utp.cpp index 1a684c40f..b2c41be57 100644 --- a/test/test_utp.cpp +++ b/test/test_utp.cpp @@ -45,8 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; void test_transfer() { diff --git a/test/test_web_seed.cpp b/test/test_web_seed.cpp index e3ba37de6..c25d4762b 100644 --- a/test/test_web_seed.cpp +++ b/test/test_web_seed.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::none; +const int proxy = lt::settings_pack::none; #ifdef TORRENT_USE_OPENSSL TORRENT_TEST(web_seed_ssl) diff --git a/test/test_web_seed_ban.cpp b/test/test_web_seed_ban.cpp index 533b9f083..ad203679b 100644 --- a/test/test_web_seed_ban.cpp +++ b/test/test_web_seed_ban.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::none; +const int proxy = lt::settings_pack::none; #ifdef TORRENT_USE_OPENSSL TORRENT_TEST(http_seed_ssl) diff --git a/test/test_web_seed_chunked.cpp b/test/test_web_seed_chunked.cpp index 77afe524d..9ff41ee5b 100644 --- a/test/test_web_seed_chunked.cpp +++ b/test/test_web_seed_chunked.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::none; +const int proxy = lt::settings_pack::none; #ifdef TORRENT_USE_OPENSSL TORRENT_TEST(web_seed_ssl) diff --git a/test/test_web_seed_http.cpp b/test/test_web_seed_http.cpp index 802bd7586..72aa2ff2a 100644 --- a/test/test_web_seed_http.cpp +++ b/test/test_web_seed_http.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::http; +const int proxy = lt::settings_pack::http; TORRENT_TEST(web_seed_http) { diff --git a/test/test_web_seed_http_pw.cpp b/test/test_web_seed_http_pw.cpp index 067f5e34c..e2f1dfb02 100644 --- a/test/test_web_seed_http_pw.cpp +++ b/test/test_web_seed_http_pw.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::http_pw; +const int proxy = lt::settings_pack::http_pw; TORRENT_TEST(web_seed_http_pw) { diff --git a/test/test_web_seed_redirect.cpp b/test/test_web_seed_redirect.cpp index 94c292d3d..2358867a5 100644 --- a/test/test_web_seed_redirect.cpp +++ b/test/test_web_seed_redirect.cpp @@ -37,11 +37,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/create_torrent.hpp" #include "libtorrent/torrent_info.hpp" -using namespace libtorrent; +using namespace lt; TORRENT_TEST(web_seed_redirect) { - using namespace libtorrent; + using namespace lt; error_code ec; @@ -66,7 +66,7 @@ TORRENT_TEST(web_seed_redirect) // generate a torrent with pad files to make sure they // are not requested web seeds - libtorrent::create_torrent t(fs, piece_size, 0x4000); + lt::create_torrent t(fs, piece_size, 0x4000); char tmp[512]; std::snprintf(tmp, sizeof(tmp), "http://127.0.0.1:%d/redirect", port); @@ -92,7 +92,7 @@ TORRENT_TEST(web_seed_redirect) settings_pack p = settings(); p.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024); p.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification)); - libtorrent::session ses(p); + lt::session ses(p); // disable keep-alive because otherwise the test will choke on seeing // the disconnect (from the redirect) diff --git a/test/test_web_seed_socks4.cpp b/test/test_web_seed_socks4.cpp index 0ae47bed0..a9187ff10 100644 --- a/test/test_web_seed_socks4.cpp +++ b/test/test_web_seed_socks4.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::socks4; +const int proxy = lt::settings_pack::socks4; #ifdef TORRENT_USE_OPENSSL TORRENT_TEST(http_seed_ssl) diff --git a/test/test_web_seed_socks5.cpp b/test/test_web_seed_socks5.cpp index e7a3d5759..59d0f909a 100644 --- a/test/test_web_seed_socks5.cpp +++ b/test/test_web_seed_socks5.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::socks5; +const int proxy = lt::settings_pack::socks5; #ifdef TORRENT_USE_OPENSSL TORRENT_TEST(http_seed_ssl) diff --git a/test/test_web_seed_socks5_no_peers.cpp b/test/test_web_seed_socks5_no_peers.cpp index 802d2adea..083cd6a3e 100644 --- a/test/test_web_seed_socks5_no_peers.cpp +++ b/test/test_web_seed_socks5_no_peers.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::socks5; +const int proxy = lt::settings_pack::socks5; TORRENT_TEST(web_seed_socks5_no_peers_ssl) { diff --git a/test/test_web_seed_socks5_pw.cpp b/test/test_web_seed_socks5_pw.cpp index 6e2f5c5b6..76a180dab 100644 --- a/test/test_web_seed_socks5_pw.cpp +++ b/test/test_web_seed_socks5_pw.cpp @@ -34,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #include "setup_transfer.hpp" #include "web_seed_suite.hpp" -using namespace libtorrent; +using namespace lt; -const int proxy = libtorrent::settings_pack::socks5_pw; +const int proxy = lt::settings_pack::socks5_pw; #ifdef TORRENT_USE_OPENSSL TORRENT_TEST(http_seed_ssl) diff --git a/test/test_xml.cpp b/test/test_xml.cpp index fdbc849e5..4f1a5d27f 100644 --- a/test/test_xml.cpp +++ b/test/test_xml.cpp @@ -263,7 +263,7 @@ char upnp_xml4[] = "" ""; -using namespace libtorrent; +using namespace lt; using namespace std::placeholders; void parser_callback(std::string& out, int token, string_view s diff --git a/test/udp_tracker.cpp b/test/udp_tracker.cpp index bced8f454..8b37accf1 100644 --- a/test/udp_tracker.cpp +++ b/test/udp_tracker.cpp @@ -47,13 +47,13 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; +using namespace lt; using namespace std::placeholders; struct udp_tracker { - libtorrent::io_service m_ios; + lt::io_service m_ios; std::atomic m_udp_announces{0}; udp::socket m_socket{m_ios}; int m_port = 0; diff --git a/test/udp_tracker.hpp b/test/udp_tracker.hpp index 56dc07eed..c414a27ce 100644 --- a/test/udp_tracker.hpp +++ b/test/udp_tracker.hpp @@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" // returns the port the udp tracker is running on -int EXPORT start_udp_tracker(libtorrent::address iface - = libtorrent::address_v4::any()); +int EXPORT start_udp_tracker(lt::address iface + = lt::address_v4::any()); // the number of udp tracker announces received int EXPORT num_udp_announces(); diff --git a/test/web_seed_suite.cpp b/test/web_seed_suite.cpp index d6475bdf7..e1a42d153 100644 --- a/test/web_seed_suite.cpp +++ b/test/web_seed_suite.cpp @@ -53,8 +53,7 @@ POSSIBILITY OF SUCH DAMAGE. #include -using namespace libtorrent; -namespace lt = libtorrent; +using namespace lt; namespace { @@ -79,7 +78,7 @@ void test_transfer(lt::session& ses, std::shared_ptr torrent_file , int proxy, char const* protocol, bool url_seed , bool chunked_encoding, bool test_ban, bool keepalive, bool proxy_peers) { - using namespace libtorrent; + using namespace lt; TORRENT_ASSERT(torrent_file->web_seeds().size() > 0); @@ -278,7 +277,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed , bool chunked_encoding, bool test_ban, bool keepalive, bool test_rename , bool proxy_peers) { - using namespace libtorrent; + using namespace lt; std::string save_path = "web_seed"; save_path += proxy_name[proxy]; @@ -408,7 +407,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed pack.set_bool(settings_pack::enable_natpmp, false); pack.set_bool(settings_pack::enable_upnp, false); pack.set_bool(settings_pack::enable_dht, false); - libtorrent::session ses(pack, 0); + lt::session ses(pack, 0); test_transfer(ses, torrent_file, proxy, protocol, test_url_seed , chunked_encoding, test_ban, keepalive, proxy_peers); diff --git a/test/web_seed_suite.hpp b/test/web_seed_suite.hpp index e5181ba8d..0d1cafe04 100644 --- a/test/web_seed_suite.hpp +++ b/test/web_seed_suite.hpp @@ -36,8 +36,8 @@ int EXPORT run_http_suite(int proxy, char const* protocol , bool test_url_seed, bool chunked_encoding = false, bool test_ban = false , bool keepalive = true, bool test_rename = false, bool proxy_peers = true); -void EXPORT test_transfer(libtorrent::session& ses - , std::shared_ptr torrent_file +void EXPORT test_transfer(lt::session& ses + , std::shared_ptr torrent_file , int proxy = 0, char const* protocol = "http" , bool url_seed = true, bool chunked_encoding = false , bool test_ban = false, bool keepalive = true, bool proxy_peers = true); diff --git a/tools/dht_put.cpp b/tools/dht_put.cpp index c966a0b1e..a5ec15041 100644 --- a/tools/dht_put.cpp +++ b/tools/dht_put.cpp @@ -44,14 +44,13 @@ POSSIBILITY OF SUCH DAMAGE. #include // for PRId64 et.al. #include -using namespace libtorrent; -using namespace libtorrent::dht; +using namespace lt; +using namespace lt::dht; using namespace std::placeholders; -namespace lt = libtorrent; // TODO: don't use internal functions to libtorrent -using libtorrent::aux::from_hex; -using libtorrent::aux::to_hex; +using lt::aux::from_hex; +using lt::aux::to_hex; #ifdef TORRENT_DISABLE_DHT @@ -121,7 +120,7 @@ void put_string(entry& e, std::array& sig , std::array const& sk , char const* str) { - using libtorrent::dht::sign_mutable_item; + using lt::dht::sign_mutable_item; e = std::string(str); std::vector buf; diff --git a/tools/fuzz_torrent.cpp b/tools/fuzz_torrent.cpp index 87f85f951..d0e4856c9 100644 --- a/tools/fuzz_torrent.cpp +++ b/tools/fuzz_torrent.cpp @@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_info.hpp" #include "libtorrent/error_code.hpp" -using libtorrent::bdecode_node; +using lt::bdecode_node; using std::mt19937; using std::uniform_int_distribution; @@ -242,7 +242,7 @@ void render_variant(std::string& out, bdecode_node const& e) print_dict(out); for (int i = 0; i < e.dict_size(); ++i) { - std::pair item = e.dict_at(i); + std::pair item = e.dict_at(i); const bool duplicate = g_seed == 1; const bool skipped = g_seed == 2; g_seed -= 2; @@ -288,7 +288,7 @@ void render_variant(std::string& out, bdecode_node const& e) } int load_file(std::string const& filename, std::vector& v - , libtorrent::error_code& ec, int limit = 8000000) + , lt::error_code& ec, int limit = 8000000) { ec.clear(); FILE* f = fopen(filename.c_str(), "rb"); @@ -352,7 +352,7 @@ int load_file(std::string const& filename, std::vector& v int main(int argc, char const* argv[]) { std::vector buf; - libtorrent::error_code ec; + lt::error_code ec; if (argc < 2) { @@ -388,8 +388,8 @@ int main(int argc, char const* argv[]) test_buffer.clear(); render_variant(test_buffer, e); - libtorrent::error_code ec; - libtorrent::torrent_info t(test_buffer.c_str(), int(test_buffer.size()), ec); + lt::error_code ec; + lt::torrent_info t(test_buffer.c_str(), int(test_buffer.size()), ec); // TODO: add option to save to file unconditionally (to test other clients) /* diff --git a/tools/parse_access_log.cpp b/tools/parse_access_log.cpp index bc3dd4141..7ec26057e 100644 --- a/tools/parse_access_log.cpp +++ b/tools/parse_access_log.cpp @@ -40,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include // for PRId64 et.al. -using namespace libtorrent; -using namespace libtorrent::detail; // for write_* and read_* +using namespace lt; +using namespace lt::detail; // for write_* and read_* void print_usage() { diff --git a/tools/session_log_alerts.cpp b/tools/session_log_alerts.cpp index 5dc95673f..0e6e35bc9 100644 --- a/tools/session_log_alerts.cpp +++ b/tools/session_log_alerts.cpp @@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -using namespace libtorrent; +using namespace lt; int main(int argc, char* argv[]) {