refactor: prefer "using" over "typedef" (#1883)
* refactor: prefer "using" over "typedef"
This commit is contained in:
parent
035ca23226
commit
cc204e0b2c
|
@ -44,8 +44,6 @@
|
|||
#endif
|
||||
#include <string.h> /* strlen () */
|
||||
|
||||
#include "transmission.h"
|
||||
|
||||
#include "ConvertUTF.h"
|
||||
|
||||
static const int halfShift = 10; /* used for shifting by 10 bits */
|
||||
|
@ -364,7 +362,7 @@ tr_utf8_validate (const char * str, size_t max_len, const char ** end)
|
|||
if (str == NULL)
|
||||
return false;
|
||||
|
||||
sourceEnd = source + (max_len == TR_BAD_SIZE ? strlen (str) : max_len);
|
||||
sourceEnd = source + (max_len == ((size_t)-1) ? strlen (str) : max_len);
|
||||
|
||||
if (source == sourceEnd)
|
||||
{
|
||||
|
|
|
@ -21,21 +21,18 @@
|
|||
**** SCRAPE
|
||||
***/
|
||||
|
||||
enum
|
||||
{
|
||||
/* pick a number small enough for common tracker software:
|
||||
* - ocelot has no upper bound
|
||||
* - opentracker has an upper bound of 64
|
||||
* - udp protocol has an upper bound of 74
|
||||
* - xbtt has no upper bound
|
||||
*
|
||||
* This is only an upper bound: if the tracker complains about
|
||||
* length, announcer will incrementally lower the batch size.
|
||||
*/
|
||||
TR_MULTISCRAPE_MAX = 60
|
||||
};
|
||||
/* pick a number small enough for common tracker software:
|
||||
* - ocelot has no upper bound
|
||||
* - opentracker has an upper bound of 64
|
||||
* - udp protocol has an upper bound of 74
|
||||
* - xbtt has no upper bound
|
||||
*
|
||||
* This is only an upper bound: if the tracker complains about
|
||||
* length, announcer will incrementally lower the batch size.
|
||||
*/
|
||||
auto inline constexpr TR_MULTISCRAPE_MAX = 60;
|
||||
|
||||
typedef struct
|
||||
struct tr_scrape_request
|
||||
{
|
||||
/* the scrape URL */
|
||||
char const* url;
|
||||
|
@ -48,7 +45,7 @@ typedef struct
|
|||
|
||||
/* how many hashes to use in the info_hash field */
|
||||
int info_hash_count;
|
||||
} tr_scrape_request;
|
||||
};
|
||||
|
||||
struct tr_scrape_response_row
|
||||
{
|
||||
|
@ -95,7 +92,7 @@ struct tr_scrape_response
|
|||
int min_request_interval;
|
||||
};
|
||||
|
||||
typedef void (*tr_scrape_response_func)(tr_scrape_response const* response, void* user_data);
|
||||
using tr_scrape_response_func = void (*)(tr_scrape_response const* response, void* user_data);
|
||||
|
||||
void tr_tracker_http_scrape(
|
||||
tr_session* session,
|
||||
|
@ -113,7 +110,7 @@ void tr_tracker_udp_scrape(
|
|||
**** ANNOUNCE
|
||||
***/
|
||||
|
||||
typedef enum
|
||||
enum tr_announce_event
|
||||
{
|
||||
/* Note: the ordering of this enum's values is important to
|
||||
* announcer.c's tr_tier.announce_event_priority. If changing
|
||||
|
@ -122,11 +119,11 @@ typedef enum
|
|||
TR_ANNOUNCE_EVENT_STARTED,
|
||||
TR_ANNOUNCE_EVENT_COMPLETED,
|
||||
TR_ANNOUNCE_EVENT_STOPPED,
|
||||
} tr_announce_event;
|
||||
};
|
||||
|
||||
char const* tr_announce_event_get_string(tr_announce_event);
|
||||
|
||||
typedef struct
|
||||
struct tr_announce_request
|
||||
{
|
||||
tr_announce_event event;
|
||||
bool partial_seed;
|
||||
|
@ -168,11 +165,11 @@ typedef struct
|
|||
|
||||
/* the name to use when deep logging is enabled */
|
||||
char log_name[128];
|
||||
} tr_announce_request;
|
||||
};
|
||||
|
||||
struct tr_pex;
|
||||
|
||||
typedef struct
|
||||
struct tr_announce_response
|
||||
{
|
||||
/* the torrent's info hash */
|
||||
uint8_t info_hash[SHA_DIGEST_LENGTH];
|
||||
|
@ -221,9 +218,9 @@ typedef struct
|
|||
/* key generated by and returned from an http tracker.
|
||||
* if this is provided, subsequent http announces must include this. */
|
||||
char* tracker_id_str;
|
||||
} tr_announce_response;
|
||||
};
|
||||
|
||||
typedef void (*tr_announce_response_func)(tr_announce_response const* response, void* userdata);
|
||||
using tr_announce_response_func = void (*)(tr_announce_response const* response, void* userdata);
|
||||
|
||||
void tr_tracker_http_announce(
|
||||
tr_session* session,
|
||||
|
|
|
@ -95,14 +95,14 @@ static uint64_t evbuffer_read_ntoh_64(struct evbuffer* buf)
|
|||
*****
|
||||
****/
|
||||
|
||||
typedef uint64_t tau_connection_t;
|
||||
using tau_connection_t = uint64_t;
|
||||
|
||||
enum
|
||||
{
|
||||
TAU_CONNECTION_TTL_SECS = 60
|
||||
};
|
||||
|
||||
typedef uint32_t tau_transaction_t;
|
||||
using tau_transaction_t = uint32_t;
|
||||
|
||||
static tau_transaction_t tau_transaction_new(void)
|
||||
{
|
||||
|
@ -112,13 +112,13 @@ static tau_transaction_t tau_transaction_new(void)
|
|||
}
|
||||
|
||||
/* used in the "action" field of a request */
|
||||
typedef enum
|
||||
enum tau_action_t
|
||||
{
|
||||
TAU_ACTION_CONNECT = 0,
|
||||
TAU_ACTION_ANNOUNCE = 1,
|
||||
TAU_ACTION_SCRAPE = 2,
|
||||
TAU_ACTION_ERROR = 3
|
||||
} tau_action_t;
|
||||
};
|
||||
|
||||
static bool is_tau_response_message(tau_action_t action, size_t msglen)
|
||||
{
|
||||
|
@ -295,14 +295,14 @@ struct tau_announce_request
|
|||
void* user_data;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tau_announce_event
|
||||
{
|
||||
/* used in the "event" field of an announce request */
|
||||
TAU_ANNOUNCE_EVENT_NONE = 0,
|
||||
TAU_ANNOUNCE_EVENT_COMPLETED = 1,
|
||||
TAU_ANNOUNCE_EVENT_STARTED = 2,
|
||||
TAU_ANNOUNCE_EVENT_STOPPED = 3
|
||||
} tau_announce_event;
|
||||
};
|
||||
|
||||
static tau_announce_event get_tau_announce_event(tr_announce_event e)
|
||||
{
|
||||
|
|
|
@ -145,7 +145,7 @@ struct tr_scrape_info
|
|||
/**
|
||||
* "global" (per-tr_session) fields
|
||||
*/
|
||||
typedef struct tr_announcer
|
||||
struct tr_announcer
|
||||
{
|
||||
std::set<tr_announce_request*, StopsCompare> stops;
|
||||
std::map<std::string, tr_scrape_info> scrape_info;
|
||||
|
@ -154,7 +154,7 @@ typedef struct tr_announcer
|
|||
struct event* upkeepTimer;
|
||||
int key;
|
||||
time_t tauUpkeepAt;
|
||||
} tr_announcer;
|
||||
};
|
||||
|
||||
static struct tr_scrape_info* tr_announcerGetScrapeInfo(struct tr_announcer* announcer, std::string const& url)
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ void tr_announcerClose(tr_session* session)
|
|||
***/
|
||||
|
||||
/* a row in tr_tier's list of trackers */
|
||||
typedef struct
|
||||
struct tr_tracker
|
||||
{
|
||||
char* key;
|
||||
char* announce;
|
||||
|
@ -223,7 +223,7 @@ typedef struct
|
|||
int consecutiveFailures;
|
||||
|
||||
uint32_t id;
|
||||
} tr_tracker;
|
||||
};
|
||||
|
||||
/* format: host+':'+ port */
|
||||
static char* getKey(char const* url)
|
||||
|
@ -267,7 +267,7 @@ static void trackerDestruct(tr_tracker* tracker)
|
|||
struct tr_torrent_tiers;
|
||||
|
||||
/** @brief A group of trackers in a single tier, as per the multitracker spec */
|
||||
typedef struct tr_tier
|
||||
struct tr_tier
|
||||
{
|
||||
/* number of up/down/corrupt bytes since the last time we sent an
|
||||
* "event=stopped" message that was acknowledged by the tracker */
|
||||
|
@ -314,7 +314,7 @@ typedef struct tr_tier
|
|||
|
||||
char lastAnnounceStr[128];
|
||||
char lastScrapeStr[128];
|
||||
} tr_tier;
|
||||
};
|
||||
|
||||
static time_t get_next_scrape_time(tr_session const* session, tr_tier const* tier, int interval)
|
||||
{
|
||||
|
@ -398,7 +398,7 @@ static void tierIncrementTracker(tr_tier* tier)
|
|||
*
|
||||
* this opaque data structure can be found in tr_torrent.tiers
|
||||
*/
|
||||
typedef struct tr_torrent_tiers
|
||||
struct tr_torrent_tiers
|
||||
{
|
||||
tr_tier* tiers;
|
||||
int tier_count;
|
||||
|
@ -408,7 +408,7 @@ typedef struct tr_torrent_tiers
|
|||
|
||||
tr_tracker_callback callback;
|
||||
void* callbackData;
|
||||
} tr_torrent_tiers;
|
||||
};
|
||||
|
||||
static tr_torrent_tiers* tiersNew(void)
|
||||
{
|
||||
|
|
|
@ -21,19 +21,19 @@ struct tr_torrent_tiers;
|
|||
* *** Tracker Publish / Subscribe
|
||||
* **/
|
||||
|
||||
typedef enum
|
||||
enum TrackerEventType
|
||||
{
|
||||
TR_TRACKER_WARNING,
|
||||
TR_TRACKER_ERROR,
|
||||
TR_TRACKER_ERROR_CLEAR,
|
||||
TR_TRACKER_PEERS,
|
||||
TR_TRACKER_COUNTS,
|
||||
} TrackerEventType;
|
||||
};
|
||||
|
||||
struct tr_pex;
|
||||
|
||||
/** @brief Notification object to tell listeners about announce or scrape occurences */
|
||||
typedef struct
|
||||
struct tr_tracker_event
|
||||
{
|
||||
/* what type of event this is */
|
||||
TrackerEventType messageType;
|
||||
|
@ -49,9 +49,9 @@ typedef struct
|
|||
/* for TR_TRACKER_PEERS and TR_TRACKER_COUNTS */
|
||||
int leechers;
|
||||
int seeders;
|
||||
} tr_tracker_event;
|
||||
};
|
||||
|
||||
typedef void (*tr_tracker_callback)(tr_torrent* tor, tr_tracker_event const* event, void* client_data);
|
||||
using tr_tracker_callback = void (*)(tr_torrent* tor, tr_tracker_event const* event, void* client_data);
|
||||
|
||||
/**
|
||||
*** Session ctor/dtor
|
||||
|
|
|
@ -100,7 +100,7 @@ struct tr_band
|
|||
* and call tr_bandwidthClamp() before performing I/O to see how much
|
||||
* bandwidth they can safely use.
|
||||
*/
|
||||
typedef struct tr_bandwidth
|
||||
struct tr_bandwidth
|
||||
{
|
||||
/* these are PRIVATE IMPLEMENTATION details that should not be touched.
|
||||
* it's included in the header for inlining and composition. */
|
||||
|
@ -112,7 +112,7 @@ typedef struct tr_bandwidth
|
|||
unsigned int uniqueKey;
|
||||
tr_ptrArray children; /* struct tr_bandwidth */
|
||||
struct tr_peerIo* peer;
|
||||
} tr_bandwidth;
|
||||
};
|
||||
|
||||
/**
|
||||
***
|
||||
|
|
|
@ -16,20 +16,20 @@
|
|||
#include "tr-macros.h"
|
||||
|
||||
/** @brief Implementation of the BitTorrent spec's Bitfield array of bits */
|
||||
typedef struct tr_bitfield
|
||||
struct tr_bitfield
|
||||
{
|
||||
uint8_t* bits;
|
||||
size_t alloc_count;
|
||||
uint8_t* bits = nullptr;
|
||||
size_t alloc_count = 0;
|
||||
|
||||
size_t bit_count;
|
||||
size_t bit_count = 0;
|
||||
|
||||
size_t true_count;
|
||||
size_t true_count = 0;
|
||||
|
||||
/* Special cases for when full or empty but we don't know the bitCount.
|
||||
This occurs when a magnet link's peers send have all / have none */
|
||||
bool have_all_hint;
|
||||
bool have_none_hint;
|
||||
} tr_bitfield;
|
||||
bool have_all_hint = false;
|
||||
bool have_none_hint = false;
|
||||
};
|
||||
|
||||
/***
|
||||
****
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
struct tr_address;
|
||||
|
||||
typedef struct tr_blocklistFile tr_blocklistFile;
|
||||
struct tr_blocklistFile;
|
||||
|
||||
tr_blocklistFile* tr_blocklistFileNew(char const* filename, bool isEnabled);
|
||||
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
#include "tr-macros.h"
|
||||
|
||||
struct evbuffer;
|
||||
|
||||
typedef struct tr_cache tr_cache;
|
||||
struct tr_cache;
|
||||
|
||||
/***
|
||||
****
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "bitfield.h"
|
||||
#include "utils.h" /* tr_getRatio() */
|
||||
|
||||
typedef struct tr_completion
|
||||
struct tr_completion
|
||||
{
|
||||
tr_torrent* tor;
|
||||
|
||||
|
@ -40,7 +40,7 @@ typedef struct tr_completion
|
|||
|
||||
/* number of bytes we want or have now. [0..sizeWhenDone] */
|
||||
uint64_t sizeNow;
|
||||
} tr_completion;
|
||||
};
|
||||
|
||||
/**
|
||||
*** Life Cycle
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
|
||||
#define MY_NAME "tr_crypto_utils"
|
||||
|
||||
typedef API(ctr_drbg_context) api_ctr_drbg_context;
|
||||
typedef API(sha1_context) api_sha1_context;
|
||||
typedef API(dhm_context) api_dhm_context;
|
||||
using api_ctr_drbg_context = API(ctr_drbg_context);
|
||||
using api_sha1_context = API(sha1_context);
|
||||
using api_dhm_context = API(dhm_context);
|
||||
|
||||
static void log_polarssl_error(int error_code, char const* file, int line)
|
||||
{
|
||||
|
|
|
@ -22,17 +22,17 @@
|
|||
**/
|
||||
|
||||
/** @brief Opaque SHA1 context type. */
|
||||
typedef void* tr_sha1_ctx_t;
|
||||
using tr_sha1_ctx_t = void*;
|
||||
/** @brief Opaque DH context type. */
|
||||
typedef void* tr_dh_ctx_t;
|
||||
using tr_dh_ctx_t = void*;
|
||||
/** @brief Opaque DH secret key type. */
|
||||
typedef void* tr_dh_secret_t;
|
||||
using tr_dh_secret_t = void*;
|
||||
/** @brief Opaque SSL context type. */
|
||||
typedef void* tr_ssl_ctx_t;
|
||||
using tr_ssl_ctx_t = void*;
|
||||
/** @brief Opaque X509 certificate store type. */
|
||||
typedef void* tr_x509_store_t;
|
||||
using tr_x509_store_t = void*;
|
||||
/** @brief Opaque X509 certificate type. */
|
||||
typedef void* tr_x509_cert_t;
|
||||
using tr_x509_cert_t = void*;
|
||||
|
||||
/**
|
||||
* @brief Generate a SHA1 hash from one or more chunks of memory.
|
||||
|
|
|
@ -31,7 +31,7 @@ enum
|
|||
};
|
||||
|
||||
/** @brief Holds state information for encrypted peer communications */
|
||||
typedef struct
|
||||
struct tr_crypto
|
||||
{
|
||||
struct arc4_context* dec_key;
|
||||
struct arc4_context* enc_key;
|
||||
|
@ -41,7 +41,7 @@ typedef struct
|
|||
uint8_t torrentHash[SHA_DIGEST_LENGTH];
|
||||
bool isIncoming;
|
||||
bool torrentHashIsSet;
|
||||
} tr_crypto;
|
||||
};
|
||||
|
||||
/** @brief construct a new tr_crypto object */
|
||||
void tr_cryptoConstruct(tr_crypto* crypto, uint8_t const* torrentHash, bool isIncoming);
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
|
||||
/** @brief Structure holding error information. */
|
||||
typedef struct tr_error
|
||||
struct tr_error
|
||||
{
|
||||
/** @brief Error code, platform-specific */
|
||||
int code;
|
||||
/** @brief Error message */
|
||||
char* message;
|
||||
} tr_error;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Create new error object using literal error message.
|
||||
|
|
|
@ -27,11 +27,11 @@ struct tr_error;
|
|||
#ifndef _WIN32
|
||||
|
||||
/** @brief Platform-specific file descriptor type. */
|
||||
typedef int tr_sys_file_t;
|
||||
using tr_sys_file_t = int;
|
||||
/** @brief Platform-specific invalid file descriptor constant. */
|
||||
#define TR_BAD_SYS_FILE (-1)
|
||||
/** @brief Platform-specific directory descriptor type. */
|
||||
typedef void* tr_sys_dir_t;
|
||||
using tr_sys_dir_t = void*;
|
||||
/** @brief Platform-specific end-of-line sequence. */
|
||||
#define TR_NATIVE_EOL_STR "\n"
|
||||
/** @brief Platform-specific end-of-line sequence length. */
|
||||
|
@ -39,9 +39,10 @@ typedef void* tr_sys_dir_t;
|
|||
|
||||
#else
|
||||
|
||||
typedef HANDLE tr_sys_file_t;
|
||||
using tr_sys_file_t = HANDLE;
|
||||
#define TR_BAD_SYS_FILE INVALID_HANDLE_VALUE
|
||||
typedef struct tr_sys_dir_win32* tr_sys_dir_t;
|
||||
struct tr_sys_dir_win32;
|
||||
using tr_sys_dir_t = tr_sys_dir_win32*;
|
||||
#define TR_NATIVE_EOL_STR "\r\n"
|
||||
#define TR_NATIVE_EOL_STR_SIZE 2
|
||||
|
||||
|
@ -50,14 +51,14 @@ typedef struct tr_sys_dir_win32* tr_sys_dir_t;
|
|||
/** @brief Platform-specific invalid directory descriptor constant. */
|
||||
#define TR_BAD_SYS_DIR ((tr_sys_dir_t) nullptr)
|
||||
|
||||
typedef enum
|
||||
enum tr_std_sys_file_t
|
||||
{
|
||||
TR_STD_SYS_FILE_IN,
|
||||
TR_STD_SYS_FILE_OUT,
|
||||
TR_STD_SYS_FILE_ERR
|
||||
} tr_std_sys_file_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_sys_file_open_flags_t
|
||||
{
|
||||
TR_SYS_FILE_READ = (1 << 0),
|
||||
TR_SYS_FILE_WRITE = (1 << 1),
|
||||
|
@ -66,57 +67,57 @@ typedef enum
|
|||
TR_SYS_FILE_APPEND = (1 << 4),
|
||||
TR_SYS_FILE_TRUNCATE = (1 << 5),
|
||||
TR_SYS_FILE_SEQUENTIAL = (1 << 6)
|
||||
} tr_sys_file_open_flags_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_seek_origin_t
|
||||
{
|
||||
TR_SEEK_SET,
|
||||
TR_SEEK_CUR,
|
||||
TR_SEEK_END
|
||||
} tr_seek_origin_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_sys_file_lock_flags_t
|
||||
{
|
||||
TR_SYS_FILE_LOCK_SH = (1 << 0),
|
||||
TR_SYS_FILE_LOCK_EX = (1 << 1),
|
||||
TR_SYS_FILE_LOCK_NB = (1 << 2),
|
||||
TR_SYS_FILE_LOCK_UN = (1 << 3)
|
||||
} tr_sys_file_lock_flags_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_sys_path_get_info_flags_t
|
||||
{
|
||||
TR_SYS_PATH_NO_FOLLOW = (1 << 0)
|
||||
} tr_sys_path_get_info_flags_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_sys_file_advice_t
|
||||
{
|
||||
TR_SYS_FILE_ADVICE_WILL_NEED,
|
||||
TR_SYS_FILE_ADVICE_DONT_NEED
|
||||
} tr_sys_file_advice_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_sys_file_preallocate_flags_t
|
||||
{
|
||||
TR_SYS_FILE_PREALLOC_SPARSE = (1 << 0)
|
||||
} tr_sys_file_preallocate_flags_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_sys_dir_create_flags_t
|
||||
{
|
||||
TR_SYS_DIR_CREATE_PARENTS = (1 << 0)
|
||||
} tr_sys_dir_create_flags_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_sys_path_type_t
|
||||
{
|
||||
TR_SYS_PATH_IS_FILE,
|
||||
TR_SYS_PATH_IS_DIRECTORY,
|
||||
TR_SYS_PATH_IS_OTHER
|
||||
} tr_sys_path_type_t;
|
||||
};
|
||||
|
||||
typedef struct tr_sys_path_info
|
||||
struct tr_sys_path_info
|
||||
{
|
||||
tr_sys_path_type_t type;
|
||||
uint64_t size;
|
||||
time_t last_modified_at;
|
||||
} tr_sys_path_info;
|
||||
tr_sys_path_type_t type = {};
|
||||
uint64_t size = 0;
|
||||
time_t last_modified_at = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Platform-specific wrapper functions
|
||||
|
|
|
@ -85,7 +85,7 @@ enum
|
|||
***
|
||||
**/
|
||||
|
||||
typedef enum
|
||||
enum handshake_state_t
|
||||
{
|
||||
/* incoming */
|
||||
AWAITING_HANDSHAKE,
|
||||
|
@ -103,7 +103,7 @@ typedef enum
|
|||
AWAITING_PAD_D,
|
||||
/* */
|
||||
N_STATES
|
||||
} handshake_state_t;
|
||||
};
|
||||
|
||||
struct tr_handshake
|
||||
{
|
||||
|
@ -211,13 +211,13 @@ static bool buildHandshakeMessage(tr_handshake* handshake, uint8_t* buf)
|
|||
|
||||
static ReadState tr_handshakeDone(tr_handshake* handshake, bool isConnected);
|
||||
|
||||
typedef enum
|
||||
enum handshake_parse_err_t
|
||||
{
|
||||
HANDSHAKE_OK,
|
||||
HANDSHAKE_ENCRYPTION_WRONG,
|
||||
HANDSHAKE_BAD_TORRENT,
|
||||
HANDSHAKE_PEER_IS_SELF,
|
||||
} handshake_parse_err_t;
|
||||
};
|
||||
|
||||
static handshake_parse_err_t parseHandshake(tr_handshake* handshake, struct evbuffer* inbuf)
|
||||
{
|
||||
|
|
|
@ -22,10 +22,10 @@ struct tr_peerIo;
|
|||
|
||||
/** @brief opaque struct holding hanshake state information.
|
||||
freed when the handshake is completed. */
|
||||
typedef struct tr_handshake tr_handshake;
|
||||
struct tr_handshake;
|
||||
|
||||
/* returns true on success, false on error */
|
||||
typedef bool (*handshakeDoneCB)(
|
||||
using handshakeDoneCB = bool (*)(
|
||||
struct tr_handshake* handshake,
|
||||
struct tr_peerIo* io,
|
||||
bool readAnythingFromPeer,
|
||||
|
|
|
@ -29,7 +29,7 @@ enum
|
|||
TR_RECENT_HISTORY_PERIOD_SEC = 60
|
||||
};
|
||||
|
||||
typedef struct tr_recentHistory
|
||||
struct tr_recentHistory
|
||||
{
|
||||
/* these are PRIVATE IMPLEMENTATION details included for composition only.
|
||||
* Don't access these directly! */
|
||||
|
@ -41,7 +41,7 @@ typedef struct tr_recentHistory
|
|||
unsigned int n;
|
||||
time_t date;
|
||||
} slices[TR_RECENT_HISTORY_PERIOD_SEC];
|
||||
} tr_recentHistory;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief add a counter to the recent history object.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "transmission.h"
|
||||
#include "variant.h"
|
||||
|
||||
typedef struct tr_magnet_info
|
||||
struct tr_magnet_info
|
||||
{
|
||||
uint8_t hash[20];
|
||||
|
||||
|
@ -27,7 +27,7 @@ typedef struct tr_magnet_info
|
|||
|
||||
int webseedCount;
|
||||
char** webseeds;
|
||||
} tr_magnet_info;
|
||||
};
|
||||
|
||||
tr_magnet_info* tr_magnetParse(char const* uri);
|
||||
|
||||
|
|
|
@ -11,22 +11,22 @@
|
|||
#include "tr-macros.h"
|
||||
#include "transmission.h"
|
||||
|
||||
typedef struct tr_metainfo_builder_file
|
||||
struct tr_metainfo_builder_file
|
||||
{
|
||||
char* filename;
|
||||
uint64_t size;
|
||||
} tr_metainfo_builder_file;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_metainfo_builder_err
|
||||
{
|
||||
TR_MAKEMETA_OK,
|
||||
TR_MAKEMETA_URL,
|
||||
TR_MAKEMETA_CANCELLED,
|
||||
TR_MAKEMETA_IO_READ, /* see builder.errfile, builder.my_errno */
|
||||
TR_MAKEMETA_IO_WRITE /* see builder.errfile, builder.my_errno */
|
||||
} tr_metainfo_builder_err;
|
||||
};
|
||||
|
||||
typedef struct tr_metainfo_builder
|
||||
struct tr_metainfo_builder
|
||||
{
|
||||
/**
|
||||
*** These are set by tr_makeMetaInfoBuilderCreate()
|
||||
|
@ -78,7 +78,7 @@ typedef struct tr_metainfo_builder
|
|||
**/
|
||||
|
||||
struct tr_metainfo_builder* nextBuilder;
|
||||
} tr_metainfo_builder;
|
||||
};
|
||||
|
||||
tr_metainfo_builder* tr_metaInfoBuilderCreate(char const* topFile);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ static char const* getKey(void)
|
|||
return _("Port Forwarding (NAT-PMP)");
|
||||
}
|
||||
|
||||
typedef enum
|
||||
enum tr_natpmp_state
|
||||
{
|
||||
TR_NATPMP_IDLE,
|
||||
TR_NATPMP_ERR,
|
||||
|
@ -40,7 +40,7 @@ typedef enum
|
|||
TR_NATPMP_RECV_MAP,
|
||||
TR_NATPMP_SEND_UNMAP,
|
||||
TR_NATPMP_RECV_UNMAP
|
||||
} tr_natpmp_state;
|
||||
};
|
||||
|
||||
struct tr_natpmp
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef struct tr_natpmp tr_natpmp;
|
||||
struct tr_natpmp;
|
||||
|
||||
tr_natpmp* tr_natpmpInit(void);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "tr-macros.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef SOCKET tr_socket_t;
|
||||
using tr_socket_t = SOCKET;
|
||||
#define TR_BAD_SOCKET INVALID_SOCKET
|
||||
|
||||
#undef EADDRINUSE
|
||||
|
@ -63,7 +63,7 @@ typedef SOCKET tr_socket_t;
|
|||
#define sockerrno WSAGetLastError()
|
||||
#else
|
||||
/** @brief Platform-specific socket descriptor type. */
|
||||
typedef int tr_socket_t;
|
||||
using tr_socket_t = int;
|
||||
/** @brief Platform-specific invalid socket descriptor constant. */
|
||||
#define TR_BAD_SOCKET (-1)
|
||||
|
||||
|
@ -76,14 +76,14 @@ typedef int tr_socket_t;
|
|||
*****
|
||||
****/
|
||||
|
||||
typedef enum tr_address_type
|
||||
enum tr_address_type
|
||||
{
|
||||
TR_AF_INET,
|
||||
TR_AF_INET6,
|
||||
NUM_TR_AF_INET_TYPES
|
||||
} tr_address_type;
|
||||
};
|
||||
|
||||
typedef struct tr_address
|
||||
struct tr_address
|
||||
{
|
||||
tr_address_type type;
|
||||
union
|
||||
|
@ -91,7 +91,7 @@ typedef struct tr_address
|
|||
struct in6_addr addr6;
|
||||
struct in_addr addr4;
|
||||
} addr;
|
||||
} tr_address;
|
||||
};
|
||||
|
||||
extern tr_address const tr_inaddr_any;
|
||||
extern tr_address const tr_in6addr_any;
|
||||
|
|
|
@ -37,7 +37,7 @@ enum
|
|||
*** Peer Publish / Subscribe
|
||||
**/
|
||||
|
||||
typedef enum
|
||||
enum PeerEventType
|
||||
{
|
||||
TR_PEER_CLIENT_GOT_BLOCK,
|
||||
TR_PEER_CLIENT_GOT_CHOKE,
|
||||
|
@ -52,9 +52,9 @@ typedef enum
|
|||
TR_PEER_CLIENT_GOT_HAVE_NONE,
|
||||
TR_PEER_PEER_GOT_PIECE_DATA,
|
||||
TR_PEER_ERROR
|
||||
} PeerEventType;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct tr_peer_event
|
||||
{
|
||||
PeerEventType eventType;
|
||||
|
||||
|
@ -64,17 +64,18 @@ typedef struct
|
|||
uint32_t length; /* for GOT_BLOCK + GOT_PIECE_DATA */
|
||||
int err; /* errno for GOT_ERROR */
|
||||
tr_port port; /* for GOT_PORT */
|
||||
} tr_peer_event;
|
||||
};
|
||||
|
||||
typedef void (*tr_peer_callback)(struct tr_peer* peer, tr_peer_event const* event, void* client_data);
|
||||
using tr_peer_callback = void (*)(struct tr_peer* peer, tr_peer_event const* event, void* client_data);
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
typedef void (*tr_peer_destruct_func)(struct tr_peer* peer);
|
||||
typedef bool (
|
||||
*tr_peer_is_transferring_pieces_func)(struct tr_peer const* peer, uint64_t now, tr_direction direction, unsigned int* Bps);
|
||||
using tr_peer_destruct_func = void (*)(struct tr_peer* peer);
|
||||
|
||||
using tr_peer_is_transferring_pieces_func =
|
||||
bool (*)(tr_peer const* peer, uint64_t now, tr_direction direction, unsigned int* Bps);
|
||||
|
||||
struct tr_peer_virtual_funcs
|
||||
{
|
||||
|
@ -88,7 +89,7 @@ struct tr_peer_virtual_funcs
|
|||
* @see struct peer_atom
|
||||
* @see tr_peerMsgs
|
||||
*/
|
||||
typedef struct tr_peer
|
||||
struct tr_peer
|
||||
{
|
||||
/* whether or not we should free this peer soon.
|
||||
NOTE: private to peer-mgr.c */
|
||||
|
@ -125,7 +126,7 @@ typedef struct tr_peer
|
|||
tr_recentHistory cancelsSentToPeer;
|
||||
|
||||
struct tr_peer_virtual_funcs const* funcs;
|
||||
} tr_peer;
|
||||
};
|
||||
|
||||
void tr_peerConstruct(struct tr_peer* peer, tr_torrent const* tor);
|
||||
|
||||
|
@ -140,13 +141,13 @@ bool tr_peerIsSeed(struct tr_peer const* peer);
|
|||
****
|
||||
***/
|
||||
|
||||
typedef struct tr_swarm_stats
|
||||
struct tr_swarm_stats
|
||||
{
|
||||
int activePeerCount[2];
|
||||
int activeWebseedCount;
|
||||
int peerCount;
|
||||
int peerFromCount[TR_PEER_FROM__MAX];
|
||||
} tr_swarm_stats;
|
||||
};
|
||||
|
||||
void tr_swarmGetStats(struct tr_swarm const* swarm, tr_swarm_stats* setme);
|
||||
|
||||
|
|
|
@ -35,27 +35,27 @@ struct tr_peerIo;
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
enum ReadState
|
||||
{
|
||||
READ_NOW,
|
||||
READ_LATER,
|
||||
READ_ERR
|
||||
} ReadState;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_encryption_type
|
||||
{
|
||||
/* these match the values in MSE's crypto_select */
|
||||
PEER_ENCRYPTION_NONE = (1 << 0),
|
||||
PEER_ENCRYPTION_RC4 = (1 << 1)
|
||||
} tr_encryption_type;
|
||||
};
|
||||
|
||||
typedef ReadState (*tr_can_read_cb)(struct tr_peerIo* io, void* user_data, size_t* setme_piece_byte_count);
|
||||
using tr_can_read_cb = ReadState (*)(struct tr_peerIo* io, void* user_data, size_t* setme_piece_byte_count);
|
||||
|
||||
typedef void (*tr_did_write_cb)(struct tr_peerIo* io, size_t bytesWritten, bool wasPieceData, void* userData);
|
||||
using tr_did_write_cb = void (*)(struct tr_peerIo* io, size_t bytesWritten, bool wasPieceData, void* userData);
|
||||
|
||||
typedef void (*tr_net_error_cb)(struct tr_peerIo* io, short what, void* userData);
|
||||
using tr_net_error_cb = void (*)(struct tr_peerIo* io, short what, void* userData);
|
||||
|
||||
typedef struct tr_peerIo
|
||||
struct tr_peerIo
|
||||
{
|
||||
bool isEncrypted;
|
||||
bool isIncoming;
|
||||
|
@ -100,7 +100,7 @@ typedef struct tr_peerIo
|
|||
|
||||
struct event* event_read;
|
||||
struct event* event_write;
|
||||
} tr_peerIo;
|
||||
};
|
||||
|
||||
/**
|
||||
***
|
||||
|
|
|
@ -163,7 +163,7 @@ enum piece_sort_state
|
|||
};
|
||||
|
||||
/** @brief Opaque, per-torrent data structure for peer connection information */
|
||||
typedef struct tr_swarm
|
||||
struct tr_swarm
|
||||
{
|
||||
tr_swarm_stats stats;
|
||||
|
||||
|
@ -207,7 +207,7 @@ typedef struct tr_swarm
|
|||
* requests are considered 'fast' are allowed to request a block that's
|
||||
* already been requested from another (slower?) peer. */
|
||||
int endgame;
|
||||
} tr_swarm;
|
||||
};
|
||||
|
||||
struct tr_peerMgr
|
||||
{
|
||||
|
@ -2928,12 +2928,12 @@ static bool isPeerInteresting(tr_torrent* const tor, bool const* const piece_is_
|
|||
return false;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
enum tr_rechoke_state
|
||||
{
|
||||
RECHOKE_STATE_GOOD,
|
||||
RECHOKE_STATE_UNTESTED,
|
||||
RECHOKE_STATE_BAD
|
||||
} tr_rechoke_state;
|
||||
};
|
||||
|
||||
struct tr_rechoke_info
|
||||
{
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
*/
|
||||
|
||||
struct UTPSocket;
|
||||
struct tr_peerMgr;
|
||||
struct tr_peer_stat;
|
||||
struct tr_torrent;
|
||||
typedef struct tr_peerMgr tr_peerMgr;
|
||||
|
||||
/* added_f's bitwise-or'ed flags */
|
||||
enum
|
||||
|
@ -49,12 +49,12 @@ enum
|
|||
ADDED_F_CONNECTABLE = 16
|
||||
};
|
||||
|
||||
typedef struct tr_pex
|
||||
struct tr_pex
|
||||
{
|
||||
tr_address addr;
|
||||
tr_port port; /* this field is in network byte order */
|
||||
uint8_t flags;
|
||||
} tr_pex;
|
||||
};
|
||||
|
||||
struct peer_atom;
|
||||
struct tr_peerIo;
|
||||
|
|
|
@ -111,12 +111,12 @@ enum
|
|||
AWAITING_BT_PIECE
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum encryption_preference_t
|
||||
{
|
||||
ENCRYPTION_PREFERENCE_UNKNOWN,
|
||||
ENCRYPTION_PREFERENCE_YES,
|
||||
ENCRYPTION_PREFERENCE_NO
|
||||
} encryption_preference_t;
|
||||
};
|
||||
|
||||
/**
|
||||
***
|
||||
|
@ -2261,7 +2261,7 @@ static void tellPeerWhatWeHave(tr_peerMsgs* msgs)
|
|||
#define MAX_PEX_ADDED 50
|
||||
#define MAX_PEX_DROPPED 50
|
||||
|
||||
typedef struct
|
||||
struct PexDiffs
|
||||
{
|
||||
tr_pex* added;
|
||||
tr_pex* dropped;
|
||||
|
@ -2269,7 +2269,7 @@ typedef struct
|
|||
int addedCount;
|
||||
int droppedCount;
|
||||
int elementCount;
|
||||
} PexDiffs;
|
||||
};
|
||||
|
||||
static void pexAddedCb(void const* vpex, void* userData)
|
||||
{
|
||||
|
@ -2302,7 +2302,7 @@ static inline void pexElementCb(void const* vpex, void* userData)
|
|||
diffs->elements[diffs->elementCount++] = *pex;
|
||||
}
|
||||
|
||||
typedef void (*tr_set_func)(void const* element, void* userData);
|
||||
using tr_set_func = void (*)(void const* element, void* userData);
|
||||
|
||||
/**
|
||||
* @brief find the differences and commonalities in two sorted sets
|
||||
|
|
|
@ -26,7 +26,7 @@ struct tr_torrent;
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef struct tr_peerMsgs tr_peerMsgs;
|
||||
struct tr_peerMsgs;
|
||||
|
||||
#define PEER_MSGS(o) (tr_peerMsgsCast(o))
|
||||
|
||||
|
|
|
@ -51,9 +51,9 @@
|
|||
***/
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef DWORD tr_thread_id;
|
||||
using tr_thread_id = DWORD;
|
||||
#else
|
||||
typedef pthread_t tr_thread_id;
|
||||
using tr_thread_id = pthread_t;
|
||||
#endif
|
||||
|
||||
static tr_thread_id tr_getCurrentThread(void)
|
||||
|
|
|
@ -47,7 +47,7 @@ char* tr_getSessionIdDir(void);
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef struct tr_thread tr_thread;
|
||||
struct tr_thread;
|
||||
|
||||
/** @brief Instantiate a new process thread */
|
||||
tr_thread* tr_threadNew(void (*func)(void*), void* arg);
|
||||
|
@ -60,7 +60,7 @@ bool tr_amInThread(tr_thread const* thread);
|
|||
****
|
||||
***/
|
||||
|
||||
typedef struct tr_lock tr_lock;
|
||||
struct tr_lock;
|
||||
|
||||
/** @brief Create a new thread mutex object */
|
||||
tr_lock* tr_lockNew(void);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
struct tr_bindsockets;
|
||||
|
||||
typedef struct tr_shared tr_shared;
|
||||
struct tr_shared;
|
||||
|
||||
tr_shared* tr_sharedInit(tr_session*);
|
||||
|
||||
|
|
|
@ -23,16 +23,16 @@
|
|||
/**
|
||||
* @brief simple pointer array that resizes itself dynamically.
|
||||
*/
|
||||
typedef struct tr_ptrArray
|
||||
struct tr_ptrArray
|
||||
{
|
||||
void** items;
|
||||
int n_items;
|
||||
int n_alloc;
|
||||
} tr_ptrArray;
|
||||
};
|
||||
|
||||
typedef tr_voidptr_compare_func PtrArrayCompareFunc;
|
||||
using PtrArrayCompareFunc = tr_voidptr_compare_func;
|
||||
|
||||
typedef void (*PtrArrayForeachFunc)(void*);
|
||||
using PtrArrayForeachFunc = void (*)(void*);
|
||||
|
||||
/** @brief Destructor to free a tr_ptrArray's internal memory */
|
||||
void tr_ptrArrayDestruct(tr_ptrArray*, PtrArrayForeachFunc func);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "tr-macros.h"
|
||||
|
||||
/* Quarks — a 2-way association between a string and a unique integer identifier */
|
||||
typedef size_t tr_quark;
|
||||
using tr_quark = size_t;
|
||||
|
||||
/*
|
||||
* Predefined Quarks.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "variant.h"
|
||||
|
||||
typedef struct tr_rpc_server tr_rpc_server;
|
||||
struct tr_rpc_server;
|
||||
|
||||
tr_rpc_server* tr_rpcInit(tr_session* session, tr_variant* settings);
|
||||
|
||||
|
|
|
@ -50,11 +50,11 @@
|
|||
#define dbgmsg(...) tr_logAddDeepNamed("RPC", __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
enum tr_format
|
||||
{
|
||||
TR_FORMAT_OBJECT = 0,
|
||||
TR_FORMAT_TABLE
|
||||
} tr_format;
|
||||
};
|
||||
|
||||
/***
|
||||
****
|
||||
|
@ -2741,7 +2741,7 @@ static char const* sessionClose(
|
|||
****
|
||||
***/
|
||||
|
||||
typedef char const* (*handler)(tr_session*, tr_variant*, tr_variant*, struct tr_rpc_idle_data*);
|
||||
using handler = char const* (*)(tr_session*, tr_variant*, tr_variant*, struct tr_rpc_idle_data*);
|
||||
|
||||
static struct method
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
**** RPC processing
|
||||
***/
|
||||
|
||||
typedef void (*tr_rpc_response_func)(tr_session* session, tr_variant* response, void* user_data);
|
||||
using tr_rpc_response_func = void (*)(tr_session* session, tr_variant* response, void* user_data);
|
||||
|
||||
/* http://www.json.org/ */
|
||||
void tr_rpc_request_exec_json(
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "tr-macros.h"
|
||||
|
||||
typedef struct tr_session_id* tr_session_id_t;
|
||||
using tr_session_id_t = struct tr_session_id*;
|
||||
|
||||
/**
|
||||
* Create new session identifier object.
|
||||
|
|
|
@ -29,19 +29,19 @@
|
|||
#include "utils.h"
|
||||
#include "variant.h"
|
||||
|
||||
typedef enum
|
||||
enum tr_tristate_t
|
||||
{
|
||||
TR_NET_OK,
|
||||
TR_NET_ERROR,
|
||||
TR_NET_WAIT
|
||||
} tr_tristate_t;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_auto_switch_state_t
|
||||
{
|
||||
TR_AUTO_SWITCH_UNUSED,
|
||||
TR_AUTO_SWITCH_ON,
|
||||
TR_AUTO_SWITCH_OFF,
|
||||
} tr_auto_switch_state_t;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -112,12 +112,12 @@ void tr_torrentSetDateDone(tr_torrent* torrent, time_t doneDate);
|
|||
torrent's content than any other mime-type. */
|
||||
char const* tr_torrentPrimaryMimeType(tr_torrent const* tor);
|
||||
|
||||
typedef enum
|
||||
enum tr_verify_state
|
||||
{
|
||||
TR_VERIFY_NONE,
|
||||
TR_VERIFY_WAIT,
|
||||
TR_VERIFY_NOW
|
||||
} tr_verify_state;
|
||||
};
|
||||
|
||||
void tr_torrentSetVerifyState(tr_torrent* tor, tr_verify_state state);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
/** @brief Similar to optind, this is the current index into argv */
|
||||
extern int tr_optind;
|
||||
|
||||
typedef struct tr_option
|
||||
struct tr_option
|
||||
{
|
||||
int val; /* the value to return from tr_getopt() */
|
||||
char const* longName; /* --long-form */
|
||||
|
@ -26,7 +26,7 @@ typedef struct tr_option
|
|||
char const* shortName; /* short form */
|
||||
bool has_arg; /* 0 for no argument, 1 for argument */
|
||||
char const* argName; /* argument's description for tr_getopt_usage() */
|
||||
} tr_option;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
#ifdef _WIN32
|
||||
#include <inttypes.h>
|
||||
#include <ws2tcpip.h>
|
||||
typedef uint16_t in_port_t; /* all missing */
|
||||
using in_port_t = uint16_t; /* all missing */
|
||||
#else
|
||||
#include <ctime>
|
||||
#include <unistd.h> /* close() */
|
||||
|
|
|
@ -27,40 +27,39 @@
|
|||
|
||||
#include "tr-macros.h"
|
||||
|
||||
typedef uint32_t tr_file_index_t;
|
||||
typedef uint32_t tr_piece_index_t;
|
||||
using tr_file_index_t = uint32_t;
|
||||
using tr_piece_index_t = uint32_t;
|
||||
/* assuming a 16 KiB block, a 32-bit block index gives us a maximum torrent size of 63 TiB.
|
||||
* if we ever need to grow past that, change this to uint64_t ;) */
|
||||
typedef uint32_t tr_block_index_t;
|
||||
typedef uint16_t tr_port;
|
||||
|
||||
typedef struct tr_ctor tr_ctor;
|
||||
typedef struct tr_info tr_info;
|
||||
typedef struct tr_torrent tr_torrent;
|
||||
typedef struct tr_session tr_session;
|
||||
using tr_block_index_t = uint32_t;
|
||||
using tr_port = uint16_t;
|
||||
|
||||
struct tr_ctor;
|
||||
struct tr_error;
|
||||
struct tr_info;
|
||||
struct tr_session;
|
||||
struct tr_torrent;
|
||||
struct tr_variant;
|
||||
|
||||
typedef int8_t tr_priority_t;
|
||||
using tr_priority_t = int8_t;
|
||||
|
||||
typedef int (*tr_voidptr_compare_func)(void const* lhs, void const* rhs);
|
||||
using tr_voidptr_compare_func = int (*)(void const* lhs, void const* rhs);
|
||||
|
||||
#define TR_RPC_SESSION_ID_HEADER "X-Transmission-Session-Id"
|
||||
|
||||
typedef enum
|
||||
enum tr_preallocation_mode
|
||||
{
|
||||
TR_PREALLOCATE_NONE = 0,
|
||||
TR_PREALLOCATE_SPARSE = 1,
|
||||
TR_PREALLOCATE_FULL = 2
|
||||
} tr_preallocation_mode;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_encryption_mode
|
||||
{
|
||||
TR_CLEAR_PREFERRED,
|
||||
TR_ENCRYPTION_PREFERRED,
|
||||
TR_ENCRYPTION_REQUIRED
|
||||
} tr_encryption_mode;
|
||||
};
|
||||
|
||||
/***
|
||||
****
|
||||
|
@ -379,7 +378,7 @@ bool tr_sessionIsRPCPasswordEnabled(tr_session const* session);
|
|||
|
||||
char const* tr_sessionGetRPCBindAddress(tr_session const* session);
|
||||
|
||||
typedef enum
|
||||
enum tr_rpc_callback_type
|
||||
{
|
||||
TR_RPC_TORRENT_ADDED,
|
||||
TR_RPC_TORRENT_STARTED,
|
||||
|
@ -391,9 +390,9 @@ typedef enum
|
|||
TR_RPC_SESSION_CHANGED,
|
||||
TR_RPC_SESSION_QUEUE_POSITIONS_CHANGED, /* catch potentially multiple torrents being moved in the queue */
|
||||
TR_RPC_SESSION_CLOSE
|
||||
} tr_rpc_callback_type;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_rpc_callback_status
|
||||
{
|
||||
/* no special handling is needed by the caller */
|
||||
TR_RPC_OK = 0,
|
||||
|
@ -402,9 +401,9 @@ typedef enum
|
|||
* need to keep the torrent alive long enough to cleanly close
|
||||
* some resources in another thread. */
|
||||
TR_RPC_NOREMOVE = (1 << 1)
|
||||
} tr_rpc_callback_status;
|
||||
};
|
||||
|
||||
typedef tr_rpc_callback_status (*tr_rpc_func)( //
|
||||
using tr_rpc_func = tr_rpc_callback_status (*)( //
|
||||
tr_session* session,
|
||||
tr_rpc_callback_type type,
|
||||
struct tr_torrent* tor_or_null,
|
||||
|
@ -426,7 +425,7 @@ void tr_sessionSetRPCCallback(tr_session* session, tr_rpc_func func, void* user_
|
|||
**/
|
||||
|
||||
/** @brief Used by tr_sessionGetStats() and tr_sessionGetCumulativeStats() */
|
||||
typedef struct tr_session_stats
|
||||
struct tr_session_stats
|
||||
{
|
||||
float ratio; /* TR_RATIO_INF, TR_RATIO_NA, or total up/down */
|
||||
uint64_t uploadedBytes; /* total up */
|
||||
|
@ -434,7 +433,7 @@ typedef struct tr_session_stats
|
|||
uint64_t filesAdded; /* number of files added */
|
||||
uint64_t sessionCount; /* program started N times */
|
||||
uint64_t secondsActive; /* how long Transmisson's been running */
|
||||
} tr_session_stats;
|
||||
};
|
||||
|
||||
/** @brief Get bandwidth use statistics for the current session */
|
||||
void tr_sessionGetStats(tr_session const* session, tr_session_stats* setme);
|
||||
|
@ -486,24 +485,24 @@ void tr_sessionSetPeerPortRandomOnStart(tr_session* session, bool random);
|
|||
|
||||
bool tr_sessionGetPeerPortRandomOnStart(tr_session* session);
|
||||
|
||||
typedef enum
|
||||
enum tr_port_forwarding
|
||||
{
|
||||
TR_PORT_ERROR,
|
||||
TR_PORT_UNMAPPED,
|
||||
TR_PORT_UNMAPPING,
|
||||
TR_PORT_MAPPING,
|
||||
TR_PORT_MAPPED
|
||||
} tr_port_forwarding;
|
||||
};
|
||||
|
||||
tr_port_forwarding tr_sessionGetPortForwarding(tr_session const* session);
|
||||
|
||||
typedef enum
|
||||
enum tr_direction
|
||||
{
|
||||
TR_CLIENT_TO_PEER = 0,
|
||||
TR_UP = 0,
|
||||
TR_PEER_TO_CLIENT = 1,
|
||||
TR_DOWN = 1
|
||||
} tr_direction;
|
||||
};
|
||||
|
||||
/***
|
||||
****
|
||||
|
@ -538,7 +537,7 @@ int tr_sessionGetAltSpeedBegin(tr_session const*);
|
|||
void tr_sessionSetAltSpeedEnd(tr_session*, int minsSinceMidnight);
|
||||
int tr_sessionGetAltSpeedEnd(tr_session const*);
|
||||
|
||||
typedef enum
|
||||
enum tr_sched_day
|
||||
{
|
||||
TR_SCHED_SUN = (1 << 0),
|
||||
TR_SCHED_MON = (1 << 1),
|
||||
|
@ -550,12 +549,12 @@ typedef enum
|
|||
TR_SCHED_WEEKDAY = (TR_SCHED_MON | TR_SCHED_TUES | TR_SCHED_WED | TR_SCHED_THURS | TR_SCHED_FRI),
|
||||
TR_SCHED_WEEKEND = (TR_SCHED_SUN | TR_SCHED_SAT),
|
||||
TR_SCHED_ALL = (TR_SCHED_WEEKDAY | TR_SCHED_WEEKEND)
|
||||
} tr_sched_day;
|
||||
};
|
||||
|
||||
void tr_sessionSetAltSpeedDay(tr_session*, tr_sched_day day);
|
||||
tr_sched_day tr_sessionGetAltSpeedDay(tr_session const*);
|
||||
|
||||
typedef void (*tr_altSpeedFunc)(tr_session*, bool active, bool userDriven, void*);
|
||||
using tr_altSpeedFunc = void (*)(tr_session*, bool active, bool userDriven, void*);
|
||||
|
||||
void tr_sessionSetAltSpeedFunc(tr_session*, tr_altSpeedFunc, void*);
|
||||
|
||||
|
@ -718,18 +717,18 @@ void tr_sessionSetTorrentDoneScript(tr_session*, char const* scriptFilename);
|
|||
** Message Logging
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
enum tr_log_level
|
||||
{
|
||||
TR_LOG_SILENT = 0,
|
||||
TR_LOG_ERROR = 1,
|
||||
TR_LOG_INFO = 2,
|
||||
TR_LOG_DEBUG = 3,
|
||||
TR_LOG_FIREHOSE = 4
|
||||
} tr_log_level;
|
||||
};
|
||||
|
||||
void tr_logSetLevel(tr_log_level);
|
||||
|
||||
typedef struct tr_log_message
|
||||
struct tr_log_message
|
||||
{
|
||||
/* TR_LOG_ERROR, TR_LOG_INFO, or TR_LOG_DEBUG */
|
||||
tr_log_level level;
|
||||
|
@ -753,7 +752,7 @@ typedef struct tr_log_message
|
|||
|
||||
/* linked list of messages */
|
||||
struct tr_log_message* next;
|
||||
} tr_log_message;
|
||||
};
|
||||
|
||||
tr_log_message* tr_logGetQueue(void);
|
||||
bool tr_logGetQueueEnabled(void);
|
||||
|
@ -827,11 +826,11 @@ char const* tr_blocklistGetURL(tr_session const*);
|
|||
Every call to tr_ctorSetMetainfo* () frees the previous metainfo.
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
enum tr_ctorMode
|
||||
{
|
||||
TR_FALLBACK, /* indicates the ctor value should be used only in case of missing resume settings */
|
||||
TR_FORCE /* indicates the ctor value should be used regardless of what's in the resume settings */
|
||||
} tr_ctorMode;
|
||||
};
|
||||
|
||||
/** @brief Create a torrent constructor object used to instantiate a tr_torrent
|
||||
@param session_or_NULL the tr_session.
|
||||
|
@ -917,12 +916,12 @@ tr_session* tr_ctorGetSession(tr_ctor const* ctor);
|
|||
or NULL if tr_ctorSetMetainfoFromFile() wasn't used */
|
||||
char const* tr_ctorGetSourceFile(tr_ctor const* ctor);
|
||||
|
||||
typedef enum
|
||||
enum tr_parse_result
|
||||
{
|
||||
TR_PARSE_OK,
|
||||
TR_PARSE_ERR,
|
||||
TR_PARSE_DUPLICATE
|
||||
} tr_parse_result;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Parses the specified metainfo
|
||||
|
@ -974,7 +973,7 @@ tr_torrent* tr_torrentNew(tr_ctor const* ctor, int* setme_error, int* setme_dupl
|
|||
/** @addtogroup tr_torrent Torrents
|
||||
@{ */
|
||||
|
||||
typedef bool (*tr_fileFunc)(char const* filename, struct tr_error** error);
|
||||
using tr_fileFunc = bool (*)(char const* filename, struct tr_error** error);
|
||||
|
||||
/** @brief Removes our .torrent and .resume files for this torrent */
|
||||
void tr_torrentRemove(tr_torrent* torrent, bool removeLocalData, tr_fileFunc removeFunc);
|
||||
|
@ -985,7 +984,7 @@ void tr_torrentStart(tr_torrent* torrent);
|
|||
/** @brief Stop (pause) a torrent */
|
||||
void tr_torrentStop(tr_torrent* torrent);
|
||||
|
||||
typedef void (*tr_torrent_rename_done_func)( //
|
||||
using tr_torrent_rename_done_func = void (*)( //
|
||||
tr_torrent* torrent,
|
||||
char const* oldpath,
|
||||
char const* newname,
|
||||
|
@ -1113,7 +1112,7 @@ bool tr_torrentUsesSessionLimits(tr_torrent const*);
|
|||
***** Ratio Limits
|
||||
****/
|
||||
|
||||
typedef enum
|
||||
enum tr_ratiolimit
|
||||
{
|
||||
/* follow the global settings */
|
||||
TR_RATIOLIMIT_GLOBAL = 0,
|
||||
|
@ -1121,7 +1120,7 @@ typedef enum
|
|||
TR_RATIOLIMIT_SINGLE = 1,
|
||||
/* override the global settings, seeding regardless of ratio */
|
||||
TR_RATIOLIMIT_UNLIMITED = 2
|
||||
} tr_ratiolimit;
|
||||
};
|
||||
|
||||
void tr_torrentSetRatioMode(tr_torrent* tor, tr_ratiolimit mode);
|
||||
|
||||
|
@ -1137,7 +1136,7 @@ bool tr_torrentGetSeedRatio(tr_torrent const*, double* ratio);
|
|||
***** Idle Time Limits
|
||||
****/
|
||||
|
||||
typedef enum
|
||||
enum tr_idlelimit
|
||||
{
|
||||
/* follow the global settings */
|
||||
TR_IDLELIMIT_GLOBAL = 0,
|
||||
|
@ -1145,7 +1144,7 @@ typedef enum
|
|||
TR_IDLELIMIT_SINGLE = 1,
|
||||
/* override the global settings, seeding regardless of activity */
|
||||
TR_IDLELIMIT_UNLIMITED = 2
|
||||
} tr_idlelimit;
|
||||
};
|
||||
|
||||
void tr_torrentSetIdleMode(tr_torrent* tor, tr_idlelimit mode);
|
||||
|
||||
|
@ -1233,13 +1232,13 @@ static inline char* tr_torrentGetMagnetLink(tr_torrent const* tor)
|
|||
**/
|
||||
|
||||
/** @brief a part of tr_info that represents a single tracker */
|
||||
typedef struct tr_tracker_info
|
||||
struct tr_tracker_info
|
||||
{
|
||||
int tier;
|
||||
char* announce;
|
||||
char* scrape;
|
||||
uint32_t id; /* unique identifier used to match to a tr_tracker_stat */
|
||||
} tr_tracker_info;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Modify a torrent's tracker list.
|
||||
|
@ -1260,26 +1259,26 @@ bool tr_torrentSetAnnounceList(tr_torrent* torrent, tr_tracker_info const* track
|
|||
***
|
||||
**/
|
||||
|
||||
typedef enum
|
||||
enum tr_completeness
|
||||
{
|
||||
TR_LEECH, /* doesn't have all the desired pieces */
|
||||
TR_SEED, /* has the entire torrent */
|
||||
TR_PARTIAL_SEED /* has the desired pieces, but not the entire torrent */
|
||||
} tr_completeness;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param wasRunning whether or not the torrent was running when
|
||||
* it changed its completeness state
|
||||
*/
|
||||
typedef void (*tr_torrent_completeness_func)( //
|
||||
using tr_torrent_completeness_func = void (*)( //
|
||||
tr_torrent* torrent,
|
||||
tr_completeness completeness,
|
||||
bool wasRunning,
|
||||
void* user_data);
|
||||
|
||||
typedef void (*tr_torrent_ratio_limit_hit_func)(tr_torrent* torrent, void* user_data);
|
||||
using tr_torrent_ratio_limit_hit_func = void (*)(tr_torrent* torrent, void* user_data);
|
||||
|
||||
typedef void (*tr_torrent_idle_limit_hit_func)(tr_torrent* torrent, void* user_data);
|
||||
using tr_torrent_idle_limit_hit_func = void (*)(tr_torrent* torrent, void* user_data);
|
||||
|
||||
/**
|
||||
* Register to be notified whenever a torrent's "completeness"
|
||||
|
@ -1298,7 +1297,8 @@ void tr_torrentSetCompletenessCallback(tr_torrent* torrent, tr_torrent_completen
|
|||
|
||||
void tr_torrentClearCompletenessCallback(tr_torrent* torrent);
|
||||
|
||||
typedef void (*tr_torrent_metadata_func)(tr_torrent* torrent, void* user_data);
|
||||
using tr_torrent_metadata_func = void (*)(tr_torrent* torrent, void* user_data);
|
||||
|
||||
/**
|
||||
* Register to be notified whenever a torrent changes from
|
||||
* having incomplete metadata to having complete metadata.
|
||||
|
@ -1350,7 +1350,7 @@ bool tr_torrentCanManualUpdate(tr_torrent const* torrent);
|
|||
**** tr_peer_stat
|
||||
***/
|
||||
|
||||
typedef struct tr_peer_stat
|
||||
struct tr_peer_stat
|
||||
{
|
||||
bool isUTP;
|
||||
|
||||
|
@ -1394,7 +1394,7 @@ typedef struct tr_peer_stat
|
|||
|
||||
/* how many requests we've made and are currently awaiting a response for */
|
||||
int pendingReqsToPeer;
|
||||
} tr_peer_stat;
|
||||
};
|
||||
|
||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* torrent, int* peerCount);
|
||||
|
||||
|
@ -1404,7 +1404,7 @@ void tr_torrentPeersFree(tr_peer_stat* peerStats, int peerCount);
|
|||
**** tr_tracker_stat
|
||||
***/
|
||||
|
||||
typedef enum
|
||||
enum tr_tracker_state
|
||||
{
|
||||
/* we won't (announce,scrape) this torrent to this tracker because
|
||||
* the torrent is stopped, or because of an error, or whatever */
|
||||
|
@ -1417,9 +1417,9 @@ typedef enum
|
|||
TR_TRACKER_QUEUED = 2,
|
||||
/* we're (announcing,scraping) this torrent right now */
|
||||
TR_TRACKER_ACTIVE = 3
|
||||
} tr_tracker_state;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct tr_tracker_stat
|
||||
{
|
||||
/* how many downloads this tracker knows of (-1 means it does not know) */
|
||||
int downloadCount;
|
||||
|
@ -1510,7 +1510,7 @@ typedef struct
|
|||
|
||||
/* used to match to a tr_tracker_info */
|
||||
uint32_t id;
|
||||
} tr_tracker_stat;
|
||||
};
|
||||
|
||||
tr_tracker_stat* tr_torrentTrackers(tr_torrent const* torrent, int* setmeTrackerCount);
|
||||
|
||||
|
@ -1528,11 +1528,11 @@ void tr_torrentTrackersFree(tr_tracker_stat* trackerStats, int trackerCount);
|
|||
*/
|
||||
double* tr_torrentWebSpeeds_KBps(tr_torrent const* torrent);
|
||||
|
||||
typedef struct tr_file_stat
|
||||
struct tr_file_stat
|
||||
{
|
||||
uint64_t bytesCompleted;
|
||||
float progress;
|
||||
} tr_file_stat;
|
||||
};
|
||||
|
||||
tr_file_stat* tr_torrentFiles(tr_torrent const* torrent, tr_file_index_t* fileCount);
|
||||
|
||||
|
@ -1559,7 +1559,7 @@ void tr_torrentAmountFinished(tr_torrent const* torrent, float* tab, int size);
|
|||
* being called during verification.
|
||||
* @param user_data the user-defined pointer from tr_torrentVerify()
|
||||
*/
|
||||
typedef void (*tr_verify_done_func)(tr_torrent* torrent, bool aborted, void* user_data);
|
||||
using tr_verify_done_func = void (*)(tr_torrent* torrent, bool aborted, void* user_data);
|
||||
|
||||
/**
|
||||
* Queue a torrent for verification.
|
||||
|
@ -1575,7 +1575,7 @@ void tr_torrentVerify(tr_torrent* torrent, tr_verify_done_func callback_func_or_
|
|||
**********************************************************************/
|
||||
|
||||
/** @brief a part of tr_info that represents a single file of the torrent's content */
|
||||
typedef struct tr_file
|
||||
struct tr_file
|
||||
{
|
||||
uint64_t length; /* Length of the file, in bytes */
|
||||
char* name; /* Path to the file */
|
||||
|
@ -1585,16 +1585,16 @@ typedef struct tr_file
|
|||
tr_piece_index_t firstPiece; /* We need pieces [firstPiece... */
|
||||
tr_piece_index_t lastPiece; /* ...lastPiece] to dl this file */
|
||||
uint64_t offset; /* file begins at the torrent's nth byte */
|
||||
} tr_file;
|
||||
};
|
||||
|
||||
/** @brief a part of tr_info that represents a single piece of the torrent's content */
|
||||
typedef struct tr_piece
|
||||
struct tr_piece
|
||||
{
|
||||
time_t timeChecked; /* the last time we tested this piece */
|
||||
uint8_t hash[SHA_DIGEST_LENGTH]; /* pieces hash */
|
||||
int8_t priority; /* TR_PRI_HIGH, _NORMAL, or _LOW */
|
||||
bool dnd; /* "do not download" flag */
|
||||
} tr_piece;
|
||||
};
|
||||
|
||||
/** @brief information about a torrent that comes from its metainfo file */
|
||||
struct tr_info
|
||||
|
@ -1652,7 +1652,7 @@ static inline bool tr_torrentHasMetadata(tr_torrent const* tor)
|
|||
* Note: these values will become a straight enum at some point in the future.
|
||||
* Do not rely on their current `bitfield' implementation
|
||||
*/
|
||||
typedef enum
|
||||
enum tr_torrent_activity
|
||||
{
|
||||
TR_STATUS_STOPPED = 0, /* Torrent is stopped */
|
||||
TR_STATUS_CHECK_WAIT = 1, /* Queued to check files */
|
||||
|
@ -1661,7 +1661,7 @@ typedef enum
|
|||
TR_STATUS_DOWNLOAD = 4, /* Downloading */
|
||||
TR_STATUS_SEED_WAIT = 5, /* Queued to seed */
|
||||
TR_STATUS_SEED = 6 /* Seeding */
|
||||
} tr_torrent_activity;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -1675,7 +1675,7 @@ enum
|
|||
TR_PEER_FROM__MAX
|
||||
};
|
||||
|
||||
typedef enum
|
||||
enum tr_stat_errtype
|
||||
{
|
||||
/* everything's fine */
|
||||
TR_STAT_OK = 0,
|
||||
|
@ -1685,10 +1685,10 @@ typedef enum
|
|||
TR_STAT_TRACKER_ERROR = 2,
|
||||
/* local trouble, such as disk full or permissions error */
|
||||
TR_STAT_LOCAL_ERROR = 3
|
||||
} tr_stat_errtype;
|
||||
};
|
||||
|
||||
/** @brief Used by tr_torrentStat() to tell clients about a torrent's state and statistics */
|
||||
typedef struct tr_stat
|
||||
struct tr_stat
|
||||
{
|
||||
/** The torrent's unique Id.
|
||||
@see tr_torrentId() */
|
||||
|
@ -1858,7 +1858,7 @@ typedef struct tr_stat
|
|||
/** True if the torrent is running, but has been idle for long enough
|
||||
to be considered stalled. @see tr_sessionGetQueueStalledMinutes() */
|
||||
bool isStalled;
|
||||
} tr_stat;
|
||||
};
|
||||
|
||||
/** Return a pointer to an tr_stat structure with updated information
|
||||
on the torrent. This is typically called by the GUI clients every
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
|
||||
typedef SOCKET tr_pipe_end_t;
|
||||
using tr_pipe_end_t = SOCKET;
|
||||
|
||||
static int pgpipe(tr_pipe_end_t handles[2])
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ static int piperead(tr_pipe_end_t s, void* buf, int len)
|
|||
#define pipewrite(a, b, c) send(a, (char*)b, c, 0)
|
||||
|
||||
#else
|
||||
typedef int tr_pipe_end_t;
|
||||
using tr_pipe_end_t = int;
|
||||
#define piperead(a, b, c) read(a, b, c)
|
||||
#define pipewrite(a, b, c) write(a, b, c)
|
||||
#endif
|
||||
|
@ -148,7 +148,7 @@ typedef int tr_pipe_end_t;
|
|||
****
|
||||
***/
|
||||
|
||||
typedef struct tr_event_handle
|
||||
struct tr_event_handle
|
||||
{
|
||||
bool die;
|
||||
tr_pipe_end_t fds[2];
|
||||
|
@ -157,7 +157,7 @@ typedef struct tr_event_handle
|
|||
tr_thread* thread;
|
||||
struct event_base* base;
|
||||
struct event* pipeEvent;
|
||||
} tr_event_handle;
|
||||
};
|
||||
|
||||
struct tr_run_data
|
||||
{
|
||||
|
|
|
@ -29,14 +29,14 @@ static char const* getKey(void)
|
|||
return _("Port Forwarding (UPnP)");
|
||||
}
|
||||
|
||||
typedef enum
|
||||
enum tr_upnp_state
|
||||
{
|
||||
TR_UPNP_IDLE,
|
||||
TR_UPNP_ERR,
|
||||
TR_UPNP_DISCOVER,
|
||||
TR_UPNP_MAP,
|
||||
TR_UPNP_UNMAP
|
||||
} tr_upnp_state;
|
||||
};
|
||||
|
||||
struct tr_upnp
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef struct tr_upnp tr_upnp;
|
||||
struct tr_upnp;
|
||||
|
||||
tr_upnp* tr_upnpInit(void);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "tr-macros.h"
|
||||
|
||||
typedef void (*VariantWalkFunc)(tr_variant const* val, void* user_data);
|
||||
using VariantWalkFunc = void (*)(tr_variant const* val, void* user_data);
|
||||
|
||||
struct VariantWalkFuncs
|
||||
{
|
||||
|
|
|
@ -29,12 +29,12 @@ struct tr_error;
|
|||
* @{
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
enum tr_string_type
|
||||
{
|
||||
TR_STRING_TYPE_QUARK,
|
||||
TR_STRING_TYPE_HEAP,
|
||||
TR_STRING_TYPE_BUF
|
||||
} tr_string_type;
|
||||
};
|
||||
|
||||
/* these are PRIVATE IMPLEMENTATION details that should not be touched.
|
||||
* I'll probably change them just to break your code! HA HA HA!
|
||||
|
@ -66,11 +66,11 @@ enum
|
|||
/* These are PRIVATE IMPLEMENTATION details that should not be touched.
|
||||
* I'll probably change them just to break your code! HA HA HA!
|
||||
* it's included in the header for inlining and composition */
|
||||
typedef struct tr_variant
|
||||
struct tr_variant
|
||||
{
|
||||
char type;
|
||||
char type = '\0';
|
||||
|
||||
tr_quark key;
|
||||
tr_quark key = TR_KEY_NONE;
|
||||
|
||||
union
|
||||
{
|
||||
|
@ -88,8 +88,8 @@ typedef struct tr_variant
|
|||
size_t count;
|
||||
struct tr_variant* vals;
|
||||
} l;
|
||||
} val;
|
||||
} tr_variant;
|
||||
} val = {};
|
||||
};
|
||||
|
||||
void tr_variantFree(tr_variant*);
|
||||
|
||||
|
@ -97,12 +97,12 @@ void tr_variantFree(tr_variant*);
|
|||
**** Serialization / Deserialization
|
||||
***/
|
||||
|
||||
typedef enum
|
||||
enum tr_variant_fmt
|
||||
{
|
||||
TR_VARIANT_FMT_BENC,
|
||||
TR_VARIANT_FMT_JSON,
|
||||
TR_VARIANT_FMT_JSON_LEAN /* saves bandwidth by omitting all whitespace. */
|
||||
} tr_variant_fmt;
|
||||
};
|
||||
|
||||
int tr_variantToFile(tr_variant const* variant, tr_variant_fmt fmt, char const* filename);
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
typedef struct tr_watchdir_backend
|
||||
struct tr_watchdir_backend
|
||||
{
|
||||
void (*free_func)(struct tr_watchdir_backend*);
|
||||
} tr_watchdir_backend;
|
||||
};
|
||||
|
||||
#define BACKEND_DOWNCAST(b) (reinterpret_cast<tr_watchdir_backend*>(b))
|
||||
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
****
|
||||
***/
|
||||
|
||||
typedef struct tr_watchdir_generic
|
||||
struct tr_watchdir_generic
|
||||
{
|
||||
tr_watchdir_backend base;
|
||||
|
||||
struct event* event;
|
||||
std::unordered_set<std::string> dir_entries;
|
||||
} tr_watchdir_generic;
|
||||
};
|
||||
|
||||
#define BACKEND_UPCAST(b) (reinterpret_cast<tr_watchdir_generic*>(b))
|
||||
|
||||
|
|
|
@ -38,14 +38,14 @@
|
|||
****
|
||||
***/
|
||||
|
||||
typedef struct tr_watchdir_inotify
|
||||
struct tr_watchdir_inotify
|
||||
{
|
||||
tr_watchdir_backend base;
|
||||
|
||||
int infd;
|
||||
int inwd;
|
||||
struct bufferevent* event;
|
||||
} tr_watchdir_inotify;
|
||||
};
|
||||
|
||||
#define BACKEND_UPCAST(b) ((tr_watchdir_inotify*)(b))
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
****
|
||||
***/
|
||||
|
||||
typedef struct tr_watchdir_kqueue
|
||||
struct tr_watchdir_kqueue
|
||||
{
|
||||
tr_watchdir_backend base;
|
||||
|
||||
|
@ -52,7 +52,7 @@ typedef struct tr_watchdir_kqueue
|
|||
int dirfd;
|
||||
struct event* event;
|
||||
std::unordered_set<std::string> dir_entries;
|
||||
} tr_watchdir_kqueue;
|
||||
};
|
||||
|
||||
#define BACKEND_UPCAST(b) (reinterpret_cast<tr_watchdir_kqueue*>(b))
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
****
|
||||
***/
|
||||
|
||||
typedef struct tr_watchdir_win32
|
||||
struct tr_watchdir_win32
|
||||
{
|
||||
tr_watchdir_backend base;
|
||||
|
||||
|
@ -50,7 +50,7 @@ typedef struct tr_watchdir_win32
|
|||
evutil_socket_t notify_pipe[2];
|
||||
struct bufferevent* event;
|
||||
HANDLE thread;
|
||||
} tr_watchdir_win32;
|
||||
};
|
||||
|
||||
#define BACKEND_UPCAST(b) ((tr_watchdir_win32*)(b))
|
||||
|
||||
|
@ -67,7 +67,7 @@ static BOOL tr_get_overlapped_result_ex(
|
|||
DWORD timeout,
|
||||
BOOL alertable)
|
||||
{
|
||||
typedef BOOL(WINAPI * impl_t)(HANDLE, LPOVERLAPPED, LPDWORD, DWORD, BOOL);
|
||||
using impl_t = BOOL(WINAPI*)(HANDLE, LPOVERLAPPED, LPDWORD, DWORD, BOOL);
|
||||
|
||||
static impl_t real_impl = nullptr;
|
||||
static bool is_real_impl_valid = false;
|
||||
|
|
|
@ -113,14 +113,14 @@ static tr_watchdir_status tr_watchdir_process_impl(tr_watchdir_t handle, char co
|
|||
****
|
||||
***/
|
||||
|
||||
typedef struct tr_watchdir_retry
|
||||
struct tr_watchdir_retry
|
||||
{
|
||||
tr_watchdir_t handle;
|
||||
char* name;
|
||||
size_t counter;
|
||||
struct event* timer;
|
||||
struct timeval interval;
|
||||
} tr_watchdir_retry;
|
||||
};
|
||||
|
||||
/* Non-static and mutable for unit tests */
|
||||
auto tr_watchdir_retry_limit = size_t{ 3 };
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
|
||||
struct event_base;
|
||||
|
||||
typedef struct tr_watchdir* tr_watchdir_t;
|
||||
using tr_watchdir_t = struct tr_watchdir*;
|
||||
|
||||
typedef enum
|
||||
enum tr_watchdir_status
|
||||
{
|
||||
TR_WATCHDIR_ACCEPT,
|
||||
TR_WATCHDIR_IGNORE,
|
||||
TR_WATCHDIR_RETRY
|
||||
} tr_watchdir_status;
|
||||
};
|
||||
|
||||
typedef tr_watchdir_status (*tr_watchdir_cb)(tr_watchdir_t handle, char const* name, void* user_data);
|
||||
using tr_watchdir_cb = tr_watchdir_status (*)(tr_watchdir_t handle, char const* name, void* user_data);
|
||||
|
||||
/* ... */
|
||||
|
||||
|
|
|
@ -13,15 +13,15 @@
|
|||
struct tr_address;
|
||||
struct tr_web_task;
|
||||
|
||||
typedef enum
|
||||
enum tr_web_close_mode
|
||||
{
|
||||
TR_WEB_CLOSE_WHEN_IDLE,
|
||||
TR_WEB_CLOSE_NOW
|
||||
} tr_web_close_mode;
|
||||
};
|
||||
|
||||
void tr_webClose(tr_session* session, tr_web_close_mode close_mode);
|
||||
|
||||
typedef void (*tr_web_done_func)(
|
||||
using tr_web_done_func = void (*)(
|
||||
tr_session* session,
|
||||
bool did_connect_flag,
|
||||
bool timeout_flag,
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#error only libtransmission should #include this header.
|
||||
#endif
|
||||
|
||||
typedef struct tr_webseed tr_webseed;
|
||||
struct tr_webseed;
|
||||
|
||||
#include "peer-common.h"
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ QString getNameFromMetainfo(QByteArray const& metainfo)
|
|||
tr_ctor* ctor = tr_ctorNew(nullptr);
|
||||
tr_ctorSetMetainfo(ctor, metainfo.constData(), metainfo.size());
|
||||
|
||||
tr_info inf;
|
||||
auto inf = tr_info{};
|
||||
if (tr_torrentParse(ctor, &inf) == TR_PARSE_OK)
|
||||
{
|
||||
name = QString::fromUtf8(inf.name); // metainfo is required to be UTF-8
|
||||
|
|
|
@ -156,7 +156,7 @@ void MakeDialog::makeTorrent()
|
|||
}
|
||||
else
|
||||
{
|
||||
tr_tracker_info tmp;
|
||||
auto tmp = tr_tracker_info{};
|
||||
tmp.announce = tr_strdup(announce_url.toUtf8().constData());
|
||||
tmp.tier = tier;
|
||||
trackers.append(tmp);
|
||||
|
|
|
@ -32,7 +32,7 @@ WatchDir::WatchDir(TorrentModel const& model)
|
|||
int WatchDir::metainfoTest(QString const& filename) const
|
||||
{
|
||||
int ret;
|
||||
tr_info inf;
|
||||
auto inf = tr_info{};
|
||||
tr_ctor* ctor = tr_ctorNew(nullptr);
|
||||
|
||||
// parse
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
TEST(Crypto, torrentHash)
|
||||
{
|
||||
tr_crypto a;
|
||||
auto a = tr_crypto{};
|
||||
|
||||
auto hash = std::array<uint8_t, SHA_DIGEST_LENGTH>{};
|
||||
for (size_t i = 0; i < hash.size(); ++i)
|
||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
|||
bool isPrivate)
|
||||
{
|
||||
// char* sandbox;
|
||||
tr_info inf;
|
||||
auto inf = tr_info{};
|
||||
|
||||
// create a single input file
|
||||
auto input_file = makeString(tr_buildPath(sandboxDir().data(), "test.XXXXXX", nullptr));
|
||||
|
@ -151,7 +151,7 @@ protected:
|
|||
// now let's check our work: parse the .torrent file
|
||||
auto* ctor = tr_ctorNew(nullptr);
|
||||
tr_ctorSetMetainfoFromFile(ctor, torrent_file);
|
||||
tr_info inf;
|
||||
auto inf = tr_info{};
|
||||
auto parse_result = tr_torrentParse(ctor, &inf);
|
||||
EXPECT_EQ(TR_PARSE_OK, parse_result);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ TEST(Metainfo, magnetLink)
|
|||
|
||||
auto* ctor = tr_ctorNew(nullptr);
|
||||
tr_ctorSetMetainfoFromMagnetLink(ctor, MagnetLink);
|
||||
tr_info inf;
|
||||
auto inf = tr_info{};
|
||||
auto const parse_result = tr_torrentParse(ctor, &inf);
|
||||
EXPECT_EQ(TR_PARSE_OK, parse_result);
|
||||
EXPECT_EQ(0, inf.fileCount); // because it's a magnet link
|
||||
|
|
Loading…
Reference in New Issue