remove whitespace at end of line (#1245)

This commit is contained in:
Arvid Norberg 2016-10-22 11:47:24 -04:00 committed by GitHub
parent 31d34fec41
commit 6148984426
58 changed files with 473 additions and 472 deletions

View File

@ -123,7 +123,7 @@ script:
- cd ..
- 'if [ "$lint" == "1" ]; then
python ~/cpplint.py --extensions=cpp --headers=hpp --filter=-,+runtime/explicit --linelength=90 test/*.{cpp,hpp} src/*.cpp include/libtorrent/*.hpp include/libtorrent/kademlia/*.hpp src/kademlia/*.cpp include/libtorrent/aux_/*.hpp include/libtorrent/extensions/*.hpp simulation/*.{cpp,hpp} tools/*.{cpp,hpp} examples/*.{cpp,hpp};
python ~/cpplint.py --extensions=cpp --headers=hpp --filter=-,+runtime/explicit,+whitespace/end_of_line --linelength=90 test/*.{cpp,hpp} src/*.cpp include/libtorrent/*.hpp include/libtorrent/kademlia/*.hpp src/kademlia/*.cpp include/libtorrent/aux_/*.hpp include/libtorrent/extensions/*.hpp simulation/*.{cpp,hpp} tools/*.{cpp,hpp} examples/*.{cpp,hpp};
fi'
# if variant is not set, we do not want to build anything

View File

@ -80,8 +80,9 @@ for l in f:
mode = ''
continue
if l.startswith('// '):
description += l[3:]
if l.startswith('//'):
if l[2] == ' ': description += l[3:]
else: description += l[2:]
continue
l = l.strip()

View File

@ -81,7 +81,7 @@ names = []
types = []
for l in f:
description_line = l.lstrip().startswith('// ')
description_line = l.lstrip().startswith('//')
l = l.strip()

View File

@ -112,10 +112,10 @@ namespace libtorrent
// if a torrent is created and seeded, or if the user already know
// that the files are complete, this is a way to avoid the initial
// file checks, and significantly reduce the startup time.
//
//
// Setting ``flag_seed_mode`` on a torrent without metadata (a
// .torrent file) is a no-op and will be ignored.
//
//
// If resume data is passed in with this torrent, the seed mode saved
// in there will override the seed mode you set here.
flag_seed_mode = 0x001,
@ -127,7 +127,7 @@ namespace libtorrent
// periodically. This mode can be used to avoid race conditions when
// adjusting priorities of pieces before allowing the torrent to start
// downloading.
//
//
// If the torrent is auto-managed (``flag_auto_managed``), the torrent
// will eventually be taken out of upload-mode, regardless of how it
// got there. If it's important to manually control when the torrent
@ -143,13 +143,13 @@ namespace libtorrent
// download anything. This mode is intended to be safe to add any
// number of torrents to, without manual screening, without the risk
// of downloading more than is uploaded.
//
//
// A torrent in share mode sets the priority to all pieces to 0,
// except for the pieces that are downloaded, when pieces are decided
// to be downloaded. This affects the progress bar, which might be set
// to "100% finished" most of the time. Do not change file or piece
// priorities for torrents in share mode, it will make it not work.
//
//
// The share mode has one setting, the share ratio target, see
// ``settings_pack::share_mode_target`` for more info.
flag_share_mode = 0x008,
@ -172,13 +172,13 @@ namespace libtorrent
// may be resumed at any point, regardless of how it paused. If it's
// important to manually control when the torrent is paused and
// resumed, don't make it auto managed.
//
//
// If ``flag_auto_managed`` is set, the torrent will be queued,
// started and seeded automatically by libtorrent. When this is set,
// the torrent should also be started as paused. The default queue
// order is the order the torrents were added. They are all downloaded
// in that order. For more details, see queuing_.
//
//
// If you pass in resume data, the auto_managed state of the torrent
// when the resume data was saved will override the auto_managed state
// you pass in here. You can override this by setting
@ -305,7 +305,7 @@ namespace libtorrent
std::string name;
// the path where the torrent is or will be stored.
//
//
// .. note::
// On windows this path (and other paths) are interpreted as UNC
// paths. This means they must use backslashes as directory separators
@ -358,7 +358,7 @@ namespace libtorrent
// flags controlling aspects of this torrent and how it's added. See
// flags_t for details.
//
//
// .. note::
// The ``flags`` field is initialized with default flags by the
// constructor. In order to preserve default behavior when clearing or
@ -377,7 +377,7 @@ namespace libtorrent
// ``set_download_limit()`` functions on torrent_handle. These values let
// you initialize these settings when the torrent is added, instead of
// calling these functions immediately following adding it.
//
//
// -1 means unlimited on these settings just like their counterpart
// functions on torrent_handle
int max_uploads;
@ -418,7 +418,7 @@ namespace libtorrent
// every piece. ``num_downloaded`` is the number of times the torrent has
// been downloaded (not initiated, but the number of times a download has
// completed).
//
//
// Leaving any of these values set to -1 indicates we don't know, or we
// have not received any scrape data.
int num_complete;
@ -429,10 +429,10 @@ namespace libtorrent
// seeds to be used by the torrent. If the ``flag_override_web_seeds``
// is set, these will be the _only_ ones to be used. i.e. any web seeds
// found in the .torrent file will be overridden.
//
//
// http_seeds expects URLs to web servers implementing the original HTTP
// seed specification `BEP 17`_.
//
//
// url_seeds expects URLs to regular web servers, aka "get right" style,
// specified in `BEP 19`_.
std::vector<std::string> http_seeds;

View File

@ -40,18 +40,18 @@ POSSIBILITY OF SUCH DAMAGE.
// The pop_alerts() function on session is the main interface for retrieving
// alerts (warnings, messages and errors from libtorrent). If no alerts have
// been posted by libtorrent pop_alerts() will return an empty list.
//
//
// By default, only errors are reported. settings_pack::alert_mask can be
// used to specify which kinds of events should be reported. The alert mask is
// comprised by bits from the category_t enum.
//
//
// Every alert belongs to one or more category. There is a cost associated with
// posting alerts. Only alerts that belong to an enabled category are
// posted. Setting the alert bitmask to 0 will disable all alerts (except those
// that are non-discardable). Alerts that are responses to API calls such as
// save_resume_data() and post_session_stats() are non-discardable and will be
// posted even if their category is disabled.
//
//
// There are other alert base classes that some alerts derive from, all the
// alerts that are generated for a specific torrent are derived from
// torrent_alert, and tracker events derive from tracker_alert.
@ -88,7 +88,7 @@ namespace libtorrent {
enum category_t
{
// Enables alerts that report an error. This includes:
//
//
// * tracker errors
// * tracker warnings
// * file errors
@ -202,7 +202,7 @@ namespace libtorrent {
// compared against a specific alert by querying a static constant called ``alert_type``
// in the alert. It can be used to determine the run-time type of an alert* in
// order to cast to that alert type and access specific members.
//
//
// e.g:
//
// .. code:: c++
@ -211,7 +211,7 @@ namespace libtorrent {
// ses.pop_alerts(&alerts);
// for (alert* i : alerts) {
// switch (a->type()) {
//
//
// case read_piece_alert::alert_type:
// {
// read_piece_alert* p = (read_piece_alert*)a;
@ -268,7 +268,7 @@ namespace libtorrent {
// When you get an alert, you can use ``alert_cast<>`` to attempt to cast the
// pointer to a specific alert type, in order to query it for more
// information.
//
//
// .. note::
// ``alert_cast<>`` can only cast to an exact alert type, not a base class
template <class T> T* alert_cast(alert* a)

View File

@ -185,11 +185,11 @@ namespace libtorrent
// the torrent handle in its base class will always be invalid (since the torrent
// is already removed) it has the info hash as a member, to identify it.
// It's posted when the ``status_notification`` bit is set in the alert_mask.
//
//
// Even though the ``handle`` member doesn't point to an existing torrent anymore,
// it is still useful for comparing to other handles, which may also no
// longer point to existing torrents, but to the same non-existing torrents.
//
//
// The ``torrent_handle`` acts as a ``weak_ptr``, even though its object no
// longer exists, it can still compare equal to another weak pointer which
// points to the same non-existent object.
@ -211,7 +211,7 @@ namespace libtorrent
// is 0. If successful, ``buffer`` points to a buffer containing all the data
// of the piece. ``piece`` is the piece index that was read. ``size`` is the
// number of bytes that was read.
//
//
// If the operation fails, ``error`` will indicate what went wrong.
struct TORRENT_EXPORT read_piece_alert final : torrent_alert
{
@ -350,9 +350,9 @@ namespace libtorrent
// send it all before the disk gets back to us.
// The number of bytes that we keep outstanding, requested from the disk, is calculated
// as follows::
//
//
// min(512, max(upload_rate * send_buffer_watermark_factor / 100, send_buffer_watermark))
//
//
// If you receive this alert, you might want to either increase your ``send_buffer_watermark``
// or ``send_buffer_watermark_factor``.
send_buffer_watermark_too_low,
@ -927,12 +927,12 @@ namespace libtorrent
};
// This alert is generated when a request to delete the files of a torrent complete.
//
//
// The ``info_hash`` is the info-hash of the torrent that was just deleted. Most of
// the time the torrent_handle in the ``torrent_alert`` will be invalid by the time
// this alert arrives, since the torrent is being deleted. The ``info_hash`` member
// is hence the main way of identifying which torrent just completed the delete.
//
//
// This alert is posted in the ``storage_notification`` category, and that bit
// needs to be set in the alert_mask.
struct TORRENT_EXPORT torrent_deleted_alert final : torrent_alert
@ -1149,13 +1149,13 @@ namespace libtorrent
// This alert is generated when the metadata has been completely received and the torrent
// can start downloading. It is not generated on torrents that are started with metadata, but
// only those that needs to download it from peers (when utilizing the libtorrent extension).
//
//
// There are no additional data members in this alert.
//
//
// Typically, when receiving this alert, you would want to save the torrent file in order
// to load it back up again when the session is restarted. Here's an example snippet of
// code to do that::
//
//
// torrent_handle h = alert->handle();
// if (h.is_valid()) {
// std::shared_ptr<torrent_info const> ti = h.torrent_file();
@ -1169,7 +1169,7 @@ namespace libtorrent
// fclose(f);
// }
// }
//
//
struct TORRENT_EXPORT metadata_received_alert final : torrent_alert
{
// internal
@ -1494,7 +1494,7 @@ namespace libtorrent
// This alert is posted when an incoming peer connection, or a peer that's about to be added
// to our peer list, is blocked for some reason. This could be any of:
//
//
// * the IP filter
// * i2p mixed mode restrictions (a normal peer is not allowed on an i2p swarm)
// * the port filter
@ -1769,7 +1769,7 @@ namespace libtorrent
// tells you what kind of socket the connection was accepted
// as:
//
//
// 0. none (no socket instantiated)
// 1. TCP
// 2. Socks5
@ -1780,7 +1780,7 @@ namespace libtorrent
// 7. SSL/Socks5
// 8. HTTPS (SSL/HTTP)
// 9. SSL/uTP
//
//
int const socket_type;
// is the IP address and port the connection came from.
@ -1880,7 +1880,7 @@ namespace libtorrent
// happens in very specific cases. For instance, when a torrent is
// downloaded from a URL, the true info hash is not known immediately. First
// the .torrent file must be downloaded and parsed.
//
//
// Once this download completes, the ``torrent_update_alert`` is posted to
// notify the client of the info-hash changing.
struct TORRENT_EXPORT torrent_update_alert final : torrent_alert

View File

@ -72,7 +72,7 @@ namespace libtorrent
// returns the number of seconds to the next announce on this tracker.
// ``min_announce_in()`` returns the number of seconds until we are
// allowed to force another tracker update with this tracker.
//
//
// If the last time this tracker was contacted failed, ``last_error`` is
// the error code describing what error occurred.
int next_announce_in() const;

View File

@ -224,11 +224,11 @@ struct bdecode_token
// a ``bdecode_node`` is used to traverse and hold the tree structure defined
// by bencoded data after it has been parse by bdecode().
//
//
// There are primarily two kinds of bdecode_nodes. The ones that own the tree
// structure, and defines its lifetime, and nodes that are child nodes in the
// tree, pointing back into the root's tree.
//
//
// The ``bdecode_node`` passed in to ``bdecode()`` becomes the one owning the
// tree structure. Make sure not to destruct that object for as long as you
// use any of its child nodes. Also, keep in mind that the buffer originally
@ -307,7 +307,7 @@ struct TORRENT_EXPORT bdecode_node
// but have to use ``std::string`` instead. ``dict_find_list`` will return a
// valid ``bdecode_node`` if the key is found _and_ it is a list. Otherwise
// it will return a default-constructed bdecode_node.
//
//
// Functions with the ``_value`` suffix return the value of the node
// directly, rather than the nodes. In case the node is not found, or it has
// a different type, a default value is returned (which can be specified).
@ -397,20 +397,20 @@ TORRENT_EXPORT std::string print_entry(bdecode_node const& e
// non-zero value and fills in ``ec`` with the error code. The optional
// argument ``error_pos``, if set to non-nullptr, will be set to the byte offset
// into the buffer where the parse failure occurred.
//
//
// ``depth_limit`` specifies the max number of nested lists or dictionaries are
// allowed in the data structure. (This affects the stack usage of the
// function, be careful not to set it too high).
//
// ``token_limit`` is the max number of tokens allowed to be parsed from the
// buffer. This is simply a sanity check to not have unbounded memory usage.
//
//
// The resulting ``bdecode_node`` is an *owning* node. That means it will
// be holding the whole parsed tree. When iterating lists and dictionaries,
// those ``bdecode_node`` objects will simply have references to the root or
// owning ``bdecode_node``. If the root node is destructed, all other nodes
// that refer to anything in that tree become invalid.
//
//
// However, the underlying buffer passed in to this function (``start``, ``end``)
// must also remain valid while the bdecoded tree is used. The parsed tree
// produced by this function does not copy any data out of the buffer, but

View File

@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_BENCODE_HPP_INCLUDED
// OVERVIEW
//
//
// Bencoding is a common representation in bittorrent used for for dictionary,
// list, int and string hierarchies. It's used to encode .torrent files and
// some messages in the network protocol. libtorrent also uses it to store
@ -367,15 +367,15 @@ namespace libtorrent
}
// These functions will encode data to bencoded or decode bencoded data.
//
//
// If possible, ``bdecode()`` producing a bdecode_node should be preferred
// over this function.
//
//
// The entry_ class is the internal representation of the bencoded data
// and it can be used to retrieve information, an entry_ can also be build by
// the program and given to ``bencode()`` to encode it into the ``OutIt``
// iterator.
//
//
// The ``OutIt`` and ``InIt`` are iterators
// (InputIterator_ and OutputIterator_ respectively). They
// are templates and are usually instantiated as ostream_iterator_,
@ -383,30 +383,30 @@ namespace libtorrent
// functions will assume that the iterator refers to a character
// (``char``). So, if you want to encode entry ``e`` into a buffer
// in memory, you can do it like this::
//
//
// std::vector<char> buffer;
// bencode(std::back_inserter(buf), e);
//
//
// .. _InputIterator: http://www.sgi.com/tech/stl/InputIterator.html
// .. _OutputIterator: http://www.sgi.com/tech/stl/OutputIterator.html
// .. _ostream_iterator: http://www.sgi.com/tech/stl/ostream_iterator.html
// .. _back_insert_iterator: http://www.sgi.com/tech/stl/back_insert_iterator.html
// .. _istream_iterator: http://www.sgi.com/tech/stl/istream_iterator.html
//
//
// If you want to decode a torrent file from a buffer in memory, you can do it like this::
//
//
// std::vector<char> buffer;
// // ...
// entry e = bdecode(buf.begin(), buf.end());
//
//
// Or, if you have a raw char buffer::
//
//
// const char* buf;
// // ...
// entry e = bdecode(buf, buf + data_size);
//
//
// Now we just need to know how to retrieve information from the entry.
//
//
// If ``bdecode()`` encounters invalid encoded data in the range given to it
// it will return a default constructed ``entry`` object.
template<class OutIt> int bencode(OutIt out, const entry& e)

View File

@ -142,5 +142,5 @@ namespace libtorrent
bool m_abort;
};
}
#endif

View File

@ -54,7 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
// to create torrent files. It is a layered API with low level classes
// and higher level convenience functions. A torrent is created in 4
// steps:
//
//
// 1. first the files that will be part of the torrent are determined.
// 2. the torrent properties are set, such as tracker url, web seeds,
// DHT nodes etc.
@ -64,22 +64,22 @@ POSSIBILITY OF SUCH DAMAGE.
//
// If there are a lot of files and or deep directory hierarchies to
// traverse, step one can be time consuming.
//
//
// Typically step 3 is by far the most time consuming step, since it
// requires to read all the bytes from all the files in the torrent.
//
// All of these classes and functions are declared by including
// ``libtorrent/create_torrent.hpp``.
//
//
// example:
//
// .. code:: c++
//
//
// file_storage fs;
//
// // recursively adds files in directories
// add_files(fs, "./my_torrent");
//
//
// create_torrent t(fs);
// t.add_tracker("http://my.tracker.com/announce");
// t.set_creator("libtorrent example");
@ -89,7 +89,7 @@ POSSIBILITY OF SUCH DAMAGE.
//
// ofstream out("my_torrent.torrent", std::ios_base::binary);
// bencode(std::ostream_iterator<char>(out), t.generate());
//
//
namespace libtorrent
{
class torrent_info;
@ -140,7 +140,7 @@ namespace libtorrent
// to create a torrent that can be updated via a *mutable torrent*
// (see BEP38_). This also needs to be enabled for torrents that update
// another torrent.
//
//
// .. _BEP38: http://www.bittorrent.org/beps/bep_0038.html
mutable_torrent_support = 16
};
@ -148,23 +148,23 @@ namespace libtorrent
// The ``piece_size`` is the size of each piece in bytes. It must
// be a multiple of 16 kiB. If a piece size of 0 is specified, a
// piece_size will be calculated such that the torrent file is roughly 40 kB.
//
//
// If a ``pad_file_limit`` is specified (other than -1), any file larger than
// the specified number of bytes will be preceded by a pad file to align it
// with the start of a piece. The pad_file_limit is ignored unless the
// ``optimize_alignment`` flag is passed. Typically it doesn't make sense
// to set this any lower than 4kiB.
//
//
// The overload that takes a ``torrent_info`` object will make a verbatim
// copy of its info dictionary (to preserve the info-hash). The copy of
// the info dictionary will be used by create_torrent::generate(). This means
// that none of the member functions of create_torrent that affects
// the content of the info dictionary (such as ``set_hash()``), will
// have any affect.
//
//
// The ``flags`` arguments specifies options for the torrent creation. It can
// be any combination of the flags defined by create_torrent::flags_t.
//
//
// ``alignment`` is used when pad files are enabled. This is the size
// eligible files are aligned to. The default is -1, which means the
// piece size of the torrent.
@ -178,16 +178,16 @@ namespace libtorrent
// This function will generate the .torrent file as a bencode tree. In order to
// generate the flat file, use the bencode() function.
//
//
// It may be useful to add custom entries to the torrent file before bencoding it
// and saving it to disk.
//
//
// If anything goes wrong during torrent generation, this function will return
// an empty ``entry`` structure. You can test for this condition by querying the
// type of the entry:
//
// .. code:: c++
//
//
// file_storage fs;
// // add file ...
// create_torrent t(fs);
@ -198,7 +198,7 @@ namespace libtorrent
// {
// // something went wrong
// }
//
//
// For instance, you cannot generate a torrent with 0 files in it. If you don't add
// any files to the ``file_storage``, torrent generation will fail.
entry generate() const;
@ -231,7 +231,7 @@ namespace libtorrent
// content as the file of the torrent. For a multi-file torrent, it should point to
// a directory containing a directory with the same name as this torrent, and all the
// files of the torrent in it.
//
//
// The second function, ``add_http_seed()`` adds an HTTP seed instead.
void add_url_seed(string_view url);
void add_http_seed(string_view url);
@ -254,7 +254,7 @@ namespace libtorrent
// torrent an *SSL torrent*. An SSL torrent requires that each peer has a valid certificate
// signed by this root certificate. For SSL torrents, all peers are connecting over SSL
// connections. For more information, see the section on ssl-torrents_.
//
//
// The string is not the path to the cert, it's the actual content of the
// certificate.
void set_root_cert(string_view pem);
@ -289,7 +289,7 @@ namespace libtorrent
// to share files with this torrent. A torrent may have more than one
// collection and more than one similar torrents. For more information,
// see `BEP 38`_.
//
//
// .. _`BEP 38`: http://www.bittorrent.org/beps/bep_0038.html
void add_similar_torrent(sha1_hash ih);
void add_collection(string_view c);
@ -352,7 +352,7 @@ namespace libtorrent
// or not. e.g. test/test there's one file and one directory
// and they have the same name.
bool m_multifile:1;
// this is true if the torrent is private. i.e., is should not
// be announced on the dht
bool m_private:1;
@ -377,33 +377,33 @@ namespace libtorrent
// Adds the file specified by ``path`` to the file_storage object. In case ``path``
// refers to a directory, files will be added recursively from the directory.
//
//
// If specified, the predicate ``p`` is called once for every file and directory that
// is encountered. Files for which ``p`` returns true are added, and directories for
// which ``p`` returns true are traversed. ``p`` must have the following signature::
//
//
// bool Pred(std::string const& p);
//
//
// The path that is passed in to the predicate is the full path of the file or
// directory. If no predicate is specified, all files are added, and all directories
// are traversed.
//
//
// The ".." directory is never traversed.
//
//
// The ``flags`` argument should be the same as the flags passed to the `create_torrent`_
// constructor.
TORRENT_EXPORT void add_files(file_storage& fs, std::string const& file
, std::function<bool(std::string)> p, std::uint32_t flags = 0);
TORRENT_EXPORT void add_files(file_storage& fs, std::string const& file
, std::uint32_t flags = 0);
// This function will assume that the files added to the torrent file exists at path
// ``p``, read those files and hash the content and set the hashes in the ``create_torrent``
// object. The optional function ``f`` is called in between every hash that is set. ``f``
// must have the following signature::
//
//
// void Fun(int);
//
//
// The overloads that don't take an ``error_code&`` may throw an exception in case of a
// file error, the other overloads sets the error code to reflect the error, if any.
TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::string const& p
@ -443,7 +443,7 @@ namespace libtorrent
TORRENT_DEPRECATED
TORRENT_EXPORT void add_files(file_storage& fs, std::wstring const& wfile
, std::uint32_t flags = 0);
TORRENT_DEPRECATED
TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::wstring const& p
, std::function<void(int)> f, error_code& ec);
@ -478,7 +478,7 @@ namespace libtorrent
, std::wstring const& p, error_code& ec)
{
set_piece_hashes_deprecated(t, p, detail::nop, ec);
}
}
#endif // TORRENT_NO_DEPRECATE
#endif // TORRENT_USE_WSTRING

View File

@ -60,7 +60,7 @@ namespace libtorrent
// The disk buffer holder acts like a ``unique_ptr`` that frees a disk buffer
// when it's destructed, unless it's released. ``release`` returns the disk
// buffer and transfers ownership and responsibility to free it to the caller.
//
//
// ``get()`` returns the pointer without transferring ownership. If
// this buffer has been released, ``get()`` will return nullptr.
struct TORRENT_EXTRA_EXPORT disk_buffer_holder

View File

@ -150,7 +150,7 @@ namespace libtorrent
// the total number of write operations performed since this
// session was started.
//
//
// The ratio (``blocks_written`` - ``writes``) / ``blocks_written`` represents
// the number of saved write operations per total write operations. i.e. a kind
// of cache hit ratio for the write cahe.

View File

@ -204,20 +204,20 @@ namespace libtorrent
// isn't of the type you request, the accessor will throw
// system_error. You can ask an ``entry`` for its type through the
// ``type()`` function.
//
//
// If you want to create an ``entry`` you give it the type you want it to
// have in its constructor, and then use one of the non-const accessors
// to get a reference which you then can assign the value you want it to
// have.
//
//
// The typical code to get info from a torrent file will then look like
// this:
//
// .. code:: c++
//
//
// entry torrent_file;
// // ...
//
//
// // throws if this is not a dictionary
// entry::dictionary_type const& dict = torrent_file.dict();
// entry::dictionary_type::const_iterator i;
@ -227,23 +227,23 @@ namespace libtorrent
// std::string tracker_url = i->second.string();
// std::cout << tracker_url << "\n";
// }
//
//
//
//
// The following code is equivalent, but a little bit shorter:
//
// .. code:: c++
//
//
// entry torrent_file;
// // ...
//
//
// // throws if this is not a dictionary
// if (entry* i = torrent_file.find_key("announce"))
// {
// std::string tracker_url = i->string();
// std::cout << tracker_url << "\n";
// }
//
//
//
//
// To make it easier to extract information from a torrent file, the
// class torrent_info exists.
integer_type& integer();

View File

@ -34,14 +34,14 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_EXTENSIONS_HPP_INCLUDED
// OVERVIEW
//
//
// libtorrent has a plugin interface for implementing extensions to the protocol.
// These can be general extensions for transferring metadata or peer exchange
// extensions, or it could be used to provide a way to customize the protocol
// to fit a particular (closed) network.
//
//
// In short, the plugin interface makes it possible to:
//
//
// * register extension messages (sent in the extension handshake), see
// extensions_.
// * add data and parse data from the extension handshake.
@ -49,16 +49,16 @@ POSSIBILITY OF SUCH DAMAGE.
// * override or block the handling of standard bittorrent messages.
// * save and restore state via the session state
// * see all alerts that are posted
//
//
// .. _extensions: extension_protocol.html
//
//
// a word of caution
// -----------------
//
//
// Writing your own plugin is a very easy way to introduce serious bugs such as
// dead locks and race conditions. Since a plugin has access to internal
// structures it is also quite easy to sabotage libtorrent's operation.
//
//
// All the callbacks are always called from the libtorrent network thread. In
// case portions of your plugin are called from other threads, typically the main
// thread, you cannot use any of the member functions on the internal structures
@ -67,91 +67,91 @@ POSSIBILITY OF SUCH DAMAGE.
// sure it is not accessed at the same time from the libtorrent thread (through a
// callback). If you need to send out a message from another thread, it is
// advised to use an internal queue, and do the actual sending in ``tick()``.
//
//
// Since the plugin interface gives you easy access to internal structures, it
// is not supported as a stable API. Plugins should be considered specific to a
// specific version of libtorrent. Although, in practice the internals mostly
// don't change that dramatically.
//
//
//
//
// plugin-interface
// ================
//
//
// The plugin interface consists of three base classes that the plugin may
// implement. These are called plugin, torrent_plugin and peer_plugin.
// They are found in the ``<libtorrent/extensions.hpp>`` header.
//
//
// These plugins are instantiated for each session, torrent and possibly each peer,
// respectively.
//
//
// For plugins that only need per torrent state, it is enough to only implement
// ``torrent_plugin`` and pass a constructor function or function object to
// ``session::add_extension()`` or ``torrent_handle::add_extension()`` (if the
// torrent has already been started and you want to hook in the extension at
// run-time).
//
//
// The signature of the function is::
//
//
// std::shared_ptr<torrent_plugin> (*)(torrent_handle const&, void*);
//
//
// The second argument is the userdata passed to ``session::add_torrent()`` or
// ``torrent_handle::add_extension()``.
//
//
// The function should return a ``std::shared_ptr<torrent_plugin>`` which
// may or may not be 0. If it is a nullptr, the extension is simply ignored
// for this torrent. If it is a valid pointer (to a class inheriting
// ``torrent_plugin``), it will be associated with this torrent and callbacks
// will be made on torrent events.
//
//
// For more elaborate plugins which require session wide state, you would
// implement ``plugin``, construct an object (in a ``std::shared_ptr``) and pass
// it in to ``session::add_extension()``.
//
//
// custom alerts
// =============
//
//
// Since plugins are running within internal libtorrent threads, one convenient
// way to communicate with the client is to post custom alerts.
//
//
// The expected interface of any alert, apart from deriving from the alert
// base class, looks like this:
//
//
// .. parsed-literal::
//
//
// static const int alert_type = *<unique alert ID>*;
// virtual int type() const { return alert_type; }
//
//
// virtual std::string message() const;
//
//
// static const int static_category = *<bitmask of alert::category_t flags>*;
// virtual int category() const { return static_category; }
//
//
// virtual char const* what() const { return *<string literal of the name of this alert>*; }
//
//
// The ``alert_type`` is used for the type-checking in ``alert_cast``. It must
// not collide with any other alert. The built-in alerts in libtorrent will
// not use alert type IDs greater than ``user_alert_id``. When defining your
// own alert, make sure it's greater than this constant.
//
//
// ``type()`` is the run-time equivalence of the ``alert_type``.
//
//
// The ``message()`` virtual function is expected to construct a useful
// string representation of the alert and the event or data it represents.
// Something convenient to put in a log file for instance.
//
//
// ``clone()`` is used internally to copy alerts. The suggested implementation
// of simply allocating a new instance as a copy of ``*this`` is all that's
// expected.
//
//
// The static category is required for checking whether or not the category
// for a specific alert is enabled or not, without instantiating the alert.
// The ``category`` virtual function is the run-time equivalence.
//
//
// The ``what()`` virtual function may simply be a string literal of the class
// name of your alert.
//
//
// For more information, see the `alert section`_.
//
//
// .. _`alert section`: reference-Alerts.html
@ -283,16 +283,16 @@ namespace libtorrent
// may choose to ignore this by just returning a default constructed
// ``shared_ptr`` (in which case you don't need to override this member
// function).
//
//
// If you need an extension to the peer connection (which most plugins do) you
// are supposed to return an instance of your peer_plugin class. Which in
// turn will have its hook functions called on event specific to that peer.
//
//
// The ``peer_connection_handle`` will be valid as long as the ``shared_ptr``
// is being held by the torrent object. So, it is generally a good idea to not
// keep a ``shared_ptr`` to your own peer_plugin. If you want to keep references
// to it, use ``weak_ptr``.
//
//
// If this function throws an exception, the connection will be closed.
virtual std::shared_ptr<peer_plugin> new_connection(peer_connection_handle const&)
{ return std::shared_ptr<peer_plugin>(); }
@ -314,7 +314,7 @@ namespace libtorrent
// will have this hook function called, and the standard handler will also not be
// invoked. So, returning true effectively overrides the standard behavior of
// pause or unpause.
//
//
// Note that if you call ``pause()`` or ``resume()`` on the torrent from your
// handler it will recurse back into your handler, so in order to invoke the
// standard handler, you have to keep your own state on whether you want standard
@ -324,7 +324,7 @@ namespace libtorrent
// This function is called when the initial files of the torrent have been
// checked. If there are no files to check, this function is called immediately.
//
//
// i.e. This function is always called when the torrent is in a state where it
// can start downloading.
virtual void on_files_checked() {}
@ -392,7 +392,7 @@ namespace libtorrent
// called when the extension handshake from the other end is received
// if this returns false, it means that this extension isn't
// supported by this peer. It will result in this peer_plugin
// being removed from the peer_connection and destructed.
// being removed from the peer_connection and destructed.
// this is not called for web seeds
virtual bool on_extension_handshake(bdecode_node const&) { return true; }

View File

@ -50,7 +50,7 @@ namespace libtorrent
// other. This is the main building block in making magnet links work.
// This extension is enabled by default unless explicitly disabled in
// the session constructor.
//
//
// This can either be passed in the add_torrent_params::extensions field, or
// via torrent_handle::add_extension().
TORRENT_EXPORT std::shared_ptr<torrent_plugin> create_ut_metadata_plugin(torrent_handle const&, void*);

View File

@ -49,7 +49,7 @@ namespace libtorrent
// the swarm stay well connected and peers aware of more peers in the
// swarm. This extension is enabled by default unless explicitly disabled in
// the session constructor.
//
//
// This can either be passed in the add_torrent_params::extensions field, or
// via torrent_handle::add_extension().
TORRENT_EXPORT std::shared_ptr<torrent_plugin> create_ut_pex_plugin(torrent_handle const&, void*);

View File

@ -51,9 +51,9 @@ namespace libtorrent
// ``open_mode`` is a bitmask of the file flags this file is currently opened with. These
// are the flags used in the ``file::open()`` function. This enum is defined as a member
// of the ``file`` class.
//
//
// ::
//
//
// enum
// {
// read_only = 0,
@ -66,7 +66,7 @@ namespace libtorrent
// random_access = 32,
// lock_file = 64,
// };
//
//
// Note that the read/write mode is not a bitmask. The two least significant bits are used
// to represent the read/write mode. Those bits can be masked out using the ``rw_mask`` constant.
int open_mode;

View File

@ -251,32 +251,32 @@ namespace libtorrent
// of this file_storage object or any copy of it. The same thing applies
// to ``filehash``, which is an optional pointer to a 20 byte binary
// SHA-1 hash of the file.
//
//
// if ``filename`` is nullptr, the filename from ``path`` is used and not
// borrowed. In this case ``filename_len`` is ignored.
//
//
// The ``path`` argument is the full path (in the torrent file) to
// the file to add. Note that this is not supposed to be an absolute
// path, but it is expected to include the name of the torrent as the
// first path element.
//
//
// ``file_size`` is the size of the file in bytes.
//
//
// The ``file_flags`` argument sets attributes on the file. The file
// attributes is an extension and may not work in all bittorrent clients.
//
// For possible file attributes, see file_storage::flags_t.
//
//
// The ``mtime`` argument is optional and can be set to 0. If non-zero,
// it is the posix time of the last modification time of this file.
//
//
// ``symlink_path`` is the path the file is a symlink to. To make this a
// symlink you also need to set the file_storage::flag_symlink file flag.
//
// If more files than one are added, certain restrictions to their paths
// apply. In a multi-file file storage (torrent), all files must share
// the same root directory.
//
//
// That is, the first path element of all files must be the same.
// This shared path element is also set to the name of the torrent. It
// can be changed by calling ``set_name``.
@ -317,9 +317,9 @@ namespace libtorrent
//
// 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(int piece, std::int64_t offset
, int size) const;
@ -437,19 +437,19 @@ namespace libtorrent
// These functions are used to query attributes of files at
// a given index.
//
//
// The ``hash()`` is a sha-1 hash of the file, or 0 if none was
// provided in the torrent file. This can potentially be used to
// join a bittorrent network with other file sharing networks.
//
//
// The ``mtime()`` is the modification time is the posix
// time when a file was last modified when the torrent
// was created, or 0 if it was not included in the torrent file.
//
//
// ``file_path()`` returns the full path to a file.
//
//
// ``file_size()`` returns the size of a file.
//
//
// ``pad_file_at()`` returns true if the file at the given
// index is a pad-file.
//

View File

@ -52,7 +52,7 @@ namespace libtorrent
// The constructor takes a ``char const*`` that should point to a string constant containing
// exactly two characters. These are the characters that should be unique for your client. Make
// sure not to clash with anybody else. Here are some taken id's:
//
//
// +----------+-----------------------+
// | id chars | client |
// +==========+=======================+
@ -70,9 +70,9 @@ namespace libtorrent
// +----------+-----------------------+
// | 'XT' | Xan Torrent |
// +----------+-----------------------+
//
//
// There's an informal directory of client id's here_.
//
//
// .. _here: http://wiki.theory.org/BitTorrentSpecification#peer_id
//
// The ``major``, ``minor``, ``revision`` and ``tag`` parameters are used to identify the

View File

@ -64,19 +64,19 @@ extern "C" {
namespace libtorrent
{
// this is a SHA-1 hash class.
//
//
// You use it by first instantiating it, then call ``update()`` to feed it
// with data. i.e. you don't have to keep the entire buffer of which you want to
// create the hash in memory. You can feed the hasher parts of it at a time. When
// You have fed the hasher with all the data, you call ``final()`` and it
// will return the sha1-hash of the data.
//
//
// The constructor that takes a ``char const*`` and an integer will construct the
// sha1 context and feed it the data passed in.
//
//
// If you want to reuse the hasher object once you have created a hash, you have to
// call ``reset()`` to reinitialize it.
//
//
// The built-in software version of sha1-algorithm was implemented
// by Steve Reid and released as public domain.
// For more info, see ``src/sha1.cpp``.

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
struct http_connection;
class entry;
class http_parser;

View File

@ -94,7 +94,7 @@ namespace detail
}
inline std::uint16_t plus_one(std::uint16_t val) { return val + 1; }
template<class Addr>
Addr minus_one(Addr const& a)
{
@ -270,13 +270,13 @@ struct TORRENT_EXPORT ip_filter
// ip addresses that will be marked with the given flags. The ``flags``
// can currently be 0, which means allowed, or ``ip_filter::blocked``, which
// means disallowed.
//
//
// precondition:
// ``first.is_v4() == last.is_v4() && first.is_v6() == last.is_v6()``
//
//
// postcondition:
// ``access(x) == flags`` for every ``x`` in the range [``first``, ``last``]
//
//
// This means that in a case of overlapping ranges, the last one applied takes
// precedence.
void add_rule(address first, address last, std::uint32_t flags);

View File

@ -109,7 +109,7 @@ namespace dht
// must be stored as a string in peers["n"]
//
// If the scrape parameter is true, you should fill these keys:
//
//
// peers["BFpe"] - with the standard bit representation of a
// 256 bloom filter containing the downloaders
// peers["BFsd"] - with the standard bit representation of a

View File

@ -51,12 +51,12 @@ namespace libtorrent
struct lazy_entry;
// This function decodes bencoded_ data.
//
//
// .. _bencoded: http://wiki.theory.org/index.php/BitTorrentSpecification
//
//
// The lazy bdecoder and lazy_entry has been deprecated in favour of
// bdecode_node and its corresponding bdecode() function.
//
//
// *lazy* refers to the fact that it doesn't copy any actual data out of the
// bencoded buffer. It builds a tree of ``lazy_entry`` which has pointers into
// the bencoded buffer. This makes it very fast and efficient. On top of that,
@ -75,7 +75,7 @@ namespace libtorrent
// upper limit for desktop computers. Very few torrents have more items in them.
// The limit corresponds to about 25 MB, which might be a bit much for embedded
// systems.
//
//
// ``start`` and ``end`` defines the bencoded buffer to be decoded. ``ret`` is
// the ``lazy_entry`` which is filled in with the whole decoded tree. ``ec``
// is a reference to an ``error_code`` which is set to describe the error encountered

View File

@ -45,9 +45,9 @@ namespace libtorrent
// Generates a magnet URI from the specified torrent. If the torrent
// handle is invalid, an empty string is returned.
//
//
// For more information about magnet links, see magnet-links_.
//
//
std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle);
std::string TORRENT_EXPORT make_magnet_uri(torrent_info const& info);

View File

@ -88,7 +88,7 @@ namespace libtorrent
// ``disallow()`` and ``allow()`` adds and removes a peer class to be
// removed from new peers based on socket type.
//
//
// The ``peer_class`` argument cannot be greater than 31. The bitmasks representing
// peer classes in the ``peer_class_type_filter`` are 32 bits.
void disallow(socket_type_t st, int peer_class)

View File

@ -91,7 +91,7 @@ namespace libtorrent
// means that this peer supports the
// `extension protocol`__.
//
//
// __ extension_protocol.html
supports_extensions = 0x10,

View File

@ -45,7 +45,7 @@ namespace libtorrent
// fields in an add_torrent_params object. This object can then be used to add
// the actual torrent_info object to and pass to session::add_torrent() or
// session::async_add_torrent().
//
//
// If the client wants to override any field that was loaded from the resume
// data, e.g. save_path, those fields must be changed after loading resume
// data but before adding the torrent.

View File

@ -58,7 +58,7 @@ namespace libtorrent
// can set the session settings to pre set settings for other environments.
// These can be used for the basis, and should be tweaked to fit your needs
// better.
//
//
// ``min_memory_usage`` returns settings that will use the minimal amount of
// RAM, at the potential expense of upload and download performance. It
// adjusts the socket buffer sizes, disables the disk cache, lowers the send
@ -68,10 +68,10 @@ namespace libtorrent
// to disk at any given time. It lowers the max number of peers in the peer
// list for torrents. It performs multiple smaller reads when it hashes
// pieces, instead of reading it all into memory before hashing.
//
//
// This configuration is intended to be the starting point for embedded
// devices. It will significantly reduce memory usage.
//
//
// ``high_performance_seed`` returns settings optimized for a seed box,
// serving many peers and that doesn't do any downloading. It has a 128 MB
// disk cache and has a limit of 400 files in its file pool. It support fast
@ -170,7 +170,7 @@ namespace libtorrent
// ``session_handle::apply_settings()`` member function. To change one or more
// configuration options, create a settings_pack. object and fill it with
// the settings to be set and pass it in to ``session::apply_settings()``.
//
//
// see apply_settings().
class TORRENT_EXPORT session : public session_handle
{
@ -213,7 +213,7 @@ namespace libtorrent
// starting the session and configuring it, you can pass in a
// settings_pack object. Its settings will take effect before the session
// starts up.
//
//
// The ``flags`` parameter can be used to start default features (upnp &
// nat-pmp) and default plugins (ut_metadata, ut_pex and smart_ban). The
// default is to start those features. If you do not want them to start,
@ -239,7 +239,7 @@ namespace libtorrent
// to run multiple sessions on a single io_service, or low resource
// systems where additional threads are expensive and sharing an
// io_service with other events is fine.
//
//
// .. warning::
// The session object does not cleanly terminate with an external
// ``io_service``. The ``io_service::run()`` call _must_ have returned
@ -330,7 +330,7 @@ namespace libtorrent
// call. The ``session_proxy`` does not have any operations on it (since
// the session is being closed down, no operations are allowed on it).
// The only valid operation is calling the destructor::
//
//
// class session_proxy
// {
// public:

View File

@ -40,15 +40,15 @@ POSSIBILITY OF SUCH DAMAGE.
#include <memory>
// OVERVIEW
//
//
// You have some control over session configuration through the session::apply_settings()
// member function. To change one or more configuration options, create a settings_pack.
// object and fill it with the settings to be set and pass it in to session::apply_settings().
//
//
// You have control over proxy and authorization settings and also the user-agent
// that will be sent to the tracker. The user-agent will also be used to identify the
// client with other peers.
//
//
namespace libtorrent
{
namespace aux { struct session_impl; struct session_settings; }
@ -74,9 +74,9 @@ namespace libtorrent
// enum values. These values are passed in to the ``set_str()``,
// ``set_int()``, ``set_bool()`` functions, to specify the setting to
// change.
//
//
// These are the available settings:
//
//
// .. include:: settings-ref.rst
//
struct TORRENT_EXPORT settings_pack
@ -137,7 +137,7 @@ namespace libtorrent
// file specified will be created and truncated to the disk cache size
// (``cache_size``). Any existing file with the same name will be
// replaced.
//
//
// This feature requires the ``mmap`` system call, on systems that
// don't have ``mmap`` this setting is ignored.
mmap_cache,
@ -166,24 +166,24 @@ namespace libtorrent
// multiple ports. Binding to port 0 will make the operating system
// pick the port. The default is "0.0.0.0:6881,[::]:6881", which binds
// to all interfaces on port 6881.
//
//
// a port that has an "s" suffix will accept SSL connections. (note
// that SSL sockets are not enabled by default).
//
//
// if binding fails, the listen_failed_alert is posted. If or once a
// socket binding succeeds, the listen_succeeded_alert is posted. There
// may be multiple failures before a success.
//
//
// For example:
// ``[::1]:8888`` - will only accept connections on the IPv6 loopback
// address on port 8888.
//
//
// ``eth0:4444,eth1:4444`` - will accept connections on port 4444 on
// any IP address bound to device ``eth0`` or ``eth1``.
//
//
// ``[::]:0s`` - will accept SSL connections on a port chosen by the
// OS. And not accept non-SSL connections at all.
//
//
// .. note::
// The current support for opening arbitrary UDP sockets is limited.
// In this version of libtorrent, there will only ever be two UDP
@ -201,7 +201,7 @@ namespace libtorrent
// sets the i2p_ SAM bridge to connect to. set the port with the
// ``i2p_port`` setting.
//
//
// .. _i2p: http://www.i2p2.de
i2p_hostname,
@ -214,7 +214,7 @@ namespace libtorrent
// to the DHT node (if it's enabled) as back-up nodes in case we don't
// know of any. This setting will contain one or more bootstrap nodes
// by default.
//
//
// Changing these after the DHT has been started may not have any
// effect until the DHT is restarted.
dht_bootstrap_nodes,
@ -334,7 +334,7 @@ namespace libtorrent
// behavior is as defined by the multi tracker specification. It
// defaults to false, which is the same behavior previous versions of
// libtorrent has had as well.
//
//
// ``announce_to_all_tiers`` also controls how multi tracker torrents
// are treated. When this is set to true, one tracker from each tier
// is announced to. This is the uTorrent behavior. This is false by
@ -492,7 +492,7 @@ namespace libtorrent
// tracker proxy). Since no incoming connections are accepted,
// NAT-PMP, UPnP, DHT and local peer discovery are all turned off when
// this setting is enabled.
//
//
// If you're using I2P, it might make sense to enable anonymous mode
// as well.
anonymous_mode,
@ -636,7 +636,7 @@ namespace libtorrent
// Starts and stops the UPnP service. When started, the listen port
// and the DHT port are attempted to be forwarded on local UPnP router
// devices.
//
//
// The upnp object returned by ``start_upnp()`` can be used to add and
// remove arbitrary port mappings. Mapping status is returned through
// the portmap_alert and the portmap_error_alert. The object will be
@ -646,7 +646,7 @@ namespace libtorrent
// Starts and stops the NAT-PMP service. When started, the listen port
// and the DHT port are attempted to be forwarded on the router
// through NAT-PMP.
//
//
// The natpmp object returned by ``start_natpmp()`` can be used to add
// and remove arbitrary port mappings. Mapping status is returned
// through the portmap_alert and the portmap_error_alert. The object
@ -844,7 +844,7 @@ namespace libtorrent
// ``suggest_mode`` controls whether or not libtorrent will send out
// suggest messages to create a bias of its peers to request certain
// pieces. The modes are:
//
//
// * ``no_piece_suggestions`` which is the default and will not send
// out suggest messages.
// * ``suggest_read_cache`` which will send out suggest messages for
@ -870,13 +870,13 @@ namespace libtorrent
// and snappy seeding performance, set this fairly high, to at least
// fit a few blocks. This is essentially the initial window size which
// will determine how fast we can ramp up the send rate
//
//
// if the send buffer has fewer bytes than ``send_buffer_watermark``,
// we'll read another 16kB block onto it. If set too small, upload
// rate capacity will suffer. If set too high, memory will be wasted.
// The actual watermark may be lower than this in case the upload rate
// is low, this is the upper limit.
//
//
// the current upload rate to a peer is multiplied by this factor to
// get the send buffer watermark. The factor is specified as a
// percentage. i.e. 50 -> 0.5 This product is clamped to the
@ -891,17 +891,17 @@ namespace libtorrent
// ``choking_algorithm`` specifies which algorithm to use to determine
// which peers to unchoke.
//
//
// The options for choking algorithms are:
//
//
// * ``fixed_slots_choker`` is the traditional choker with a fixed
// number of unchoke slots (as specified by
// ``session::set_max_uploads()``).
//
//
// * ``rate_based_choker`` opens up unchoke slots based on the upload
// rate achieved to peers. The more slots that are opened, the
// marginal upload rate required to open up another slot increases.
//
//
// * ``bittyrant_choker`` attempts to optimize download rate by
// finding the reciprocation rate of each peer individually and
// prefers peers that gives the highest *return on investment*. It
@ -911,21 +911,21 @@ namespace libtorrent
// (``session::set_upload_rate_limit()``). For more information
// about this choker, see the paper_. This choker is not fully
// implemented nor tested.
//
//
// .. _paper: http://bittyrant.cs.washington.edu/#papers
//
//
// ``seed_choking_algorithm`` controls the seeding unchoke behavior.
// The available options are:
//
//
// * ``round_robin`` which round-robins the peers that are unchoked
// when seeding. This distributes the upload bandwidht uniformly and
// fairly. It minimizes the ability for a peer to download everything
// without redistributing it.
//
//
// * ``fastest_upload`` unchokes the peers we can send to the fastest.
// This might be a bit more reliable in utilizing all available
// capacity.
//
//
// * ``anti_leech`` prioritizes peers who have just started or are
// just about to finish the download. The intention is to force
// peers in the middle of the download to trade with each other.
@ -940,7 +940,7 @@ namespace libtorrent
// to -1, the cache size is automatically set to the amount of
// physical RAM available in the machine divided by 8. If the amount
// of physical RAM cannot be determined, it's set to 1024 (= 16 MiB).
//
//
// Disk buffers are allocated using a pool allocator, the number of
// blocks that are allocated at a time when the pool needs to grow can
// be specified in ``cache_buffer_chunk_size``. Lower numbers saves
@ -950,7 +950,7 @@ namespace libtorrent
// usage. It defaults to 0. ``cache_expiry`` is the number of seconds
// from the last cached write to a piece in the write cache, to when
// it's forcefully flushed to disk. Default is 60 second.
//
//
// On 32 bit builds, the effective cache size will be limited to 3/4 of
// 2 GiB to avoid exceeding the virtual address space limit.
cache_size,
@ -959,7 +959,7 @@ namespace libtorrent
// determines how files are opened when they're in read only mode
// versus read and write mode. The options are:
//
//
// enable_os_cache
// This is the default and files are opened normally, with the OS
// caching reads and writes.
@ -970,7 +970,7 @@ namespace libtorrent
// potentially evict all other processes' cache by simply handling
// high throughput and large files. If libtorrent's read cache is
// disabled, enabling this may reduce performance.
//
//
// One reason to disable caching is that it may help the operating
// system from growing its file cache indefinitely.
disk_io_write_mode,
@ -981,13 +981,13 @@ namespace libtorrent
// based on local port. when binding outgoing connections to specific
// ports, ``num_outgoing_ports`` is the size of the range. It should
// be more than a few
//
//
// .. warning:: setting outgoing ports will limit the ability to keep
// multiple connections to the same client, even for different
// torrents. It is not recommended to change this setting. Its main
// purpose is to use as an escape hatch for cheap routers with QoS
// capability but can only classify flows based on port numbers.
//
//
// It is a range instead of a single port because of the problems with
// failing to reconnect to peers if a previous socket to that peer and
// port is in ``TIME_WAIT`` state.
@ -999,7 +999,7 @@ namespace libtorrent
// this is ``0x0`` (no marking). One potentially useful TOS mark is
// ``0x20``, this represents the *QBone scavenger service*. For more
// details, see QBSS_.
//
//
// .. _`QBSS`: http://qbone.internet2.edu/qbss/
peer_tos,
@ -1020,32 +1020,32 @@ namespace libtorrent
// then there will be 2 downloading torrents and 4 seeding torrents
// active. Torrents that are not auto managed are not counted against
// these limits.
//
//
// ``active_checking`` is the limit of number of simultaneous checking
// torrents.
//
//
// ``active_limit`` is a hard limit on the number of active (auto
// managed) torrents. This limit also applies to slow torrents.
//
//
// ``active_dht_limit`` is the max number of torrents to announce to
// the DHT. By default this is set to 88, which is no more than one
// DHT announce every 10 seconds.
//
//
// ``active_tracker_limit`` is the max number of torrents to announce
// to their trackers. By default this is 360, which is no more than
// one announce every 5 seconds.
//
//
// ``active_lsd_limit`` is the max number of torrents to announce to
// the local network over the local service discovery protocol. By
// default this is 80, which is no more than one announce every 5
// seconds (assuming the default announce interval of 5 minutes).
//
//
// You can have more torrents *active*, even though they are not
// announced to the DHT, lsd or their tracker. If some peer knows
// about you for any reason and tries to connect, it will still be
// accepted, unless the torrent is paused, which means it won't accept
// any connections.
//
//
// ``active_loaded_limit`` is the number of torrents that are allowed
// to be *loaded* at any given time. Note that a torrent can be active
// even though it's not loaded. If an unloaded torrents finds a peer
@ -1077,7 +1077,7 @@ namespace libtorrent
// torrents that are paused, are scraped regularly in order to keep
// track of their downloader/seed ratio. This ratio is used to
// determine which torrents to seed and which to pause.
//
//
// ``auto_scrape_min_interval`` is the minimum number of seconds
// between any automatic scrape (regardless of torrent). In case there
// are a large number of paused auto managed torrents, this puts a
@ -1092,7 +1092,7 @@ namespace libtorrent
// 90% of this limit, and once the size hits the limit, peers are no
// longer added to the list. If this limit is set to 0, there is no
// limit on how many peers we'll keep in the peer list.
//
//
// ``max_paused_peerlist_size`` is the max peer list size used for
// torrents that are paused. This default to the same as
// ``max_peerlist_size``, but can be used to save memory for paused
@ -1151,7 +1151,7 @@ namespace libtorrent
// essentially the same thing as disabling read cache. The number of
// blocks read into the read cache is always capped by the piece
// boundary.
//
//
// When a piece in the write cache has ``write_cache_line_size``
// contiguous blocks in it, they will be flushed. Setting this to 1
// effectively disables the write cache.
@ -1161,10 +1161,10 @@ namespace libtorrent
// ``optimistic_disk_retry`` is the number of seconds from a disk
// write errors occur on a torrent until libtorrent will take it out
// of the upload mode, to test if the error condition has been fixed.
//
//
// libtorrent will only do this automatically for auto managed
// torrents.
//
//
// You can explicitly take a torrent out of upload only mode using
// set_upload_mode().
optimistic_disk_retry,
@ -1219,12 +1219,12 @@ namespace libtorrent
// more altruistic while finding the true reciprocation rate, if it's
// set too low, you'll be too stingy and waste finding the true
// reciprocation rate.
//
//
// ``increase_est_reciprocation_rate`` specifies how many percent the
// estimated reciprocation rate should be increased by each unchoke
// interval a peer is still choking us back. This defaults to 20%.
// This only applies to the BitTyrant choker.
//
//
// ``decrease_est_reciprocation_rate`` specifies how many percent the
// estimated reciprocation rate should be decreased by each unchoke
// interval a peer unchokes us. This default to 3%. This only applies
@ -1264,14 +1264,14 @@ namespace libtorrent
// bytes per second. The local rates refer to peers on the local
// network. By default peers on the local network are not rate
// limited.
//
//
// These rate limits are only used for local peers (peers within the
// same subnet as the client itself) and it is only used when
// ``ignore_limits_on_local_network`` is set to true (which it is by
// default). These rate limits default to unthrottled, but can be
// useful in case you want to treat local peers preferentially, but
// not quite unthrottled.
//
//
// A value of 0 means unlimited.
upload_rate_limit,
download_rate_limit,
@ -1344,7 +1344,7 @@ namespace libtorrent
// than this value. A connection times out when every packet in a
// window is lost, or when a packet is lost twice in a row (i.e. the
// resent packet is lost as well).
//
//
// The shorter the timeout is, the faster the connection will recover
// from this situation, assuming the RTT is low enough.
// ``utp_syn_resends`` is the number of SYN packets that are sent (and
@ -1447,7 +1447,7 @@ namespace libtorrent
aio_max,
// .. note:: This is not implemented
//
//
// ``network_threads`` is the number of threads to use to call
// ``async_write_some`` (i.e. send) on peer connection sockets. When
// seeding at extremely high rates, this may become a bottleneck, and
@ -1473,9 +1473,9 @@ namespace libtorrent
// retrying failing trackers. This value determines *x* in the
// following formula, determining the number of seconds to wait until
// the next retry:
//
//
// delay = 5 + 5 * x / 100 * fails^2
//
//
// This setting may be useful to make libtorrent more or less
// aggressive in hitting trackers.
tracker_backoff,
@ -1531,7 +1531,7 @@ namespace libtorrent
// respectively. see enc_policy enum for the available options.
// Keep in mind that protocol encryption degrades performance in
// several respects:
//
//
// 1. It prevents "zero copy" disk buffers being sent to peers, since
// each peer needs to mutate the data (i.e. encrypt it) the data
// must be copied per peer connection rather than sending the same
@ -1567,7 +1567,7 @@ namespace libtorrent
// sets the i2p_ SAM bridge port to connect to. set the hostname with
// the ``i2p_hostname`` setting.
//
//
// .. _i2p: http://www.i2p2.de
i2p_port,

View File

@ -67,13 +67,13 @@ POSSIBILITY OF SUCH DAMAGE.
// general conventions of bittorrent clients, mimicking the original file layout
// when the torrent was created. The libtorrent user may define a custom
// storage to store piece data in a different way.
//
//
// A custom storage implementation must derive from and implement the
// storage_interface. You must also provide a function that constructs the
// custom storage object and provide this function to the add_torrent() call
// via add_torrent_params. Either passed in to the constructor or by setting
// the add_torrent_params::storage field.
//
//
// This is an example storage implementation that stores all pieces in a
// ``std::map``, i.e. in RAM. It's not necessarily very useful in practice, but
// illustrates the basics of implementing a custom storage.
@ -128,7 +128,7 @@ POSSIBILITY OF SUCH DAMAGE.
// }
// virtual bool release_files() { return false; }
// virtual bool delete_files() { return false; }
//
//
// std::map<int, std::vector<char> > m_file_data;
// file_storage m_files;
// };
@ -181,16 +181,16 @@ namespace libtorrent
// data in RAM, or in some optimized order on disk (the order the pieces are
// received for instance), or saving multifile torrents in a single file in
// order to be able to take advantage of optimized disk-I/O.
//
//
// It is also possible to write a thin class that uses the default storage
// but modifies some particular behavior, for instance encrypting the data
// before it's written to disk, and decrypting it when it's read again.
//
//
// The storage interface is based on pieces. Avery read and write operation
// happens in the piece-space. Each piece fits 'piece_size' number
// of bytes. All access is done by writing and reading whole or partial
// pieces.
//
//
// libtorrent comes with two built-in storage implementations;
// ``default_storage`` and ``disabled_storage``. Their constructor functions
// are called default_storage_constructor() and
@ -232,12 +232,12 @@ namespace libtorrent
// allocated buffer can be assumed to fit a fully page aligned number of
// bytes though. This is useful when reading and writing the last piece
// of a file in unbuffered mode.
//
//
// The ``offset`` is aligned to 16 kiB boundaries *most of the time*, but
// there are rare exceptions when it's not. Specifically if the read
// cache is disabled/or full and a peer requests unaligned data. Most
// clients request aligned data.
//
//
// The number of bytes read or written should be returned, or -1 on
// error. If there's an error, the ``storage_error`` must be filled out
// to represent the error that occurred.
@ -250,7 +250,7 @@ namespace libtorrent
// storage for a torrent. It should return true if any of the files that
// is used in this storage exists on disk. If so, the storage will be
// checked for existing pieces before starting the download.
//
//
// If an error occurs, ``storage_error`` should be set to reflect it.
virtual bool has_any_file(storage_error& ec) = 0;
@ -263,12 +263,12 @@ namespace libtorrent
// This function should move all the files belonging to the storage to
// the new save_path. The default storage moves the single file or the
// directory of the torrent.
//
//
// Before moving the files, any open file handles may have to be closed,
// like ``release_files()``.
//
//If an error occurs, ``storage_error`` should be set to reflect it.
//
//
// returns one of:
// | no_error = 0
// | fatal_disk_error = -1
@ -280,15 +280,15 @@ namespace libtorrent
// This function should verify the resume data ``rd`` with the files
// on disk. If the resume data seems to be up-to-date, return true. If
// not, set ``error`` to a description of what mismatched and return false.
//
//
// The default storage may compare file sizes and time stamps of the files.
//
//
// If an error occurs, ``storage_error`` should be set to reflect it.
//
//
// This function should verify the resume data ``rd`` with the files
// on disk. If the resume data seems to be up-to-date, return true. If
// not, set ``error`` to a description of what mismatched and return false.
//
//
// If the ``links`` pointer is non-empty, it has the same number
// of elements as there are files. Each element is either empty or contains
// the absolute path to a file identical to the corresponding file in this
@ -301,15 +301,15 @@ namespace libtorrent
// This function should release all the file handles that it keeps open
// to files belonging to this storage. The default implementation just
// calls file_pool::release_files().
//
//
// If an error occurs, ``storage_error`` should be set to reflect it.
//
//
virtual void release_files(storage_error& ec) = 0;
// Rename file with index ``index`` to the name ``new_filename``.
//
//
// If an error occurs, ``storage_error`` should be set to reflect it.
//
//
virtual void rename_file(int index, std::string const& new_filename
, storage_error& ec) = 0;
@ -317,12 +317,12 @@ namespace libtorrent
// The ``options`` parameter specifies whether to delete all files or just
// the partfile. ``options`` are set to the same value as the options
// passed to session::remove_torrent().
//
//
// If an error occurs, ``storage_error`` should be set to reflect it.
//
//
// The ``disk_buffer_pool`` is used to allocate and free disk buffers. It
// has the following members::
//
//
// struct disk_buffer_pool : boost::noncopyable
// {
// char* allocate_buffer(char const* category);
@ -335,21 +335,21 @@ namespace libtorrent
//
// void release_memory();
// };
//
//
virtual void delete_files(int options, storage_error& ec) = 0;
#ifndef TORRENT_NO_DEPRECATE
// This function is called each time a file is completely downloaded. The
// storage implementation can perform last operations on a file. The file
// will not be opened for writing after this.
//
//
// ``index`` is the index of the file that completed.
//
//
// On windows the default storage implementation clears the sparse file
// flag on the specified file.
//
// If an error occurs, ``storage_error`` should be set to reflect it.
//
//
virtual void finalize_file(int, storage_error&) {}
#endif

View File

@ -184,7 +184,7 @@ namespace libtorrent
// the download speed class this piece falls into.
// this is used internally to cluster peers of the same
// speed class together when requesting blocks.
//
//
// set to either ``fast``, ``medium``, ``slow`` or ``none``. It tells
// which download rate category the peers downloading this piece falls
// into. ``none`` means that no peer is currently downloading any part of
@ -202,7 +202,7 @@ namespace libtorrent
// You will usually have to store your torrent handles somewhere, since it's
// the object through which you retrieve information about the torrent and
// aborts the torrent.
//
//
// .. warning::
// Any member function that returns a value or fills in a value has to be
// made synchronously. This means it has to wait for the main thread to
@ -212,19 +212,19 @@ namespace libtorrent
// try to do it in as few calls as possible. You can get most of the
// interesting information about a torrent from the
// torrent_handle::status() call.
//
//
// The default constructor will initialize the handle to an invalid state.
// Which means you cannot perform any operation on it, unless you first
// assign it a valid handle. If you try to perform any operation on an
// uninitialized handle, it will throw ``invalid_handle``.
//
//
// .. warning::
// All operations on a torrent_handle may throw system_error
// exception, in case the handle is no longer referring to a torrent.
// There is one exception is_valid() will never throw. Since the torrents
// are processed by a background thread, there is no guarantee that a
// handle will remain valid between two calls.
//
//
struct TORRENT_EXPORT torrent_handle
{
// TODO: 3 consider replacing all the setters and getters for pause,
@ -272,11 +272,11 @@ namespace libtorrent
// This function starts an asynchronous read operation of the specified
// piece from this torrent. You must have completed the download of the
// specified piece before calling this function.
//
//
// When the read operation is completed, it is passed back through an
// alert, read_piece_alert. Since this alert is a response to an explicit
// call, it will always be posted, regardless of the alert mask.
//
//
// Note that if you read multiple pieces, the read operations are not
// guaranteed to finish in the same order as you initiated them.
void read_piece(int piece) const;
@ -335,7 +335,7 @@ namespace libtorrent
// Some information in there is relatively expensive to calculate, and if
// you're not interested in it (and see performance issues), you can
// filter them out.
//
//
// By default everything is included. The flags you can use to decide
// what to *include* are defined in the status_flags_t enum.
torrent_status status(std::uint32_t flags = 0xffffffff) const;
@ -356,23 +356,23 @@ namespace libtorrent
// prioritized over pieces with a deadline further ahead in time. The
// deadline (and flags) of a piece can be changed by calling this
// function again.
//
//
// The ``flags`` parameter can be used to ask libtorrent to send an alert
// once the piece has been downloaded, by passing alert_when_available.
// When set, the read_piece_alert alert will be delivered, with the piece
// data, when it's downloaded.
//
//
// If the piece is already downloaded when this call is made, nothing
// happens, unless the alert_when_available flag is set, in which case it
// will do the same thing as calling read_piece() for ``index``.
//
//
// ``deadline`` is the number of milliseconds until this piece should be
// completed.
//
//
// ``reset_piece_deadline`` removes the deadline from the piece. If it
// hasn't already been downloaded, it will no longer be considered a
// priority.
//
//
// ``clear_piece_deadlines()`` removes deadlines on all pieces in
// the torrent. As if reset_piece_deadline() was called on all pieces.
void set_piece_deadline(int index, int deadline, int flags = 0) const;
@ -384,18 +384,18 @@ namespace libtorrent
// torrent determines how much bandwidth its peers are assigned when
// distributing upload and download rate quotas. A high number gives more
// bandwidth. The priority must be within the range [0, 255].
//
//
// The default priority is 0, which is the lowest priority.
//
//
// To query the priority of a torrent, use the
// ``torrent_handle::status()`` call.
//
//
// Torrents with higher priority will not necessarily get as much
// bandwidth as they can consume, even if there's is more quota. Other
// peers will still be weighed in when bandwidth is being distributed.
// With other words, bandwidth is not distributed strictly in order of
// priority, but the priority is used as a weight.
//
//
// Peers whose Torrent has a higher priority will take precedence when
// distributing unchoke slots. This is a strict prioritization where
// every interested peer on a high priority torrent will be unchoked
@ -432,7 +432,7 @@ namespace libtorrent
// not very cheap. Its complexity is *O(n + mj)*. Where *n* is the number
// of files, *m* is the number of downloading pieces and *j* is the
// number of blocks in a piece.
//
//
// The ``flags`` parameter can be used to specify the granularity of the
// file progress. If left at the default value of 0, the progress will be
// as accurate as possible, but also more expensive to calculate. If
@ -465,12 +465,12 @@ namespace libtorrent
// one returned from ``trackers()`` and will replace it. If you want an
// immediate effect, you have to call force_reannounce(). See
// announce_entry.
//
//
// ``add_tracker()`` will look if the specified tracker is already in the
// set. If it is, it doesn't do anything. If it's not in the current set
// of trackers, it will insert it in the tier specified in the
// announce_entry.
//
//
// The updated set of trackers will be saved in the resume data, and when
// a torrent is started with resume data, the trackers from the resume
// data will replace the original ones.
@ -489,7 +489,7 @@ namespace libtorrent
// ``url_seeds()`` return a set of the url seeds currently in this
// torrent. Note that urls that fails may be removed automatically from
// the list.
//
//
// See http-seeding_ for more information.
void add_url_seed(std::string const& url) const;
void remove_url_seed(std::string const& url) const;
@ -497,7 +497,7 @@ namespace libtorrent
// These functions are identical as the ``*_url_seed()`` variants, but
// they operate on `BEP 17`_ web seeds instead of `BEP 19`_.
//
//
// See http-seeding_ for more information.
void add_http_seed(std::string const& url) const;
void remove_http_seed(std::string const& url) const;
@ -546,10 +546,10 @@ namespace libtorrent
// connected) peers. Torrents may be paused automatically if there is a
// file error (e.g. disk full) or something similar. See
// file_error_alert.
//
//
// To know if a torrent is paused or not, call
// ``torrent_handle::status()`` and inspect ``torrent_status::paused``.
//
//
// The ``flags`` argument to pause can be set to
// ``torrent_handle::graceful_pause`` which will delay the disconnect of
// peers that we're still downloading outstanding requests from. The
@ -557,13 +557,13 @@ namespace libtorrent
// peers. As soon as a peer is done transferring the blocks that were
// requested from it, it is disconnected. This is a graceful shut down of
// the torrent in the sense that no downloaded bytes are wasted.
//
//
// .. note::
// Torrents that are auto-managed may be automatically resumed again. It
// does not make sense to pause an auto-managed torrent without making it
// not automanaged first. Torrents are auto-managed by default when added
// to the session. For more information, see queuing_.
//
//
void pause(int flags = 0) const;
void resume() const;
@ -575,23 +575,23 @@ namespace libtorrent
// to do so. A torrent may need to have its files checked for instance, so
// it needs to be started and possibly queued for checking (auto-managed
// and started) but as soon as it's done, it should be stopped.
//
//
// *Force stopped* means auto-managed is set to false and it's paused. As
// if auto_manage(false) and pause() were called on the torrent.
//
//
// Note that the torrent may transition into a downloading state while
// calling this function, and since the logic is edge triggered you may
// miss the edge. To avoid this race, if the torrent already is in a
// downloading state when this call is made, it will trigger the
// stop-when-ready immediately.
//
//
// When the stop-when-ready logic fires, the flag is cleared. Any
// subsequent transitions between downloading and non-downloading states
// will not be affected, until this function is used to set it again.
//
//
// The behavior is more robust when setting this flag as part of adding
// the torrent. See add_torrent_params.
//
//
// The stop-when-ready flag fixes the inherent race condition of waiting
// for the state_changed_alert and then call pause(). The download/seeding
// will most likely start in between posting the alert and receiving the
@ -604,9 +604,9 @@ namespace libtorrent
// ``settings_pack::optimistic_disk_retry``). Torrents are
// automatically put in upload mode whenever they encounter a disk write
// error.
//
//
// ``m`` should be true to enter upload mode, and false to leave it.
//
//
// To test if a torrent is in upload mode, call
// ``torrent_handle::status()`` and inspect
// ``torrent_status::upload_mode``.
@ -622,7 +622,7 @@ namespace libtorrent
// Instructs libtorrent to flush all the disk caches for this torrent and
// close all file handles. This is done asynchronously and you will be
// notified that it's complete through cache_flushed_alert.
//
//
// Note that by the time you get the alert, libtorrent may have cached
// more data for the torrent, but you are guaranteed that whatever cached
// data libtorrent had by the time you called
@ -667,32 +667,32 @@ namespace libtorrent
// ``save_resume_data()`` asks libtorrent to generate fast-resume data for
// this torrent.
//
//
// The ``flags`` argument is a bitmask of flags ORed together. see
// save_resume_flags_t
//
//
// This operation is asynchronous, ``save_resume_data`` will return
// immediately. The resume data is delivered when it's done through an
// save_resume_data_alert.
//
//
// The fast resume data will be empty in the following cases:
//
//
// 1. The torrent handle is invalid.
// 2. The torrent hasn't received valid metadata and was started without
// metadata (see libtorrent's metadata-from-peers_ extension)
//
//
// Note that by the time you receive the fast resume data, it may already
// be invalid if the torrent is still downloading! The recommended
// practice is to first pause the session, then generate the fast resume
// data, and then close it down. Make sure to not remove_torrent() before
// you receive the save_resume_data_alert though. There's no need to
// pause when saving intermittent resume data.
//
//
//.. warning::
// If you pause every torrent individually instead of pausing the
// session, every torrent will have its paused state saved in the
// resume data!
//
//
//.. warning::
// The resume data contains the modification timestamps for all files.
// If one file has been modified when the torrent is added again, the
@ -701,7 +701,7 @@ namespace libtorrent
// file timestamps are up to date and won't be modified after saving
// the resume data. The recommended way to do this is to pause the
// torrent, which will flush the cache and disconnect all peers.
//
//
//.. note::
// It is typically a good idea to save resume data whenever a torrent
// is completed or paused. In those cases you don't need to pause the
@ -711,26 +711,26 @@ namespace libtorrent
// data again for paused torrents. Completed torrents should have their
// resume data saved when they complete and on exit, since their
// statistics might be updated.
//
//
// In full allocation mode the resume data is never invalidated by
// subsequent writes to the files, since pieces won't move around. This
// means that you don't need to pause before writing resume data in full
// or sparse mode. If you don't, however, any data written to disk after
// you saved resume data and before the session closed is lost.
//
//
// It also means that if the resume data is out dated, libtorrent will
// not re-check the files, but assume that it is fairly recent. The
// assumption is that it's better to loose a little bit than to re-check
// the entire file.
//
//
// It is still a good idea to save resume data periodically during
// download as well as when closing down.
//
//
// Example code to pause and save resume data for all torrents and wait
// for the alerts:
//
//
// .. code:: c++
//
//
// extern int outstanding_resume_data; // global counter of outstanding resume data
// std::vector<torrent_handle> handles = ses.get_torrents();
// ses.pause();
@ -752,7 +752,7 @@ namespace libtorrent
//
// // if we don't get an alert within 10 seconds, abort
// if (a == 0) break;
//
//
// std::vector<alert*> alerts;
// ses.pop_alerts(&alerts);
//
@ -771,7 +771,7 @@ namespace libtorrent
// process_alert(a);
// continue;
// }
//
//
// torrent_handle h = rd->handle;
// torrent_status st = h.status(torrent_handle::query_save_path
// | torrent_handle::query_name);
@ -783,7 +783,7 @@ namespace libtorrent
// --outstanding_resume_data;
// }
// }
//
//
//.. note::
// Note how ``outstanding_resume_data`` is a global counter in this
// example. This is deliberate, otherwise there is a race condition for
@ -813,18 +813,18 @@ namespace libtorrent
// greater than the greatest queue position of all existing torrents.
// Torrents that are being seeded have -1 as their queue position, since
// they're no longer in line to be downloaded.
//
//
// When a torrent is removed or turns into a seed, all torrents with
// greater queue positions have their positions decreased to fill in the
// space in the sequence.
//
//
// ``queue_position()`` returns the torrent's position in the download
// queue. The torrents with the smallest numbers are the ones that are
// being downloaded. The smaller number, the closer the torrent is to the
// front of the line to be started.
//
//
// The queue position is also available in the torrent_status.
//
//
// The ``queue_position_*()`` functions adjust the torrents position in
// the queue. Up means closer to the front and down means closer to the
// back of the queue. Top and bottom refers to the front and the back of
@ -843,26 +843,26 @@ namespace libtorrent
// private key and DH params as strings, rather than paths to files. This
// overload is only available when libtorrent is built against boost
// 1.54 or later.
//
//
// ``cert`` is a path to the (signed) certificate in .pem format
// corresponding to this torrent.
//
//
// ``private_key`` is a path to the private key for the specified
// certificate. This must be in .pem format.
//
//
// ``dh_params`` is a path to the Diffie-Hellman parameter file, which
// needs to be in .pem format. You can generate this file using the
// openssl command like this: ``openssl dhparam -outform PEM -out
// dhparams.pem 512``.
//
//
// ``passphrase`` may be specified if the private key is encrypted and
// requires a passphrase to be decrypted.
//
//
// Note that when a torrent first starts up, and it needs a certificate,
// it will suspend connecting to any peers until it has one. It's
// typically desirable to resume the torrent after setting the ssl
// certificate.
//
//
// If you receive a torrent_need_cert_alert, you need to call this to
// provide a valid cert. If you don't have a cert you won't be allowed to
// connect to any peers.
@ -977,7 +977,7 @@ namespace libtorrent
// each piece in this torrent. libtorrent does not keep track of
// availability for seeds, so if the torrent is seeding the availability
// for all pieces is reported as 0.
//
//
// The piece availability is the number of peers that we are connected
// that has advertised having a particular piece. This is the information
// that libtorrent uses in order to prefer picking rare pieces.
@ -991,15 +991,15 @@ namespace libtorrent
// lower priority values means less likely to be picked. Piece priority
// takes precedence over piece availability. Every priority-7 piece will
// be attempted to be picked before a priority 6 piece and so on.
//
//
// Piece priorities can not be changed for torrents that have not
// downloaded the metadata yet. For instance, magnet links and torrents
// added by URL won't have metadata immediately. see the
// metadata_received_alert.
//
//
// ``piece_priority`` sets or gets the priority for an individual piece,
// specified by ``index``.
//
//
// ``prioritize_pieces`` takes a vector of integers, one integer per
// piece in the torrent. All the piece priorities will be updated with
// the priorities in the vector.
@ -1009,7 +1009,7 @@ namespace libtorrent
// the piece index and the second item is the priority of that piece.
// Invalid entries, where the piece index or priority is out of range, are
// not allowed.
//
//
// ``piece_priorities`` returns a vector with one element for each piece
// in the torrent. Each element is the current priority of that piece.
void piece_priority(int index, int priority) const;
@ -1019,24 +1019,24 @@ namespace libtorrent
std::vector<int> piece_priorities() const;
// ``index`` must be in the range [0, number_of_files).
//
//
// ``file_priority()`` queries or sets the priority of file ``index``.
//
//
// ``prioritize_files()`` takes a vector that has at as many elements as
// there are files in the torrent. Each entry is the priority of that
// file. The function sets the priorities of all the pieces in the
// torrent based on the vector.
//
//
// ``file_priorities()`` returns a vector with the priorities of all
// files.
//
//
// The priority values are the same as for piece_priority().
//
//
// Whenever a file priority is changed, all other piece priorities are
// reset to match the file priorities. In order to maintain special
// priorities for particular pieces, piece_priority() has to be called
// again for those pieces.
//
//
// You cannot set the file priorities on a torrent that does not yet have
// metadata or a torrent that is a seed. ``file_priority(int, int)`` and
// prioritize_files() are both no-ops for such torrents.
@ -1048,7 +1048,7 @@ namespace libtorrent
// ``force_reannounce()`` will force this torrent to do another tracker
// request, to receive new peers. The ``seconds`` argument specifies how
// many seconds from now to issue the tracker announces.
//
//
// If the tracker's ``min_interval`` has not passed since the last
// announce, the forced announce will be scheduled to happen immediately
// as the ``min_interval`` expires. This is to honor trackers minimum
@ -1056,7 +1056,7 @@ namespace libtorrent
//
// The ``tracker_index`` argument specifies which tracker to re-announce.
// If set to -1 (which is the default), all trackers are re-announce.
//
//
// ``force_dht_announce`` will announce the torrent to the DHT
// immediately.
void force_reannounce(int seconds = 0, int tracker_index = -1) const;
@ -1074,10 +1074,10 @@ namespace libtorrent
// ``scrape_tracker()`` will send a scrape request to a tracker. By
// default (``idx`` = -1) it will scrape the last working tracker. If
// ``idx`` is >= 0, the tracker with the specified index will scraped.
//
//
// A scrape request queries the tracker for statistics such as total
// number of incomplete peers, complete peers, number of downloads etc.
//
//
// This request will specifically update the ``num_complete`` and
// ``num_incomplete`` fields in the torrent_status struct once it
// completes. When it completes, it will generate a scrape_reply_alert.
@ -1093,7 +1093,7 @@ namespace libtorrent
// (``settings_pack::upload_rate_limit``) will not override the global
// rate limit. The torrent can never upload more than the global rate
// limit.
//
//
// ``upload_limit`` and ``download_limit`` will return the current limit
// setting, for upload and download, respectively.
void set_upload_limit(int limit) const;
@ -1106,16 +1106,16 @@ namespace libtorrent
// loading and unloading of torrents is enabled (by setting a load
// function on the session), this can be used to exempt certain torrents
// from the unloading logic.
//
//
// Magnet links, and other torrents that start out without having
// metadata are pinned automatically. This is to give the client a chance
// to get the metadata and save it before it's unloaded. In this case, it
// may be useful to un-pin the torrent once its metadata has been saved
// to disk.
//
//
// For more information about dynamically loading and unloading torrents,
// see dynamic-loading-of-torrent-files_.
//
//
void set_pinned(bool p) const;
#endif
@ -1124,7 +1124,7 @@ namespace libtorrent
// instead of rarest first. In this mode, piece priorities are ignored,
// with the exception of priority 7, which are still preferred over the
// sequential piece order.
//
//
// Enabling sequential download will affect the piece distribution
// negatively in the swarm. It should be used sparingly.
void set_sequential_download(bool sd) const;
@ -1143,12 +1143,12 @@ namespace libtorrent
//
// ==== ==========================================
// 0x01 peer supports encryption.
//
//
// 0x02 peer is a seed
//
//
// 0x04 supports uTP. If this is not set, the peer will only be contacted
// over TCP.
//
//
// 0x08 supports holepunching protocol. If this
// flag is received from a peer, it can be
// used as a rendezvous point in case direct
@ -1162,7 +1162,7 @@ namespace libtorrent
// no limit. This defaults to infinite. The primary setting controlling
// this is the global unchoke slots limit, set by unchoke_slots_limit in
// settings_pack.
//
//
// ``max_uploads()`` returns the current settings.
void set_max_uploads(int max_uploads) const;
int max_uploads() const;
@ -1174,7 +1174,7 @@ namespace libtorrent
// -1 is given to the function, it means unlimited. There is also a
// global limit of the number of connections, set by
// ``connections_limit`` in settings_pack.
//
//
// ``max_connections()`` returns the current settings.
void set_max_connections(int max_connections) const;
int max_connections() const;
@ -1193,24 +1193,24 @@ namespace libtorrent
// drive and removed from their original location. This will block all
// other disk IO, and other torrents download and upload rates may drop
// while copying the file.
//
//
// Since disk IO is performed in a separate thread, this operation is
// also asynchronous. Once the operation completes, the
// ``storage_moved_alert`` is generated, with the new path as the
// message. If the move fails for some reason,
// ``storage_moved_failed_alert`` is generated instead, containing the
// error message.
//
//
// The ``flags`` argument determines the behavior of the copying/moving
// of the files in the torrent. see move_flags_t.
//
//
// * always_replace_files = 0
// * fail_if_exist = 1
// * dont_replace = 2
//
//
// ``always_replace_files`` is the default and replaces any file that
// exist in both the source directory and the target directory.
//
//
// ``fail_if_exist`` first check to see that none of the copy operations
// would cause an overwrite. If it would, it will fail. Otherwise it will
// proceed as if it was in ``always_replace_files`` mode. Note that there
@ -1220,15 +1220,15 @@ namespace libtorrent
// already existing in the target path, the ``error`` of
// ``move_storage_failed_alert`` is set to
// ``boost::system::errc::file_exists``.
//
//
// The intention is that a client may use this as a probe, and if it
// fails, ask the user which mode to use. The client may then re-issue
// the ``move_storage`` call with one of the other modes.
//
//
// ``dont_replace`` always takes the existing file in the target
// directory, if there is one. The source files will still be removed in
// that case.
//
//
// Files that have been renamed to have absolute paths are not moved by
// this function. Keep in mind that files that don't belong to the
// torrent but are stored in the torrent's directory may be moved as

View File

@ -120,15 +120,15 @@ namespace libtorrent
// internally when downloading torrents without the metadata. The
// metadata will be created by libtorrent as soon as it has been
// downloaded from the swarm.
//
//
// The constructor that takes a bdecode_node will create a torrent_info
// object from the information found in the given torrent_file. The
// bdecode_node represents a tree node in an bencoded file. To load an
// ordinary .torrent file into a bdecode_node, use bdecode().
//
//
// The version that takes a buffer pointer and a size will decode it as a
// .torrent file and initialize the torrent_info object for you.
//
//
// The version that takes a filename will simply load the torrent file
// and decode it inside the constructor, for convenience. This might not
// be the most suitable for applications that want to be able to report
@ -137,14 +137,14 @@ namespace libtorrent
// There is an upper limit on the size of the torrent file that will be
// loaded by the overload taking a filename. If it's important that even
// very large torrent files are loaded, use one of the other overloads.
//
//
// The overloads that takes an ``error_code const&`` never throws if an
// error occur, they will simply set the error code to describe what went
// wrong and not fully initialize the torrent_info object. The overloads
// that do not take the extra error_code parameter will always throw if
// an error occurs. These overloads are not available when building
// without exception support.
//
//
// The ``flags`` argument is currently unused.
#ifndef BOOST_NO_EXCEPTIONS
explicit torrent_info(bdecode_node const& torrent_file, int flags = 0);
@ -182,12 +182,12 @@ namespace libtorrent
// having a torrent file. When renaming files in a storage, the storage
// needs to make its own copy of the file_storage in order to make its
// mapping differ from the one in the torrent file.
//
//
// ``orig_files()`` returns the original (unmodified) file storage for
// this torrent. This is used by the web server connection, which needs
// to request files with the original names. Filename may be changed using
// ``torrent_info::rename_file()``.
//
//
// For more information on the file_storage object, see the separate
// document on how to create torrents.
file_storage const& files() const { return m_files; }
@ -200,11 +200,11 @@ namespace libtorrent
// Renames a the file with the specified index to the new name. The new
// filename is reflected by the ``file_storage`` returned by ``files()``
// but not by the one returned by ``orig_files()``.
//
//
// If you want to rename the base name of the torrent (for a multifile
// torrent), you can copy the ``file_storage`` (see files() and
// orig_files() ), change the name, and then use `remap_files()`_.
//
//
// The ``new_filename`` can both be a relative path, in which case the
// file name is relative to the ``save_path`` of the torrent. If the
// ``new_filename`` is an absolute path (i.e. ``is_complete(new_filename)
@ -232,7 +232,7 @@ namespace libtorrent
// instance, download all data in a torrent to a single file, or to a
// number of fixed size sector aligned files, regardless of the number
// and sizes of the files in the torrent.
//
//
// The new specified ``file_storage`` must have the exact same size as
// the current one.
void remap_files(file_storage const& f);
@ -254,7 +254,7 @@ namespace libtorrent
// "collections" keys in the .torrent file. Both info-hashes and
// collections from within the info-dict and from outside of it are
// included.
//
//
// .. _BEP38: http://www.bittorrent.org/beps/bep_0038.html
std::vector<sha1_hash> similar_torrents() const;
std::vector<std::string> collections() const;
@ -275,23 +275,23 @@ namespace libtorrent
// ``web_seeds()`` returns all url seeds and http seeds in the torrent.
// Each entry is a ``web_seed_entry`` and may refer to either a url seed
// or http seed.
//
//
// ``add_url_seed()`` and ``add_http_seed()`` adds one url to the list of
// url/http seeds. Currently, the only transport protocol supported for
// the url is http.
//
//
// ``set_web_seeds()`` replaces all web seeds with the ones specified in
// the ``seeds`` vector.
//
//
// The ``extern_auth`` argument can be used for other authorization
// schemes than basic HTTP authorization. If set, it will override any
// username and password found in the URL itself. The string will be sent
// as the HTTP authorization header's value (without specifying "Basic").
//
//
// The ``extra_headers`` argument defaults to an empty list, but can be
// used to insert custom HTTP headers in the requests to a specific web
// seed.
//
//
// See http-seeding_ for more information.
void add_url_seed(std::string const& url
, std::string const& extern_auth = std::string()
@ -328,7 +328,7 @@ namespace libtorrent
// ``end_files()``, ``rbegin_files()`` and ``rend_files()``. These will
// give you standard vector iterators with the type
// ``internal_file_entry``, which is an internal type.
//
//
// You can resolve it into the public representation of a file
// (``file_entry``) using the ``file_storage::at`` function, which takes
// an index and an iterator.
@ -364,7 +364,7 @@ namespace libtorrent
// This function will map a range in a specific file into a range in the
// torrent. The ``file_offset`` parameter is the offset in the file,
// given in bytes, where 0 is the start of the file. See peer_request.
//
//
// The input range is assumed to be valid within the torrent.
// ``file_offset`` + ``size`` is not allowed to be greater than the file
// size. ``file_index`` must refer to a valid file, i.e. it cannot be >=
@ -438,7 +438,7 @@ namespace libtorrent
// ``merkle_tree()`` returns a reference to the merkle tree for this
// torrent, if any.
//
//
// ``set_merkle_tree()`` moves the passed in merkle tree into the
// torrent_info object. i.e. ``h`` will not be identical after the call.
// You need to set the merkle tree for a torrent that you've just created
@ -451,18 +451,18 @@ namespace libtorrent
{ TORRENT_ASSERT(h.size() == m_merkle_tree.size() ); m_merkle_tree.swap(h); }
// ``name()`` returns the name of the torrent.
//
//
// ``comment()`` returns the comment associated with the torrent. If
// there's no comment, it will return an empty string.
// ``creation_date()`` returns the creation date of the torrent as time_t
// (`posix time`_). If there's no time stamp in the torrent file, the
// optional object will be uninitialized.
//
//
// Both the name and the comment is UTF-8 encoded strings.
//
//
// ``creator()`` returns the creator string in the torrent. If there is
// no creator string it will return an empty string.
//
//
// .. _`posix time`: http://www.opengroup.org/onlinepubs/009695399/functions/time.html
const std::string& name() const { return m_files.name(); }
time_t creation_date() const

View File

@ -74,7 +74,7 @@ namespace libtorrent
int live_allocations() const { return m_live_allocations; }
private:
// this is a shared pool where torrent_peer objects
// are allocated. It's a pool since we're likely
// to have tens of thousands of peers, and a pool

View File

@ -271,7 +271,7 @@ namespace libtorrent
// progress parts per million (progress * 1000000) when disabling
// floating point operations, this is the only option to query progress
//
//
// reflects the same value as ``progress``, but instead in a range [0,
// 1000000] (ppm = parts per million). When floating point operations are
// disabled, this is the only alternative to the floating point value in
@ -339,12 +339,12 @@ namespace libtorrent
// tells the share of pieces that have more copies than the rarest
// piece(s). Divide this number by 1000 to get the fraction.
//
//
// For example, if ``distributed_full_copies`` is 2 and
// ``distributed_fraction`` is 500, it means that the rarest pieces have
// only 2 copies among the peers this torrent is connected to, and that
// 50% of all the pieces have more than two copies.
//
//
// If we are a seed, the piece picker is deallocated as an optimization,
// and piece availability is no longer tracked. In this case the
// distributed copies members are set to -1.

View File

@ -82,7 +82,7 @@ namespace libtorrent
{
return m_queued_bytes;
}
// non prioritized means that, if there's a line for bandwidth,
// others will cut in front of the non-prioritized peers.
// this is used by web seeds

View File

@ -140,7 +140,7 @@ namespace libtorrent
return ret ^ 0xffffffff;
}
#endif
boost::crc_optimal<32, 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc;
crc.process_bytes(buf, num_words * 8);
return crc.checksum();

View File

@ -1568,7 +1568,7 @@ namespace libtorrent
// one and it sets outstanding_read flag and possibly queues
// up the job in the piece read job list
// the cache std::mutex must be held when calling this
//
//
// returns 0 if the job succeeded immediately
// 1 if it needs to be added to the job queue
// 2 if it was deferred and will be performed later (no need to

View File

@ -385,7 +385,7 @@ namespace libtorrent
{
unsigned char inbuf[8];
unsigned char outbuf[5];
std::string ret;
for (std::string::const_iterator i = s.begin(); i != s.end();)
{

View File

@ -384,7 +384,7 @@ restart_response:
{
m_partial_chunk_header += incoming;
header_size = incoming;
// std::fprintf(stderr, "parse_chunk_header(%d, -> %d, -> %d) -> %d\n"
// " incoming = %d\n m_recv_pos = %d\n m_cur_chunk_end = %d\n"
// " content-length = %d\n"

View File

@ -89,7 +89,7 @@ namespace libtorrent { namespace dht
// from this node. Ignore it until it's silent for 5 minutes
match->limit = now + seconds(m_block_timeout);
}
return false;
}

View File

@ -44,7 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
// the size of the torrent (and can be used to calculate the size
// of the file header)
uint32_t num_pieces;
// the number of bytes in each piece. This determines the size of
// each slot in the part file. This is typically an even power of 2,
// but it is not guaranteed to be.
@ -58,7 +58,7 @@ POSSIBILITY OF SUCH DAMAGE.
// unused, n is defined as the number to align the size of this
// header to an even multiple of 1024 bytes.
uint8_t padding[n];
*/
#include "libtorrent/part_file.hpp"

View File

@ -419,7 +419,7 @@ namespace libtorrent
// the number of incoming DHT requests that were dropped. There are a few
// different reasons why incoming DHT packets may be dropped:
//
//
// 1. there wasn't enough send quota to respond to them.
// 2. the Denial of service logic kicked in, blocking the peer
// 3. ignore_dark_internet is enabled, and the packet came from a

View File

@ -241,7 +241,7 @@ void SHA1_final(u8* digest, sha1_ctx* context)
/************************************************************
-----------------
Modified 7/98
Modified 7/98
By James H. Brown <jbrown@burgoyne.com>
Still 100% Public Domain
@ -263,7 +263,7 @@ Since the file IO in main() reads 16K at a time, any file 8K or larger would
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
"a"s).
I also changed the declaration of variables i & j in SHA1Update to
I also changed the declaration of variables i & j in SHA1Update to
unsigned long from unsigned int for the same reason.
These changes should make no difference to any 32 bit implementations since
@ -290,7 +290,7 @@ Still 100% public domain
Modified 4/01
By Saul Kravitz <Saul.Kravitz@celera.com>
Still 100% PD
Modified to run on Compaq Alpha hardware.
Modified to run on Compaq Alpha hardware.
-----------------
Converted to C++ 6/04

View File

@ -30,45 +30,45 @@ namespace libtorrent
/* the K array */
static const u64 K[80] = {
UINT64_C(0x428a2f98d728ae22), UINT64_C(0x7137449123ef65cd),
UINT64_C(0x428a2f98d728ae22), UINT64_C(0x7137449123ef65cd),
UINT64_C(0xb5c0fbcfec4d3b2f), UINT64_C(0xe9b5dba58189dbbc),
UINT64_C(0x3956c25bf348b538), UINT64_C(0x59f111f1b605d019),
UINT64_C(0x3956c25bf348b538), UINT64_C(0x59f111f1b605d019),
UINT64_C(0x923f82a4af194f9b), UINT64_C(0xab1c5ed5da6d8118),
UINT64_C(0xd807aa98a3030242), UINT64_C(0x12835b0145706fbe),
UINT64_C(0xd807aa98a3030242), UINT64_C(0x12835b0145706fbe),
UINT64_C(0x243185be4ee4b28c), UINT64_C(0x550c7dc3d5ffb4e2),
UINT64_C(0x72be5d74f27b896f), UINT64_C(0x80deb1fe3b1696b1),
UINT64_C(0x72be5d74f27b896f), UINT64_C(0x80deb1fe3b1696b1),
UINT64_C(0x9bdc06a725c71235), UINT64_C(0xc19bf174cf692694),
UINT64_C(0xe49b69c19ef14ad2), UINT64_C(0xefbe4786384f25e3),
UINT64_C(0xe49b69c19ef14ad2), UINT64_C(0xefbe4786384f25e3),
UINT64_C(0x0fc19dc68b8cd5b5), UINT64_C(0x240ca1cc77ac9c65),
UINT64_C(0x2de92c6f592b0275), UINT64_C(0x4a7484aa6ea6e483),
UINT64_C(0x2de92c6f592b0275), UINT64_C(0x4a7484aa6ea6e483),
UINT64_C(0x5cb0a9dcbd41fbd4), UINT64_C(0x76f988da831153b5),
UINT64_C(0x983e5152ee66dfab), UINT64_C(0xa831c66d2db43210),
UINT64_C(0x983e5152ee66dfab), UINT64_C(0xa831c66d2db43210),
UINT64_C(0xb00327c898fb213f), UINT64_C(0xbf597fc7beef0ee4),
UINT64_C(0xc6e00bf33da88fc2), UINT64_C(0xd5a79147930aa725),
UINT64_C(0xc6e00bf33da88fc2), UINT64_C(0xd5a79147930aa725),
UINT64_C(0x06ca6351e003826f), UINT64_C(0x142929670a0e6e70),
UINT64_C(0x27b70a8546d22ffc), UINT64_C(0x2e1b21385c26c926),
UINT64_C(0x27b70a8546d22ffc), UINT64_C(0x2e1b21385c26c926),
UINT64_C(0x4d2c6dfc5ac42aed), UINT64_C(0x53380d139d95b3df),
UINT64_C(0x650a73548baf63de), UINT64_C(0x766a0abb3c77b2a8),
UINT64_C(0x650a73548baf63de), UINT64_C(0x766a0abb3c77b2a8),
UINT64_C(0x81c2c92e47edaee6), UINT64_C(0x92722c851482353b),
UINT64_C(0xa2bfe8a14cf10364), UINT64_C(0xa81a664bbc423001),
UINT64_C(0xc24b8b70d0f89791), UINT64_C(0xc76c51a30654be30),
UINT64_C(0xd192e819d6ef5218), UINT64_C(0xd69906245565a910),
UINT64_C(0xd192e819d6ef5218), UINT64_C(0xd69906245565a910),
UINT64_C(0xf40e35855771202a), UINT64_C(0x106aa07032bbd1b8),
UINT64_C(0x19a4c116b8d2d0c8), UINT64_C(0x1e376c085141ab53),
UINT64_C(0x19a4c116b8d2d0c8), UINT64_C(0x1e376c085141ab53),
UINT64_C(0x2748774cdf8eeb99), UINT64_C(0x34b0bcb5e19b48a8),
UINT64_C(0x391c0cb3c5c95a63), UINT64_C(0x4ed8aa4ae3418acb),
UINT64_C(0x391c0cb3c5c95a63), UINT64_C(0x4ed8aa4ae3418acb),
UINT64_C(0x5b9cca4f7763e373), UINT64_C(0x682e6ff3d6b2b8a3),
UINT64_C(0x748f82ee5defb2fc), UINT64_C(0x78a5636f43172f60),
UINT64_C(0x748f82ee5defb2fc), UINT64_C(0x78a5636f43172f60),
UINT64_C(0x84c87814a1f0ab72), UINT64_C(0x8cc702081a6439ec),
UINT64_C(0x90befffa23631e28), UINT64_C(0xa4506cebde82bde9),
UINT64_C(0x90befffa23631e28), UINT64_C(0xa4506cebde82bde9),
UINT64_C(0xbef9a3f7b2c67915), UINT64_C(0xc67178f2e372532b),
UINT64_C(0xca273eceea26619c), UINT64_C(0xd186b8c721c0c207),
UINT64_C(0xca273eceea26619c), UINT64_C(0xd186b8c721c0c207),
UINT64_C(0xeada7dd6cde0eb1e), UINT64_C(0xf57d4f7fee6ed178),
UINT64_C(0x06f067aa72176fba), UINT64_C(0x0a637dc5a2c898a6),
UINT64_C(0x06f067aa72176fba), UINT64_C(0x0a637dc5a2c898a6),
UINT64_C(0x113f9804bef90dae), UINT64_C(0x1b710b35131c471b),
UINT64_C(0x28db77f523047d84), UINT64_C(0x32caab7b40c72493),
UINT64_C(0x28db77f523047d84), UINT64_C(0x32caab7b40c72493),
UINT64_C(0x3c9ebe0a15c9bebc), UINT64_C(0x431d67c49c100d4c),
UINT64_C(0x4cc5d4becb3e42b6), UINT64_C(0x597f299cfc657e2a),
UINT64_C(0x4cc5d4becb3e42b6), UINT64_C(0x597f299cfc657e2a),
UINT64_C(0x5fcb6fab3ad6faec), UINT64_C(0x6c44198c4a475817)
};
@ -92,7 +92,7 @@ static const u64 K[80] = {
#define Ch(x,y,z) (z ^ (x & (y ^ z)))
#define Maj(x,y,z) (((x | y) & z) | (x & y))
#define Maj(x,y,z) (((x | y) & z) | (x & y))
#define S(x, n) ROR64c(x, n)
#define R(x, n) (((x) &UINT64_C(0xFFFFFFFFFFFFFFFF))>>((u64)n))
#define Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39))
@ -122,7 +122,7 @@ static int sha512_compress(sha512_ctx *md, unsigned char *buf)
/* fill W[16..79] */
for (i = 16; i < 80; i++) {
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
}
}
/* Compress */
#define RND(a,b,c,d,e,f,g,h,i) \
@ -185,24 +185,24 @@ int SHA512_init(sha512_ctx* md) {
@return 0 if successful
*/
int SHA512_update(sha512_ctx* md, std::uint8_t const* in, std::uint32_t inlen)
{
{
size_t n;
size_t i;
int err;
if (md == NULL) return 1;
if (in == NULL) return 1;
if (md->curlen > sizeof(md->buf)) {
return 1;
}
while (inlen > 0) {
if (md->curlen == 0 && inlen >= 128) {
if ((err = sha512_compress (md, (unsigned char *)in)) != 0) {
return err;
}
md->length += 128 * 8;
in += 128;
inlen -= 128;
} else {
size_t i;
int err;
if (md == NULL) return 1;
if (in == NULL) return 1;
if (md->curlen > sizeof(md->buf)) {
return 1;
}
while (inlen > 0) {
if (md->curlen == 0 && inlen >= 128) {
if ((err = sha512_compress (md, (unsigned char *)in)) != 0) {
return err;
}
md->length += 128 * 8;
in += 128;
inlen -= 128;
} else {
n = MIN(inlen, (128 - md->curlen));
for (i = 0; i < n; i++) {
@ -210,19 +210,19 @@ int SHA512_update(sha512_ctx* md, std::uint8_t const* in, std::uint32_t inlen)
}
md->curlen += n;
in += n;
inlen -= n;
if (md->curlen == 128) {
if ((err = sha512_compress (md, md->buf)) != 0) {
return err;
}
md->length += 8*128;
md->curlen = 0;
}
}
}
return 0;
md->curlen += n;
in += n;
inlen -= n;
if (md->curlen == 128) {
if ((err = sha512_compress (md, md->buf)) != 0) {
return err;
}
md->length += 8*128;
md->curlen = 0;
}
}
}
return 0;
}
/**
@ -260,7 +260,7 @@ int SHA512_final(std::uint8_t* out, sha512_ctx* md)
md->curlen = 0;
}
/* pad upto 120 bytes of zeroes
/* pad upto 120 bytes of zeroes
* note: that from 112 to 120 is the 64 MSB of the length. We assume that you won't hash
* > 2^64 bits of data... :-)
*/

View File

@ -67,7 +67,7 @@ namespace libtorrent
// the lower 64 bits are always unmasked
//
// * for IPv6 addresses, compare /32 and /48 instead of /16 and /24
//
//
// * the two IP addresses that are used to calculate the rank must
// always be of the same address family
//

View File

@ -221,7 +221,7 @@ namespace libtorrent
for (std::vector<tcp::endpoint>::iterator k = m_endpoints.begin();
k != m_endpoints.end();)
{
if (tracker_req().filter->access(k->address()) == ip_filter::blocked)
if (tracker_req().filter->access(k->address()) == ip_filter::blocked)
{
#ifndef TORRENT_DISABLE_LOGGING
if (cb && cb->should_log())
@ -243,7 +243,7 @@ namespace libtorrent
fail(error_code(errors::banned_by_ip_filter));
return;
}
m_target = pick_target_endpoint();
start_announce();

View File

@ -60,7 +60,7 @@ namespace libtorrent { namespace
{
// don't send out those peers that we haven't connected to
// (that have connected to us) and that aren't sharing their
// listening port
// listening port
if (!p.is_outgoing() && !p.received_listen_port()) return false;
// don't send out peers that we haven't successfully connected to
if (p.is_connecting()) return false;
@ -202,7 +202,7 @@ namespace libtorrent { namespace
for (std::set<tcp::endpoint>::const_iterator i = dropped.begin()
, end(dropped.end()); i != end; ++i)
{
{
if (i->address().is_v4())
detail::write_endpoint(*i, pld_out);
#if TORRENT_USE_IPV6

View File

@ -95,7 +95,7 @@ void test_swarm()
torrent_handle tor2;
torrent_handle tor3;
std::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true, false, true, "_unchoke");
std::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true, false, true, "_unchoke");
std::map<std::string, std::int64_t> cnt = get_counters(ses1);

View File

@ -814,7 +814,7 @@ TORRENT_TEST(dict_find_funs)
TEST_EQUAL(e.type(), bdecode_node::dict_t);
// dict_find_int*
// dict_find_int*
TEST_EQUAL(e.dict_find_int_value("a"), 1);
TEST_EQUAL(e.dict_find_int("a").type(), bdecode_node::int_t);

View File

@ -53,7 +53,7 @@ TORRENT_TEST(create_verbatim_torrent)
info.add_tracker("http://test.com");
info.add_tracker("http://test.com");
TEST_EQUAL(info.trackers().size(), 1);
lt::create_torrent t(info);
std::vector<char> buffer;

View File

@ -240,7 +240,7 @@ void send_dht_request(node& node, char const* msg, udp::endpoint const& ep
dht::msg m(decoded, ep);
node.incoming(m);
// If the request is supposed to get a response, by now the node should have
// If the request is supposed to get a response, by now the node should have
// invoked the send function and put the response in g_sent_packets
std::list<std::pair<udp::endpoint, entry> >::iterator i = find_packet(ep);
if (has_response)

View File

@ -105,7 +105,7 @@ TORRENT_TEST(set_name)
// torrent, the path of the files should change too
file_storage st;
setup_test_storage(st);
st.set_name("test_2");
TEST_EQUAL(st.file_path(0, "."), combine_path(".", combine_path("test_2"
, "a")));

View File

@ -98,7 +98,7 @@ TORRENT_TEST(part_file)
{
// load the part file back in
part_file pf(combine_path(cwd, "partfile_test_dir2"), "partfile.parts", 100, piece_size);
memset(buf, 0, sizeof(buf));
file::iovec_t v = {&buf, 1024};

View File

@ -363,7 +363,7 @@ TORRENT_TEST(update_peer_port_collide)
auto c = std::make_shared<mock_peer_connection>(&t, true, ep("10.0.0.1", 8080));
p.new_connection(*c, 0, &st);
TEST_EQUAL(p.num_connect_candidates(), 1);
// at this point we have two peers, because we think they have different
// at this point we have two peers, because we think they have different
// ports
TEST_EQUAL(p.num_peers(), 2);
st.erased.clear();

View File

@ -1310,7 +1310,7 @@ TORRENT_TEST(storage_paths_string_pooling)
file_storage.add_file(combine_path("test_storage", combine_path("sub", "test2.txt")), 0x4000);
file_storage.add_file(combine_path("test_storage", combine_path("sub", "test3.txt")), 0x4000);
// "sub" paths should point to same string item, so paths.size() must not grow
// "sub" paths should point to same string item, so paths.size() must not grow
TEST_CHECK(file_storage.paths().size() <= 2);
}

View File

@ -164,7 +164,7 @@ int main(int argc, char* argv[])
"set style line 2 lc rgb \"#88ff88\"\n"
"set style arrow 1 nohead ls 1\n"
"set style arrow 2 nohead ls 2\n"
"plot \"writes.log\" using 1:2:3:(0) title \"writes\" with vectors arrowstyle 1, "
"plot \"writes.log\" using 1:2:3:(0) title \"writes\" with vectors arrowstyle 1, "
"\"reads.log\" using 1:2:3:(0) title \"reads\" with vectors arrowstyle 2\n";
std::fwrite(gnuplot_file, strlen(gnuplot_file), 1, gnuplot);