fix deprecation warnings for deprecated classes
This commit is contained in:
parent
0c2d3a0dac
commit
78aefcc806
|
@ -219,6 +219,7 @@ set(libtorrent_aux_include_files
|
||||||
cppint_import_export
|
cppint_import_export
|
||||||
cpuid
|
cpuid
|
||||||
deferred_handler
|
deferred_handler
|
||||||
|
deprecated
|
||||||
deque
|
deque
|
||||||
dev_random
|
dev_random
|
||||||
disable_warnings_pop
|
disable_warnings_pop
|
||||||
|
|
|
@ -1082,10 +1082,9 @@ example alert_masks:
|
||||||
std::vector<char> in;
|
std::vector<char> in;
|
||||||
if (load_file(".ses_state", in))
|
if (load_file(".ses_state", in))
|
||||||
{
|
{
|
||||||
lt::bdecode_node e;
|
|
||||||
lt::error_code ec;
|
lt::error_code ec;
|
||||||
if (bdecode(&in[0], &in[0] + in.size(), e, ec) == 0)
|
lt::bdecode_node e = lt::bdecode(in, ec);
|
||||||
params = read_session_params(e, session_handle::save_dht_state);
|
if (!ec) params = read_session_params(e, session_handle::save_dht_state);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,16 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
||||||
{
|
{
|
||||||
lt::error_code ec;
|
lt::error_code ec;
|
||||||
lt::lazy_entry ret;
|
|
||||||
int pos;
|
int pos;
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
lt::lazy_entry ret;
|
||||||
lazy_bdecode(reinterpret_cast<char const*>(data), reinterpret_cast<char const*>(data) + size, ret, ec, &pos);
|
lazy_bdecode(reinterpret_cast<char const*>(data), reinterpret_cast<char const*>(data) + size, ret, ec, &pos);
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,7 @@ nobase_include_HEADERS = \
|
||||||
aux_/disable_warnings_pop.hpp \
|
aux_/disable_warnings_pop.hpp \
|
||||||
aux_/disk_job_fence.hpp \
|
aux_/disk_job_fence.hpp \
|
||||||
aux_/deferred_handler.hpp \
|
aux_/deferred_handler.hpp \
|
||||||
|
aux_/deprecated.hpp \
|
||||||
aux_/dev_random.hpp \
|
aux_/dev_random.hpp \
|
||||||
aux_/deque.hpp \
|
aux_/deque.hpp \
|
||||||
aux_/escape_string.hpp \
|
aux_/escape_string.hpp \
|
||||||
|
|
|
@ -54,6 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/stack_allocator.hpp"
|
#include "libtorrent/stack_allocator.hpp"
|
||||||
#include "libtorrent/aux_/noexcept_movable.hpp"
|
#include "libtorrent/aux_/noexcept_movable.hpp"
|
||||||
#include "libtorrent/portmap.hpp" // for portmap_transport
|
#include "libtorrent/portmap.hpp" // for portmap_transport
|
||||||
|
#include "libtorrent/aux_/deprecated.hpp"
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
#include <boost/shared_array.hpp>
|
#include <boost/shared_array.hpp>
|
||||||
|
@ -209,6 +210,17 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
TORRENT_DEFINE_ALERT_IMPL(name, seq, prio)
|
TORRENT_DEFINE_ALERT_IMPL(name, seq, prio)
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
#if TORRENT_ABI_VERSION == 1
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push, 1)
|
||||||
|
// warning C4996: X: was declared deprecated
|
||||||
|
#pragma warning( disable : 4996 )
|
||||||
|
#endif
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
|
||||||
// The ``torrent_added_alert`` is posted once every time a torrent is successfully
|
// The ``torrent_added_alert`` is posted once every time a torrent is successfully
|
||||||
// added. It doesn't contain any members of its own, but inherits the torrent handle
|
// added. It doesn't contain any members of its own, but inherits the torrent handle
|
||||||
// from its base class.
|
// from its base class.
|
||||||
|
@ -224,6 +236,14 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
static constexpr alert_category_t static_category = alert::status_notification;
|
static constexpr alert_category_t static_category = alert::status_notification;
|
||||||
std::string message() const override;
|
std::string message() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The ``torrent_removed_alert`` is posted whenever a torrent is removed. Since
|
// The ``torrent_removed_alert`` is posted whenever a torrent is removed. Since
|
||||||
|
@ -1819,6 +1839,17 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
};
|
};
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
#if TORRENT_ABI_VERSION == 1
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push, 1)
|
||||||
|
// warning C4996: X: was declared deprecated
|
||||||
|
#pragma warning( disable : 4996 )
|
||||||
|
#endif
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
|
||||||
// This alert is posted when a bittorrent feature is blocked because of the
|
// This alert is posted when a bittorrent feature is blocked because of the
|
||||||
// anonymous mode. For instance, if the tracker proxy is not set up, no
|
// anonymous mode. For instance, if the tracker proxy is not set up, no
|
||||||
// trackers will be used, because trackers can only be used through proxies
|
// trackers will be used, because trackers can only be used through proxies
|
||||||
|
@ -1846,6 +1877,14 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
int kind;
|
int kind;
|
||||||
std::string str;
|
std::string str;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // TORRENT_ABI_VERSION
|
#endif // TORRENT_ABI_VERSION
|
||||||
|
|
||||||
// This alert is generated when we receive a local service discovery message
|
// This alert is generated when we receive a local service discovery message
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2019, Arvid Norberg
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the author nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TORRENT_DEPRECATED_HPP_INCLUDED
|
||||||
|
#define TORRENT_DEPRECATED_HPP_INCLUDED
|
||||||
|
|
||||||
|
#if defined __clang__
|
||||||
|
|
||||||
|
// ====== CLANG ========
|
||||||
|
|
||||||
|
# if !defined TORRENT_BUILDING_LIBRARY
|
||||||
|
// TODO: figure out which version of clang this is supported in
|
||||||
|
# define TORRENT_DEPRECATED __attribute__ ((deprecated))
|
||||||
|
# define TORRENT_DEPRECATED_ENUM __attribute__ ((deprecated))
|
||||||
|
# define TORRENT_DEPRECATED_MEMBER __attribute__ ((deprecated))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined __GNUC__
|
||||||
|
|
||||||
|
// ======== GCC ========
|
||||||
|
|
||||||
|
// deprecation markup is only enabled when libtorrent
|
||||||
|
// headers are included by clients, not while building
|
||||||
|
// libtorrent itself
|
||||||
|
# if __GNUC__ >= 3 && !defined TORRENT_BUILDING_LIBRARY
|
||||||
|
# define TORRENT_DEPRECATED __attribute__ ((deprecated))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if __GNUC__ >= 6 && !defined TORRENT_BUILDING_LIBRARY
|
||||||
|
# define TORRENT_DEPRECATED_ENUM __attribute__ ((deprecated))
|
||||||
|
# define TORRENT_DEPRECATED_MEMBER __attribute__ ((deprecated))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#elif defined _MSC_VER
|
||||||
|
|
||||||
|
// ======= MSVC =========
|
||||||
|
|
||||||
|
// deprecation markup is only enabled when libtorrent
|
||||||
|
// headers are included by clients, not while building
|
||||||
|
// libtorrent itself
|
||||||
|
#if !defined TORRENT_BUILDING_LIBRARY
|
||||||
|
# define TORRENT_DEPRECATED __declspec(deprecated)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_DEPRECATED
|
||||||
|
#define TORRENT_DEPRECATED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_DEPRECATED_ENUM
|
||||||
|
#define TORRENT_DEPRECATED_ENUM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_DEPRECATED_MEMBER
|
||||||
|
#define TORRENT_DEPRECATED_MEMBER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -35,6 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#include "libtorrent/aux_/deprecated.hpp"
|
||||||
|
|
||||||
#if !defined TORRENT_ABI_VERSION
|
#if !defined TORRENT_ABI_VERSION
|
||||||
# ifdef TORRENT_NO_DEPRECATE
|
# ifdef TORRENT_NO_DEPRECATE
|
||||||
# define TORRENT_ABI_VERSION 2
|
# define TORRENT_ABI_VERSION 2
|
||||||
|
@ -91,9 +93,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// only export this type if deprecated functions are enabled
|
// only export this type if deprecated functions are enabled
|
||||||
#if TORRENT_ABI_VERSION >= 2
|
#if TORRENT_ABI_VERSION >= 2
|
||||||
# define TORRENT_DEPRECATED_EXPORT TORRENT_EXTRA_EXPORT
|
# define TORRENT_DEPRECATED_EXPORT TORRENT_EXTRA_EXPORT TORRENT_DEPRECATED
|
||||||
#else
|
#else
|
||||||
# define TORRENT_DEPRECATED_EXPORT TORRENT_EXPORT
|
# define TORRENT_DEPRECATED_EXPORT TORRENT_EXPORT TORRENT_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,9 +45,7 @@ namespace aux {
|
||||||
|
|
||||||
struct session_settings;
|
struct session_settings;
|
||||||
|
|
||||||
// The ``proxy_settings`` structs contains the information needed to
|
struct TORRENT_EXTRA_EXPORT proxy_settings
|
||||||
// direct certain traffic to a proxy.
|
|
||||||
struct TORRENT_DEPRECATED_EXPORT proxy_settings
|
|
||||||
{
|
{
|
||||||
// defaults constructs proxy settings, initializing it to the default
|
// defaults constructs proxy settings, initializing it to the default
|
||||||
// settings.
|
// settings.
|
||||||
|
@ -89,7 +87,6 @@ namespace aux {
|
||||||
bool proxy_tracker_connections = true;
|
bool proxy_tracker_connections = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,36 +56,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#pragma GCC diagnostic ignored "-Wformat-extra-args"
|
#pragma GCC diagnostic ignored "-Wformat-extra-args"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ====== CLANG ========
|
#if defined __GNUC__
|
||||||
|
|
||||||
#if defined __clang__
|
|
||||||
|
|
||||||
# if !defined TORRENT_BUILDING_LIBRARY
|
|
||||||
// TODO: figure out which version of clang this is supported in
|
|
||||||
# define TORRENT_DEPRECATED_ENUM __attribute__ ((deprecated))
|
|
||||||
# define TORRENT_DEPRECATED_MEMBER __attribute__ ((deprecated))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// ======= GCC =========
|
|
||||||
|
|
||||||
#elif defined __GNUC__
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_CONCEPT_CHECKS
|
#ifdef _GLIBCXX_CONCEPT_CHECKS
|
||||||
#define TORRENT_COMPLETE_TYPES_REQUIRED 1
|
#define TORRENT_COMPLETE_TYPES_REQUIRED 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// deprecation markup is only enabled when libtorrent
|
|
||||||
// headers are included by clients, not while building
|
|
||||||
// libtorrent itself
|
|
||||||
# if __GNUC__ >= 3 && !defined TORRENT_BUILDING_LIBRARY
|
|
||||||
# define TORRENT_DEPRECATED __attribute__ ((deprecated))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# if __GNUC__ >= 6 && !defined TORRENT_BUILDING_LIBRARY
|
|
||||||
# define TORRENT_DEPRECATED_ENUM __attribute__ ((deprecated))
|
|
||||||
# define TORRENT_DEPRECATED_MEMBER __attribute__ ((deprecated))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// ======= SUNPRO =========
|
// ======= SUNPRO =========
|
||||||
|
|
||||||
#elif defined __SUNPRO_CC
|
#elif defined __SUNPRO_CC
|
||||||
|
@ -99,13 +75,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
// class X needs to have dll-interface to be used by clients of class Y
|
// class X needs to have dll-interface to be used by clients of class Y
|
||||||
#pragma warning(disable:4251)
|
#pragma warning(disable:4251)
|
||||||
|
|
||||||
// deprecation markup is only enabled when libtorrent
|
|
||||||
// headers are included by clients, not while building
|
|
||||||
// libtorrent itself
|
|
||||||
#if !defined TORRENT_BUILDING_LIBRARY
|
|
||||||
# define TORRENT_DEPRECATED __declspec(deprecated)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// auto and decltype(auto) return types supports since MSVS2015
|
// auto and decltype(auto) return types supports since MSVS2015
|
||||||
// https://msdn.microsoft.com/en-us/library/hh567368.aspx
|
// https://msdn.microsoft.com/en-us/library/hh567368.aspx
|
||||||
// we need to force C++14 feature due VS2017 inability to parse C++11 syntax
|
// we need to force C++14 feature due VS2017 inability to parse C++11 syntax
|
||||||
|
@ -402,18 +371,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_HAS_FALLOCATE 1
|
#define TORRENT_HAS_FALLOCATE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DEPRECATED
|
|
||||||
#define TORRENT_DEPRECATED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_DEPRECATED_ENUM
|
|
||||||
#define TORRENT_DEPRECATED_ENUM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_DEPRECATED_MEMBER
|
|
||||||
#define TORRENT_DEPRECATED_MEMBER
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_USE_COMMONCRYPTO
|
#ifndef TORRENT_USE_COMMONCRYPTO
|
||||||
#define TORRENT_USE_COMMONCRYPTO 0
|
#define TORRENT_USE_COMMONCRYPTO 0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,6 +55,10 @@ namespace libtorrent {
|
||||||
// information about a file in a file_storage
|
// information about a file in a file_storage
|
||||||
struct TORRENT_DEPRECATED_EXPORT file_entry
|
struct TORRENT_DEPRECATED_EXPORT file_entry
|
||||||
{
|
{
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
// hidden
|
// hidden
|
||||||
file_entry();
|
file_entry();
|
||||||
// hidden
|
// hidden
|
||||||
|
@ -64,6 +68,10 @@ namespace libtorrent {
|
||||||
file_entry(file_entry&&) noexcept = default;
|
file_entry(file_entry&&) noexcept = default;
|
||||||
file_entry& operator=(file_entry&&) & noexcept = default;
|
file_entry& operator=(file_entry&&) & noexcept = default;
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
// the full path of this file. The paths are unicode strings
|
// the full path of this file. The paths are unicode strings
|
||||||
// encoded in UTF-8.
|
// encoded in UTF-8.
|
||||||
std::string path;
|
std::string path;
|
||||||
|
@ -282,6 +290,14 @@ namespace libtorrent {
|
||||||
void rename_file(file_index_t index, std::string const& new_filename);
|
void rename_file(file_index_t index, std::string const& new_filename);
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
#if TORRENT_ABI_VERSION == 1
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push, 1)
|
||||||
|
#pragma warning(disable: 4996)
|
||||||
|
#endif
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
void add_file_borrow(char const* filename, int filename_len
|
void add_file_borrow(char const* filename, int filename_len
|
||||||
, std::string const& path, std::int64_t file_size
|
, std::string const& path, std::int64_t file_size
|
||||||
|
@ -303,30 +319,6 @@ namespace libtorrent {
|
||||||
void set_name(std::wstring const& n);
|
void set_name(std::wstring const& n);
|
||||||
|
|
||||||
void rename_file_deprecated(file_index_t index, std::wstring const& new_filename);
|
void rename_file_deprecated(file_index_t index, std::wstring const& new_filename);
|
||||||
#endif // TORRENT_ABI_VERSION
|
|
||||||
|
|
||||||
// returns a list of file_slice objects representing the portions of
|
|
||||||
// files the specified piece index, byte offset and size range overlaps.
|
|
||||||
// this is the inverse mapping of map_file().
|
|
||||||
//
|
|
||||||
// Preconditions of this function is that the input range is within the
|
|
||||||
// torrents address space. ``piece`` may not be negative and
|
|
||||||
//
|
|
||||||
// ``piece`` * piece_size + ``offset`` + ``size``
|
|
||||||
//
|
|
||||||
// may not exceed the total size of the torrent.
|
|
||||||
std::vector<file_slice> map_block(piece_index_t piece, std::int64_t offset
|
|
||||||
, int size) const;
|
|
||||||
|
|
||||||
// returns a peer_request representing the piece index, byte offset
|
|
||||||
// and size the specified file range overlaps. This is the inverse
|
|
||||||
// mapping over map_block(). Note that the ``peer_request`` return type
|
|
||||||
// is meant to hold bittorrent block requests, which may not be larger
|
|
||||||
// than 16 kiB. Mapping a range larger than that may return an overflown
|
|
||||||
// integer.
|
|
||||||
peer_request map_file(file_index_t file, std::int64_t offset, int size) const;
|
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
|
||||||
// all functions depending on internal_file_entry
|
// all functions depending on internal_file_entry
|
||||||
// were deprecated in 1.0. Use the variants that take an
|
// were deprecated in 1.0. Use the variants that take an
|
||||||
// index instead
|
// index instead
|
||||||
|
@ -359,8 +351,36 @@ namespace libtorrent {
|
||||||
reverse_iterator rend_deprecated() const { return m_files.rend(); }
|
reverse_iterator rend_deprecated() const { return m_files.rend(); }
|
||||||
iterator file_at_offset_deprecated(std::int64_t offset) const;
|
iterator file_at_offset_deprecated(std::int64_t offset) const;
|
||||||
file_entry at_deprecated(int index) const;
|
file_entry at_deprecated(int index) const;
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
#endif // TORRENT_ABI_VERSION
|
#endif // TORRENT_ABI_VERSION
|
||||||
|
|
||||||
|
// returns a list of file_slice objects representing the portions of
|
||||||
|
// files the specified piece index, byte offset and size range overlaps.
|
||||||
|
// this is the inverse mapping of map_file().
|
||||||
|
//
|
||||||
|
// Preconditions of this function is that the input range is within the
|
||||||
|
// torrents address space. ``piece`` may not be negative and
|
||||||
|
//
|
||||||
|
// ``piece`` * piece_size + ``offset`` + ``size``
|
||||||
|
//
|
||||||
|
// may not exceed the total size of the torrent.
|
||||||
|
std::vector<file_slice> map_block(piece_index_t piece, std::int64_t offset
|
||||||
|
, int size) const;
|
||||||
|
|
||||||
|
// returns a peer_request representing the piece index, byte offset
|
||||||
|
// and size the specified file range overlaps. This is the inverse
|
||||||
|
// mapping over map_block(). Note that the ``peer_request`` return type
|
||||||
|
// is meant to hold bittorrent block requests, which may not be larger
|
||||||
|
// than 16 kiB. Mapping a range larger than that may return an overflown
|
||||||
|
// integer.
|
||||||
|
peer_request map_file(file_index_t file, std::int64_t offset, int size) const;
|
||||||
|
|
||||||
// returns the number of files in the file_storage
|
// returns the number of files in the file_storage
|
||||||
int num_files() const noexcept;
|
int num_files() const noexcept;
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace libtorrent {
|
||||||
|
|
||||||
// The fingerprint class represents information about a client and its version. It is used
|
// The fingerprint class represents information about a client and its version. It is used
|
||||||
// to encode this information into the client's peer id.
|
// to encode this information into the client's peer id.
|
||||||
struct TORRENT_DEPRECATED TORRENT_DEPRECATED_EXPORT fingerprint
|
struct TORRENT_DEPRECATED_EXPORT fingerprint
|
||||||
{
|
{
|
||||||
fingerprint(const char* id_string, int major, int minor, int revision, int tag);
|
fingerprint(const char* id_string, int major, int minor, int revision, int tag);
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,17 @@ namespace libtorrent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
#if TORRENT_ABI_VERSION == 1
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push, 1)
|
||||||
|
// warning C4996: X: was declared deprecated
|
||||||
|
#pragma warning( disable : 4996 )
|
||||||
|
#endif
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
|
||||||
// deprecated in 1.2
|
// deprecated in 1.2
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
inline void to_hex(char const* in, int len, char* out)
|
inline void to_hex(char const* in, int len, char* out)
|
||||||
|
@ -76,6 +87,14 @@ namespace libtorrent {
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
inline bool from_hex(char const *in, int len, char* out)
|
inline bool from_hex(char const *in, int len, char* out)
|
||||||
{ return aux::from_hex({in, len}, out); }
|
{ return aux::from_hex({in, len}, out); }
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace aux {
|
||||||
// id. This can be used to automate the identification of clients. It will
|
// id. This can be used to automate the identification of clients. It will
|
||||||
// not be able to identify peers with non- standard encodings. Only Azureus
|
// not be able to identify peers with non- standard encodings. Only Azureus
|
||||||
// style, Shadow's style and Mainline style.
|
// style, Shadow's style and Mainline style.
|
||||||
TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED
|
TORRENT_DEPRECATED_EXPORT
|
||||||
boost::optional<fingerprint>
|
boost::optional<fingerprint>
|
||||||
client_fingerprint(peer_id const& p);
|
client_fingerprint(peer_id const& p);
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,16 @@ namespace libtorrent {
|
||||||
TORRENT_DEPRECATED_EXPORT int lazy_bdecode(char const* start, char const* end
|
TORRENT_DEPRECATED_EXPORT int lazy_bdecode(char const* start, char const* end
|
||||||
, lazy_entry& ret, int depth_limit = 1000, int item_limit = 1000000);
|
, lazy_entry& ret, int depth_limit = 1000, int item_limit = 1000000);
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push, 1)
|
||||||
|
// warning C4996: X: was declared deprecated
|
||||||
|
#pragma warning( disable : 4996 )
|
||||||
|
#endif
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
|
||||||
// this is a string that is not 0-terminated. Instead it
|
// this is a string that is not 0-terminated. Instead it
|
||||||
// comes with a length, specified in bytes. This is particularly
|
// comes with a length, specified in bytes. This is particularly
|
||||||
// useful when parsing bencoded structures, because strings are
|
// useful when parsing bencoded structures, because strings are
|
||||||
|
@ -400,6 +410,13 @@ namespace libtorrent {
|
||||||
TORRENT_DEPRECATED_EXPORT std::string print_entry(lazy_entry const& e
|
TORRENT_DEPRECATED_EXPORT std::string print_entry(lazy_entry const& e
|
||||||
, bool single_line = false, int indent = 0);
|
, bool single_line = false, int indent = 0);
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
// defined in bdecode.cpp
|
// defined in bdecode.cpp
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
TORRENT_EXTRA_EXPORT char const* parse_int(char const* start
|
TORRENT_EXTRA_EXPORT char const* parse_int(char const* start
|
||||||
|
|
|
@ -809,14 +809,6 @@ namespace libtorrent {
|
||||||
// shifting.
|
// shifting.
|
||||||
void remove_torrent(const torrent_handle& h, remove_flags_t options = {});
|
void remove_torrent(const torrent_handle& h, remove_flags_t options = {});
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
|
||||||
// deprecated in libtorrent 1.1. use settings_pack instead
|
|
||||||
TORRENT_DEPRECATED
|
|
||||||
void set_pe_settings(pe_settings const& settings);
|
|
||||||
TORRENT_DEPRECATED
|
|
||||||
pe_settings get_pe_settings() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Applies the settings specified by the settings_pack ``s``. This is an
|
// Applies the settings specified by the settings_pack ``s``. This is an
|
||||||
// asynchronous operation that will return immediately and actually apply
|
// asynchronous operation that will return immediately and actually apply
|
||||||
// the settings to the main thread of libtorrent some time later.
|
// the settings to the main thread of libtorrent some time later.
|
||||||
|
@ -825,6 +817,22 @@ namespace libtorrent {
|
||||||
settings_pack get_settings() const;
|
settings_pack get_settings() const;
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
#if TORRENT_ABI_VERSION == 1
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// deprecated in libtorrent 1.1. use settings_pack instead
|
||||||
|
TORRENT_DEPRECATED
|
||||||
|
void set_pe_settings(pe_settings const& settings);
|
||||||
|
TORRENT_DEPRECATED
|
||||||
|
pe_settings get_pe_settings() const;
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
// ``set_i2p_proxy`` sets the i2p_ proxy, and tries to open a persistent
|
// ``set_i2p_proxy`` sets the i2p_ proxy, and tries to open a persistent
|
||||||
// connection to it. The only used fields in the proxy settings structs
|
// connection to it. The only used fields in the proxy settings structs
|
||||||
// are ``hostname`` and ``port``.
|
// are ``hostname`` and ``port``.
|
||||||
|
|
|
@ -394,8 +394,26 @@ namespace libtorrent {
|
||||||
file_iterator file_at_offset(std::int64_t offset) const
|
file_iterator file_at_offset(std::int64_t offset) const
|
||||||
{ return m_files.file_at_offset_deprecated(offset); }
|
{ return m_files.file_at_offset_deprecated(offset); }
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push, 1)
|
||||||
|
// warning C4996: X: was declared deprecated
|
||||||
|
#pragma warning( disable : 4996 )
|
||||||
|
#endif
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
file_entry file_at(int index) const { return m_files.at_deprecated(index); }
|
file_entry file_at(int index) const { return m_files.at_deprecated(index); }
|
||||||
|
|
||||||
|
#if defined __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // TORRENT_ABI_VERSION
|
#endif // TORRENT_ABI_VERSION
|
||||||
|
|
||||||
// If you need index-access to files you can use the ``num_files()`` along
|
// If you need index-access to files you can use the ``num_files()`` along
|
||||||
|
|
|
@ -32,7 +32,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#include "libtorrent/session.hpp"
|
#include "libtorrent/session.hpp"
|
||||||
#include "libtorrent/hex.hpp" // for from_hex
|
|
||||||
#include "libtorrent/alert_types.hpp"
|
#include "libtorrent/alert_types.hpp"
|
||||||
#include "libtorrent/bencode.hpp" // for bencode()
|
#include "libtorrent/bencode.hpp" // for bencode()
|
||||||
#include "libtorrent/kademlia/item.hpp" // for sign_mutable_item
|
#include "libtorrent/kademlia/item.hpp" // for sign_mutable_item
|
||||||
|
@ -49,10 +48,6 @@ using namespace lt;
|
||||||
using namespace lt::dht;
|
using namespace lt::dht;
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
// TODO: don't use internal functions to libtorrent
|
|
||||||
using lt::aux::from_hex;
|
|
||||||
using lt::aux::to_hex;
|
|
||||||
|
|
||||||
#ifdef TORRENT_DISABLE_DHT
|
#ifdef TORRENT_DISABLE_DHT
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
@ -63,6 +58,43 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
std::string to_hex(lt::span<char const> key)
|
||||||
|
{
|
||||||
|
std::string out;
|
||||||
|
for (auto const b : key)
|
||||||
|
{
|
||||||
|
char buf[20];
|
||||||
|
std::snprintf(buf, sizeof(3), "%02x", static_cast<unsigned char>(b));
|
||||||
|
out += (char*)buf;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hex_to_int(char in)
|
||||||
|
{
|
||||||
|
if (in >= '0' && in <= '9') return int(in) - '0';
|
||||||
|
if (in >= 'A' && in <= 'F') return int(in) - 'A' + 10;
|
||||||
|
if (in >= 'a' && in <= 'f') return int(in) - 'a' + 10;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool from_hex(span<char const> in, span<char> out)
|
||||||
|
{
|
||||||
|
if (in.size() != out.size() * 2) return false;
|
||||||
|
auto o = out.begin();
|
||||||
|
for (auto i = in.begin(); i != in.end(); ++i, ++o)
|
||||||
|
{
|
||||||
|
int const t1 = hex_to_int(*i);
|
||||||
|
if (t1 == -1) return false;
|
||||||
|
++i;
|
||||||
|
if (i == in.end()) return false;
|
||||||
|
int const t2 = hex_to_int(*i);
|
||||||
|
if (t2 == -1) return false;
|
||||||
|
*o = (t1 << 4) | (t2 & 0xf);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void usage()
|
void usage()
|
||||||
{
|
{
|
||||||
|
@ -198,12 +230,13 @@ void load_dht_state(lt::session& s)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bdecode_node e;
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
bdecode(state.data(), state.data() + state.size(), e, ec);
|
bdecode_node e = bdecode(state, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
|
{
|
||||||
std::fprintf(stderr, "failed to parse .dht file: (%d) %s\n"
|
std::fprintf(stderr, "failed to parse .dht file: (%d) %s\n"
|
||||||
, ec.value(), ec.message().c_str());
|
, ec.value(), ec.message().c_str());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::printf("load dht state from .dht\n");
|
std::printf("load dht state from .dht\n");
|
||||||
|
@ -273,8 +306,7 @@ int main(int argc, char* argv[])
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
sha1_hash target;
|
sha1_hash target;
|
||||||
bool ret = from_hex({argv[0], 40}, target.data());
|
if (!from_hex({argv[0], 40}, target))
|
||||||
if (!ret)
|
|
||||||
{
|
{
|
||||||
std::fprintf(stderr, "invalid hex encoding of target hash\n");
|
std::fprintf(stderr, "invalid hex encoding of target hash\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -352,8 +384,7 @@ int main(int argc, char* argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::array<char, 32> public_key;
|
std::array<char, 32> public_key;
|
||||||
bool ret = from_hex({argv[0], len}, &public_key[0]);
|
if (!from_hex({argv[0], len}, public_key))
|
||||||
if (!ret)
|
|
||||||
{
|
{
|
||||||
std::fprintf(stderr, "invalid hex encoding of public key\n");
|
std::fprintf(stderr, "invalid hex encoding of public key\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue