style: use the new paragraph comment style everywhere (#4634)

This commit is contained in:
Charles Kerr 2023-01-22 13:21:30 -06:00 committed by GitHub
parent 0f4077a445
commit 7367d465b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 173 additions and 476 deletions

View File

@ -72,9 +72,7 @@ void verboseLog(std::string_view description, tr_direction direction, std::strin
auto constexpr MaxBencDepth = 8;
} // namespace
/****
***** ANNOUNCE
****/
// --- Announce
namespace
{

View File

@ -26,9 +26,7 @@ class tr_announcer;
class tr_announcer_udp;
struct tr_torrent_announcer;
/**
*** Tracker Publish / Subscribe
**/
// --- Tracker Publish / Subscribe
struct tr_pex;
@ -80,9 +78,7 @@ public:
std::unique_ptr<tr_announcer> tr_announcerCreate(tr_session* session);
/**
*** For torrent customers
**/
// --- For torrent customers
void tr_announcerChangeMyPort(tr_torrent*);

View File

@ -15,9 +15,7 @@
#include "bitfield.h"
#include "tr-assert.h"
/****
*****
****/
// ---
namespace
{
@ -76,9 +74,7 @@ void setAllTrue(uint8_t* array, size_t bit_count)
} // namespace
/****
*****
****/
// ---
size_t tr_bitfield::countFlags() const noexcept
{
@ -176,9 +172,7 @@ size_t tr_bitfield::count(size_t begin, size_t end) const
return countFlags(begin, end);
}
/***
****
***/
// ---
bool tr_bitfield::isValid() const
{
@ -276,9 +270,7 @@ void tr_bitfield::decrementTrueCount(size_t dec) noexcept
setTrueCount(true_count_ - dec);
}
/****
*****
****/
// ---
tr_bitfield::tr_bitfield(size_t bit_count)
: bit_count_{ bit_count }

View File

@ -129,9 +129,7 @@ Cache::Cache(tr_torrents& torrents, int64_t max_bytes)
{
}
/***
****
***/
// ---
int Cache::writeBlock(tr_torrent_id_t tor_id, tr_block_index_t block, std::unique_ptr<std::vector<uint8_t>>& writeme)
{
@ -189,9 +187,7 @@ int Cache::prefetchBlock(tr_torrent* torrent, tr_block_info::Location loc, uint3
return tr_ioPrefetch(torrent, loc, len);
}
/***
****
***/
// ---
int Cache::flushSpan(CIter const begin, CIter const end)
{

View File

@ -21,9 +21,7 @@
#define TR_CRYPTO_X509_FALLBACK
#include "crypto-utils-fallback.cc" // NOLINT(bugprone-suspicious-include)
/***
****
***/
// ---
namespace
{
@ -95,9 +93,7 @@ bool check_ccrypto_result(CCCryptorStatus result, char const* file, long line)
} // namespace
/***
****
***/
// ---
namespace
{
@ -194,9 +190,7 @@ std::unique_ptr<tr_sha256> tr_sha256::create()
return std::make_unique<Sha256Impl>();
}
/***
****
***/
// ---
bool tr_rand_buffer_crypto(void* buffer, size_t length)
{

View File

@ -12,9 +12,7 @@
#include "crypto-utils.h"
#include "tr-macros.h"
/***
****
***/
// ---
#ifdef TR_CRYPTO_X509_FALLBACK

View File

@ -24,9 +24,7 @@
#define TR_CRYPTO_X509_FALLBACK
#include "crypto-utils-fallback.cc" // NOLINT(bugprone-suspicious-include)
/***
****
***/
// ---
static void log_mbedtls_error(int error_code, char const* file, int line)
{
@ -64,9 +62,7 @@ static bool check_mbedtls_result(int result, int expected_result, char const* fi
#define check_result(result) check_mbedtls_result((result), 0, __FILE__, __LINE__)
#define check_result_eq(result, x_result) check_mbedtls_result((result), (x_result), __FILE__, __LINE__)
/***
****
***/
// ---
static int my_rand(void* /*context*/, unsigned char* buffer, size_t buffer_size)
{
@ -102,9 +98,7 @@ static mbedtls_ctr_drbg_context* get_rng()
static std::recursive_mutex rng_mutex_;
/***
****
***/
// ---
namespace
{
@ -223,9 +217,7 @@ std::unique_ptr<tr_sha256> tr_sha256::create()
return std::make_unique<Sha256Impl>();
}
/***
****
***/
// ---
bool tr_rand_buffer_crypto(void* buffer, size_t length)
{

View File

@ -30,9 +30,7 @@ using TR_WC_RNG = RNG;
#define TR_CRYPTO_X509_FALLBACK
#include "crypto-utils-fallback.cc" // NOLINT(bugprone-suspicious-include)
/***
****
***/
// ---
static void log_wolfssl_error(int error_code, char const* file, int line)
{
@ -64,9 +62,7 @@ static bool check_wolfssl_result(int result, char const* file, int line)
#define check_result(result) check_wolfssl_result((result), __FILE__, __LINE__)
/***
****
***/
// ---
static TR_WC_RNG* get_rng()
{
@ -88,9 +84,7 @@ static TR_WC_RNG* get_rng()
static std::mutex rng_mutex_;
/***
****
***/
// ---
namespace
{
@ -177,9 +171,7 @@ std::unique_ptr<tr_sha256> tr_sha256::create()
return std::make_unique<Sha256Impl>();
}
/***
****
***/
// ---
bool tr_rand_buffer_crypto(void* buffer, size_t length)
{

View File

@ -96,9 +96,7 @@ bool tr_ssha1_matches(std::string_view ssha1, std::string_view plaintext)
return tr_salt(plaintext, salt) == ssha1;
}
/***
****
***/
// ---
namespace
{
@ -145,9 +143,7 @@ std::string tr_base64_decode(std::string_view input)
return std::string{ std::data(buf), len };
}
/***
****
***/
// ---
namespace
{

View File

@ -19,9 +19,9 @@
#include "transmission.h" // tr_sha1_digest_t
/**
*** @addtogroup utils Utilities
*** @{
**/
* @addtogroup utils Utilities
* @{
*/
class tr_sha1
{

View File

@ -83,9 +83,7 @@ tr_file_piece_map::file_offset_t tr_file_piece_map::fileOffset(uint64_t offset)
return file_offset_t{ file_index, file_offset };
}
/***
****
***/
// ---
void tr_file_priorities::reset(tr_file_piece_map const* fpm)
{
@ -147,9 +145,7 @@ tr_priority_t tr_file_priorities::piecePriority(tr_piece_index_t piece) const
return *it;
}
/***
****
***/
// ---
void tr_files_wanted::reset(tr_file_piece_map const* fpm)
{

View File

@ -113,11 +113,7 @@ tr_handshake::ParseResult tr_handshake::parse_handshake(tr_peerIo* peer_io)
return ParseResult::Ok;
}
/***
****
**** OUTGOING CONNECTIONS
****
***/
// --- Outgoing Connections
// 1 A->B: our public key (Ya) and some padding (PadA)
void tr_handshake::send_ya(tr_peerIo* io)
@ -325,11 +321,7 @@ ReadState tr_handshake::read_pad_d(tr_peerIo* peer_io)
return READ_NOW;
}
/***
****
**** INCOMING CONNECTIONS
****
***/
// --- Incoming Connections
ReadState tr_handshake::read_handshake(tr_peerIo* peer_io)
{
@ -399,9 +391,7 @@ ReadState tr_handshake::read_handshake(tr_peerIo* peer_io)
}
}
/**
*** If it's an incoming message, we need to send a response handshake
**/
// If it's an incoming message, we need to send a response handshake
if (!have_sent_bittorrent_handshake_)
{
@ -599,9 +589,7 @@ ReadState tr_handshake::read_ia(tr_peerIo* peer_io)
return READ_LATER;
}
/**
*** B->A: ENCRYPT(VC, crypto_select, len(padD), padD), ENCRYPT2(Payload Stream)
**/
// B->A: ENCRYPT(VC, crypto_select, len(padD), padD), ENCRYPT2(Payload Stream)
auto const& info_hash = peer_io->torrent_hash();
TR_ASSERT_MSG(info_hash != tr_sha1_digest_t{}, "readIA requires an info_hash");
@ -682,11 +670,7 @@ ReadState tr_handshake::read_payload_stream(tr_peerIo* peer_io)
return done(true);
}
/***
****
****
****
***/
// ---
ReadState tr_handshake::can_read(tr_peerIo* peer_io, void* vhandshake, size_t* piece)
{
@ -907,9 +891,7 @@ uint32_t tr_handshake::crypto_provide() const noexcept
return provide;
}
/**
***
**/
// ---
tr_handshake::tr_handshake(Mediator* mediator, std::shared_ptr<tr_peerIo> peer_io, tr_encryption_mode mode, DoneFunc on_done)
: dh_{ tr_handshake::get_dh(mediator) }

View File

@ -115,9 +115,7 @@ int readOrWriteBytes(
return 0;
}
/***
**** Find the fd
***/
// --- Find the fd
auto fd = session->openFiles().get(tor->id(), file_index, do_write);
auto filename = tr_pathbuf{};

View File

@ -226,9 +226,7 @@ void tr_logFreeQueue(tr_log_message* freeme)
}
}
/**
***
**/
// ---
char* tr_logGetTimeStr(char* buf, size_t buflen)
{

View File

@ -165,9 +165,7 @@ std::optional<tr_sha256_digest_t> parseHash2(std::string_view sv)
} // namespace
/***
****
***/
// ---
tr_urlbuf tr_magnet_metainfo::magnet() const
{

View File

@ -60,9 +60,7 @@ std::string tr_net_strerror(int err)
#endif
}
/***********************************************************************
* TCP sockets
**********************************************************************/
// - TCP Sockets
[[nodiscard]] std::optional<tr_tos_t> tr_tos_t::from_string(std::string_view name)
{

View File

@ -308,9 +308,7 @@ struct tr_address
[[nodiscard]] bool is_valid_for_peers(tr_port port) const noexcept;
};
/***********************************************************************
* Sockets
**********************************************************************/
// --- Sockets
struct tr_session;

View File

@ -30,9 +30,7 @@ class tr_swarm;
struct peer_atom;
struct tr_bandwidth;
/**
*** Peer Publish / Subscribe
**/
// --- Peer Publish / Subscribe
class tr_peer_event
{
@ -263,9 +261,7 @@ public:
tr_recentHistory<uint16_t> cancels_sent_to_peer;
};
/***
****
***/
// ---
struct tr_swarm_stats
{
@ -279,9 +275,7 @@ tr_swarm_stats tr_swarmGetStats(tr_swarm const* swarm);
void tr_swarmIncrementActivePeers(tr_swarm* swarm, tr_direction direction, bool is_active);
/***
****
***/
// ---
#ifdef _WIN32
#undef EMSGSIZE

View File

@ -755,9 +755,7 @@ private:
static auto constexpr MaxConnectionsPerSecond = size_t{ 12 };
};
/**
*** tr_peer virtual functions
**/
// --- tr_peer virtual functions
tr_peer::tr_peer(tr_torrent const* tor, peer_atom* atom_in)
: session{ tor->session }
@ -826,23 +824,21 @@ void tr_peerMgrSetUtpFailed(tr_torrent* tor, tr_address const& addr, bool failed
}
/**
*** REQUESTS
***
*** There are two data structures associated with managing block requests:
***
*** 1. tr_swarm::active_requests, an opaque class that tracks what requests
*** we currently have, i.e. which blocks and from which peers.
*** This is used for cancelling requests that have been waiting
*** for too long and avoiding duplicate requests.
***
*** 2. tr_swarm::pieces, an array of "struct weighted_piece" which lists the
*** pieces that we want to request. It's used to decide which blocks to
*** return next when tr_peerMgrGetBlockRequests() is called.
**/
* REQUESTS
*
* There are two data structures associated with managing block requests:
*
* 1. tr_swarm::active_requests, an opaque class that tracks what requests
* we currently have, i.e. which blocks and from which peers.
* This is used for cancelling requests that have been waiting
* for too long and avoiding duplicate requests.
*
* 2. tr_swarm::pieces, an array of "struct weighted_piece" which lists the
* pieces that we want to request. It's used to decide which blocks to
* return next when tr_peerMgrGetBlockRequests() is called.
*/
/**
*** struct block_request
**/
// --- struct block_request
// TODO: if we keep this, add equivalent API to ActiveRequest
void tr_peerMgrClientSentRequests(tr_torrent* torrent, tr_peer* peer, tr_block_span_t span)
@ -924,11 +920,7 @@ std::vector<tr_block_span_t> tr_peerMgrGetNextRequests(tr_torrent* torrent, tr_p
return Wishlist::next(MediatorImpl(torrent, peer), numwant);
}
/****
*****
***** Piece List Manipulation / Accessors
*****
****/
// --- Piece List Manipulation / Accessors
bool tr_peerMgrDidPeerRequest(tr_torrent const* tor, tr_peer const* peer, tr_block_index_t block)
{
@ -1317,9 +1309,7 @@ std::vector<tr_pex> tr_peerMgrGetPeers(tr_torrent const* tor, uint8_t address_ty
tr_swarm const* s = tor->swarm;
/**
*** build a list of atoms
**/
// build a list of atoms
auto atoms = std::vector<peer_atom const*>{};
if (list_mode == TR_PEERS_CONNECTED) /* connected peers only */
@ -1344,9 +1334,7 @@ std::vector<tr_pex> tr_peerMgrGetPeers(tr_torrent const* tor, uint8_t address_ty
std::sort(std::begin(atoms), std::end(atoms), CompareAtomsByUsefulness{});
/**
*** add the first N of them into our return list
**/
// add the first N of them into our return list
auto const n = std::min(std::size(atoms), max_peer_count);
auto pex = std::vector<tr_pex>{};
@ -2132,11 +2120,7 @@ void tr_peerMgr::rechokePulse() const
}
}
/***
****
**** Life and Death
****
***/
// --- Life and Death
namespace disconnect_helpers
{
@ -2354,11 +2338,7 @@ void tr_peerMgr::reconnectPulse()
makeNewPeerConnections(max_connections_per_pulse);
}
/****
*****
***** BANDWIDTH ALLOCATION
*****
****/
// --- Bandwidth Allocation
namespace bandwidth_helpers
{

View File

@ -706,9 +706,7 @@ private:
static auto constexpr SendPexInterval = 90s;
};
/**
***
**/
// ---
void protocolSendReject(tr_peerMsgsImpl* msgs, struct peer_request const* req)
{
@ -1933,9 +1931,7 @@ size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
bool const have_messages = !std::empty(msgs->outMessages);
bool const fext = msgs->io->supports_fext();
/**
*** Protocol messages
**/
// --- Protocol messages
if (have_messages && msgs->outMessagesBatchedAt == 0) /* fresh batch */
{
@ -1954,9 +1950,7 @@ size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
bytes_written += len;
}
/**
*** Metadata Pieces
**/
// --- Metadata Pieces
if (auto piece = int{};
msgs->io->get_write_buffer_space(now) >= METADATA_PIECE_SIZE && popNextMetadataRequest(msgs, &piece))
@ -2012,9 +2006,7 @@ size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
}
}
/**
*** Data Blocks
**/
// --- Data Blocks
if (msgs->io->get_write_buffer_space(now) >= tr_block_info::BlockSize && !std::empty(msgs->peer_requested_))
{
@ -2086,9 +2078,7 @@ size_t fillOutputBuffer(tr_peerMsgsImpl* msgs, time_t now)
}
}
/**
*** Keepalive
**/
// --- Keepalive
if (msgs != nullptr && msgs->clientSentAnythingAt != 0 && now - msgs->clientSentAnythingAt > KeepaliveIntervalSecs)
{

View File

@ -9,10 +9,6 @@
#include "transmission.h"
/***
**** RPC processing
***/
struct tr_variant;
using tr_rpc_response_func = void (*)(tr_session* session, tr_variant* response, void* user_data);

View File

@ -282,9 +282,7 @@ void tr_session::LpdMediator::setNextAnnounceTime(std::string_view info_hash_str
}
}
/***
****
***/
// ---
std::optional<std::string> tr_session::WebMediator::cookieFile() const
{
@ -356,9 +354,7 @@ void tr_sessionFetch(tr_session* session, tr_web::FetchOptions&& options)
session->fetch(std::move(options));
}
/***
****
***/
// ---
tr_encryption_mode tr_sessionGetEncryption(tr_session const* session)
{
@ -375,9 +371,7 @@ void tr_sessionSetEncryption(tr_session* session, tr_encryption_mode mode)
session->settings_.encryption_mode = mode;
}
/***
****
***/
// ---
void tr_session::onIncomingPeerConnection(tr_socket_t fd, void* vsession)
{
@ -812,9 +806,7 @@ void tr_sessionSet(tr_session* session, tr_variant* settings)
done_future.wait();
}
/***
****
***/
// ---
void tr_sessionSetDownloadDir(tr_session* session, char const* dir)
{
@ -837,9 +829,7 @@ char const* tr_sessionGetConfigDir(tr_session const* session)
return session->configDir().c_str();
}
/***
****
***/
// ---
void tr_sessionSetIncompleteFileNamingEnabled(tr_session* session, bool enabled)
{
@ -855,9 +845,7 @@ bool tr_sessionIsIncompleteFileNamingEnabled(tr_session const* session)
return session->isIncompleteFileNamingEnabled();
}
/***
****
***/
// ---
void tr_sessionSetIncompleteDir(tr_session* session, char const* dir)
{
@ -887,9 +875,7 @@ bool tr_sessionIsIncompleteDirEnabled(tr_session const* session)
return session->useIncompleteDir();
}
/***
**** Peer Port
***/
// --- Peer Port
void tr_sessionSetPeerPort(tr_session* session, uint16_t hport)
{
@ -948,9 +934,7 @@ void tr_session::onAdvertisedPeerPortChanged()
}
}
/***
****
***/
// ---
void tr_sessionSetRatioLimited(tr_session* session, bool is_limited)
{
@ -980,9 +964,7 @@ double tr_sessionGetRatioLimit(tr_session const* session)
return session->desiredRatio();
}
/***
****
***/
// ---
void tr_sessionSetIdleLimited(tr_session* session, bool is_limited)
{
@ -1012,11 +994,7 @@ uint16_t tr_sessionGetIdleLimit(tr_session const* session)
return session->idleLimitMinutes();
}
/***
****
**** SPEED LIMITS
****
***/
// --- Speed limits
std::optional<tr_bytes_per_second_t> tr_session::activeSpeedLimitBps(tr_direction dir) const noexcept
{
@ -1058,9 +1036,7 @@ void tr_session::AltSpeedMediator::isActiveChanged(bool is_active, tr_session_al
session_.runInSessionThread(in_session_thread);
}
/***
**** Primary session speed limits
***/
// --- Session primary speed limits
void tr_sessionSetSpeedLimit_KBps(tr_session* session, tr_direction dir, tr_kilobytes_per_second_t limit)
{
@ -1112,9 +1088,7 @@ bool tr_sessionIsSpeedLimited(tr_session const* session, tr_direction dir)
return session->isSpeedLimited(dir);
}
/***
**** Alternative speed limits that are used during scheduled times
***/
// --- Session alt speed limits
void tr_sessionSetAltSpeed_KBps(tr_session* session, tr_direction dir, tr_kilobytes_per_second_t limit)
{
@ -1208,9 +1182,7 @@ void tr_sessionSetAltSpeedFunc(tr_session* session, tr_altSpeedFunc func, void*
session->alt_speed_active_changed_func_user_data_ = user_data;
}
/***
****
***/
// ---
void tr_sessionSetPeerLimit(tr_session* session, uint16_t max_global_peers)
{
@ -1442,9 +1414,7 @@ size_t tr_sessionGetAllTorrents(tr_session* session, tr_torrent** buf, size_t bu
return n;
}
/***
****
***/
// ---
void tr_sessionSetPexEnabled(tr_session* session, bool enabled)
{
@ -1483,9 +1453,7 @@ void tr_sessionSetDHTEnabled(tr_session* session, bool enabled)
}
}
/***
****
***/
// ---
bool tr_session::allowsUTP() const noexcept
{
@ -1538,9 +1506,7 @@ bool tr_sessionIsLPDEnabled(tr_session const* session)
return session->allowsLPD();
}
/***
****
***/
// ---
void tr_sessionSetCacheLimit_MB(tr_session* session, size_t mb)
{
@ -1557,9 +1523,7 @@ size_t tr_sessionGetCacheLimit_MB(tr_session const* session)
return session->settings_.cache_size_mb;
}
/***
****
***/
// ---
void tr_session::setDefaultTrackers(std::string_view trackers)
{
@ -1588,9 +1552,7 @@ void tr_sessionSetDefaultTrackers(tr_session* session, char const* trackers)
session->setDefaultTrackers(trackers != nullptr ? trackers : "");
}
/***
****
***/
// ---
tr_bandwidth& tr_session::getBandwidthGroup(std::string_view name)
{
@ -1608,9 +1570,7 @@ tr_bandwidth& tr_session::getBandwidthGroup(std::string_view name)
return *group;
}
/***
****
***/
// ---
void tr_sessionSetPortForwardingEnabled(tr_session* session, bool enabled)
{
@ -1624,9 +1584,7 @@ bool tr_sessionIsPortForwardingEnabled(tr_session const* session)
return session->port_forwarding_->isEnabled();
}
/***
****
***/
// ---
void tr_session::useBlocklist(bool enabled)
{
@ -1730,9 +1688,7 @@ char const* tr_blocklistGetURL(tr_session const* session)
return session->blocklistUrl().c_str();
}
/***
****
***/
// ---
void tr_session::setRpcWhitelist(std::string_view whitelist) const
{
@ -1858,9 +1814,7 @@ bool tr_sessionIsRPCPasswordEnabled(tr_session const* session)
return session->rpc_server_->isPasswordEnabled();
}
/****
*****
****/
// ---
void tr_sessionSetScriptEnabled(tr_session* session, TrScript type, bool enabled)
{
@ -1894,9 +1848,7 @@ char const* tr_sessionGetScript(tr_session const* session, TrScript type)
return session->script(type).c_str();
}
/***
****
***/
// ---
void tr_sessionSetQueueSize(tr_session* session, tr_direction dir, size_t max_simultaneous_torrents)
{

View File

@ -40,9 +40,7 @@ struct tr_session;
struct tr_torrent;
struct tr_torrent_announcer;
/**
*** Package-visible
**/
// --- Package-visible
void tr_torrentFreeInSessionThread(tr_torrent* tor);
@ -56,9 +54,7 @@ tr_session* tr_ctorGetSession(tr_ctor const* ctor);
bool tr_ctorGetIncompleteDir(tr_ctor const* ctor, char const** setmeIncompleteDir);
/**
***
**/
// ---
void tr_torrentChangeMyPort(tr_torrent* tor);
@ -955,9 +951,7 @@ private:
bool needs_completeness_check_ = true;
};
/***
****
***/
// ---
constexpr bool tr_isTorrent(tr_torrent const* tor)
{

View File

@ -54,9 +54,7 @@
#define TR_UCLIBC_CHECK_VERSION(major, minor, micro) 0
#endif
/***
****
***/
// ---
#if __has_builtin(__builtin_expect) || TR_GNUC_CHECK_VERSION(3, 0)
#define TR_LIKELY(x) __builtin_expect((x) ? 1L : 0L, 1L)
@ -72,9 +70,7 @@
Class(Class const&) = delete; \
Class(Class&&) = delete;
/***
****
***/
// ---
#define TR_PATH_DELIMITER '/'

View File

@ -8,9 +8,7 @@
#pragma once
/***
**** Basic Types
***/
// --- Basic Types
#include <stdbool.h> /* bool */
#include <stddef.h> /* size_t */
@ -87,11 +85,7 @@ enum tr_encryption_mode
#define TR_RATIO_NA -1
#define TR_RATIO_INF -2
/***
****
**** Startup & Shutdown
****
***/
// --- Startup & Shutdown
/**
* @addtogroup tr_session Session
@ -430,9 +424,7 @@ using tr_rpc_func = tr_rpc_callback_status (*)( //
*/
void tr_sessionSetRPCCallback(tr_session* session, tr_rpc_func func, void* user_data);
/**
***
**/
// ---
/** @brief Used by tr_sessionGetStats() and tr_sessionGetCumulativeStats() */
struct tr_session_stats
@ -477,9 +469,7 @@ void tr_sessionSetCacheLimit_MB(tr_session* session, size_t mb);
tr_encryption_mode tr_sessionGetEncryption(tr_session const* session);
void tr_sessionSetEncryption(tr_session* session, tr_encryption_mode mode);
/***********************************************************************
** Incoming Peer Connections Port
*/
// --- Incoming Peer Connections Port
void tr_sessionSetPortForwardingEnabled(tr_session* session, bool enabled);
@ -514,13 +504,7 @@ enum tr_direction
TR_DOWN = 1
};
/***
****
***/
/***
**** Primary session speed limits
***/
// --- Session primary speed limits
void tr_sessionSetSpeedLimit_KBps(tr_session* session, tr_direction dir, tr_kilobytes_per_second_t limit);
tr_kilobytes_per_second_t tr_sessionGetSpeedLimit_KBps(tr_session const* session, tr_direction dir);
@ -528,9 +512,7 @@ tr_kilobytes_per_second_t tr_sessionGetSpeedLimit_KBps(tr_session const* session
void tr_sessionLimitSpeed(tr_session* session, tr_direction dir, bool limited);
bool tr_sessionIsSpeedLimited(tr_session const* session, tr_direction dir);
/***
**** Alternative speed limits that are used during scheduled times
***/
// --- Session alt speed limits
void tr_sessionSetAltSpeed_KBps(tr_session* session, tr_direction dir, tr_kilobytes_per_second_t limit);
tr_kilobytes_per_second_t tr_sessionGetAltSpeed_KBps(tr_session const* session, tr_direction dir);
@ -568,9 +550,7 @@ using tr_altSpeedFunc = void (*)(tr_session* session, bool active, bool user_dri
void tr_sessionSetAltSpeedFunc(tr_session* session, tr_altSpeedFunc func, void* user_data);
/***
****
***/
// ---
double tr_sessionGetRawSpeed_KBps(tr_session const* session, tr_direction dir);
@ -606,27 +586,24 @@ int tr_sessionGetAntiBruteForceThreshold(tr_session const* session);
void tr_sessionSetAntiBruteForceEnabled(tr_session* session, bool enabled);
bool tr_sessionGetAntiBruteForceEnabled(tr_session const* session);
/**
**/
// ---
/***
****
**** Torrent Queueing
****
**** There are independent queues for seeding (TR_UP) and leeching (TR_DOWN).
****
**** If the session already has enough non-stalled seeds/leeches when
**** tr_torrentStart() is called, the torrent will be moved into the
**** appropriate queue and its state will be TR_STATUS_{DOWNLOAD,SEED}_WAIT.
****
**** To bypass the queue and unconditionally start the torrent use
**** tr_torrentStartNow().
****
**** Torrents can be moved in the queue using the simple functions
**** tr_torrentQueueMove{Top,Up,Down,Bottom}. They can be moved to
**** arbitrary points in the queue with tr_torrentSetQueuePosition().
****
***/
/**
* Torrent Queueing
*
* There are independent queues for seeding (TR_UP) and leeching (TR_DOWN).
*
* If the session already has enough non-stalled seeds/leeches when
* tr_torrentStart() is called, the torrent will be moved into the
* appropriate queue and its state will be TR_STATUS_{DOWNLOAD,SEED}_WAIT.
*
* To bypass the queue and unconditionally start the torrent use
* tr_torrentStartNow().
*
* Torrents can be moved in the queue using the simple functions
* tr_torrentQueueMove{Top,Up,Down,Bottom}. They can be moved to
* arbitrary points in the queue with tr_torrentSetQueuePosition().
*/
/** @brief Like tr_torrentStart(), but resumes right away regardless of the queues. */
void tr_torrentStartNow(tr_torrent* tor);
@ -638,8 +615,7 @@ size_t tr_torrentGetQueuePosition(tr_torrent const* tor);
* Special cases: pos <= 0 moves to the front; pos >= queue length moves to the back */
void tr_torrentSetQueuePosition(tr_torrent* tor, size_t queue_position);
/**
**/
// ---
/** @brief Convenience function for moving a batch of torrents to the front of their queue(s) */
void tr_torrentsQueueMoveTop(tr_torrent* const* torrents, size_t torrent_count);
@ -653,8 +629,7 @@ void tr_torrentsQueueMoveDown(tr_torrent* const* torrents, size_t torrent_count)
/** @brief Convenience function for moving a batch of torrents to the back of their queue(s) */
void tr_torrentsQueueMoveBottom(tr_torrent* const* torrents, size_t torrent_count);
/**
**/
// ---
/** @brief Set the number of torrents allowed to download (if direction is TR_DOWN) or seed (if direction is TR_UP) at the same time */
void tr_sessionSetQueueSize(tr_session* session, tr_direction dir, size_t max_simultaneous_torrents);
@ -668,8 +643,7 @@ void tr_sessionSetQueueEnabled(tr_session* session, tr_direction dir, bool do_li
/** @brief Return true if we're limiting how many torrents can concurrently download (TR_DOWN) or seed (TR_UP) at the same time */
bool tr_sessionGetQueueEnabled(tr_session const* session, tr_direction dir);
/**
**/
// ---
/** @brief Consider torrent as 'stalled' when it's been inactive for N minutes.
Stalled torrents are left running but are not counted by tr_sessionGetQueueSize(). */
@ -687,10 +661,7 @@ bool tr_sessionGetQueueStalledEnabled(tr_session const* session);
/** @brief Set a callback that is invoked when the queue starts a torrent */
void tr_sessionSetQueueStartCallback(tr_session* session, void (*callback)(tr_session*, tr_torrent*, void*), void* user_data);
/***
****
****
***/
// ---
/**
* Load all the torrents in the session's torrent folder.
@ -711,9 +682,7 @@ size_t tr_sessionLoadTorrents(tr_session* session, tr_ctor* ctor);
*/
size_t tr_sessionGetAllTorrents(tr_session* session, tr_torrent** buf, size_t buflen);
/**
***
**/
// ---
enum TrScript
{
@ -734,9 +703,7 @@ bool tr_sessionIsScriptEnabled(tr_session const* session, TrScript type);
/** @} */
/**
***
**/
// ---
/** @addtogroup Blocklists
@{ */
@ -883,10 +850,7 @@ tr_torrent* tr_torrentNew(tr_ctor* ctor, tr_torrent** setme_duplicate_of);
/** @} */
/***********************************************************************
***
*** TORRENTS
**/
// --- Torrents
/** @addtogroup tr_torrent Torrents
@{ */
@ -1023,10 +987,7 @@ uint64_t tr_torrentTotalSize(tr_torrent const* tor);
/** @brief buffer variant of tr_torrentFindFile(). See tr_strvToBuf(). */
size_t tr_torrentFindFileToBuf(tr_torrent const* tor, tr_file_index_t file_num, char* buf, size_t buflen);
/***
**** Torrent speed limits
****
***/
// --- Torrent speed limits
void tr_torrentSetSpeedLimit_KBps(tr_torrent* tor, tr_direction dir, tr_kilobytes_per_second_t kilo_per_second);
tr_kilobytes_per_second_t tr_torrentGetSpeedLimit_KBps(tr_torrent const* tor, tr_direction dir);
@ -1037,9 +998,7 @@ bool tr_torrentUsesSpeedLimit(tr_torrent const* tor, tr_direction dir);
void tr_torrentUseSessionLimits(tr_torrent* tor, bool enabled);
bool tr_torrentUsesSessionLimits(tr_torrent const* tor);
/****
***** Ratio Limits
****/
// --- Ratio Limits
enum tr_ratiolimit
{
@ -1061,9 +1020,7 @@ double tr_torrentGetRatioLimit(tr_torrent const* tor);
bool tr_torrentGetSeedRatio(tr_torrent const* tor, double* ratio);
/****
***** Idle Time Limits
****/
// --- Idle Time Limits
enum tr_idlelimit
{
@ -1085,17 +1042,13 @@ uint16_t tr_torrentGetIdleLimit(tr_torrent const* tor);
bool tr_torrentGetSeedIdle(tr_torrent const* tor, uint16_t* minutes);
/****
***** Peer Limits
****/
// --- Peer Limits
void tr_torrentSetPeerLimit(tr_torrent* tor, uint16_t max_connected_peers);
uint16_t tr_torrentGetPeerLimit(tr_torrent const* tor);
/****
***** File Priorities
****/
// --- File Priorities
enum
{
@ -1144,9 +1097,7 @@ char const* tr_torrentGetCurrentDir(tr_torrent const* tor);
/** @brief buffer variant of tr_torrentGetMagnetLink(). See tr_strvToBuf(). */
size_t tr_torrentGetMagnetLinkToBuf(tr_torrent const* tor, char* buf, size_t buflen);
/**
***
**/
// ---
/**
* Returns a string listing its tracker's announce URLs.
@ -1174,9 +1125,7 @@ size_t tr_torrentGetTrackerListToBuf(tr_torrent const* tor, char* buf, size_t bu
*/
bool tr_torrentSetTrackerList(tr_torrent* tor, char const* text);
/**
***
**/
// ---
enum tr_completeness
{
@ -1259,9 +1208,7 @@ void tr_torrentManualUpdate(tr_torrent* torrent);
bool tr_torrentCanManualUpdate(tr_torrent const* torrent);
/***
**** tr_peer_stat
***/
// --- tr_peer_stat
struct tr_peer_stat
{
@ -1289,10 +1236,8 @@ struct tr_peer_stat
double rateToPeer_KBps;
double rateToClient_KBps;
/***
**** THESE NEXT FOUR FIELDS ARE EXPERIMENTAL.
**** Don't rely on them; they'll probably go away
***/
// THESE NEXT FOUR FIELDS ARE EXPERIMENTAL.
// Don't rely on them; they'll probably go away
/* how many blocks we've sent to this peer in the last 120 seconds */
uint32_t blocksToPeer;
/* how many blocks this client's sent to us in the last 120 seconds */
@ -1313,9 +1258,7 @@ tr_peer_stat* tr_torrentPeers(tr_torrent const* torrent, size_t* peer_count);
void tr_torrentPeersFree(tr_peer_stat* peer_stats, size_t peer_count);
/***
**** tr_tracker_stat
***/
// --- tr_tracker_stat
enum tr_tracker_state
{
@ -1458,14 +1401,12 @@ struct tr_torrent_view tr_torrentView(tr_torrent const* tor);
/** @brief buffer variant of tr_torrentFilename(). See tr_strvToBuf(). */
size_t tr_torrentFilenameToBuf(tr_torrent const* tor, char* buf, size_t buflen);
/***********************************************************************
* tr_torrentAvailability
***********************************************************************
/**
* Use this to draw an advanced progress bar which is 'size' pixels
* wide. Fills 'tab' which you must have allocated: each byte is set
* to either -1 if we have the piece, otherwise it is set to the number
* of connected peers who have the piece.
**********************************************************************/
*/
void tr_torrentAvailability(tr_torrent const* torrent, int8_t* tab, int size);
void tr_torrentAmountFinished(tr_torrent const* torrent, float* tab, int n_tabs);

View File

@ -58,9 +58,7 @@ using namespace std::literals;
time_t libtransmission::detail::tr_time::current_time = {};
/**
***
**/
// ---
bool tr_loadFile(std::string_view filename, std::vector<char>& contents, tr_error** error)
{
@ -169,9 +167,7 @@ tr_disk_space tr_dirSpace(std::string_view directory)
return tr_device_info_get_disk_space(tr_device_info_create(directory));
}
/****
*****
****/
// ---
size_t tr_strvToBuf(std::string_view src, char* buf, size_t buflen)
{
@ -208,9 +204,7 @@ char const* tr_strerror(int errnum)
return "Unknown Error";
}
/****
*****
****/
// ---
std::string_view tr_strvStrip(std::string_view str)
{
@ -228,18 +222,14 @@ std::string_view tr_strvStrip(std::string_view str)
return str;
}
/****
*****
****/
// ---
uint64_t tr_time_msec()
{
return std::chrono::system_clock::now().time_since_epoch() / 1ms;
}
/***
****
***/
// ---
/*
* Copy src to string dst of size siz. At most siz-1 characters
@ -259,9 +249,7 @@ size_t tr_strlcpy(void* vdst, void const* vsrc, size_t siz)
return res.size;
}
/***
****
***/
// ---
double tr_getRatio(uint64_t numerator, uint64_t denominator)
{
@ -278,9 +266,7 @@ double tr_getRatio(uint64_t numerator, uint64_t denominator)
return TR_RATIO_NA;
}
/***
****
***/
// ---
std::string tr_strv_replace_invalid(std::string_view sv, uint32_t replacement)
{
@ -412,9 +398,7 @@ int tr_main_win32(int argc, char** argv, int (*real_main)(int, char**))
#endif
/***
****
***/
// ---
namespace
{
@ -490,9 +474,7 @@ std::vector<int> tr_parseNumberRange(std::string_view str)
return { std::begin(values), std::end(values) };
}
/***
****
***/
// ---
double tr_truncd(double x, int decimal_places)
{
@ -540,9 +522,7 @@ std::string tr_strratio(double ratio, char const* infinity)
return tr_strpercent(ratio);
}
/***
****
***/
// ---
bool tr_moveFile(std::string_view oldpath_in, std::string_view newpath_in, tr_error** error)
{
@ -597,9 +577,7 @@ bool tr_moveFile(std::string_view oldpath_in, std::string_view newpath_in, tr_er
return true;
}
/***
****
***/
// ---
uint64_t tr_htonll(uint64_t x)
{
@ -642,9 +620,7 @@ uint64_t tr_ntohll(uint64_t x)
#endif
}
/***
****
***/
// ---
namespace
{
@ -833,9 +809,7 @@ void tr_formatter_get_units(void* vdict)
}
}
/***
**** ENVIRONMENT
***/
// --- ENVIRONMENT
bool tr_env_key_exists(char const* key)
{
@ -896,9 +870,7 @@ std::string tr_env_get_string(std::string_view key, std::string_view default_val
return std::string{ default_value };
}
/***
****
***/
// ---
void tr_net_init()
{

View File

@ -56,9 +56,7 @@ struct tr_error;
#define tr_ngettext(singular, plural, count) ((count) == 1 ? (singular) : (plural))
#endif
/****
*****
****/
// ---
[[nodiscard]] std::string_view tr_get_mime_type_for_filename(std::string_view filename);
@ -122,9 +120,7 @@ int tr_main_win32(int argc, char** argv, int (*real_main)(int, char**));
#endif
/***
****
***/
// ---
[[nodiscard]] constexpr bool tr_str_is_empty(char const* value)
{
@ -154,9 +150,7 @@ template<typename T>
return out;
}
/***
**** std::string_view utils
***/
// --- std::string_view utils
template<typename T>
[[nodiscard]] constexpr bool tr_strvContains(std::string_view sv, T key) noexcept // c++23
@ -221,9 +215,7 @@ constexpr bool tr_strvSep(std::string_view* sv, std::string_view* token, char de
*/
size_t tr_strvToBuf(std::string_view src, char* buf, size_t buflen);
/***
****
***/
// ---
/** @brief return TR_RATIO_NA, TR_RATIO_INF, or a number in [0..1]
@return TR_RATIO_NA, TR_RATIO_INF, or a number in [0..1] */
@ -269,9 +261,7 @@ size_t tr_strvToBuf(std::string_view src, char* buf, size_t buflen);
*/
bool tr_moveFile(std::string_view oldpath, std::string_view newpath, struct tr_error** error = nullptr);
/***
****
***/
// ---
namespace libtransmission::detail::tr_time
{
@ -305,9 +295,7 @@ constexpr void tr_timeUpdate(time_t now) noexcept
/** @brief Portability wrapper for htonll() that uses the system implementation if available */
[[nodiscard]] uint64_t tr_ntohll(uint64_t);
/***
****
***/
// ---
/* example: tr_formatter_size_init(1024, _("KiB"), _("MiB"), _("GiB"), _("TiB")); */
@ -358,9 +346,7 @@ void tr_formatter_get_units(void* dict);
return size_t(B / (tr_mem_K * tr_mem_K));
}
/***
****
***/
// ---
/** @brief Check if environment variable exists. */
[[nodiscard]] bool tr_env_key_exists(char const* key);
@ -371,8 +357,6 @@ void tr_formatter_get_units(void* dict);
/** @brief Get environment variable value as string. */
[[nodiscard]] std::string tr_env_get_string(std::string_view key, std::string_view default_value = {});
/***
****
***/
// ---
void tr_net_init();

View File

@ -99,9 +99,7 @@ struct tr_variant
*/
void tr_variantClear(tr_variant*);
/***
**** Serialization / Deserialization
***/
// --- Serialization / Deserialization
enum tr_variant_fmt
{
@ -160,9 +158,7 @@ bool tr_variantFromBuf(
return b == nullptr || b->type == '\0';
}
/***
**** Strings
***/
// --- Strings
[[nodiscard]] constexpr bool tr_variantIsString(tr_variant const* b)
{
@ -192,9 +188,7 @@ constexpr void tr_variantInitStrView(tr_variant* initme, std::string_view in)
bool tr_variantGetRaw(tr_variant const* variant, std::byte const** setme_raw, size_t* setme_len);
bool tr_variantGetRaw(tr_variant const* variant, uint8_t const** setme_raw, size_t* setme_len);
/***
**** Real Numbers
***/
// --- Real Numbers
[[nodiscard]] constexpr bool tr_variantIsReal(tr_variant const* v)
{
@ -209,9 +203,7 @@ constexpr void tr_variantInitReal(tr_variant* initme, double value)
initme->val.d = value;
}
/***
**** Booleans
***/
// --- Booleans
[[nodiscard]] constexpr bool tr_variantIsBool(tr_variant const* v)
{
@ -226,9 +218,7 @@ constexpr void tr_variantInitBool(tr_variant* initme, bool value)
initme->val.b = value;
}
/***
**** Ints
***/
// --- Ints
[[nodiscard]] constexpr bool tr_variantIsInt(tr_variant const* v)
{
@ -243,9 +233,7 @@ constexpr void tr_variantInitInt(tr_variant* initme, int64_t value)
initme->val.i = value;
}
/***
**** Lists
***/
// --- Lists
[[nodiscard]] constexpr bool tr_variantIsList(tr_variant const* v)
{
@ -274,9 +262,7 @@ bool tr_variantListRemove(tr_variant* list, size_t pos);
return tr_variantIsList(list) ? list->val.l.count : 0;
}
/***
**** Dictionaries
***/
// --- Dictionaries
[[nodiscard]] constexpr bool tr_variantIsDict(tr_variant const* v)
{

View File

@ -41,9 +41,7 @@ using namespace std::literals;
#define USE_LIBCURL_SOCKOPT
#endif
/***
****
***/
// ---
namespace curl_helpers
{
@ -150,9 +148,7 @@ static CURLcode ssl_context_func(CURL* /*curl*/, void* ssl_ctx, void* /*user_dat
}
#endif
/***
****
***/
// ---
class tr_web::Impl
{

View File

@ -326,9 +326,7 @@ private:
tr_bandwidth bandwidth_;
};
/***
****
***/
// ---
struct write_block_data
{
@ -410,9 +408,7 @@ void useFetchedBlocks(tr_webseed_task* task)
}
}
/***
****
***/
// ---
void onBufferGotData(evbuffer* /*buf*/, evbuffer_cb_info const* info, void* vtask)
{
@ -537,9 +533,7 @@ void task_request_next_chunk(tr_webseed_task* task)
} // namespace
/***
****
***/
// ---
tr_peer* tr_webseedNew(tr_torrent* torrent, std::string_view url, tr_peer_callback callback, void* callback_data)
{