Merge branch 'master' into patch-1
This commit is contained in:
commit
0a67db48bc
|
@ -453,6 +453,7 @@ set(NEEDED_FUNCTIONS
|
|||
canonicalize_file_name
|
||||
daemon
|
||||
fallocate64
|
||||
flock
|
||||
getmntent
|
||||
getpagesize
|
||||
htonll
|
||||
|
|
|
@ -345,6 +345,11 @@
|
|||
C12F19791E1AE3C30005E93F /* upnperrors.c in Sources */ = {isa = PBXBuildFile; fileRef = C12F19771E1AE3C30005E93F /* upnperrors.c */; };
|
||||
C12F197B1E1AE4460005E93F /* upnperrors.h in Headers */ = {isa = PBXBuildFile; fileRef = C12F197A1E1AE4460005E93F /* upnperrors.h */; };
|
||||
C1305EBE186A13B100F03351 /* file.c in Sources */ = {isa = PBXBuildFile; fileRef = C1305EB8186A134000F03351 /* file.c */; };
|
||||
C139E3B122BE70FB0007870C /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C139E3B022BE70FA0007870C /* libssl.dylib */; };
|
||||
C139E3B222BE71030007870C /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C139E3B022BE70FA0007870C /* libssl.dylib */; };
|
||||
C139E3B322BE71180007870C /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C139E3B022BE70FA0007870C /* libssl.dylib */; };
|
||||
C139E3B422BE71250007870C /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C139E3B022BE70FA0007870C /* libssl.dylib */; };
|
||||
C139E3B522BE712C0007870C /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C139E3B022BE70FA0007870C /* libssl.dylib */; };
|
||||
C1425B351EE9C5F5001DB85F /* tr-assert.c in Sources */ = {isa = PBXBuildFile; fileRef = C1425B321EE9C5EA001DB85F /* tr-assert.c */; };
|
||||
C1425B361EE9C605001DB85F /* tr-assert.h in Headers */ = {isa = PBXBuildFile; fileRef = C1425B331EE9C5EA001DB85F /* tr-assert.h */; };
|
||||
C1425B371EE9C705001DB85F /* tr-macros.h in Headers */ = {isa = PBXBuildFile; fileRef = C1425B341EE9C5EA001DB85F /* tr-macros.h */; };
|
||||
|
@ -994,6 +999,7 @@
|
|||
C12F19771E1AE3C30005E93F /* upnperrors.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = upnperrors.c; sourceTree = "<group>"; };
|
||||
C12F197A1E1AE4460005E93F /* upnperrors.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = upnperrors.h; sourceTree = "<group>"; };
|
||||
C1305EB8186A134000F03351 /* file.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = file.c; sourceTree = "<group>"; };
|
||||
C139E3B022BE70FA0007870C /* libssl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libssl.dylib; path = "third-party/openssl/lib/libssl.dylib"; sourceTree = "<group>"; };
|
||||
C1425B321EE9C5EA001DB85F /* tr-assert.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "tr-assert.c"; sourceTree = "<group>"; };
|
||||
C1425B331EE9C5EA001DB85F /* tr-assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "tr-assert.h"; sourceTree = "<group>"; };
|
||||
C1425B341EE9C5EA001DB85F /* tr-macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "tr-macros.h"; sourceTree = "<group>"; };
|
||||
|
@ -1035,6 +1041,7 @@
|
|||
A296EF3C11E560BD004A2781 /* libiconv.dylib in Frameworks */,
|
||||
A2290D1E14421CC100B95A09 /* libcrypto.dylib in Frameworks */,
|
||||
A2290D2F1442B23200B95A09 /* libcurl.4.dylib in Frameworks */,
|
||||
C139E3B322BE71180007870C /* libssl.dylib in Frameworks */,
|
||||
A2B6141E1395B0EC000E0975 /* libz.dylib in Frameworks */,
|
||||
A2B3FB4C0E59023000FF78FB /* Cocoa.framework in Frameworks */,
|
||||
);
|
||||
|
@ -1051,6 +1058,7 @@
|
|||
A296EF3B11E560A7004A2781 /* libiconv.dylib in Frameworks */,
|
||||
A2290D2514421D1A00B95A09 /* libcrypto.dylib in Frameworks */,
|
||||
A2290D2E1442B23200B95A09 /* libcurl.4.dylib in Frameworks */,
|
||||
C139E3B122BE70FB0007870C /* libssl.dylib in Frameworks */,
|
||||
A2B6141F1395B0F5000E0975 /* libz.dylib in Frameworks */,
|
||||
A2E669790F5B8E5A00B4251A /* Security.framework in Frameworks */,
|
||||
A22CFB820FB66EF30009BD3E /* Carbon.framework in Frameworks */,
|
||||
|
@ -1082,9 +1090,10 @@
|
|||
A2F35BE315C5A7F900EBF632 /* Foundation.framework in Frameworks */,
|
||||
A2F35BD415C5A19A00EBF632 /* libtransmission.a in Frameworks */,
|
||||
A2F35BDB15C5A4A000EBF632 /* libiconv.dylib in Frameworks */,
|
||||
A2F35BDA15C5A49200EBF632 /* libz.dylib in Frameworks */,
|
||||
A2F35BD715C5A46D00EBF632 /* libcrypto.dylib in Frameworks */,
|
||||
A2AB76EA15D8130B009EFC95 /* libcurl.4.dylib in Frameworks */,
|
||||
C139E3B222BE71030007870C /* libssl.dylib in Frameworks */,
|
||||
A2F35BDA15C5A49200EBF632 /* libz.dylib in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -1123,6 +1132,7 @@
|
|||
A296EF3D11E560C3004A2781 /* libiconv.dylib in Frameworks */,
|
||||
A2290D2014421CD000B95A09 /* libcrypto.dylib in Frameworks */,
|
||||
A2290D301442B23200B95A09 /* libcurl.4.dylib in Frameworks */,
|
||||
C139E3B422BE71250007870C /* libssl.dylib in Frameworks */,
|
||||
A2B6141D1395B0E3000E0975 /* libz.dylib in Frameworks */,
|
||||
A2B3FB530E59027100FF78FB /* Cocoa.framework in Frameworks */,
|
||||
);
|
||||
|
@ -1136,6 +1146,7 @@
|
|||
A296EF3E11E560D1004A2781 /* libiconv.dylib in Frameworks */,
|
||||
A2290D2214421CD800B95A09 /* libcrypto.dylib in Frameworks */,
|
||||
A2290D311442B23200B95A09 /* libcurl.4.dylib in Frameworks */,
|
||||
C139E3B522BE712C0007870C /* libssl.dylib in Frameworks */,
|
||||
A2B6141C1395ADE9000E0975 /* libz.dylib in Frameworks */,
|
||||
A25E03D90E4015100086C225 /* Cocoa.framework in Frameworks */,
|
||||
);
|
||||
|
@ -1590,6 +1601,7 @@
|
|||
A2F35BBA15C5A0A100EBF632 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C139E3B022BE70FA0007870C /* libssl.dylib */,
|
||||
A2F35BBB15C5A0A100EBF632 /* QuickLook.framework */,
|
||||
A2F35BE215C5A7F900EBF632 /* Foundation.framework */,
|
||||
A2F35BE015C5A7ED00EBF632 /* Cocoa.framework */,
|
||||
|
|
38
cli/cli.c
38
cli/cli.c
|
@ -75,25 +75,25 @@ static char const* torrentPath = NULL;
|
|||
|
||||
static struct tr_option const options[] =
|
||||
{
|
||||
{ 'b', "blocklist", "Enable peer blocklists", "b", 0, NULL },
|
||||
{ 'B', "no-blocklist", "Disable peer blocklists", "B", 0, NULL },
|
||||
{ 'd', "downlimit", "Set max download speed in "SPEED_K_STR, "d", 1, "<speed>" },
|
||||
{ 'D', "no-downlimit", "Don't limit the download speed", "D", 0, NULL },
|
||||
{ 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL },
|
||||
{ 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", 0, NULL },
|
||||
{ 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", 0, NULL },
|
||||
{ 'f', "finish", "Run a script when the torrent finishes", "f", 1, "<script>" },
|
||||
{ 'g', "config-dir", "Where to find configuration files", "g", 1, "<path>" },
|
||||
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL },
|
||||
{ 'M', "no-portmap", "Disable portmapping", "M", 0, NULL },
|
||||
{ 'p', "port", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", 1, "<port>" },
|
||||
{ 't', "tos", "Peer socket TOS (0 to 255, default=" TR_DEFAULT_PEER_SOCKET_TOS_STR ")", "t", 1, "<tos>" },
|
||||
{ 'u', "uplimit", "Set max upload speed in "SPEED_K_STR, "u", 1, "<speed>" },
|
||||
{ 'U', "no-uplimit", "Don't limit the upload speed", "U", 0, NULL },
|
||||
{ 'v', "verify", "Verify the specified torrent", "v", 0, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
{ 'w', "download-dir", "Where to save downloaded data", "w", 1, "<path>" },
|
||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||
{ 'b', "blocklist", "Enable peer blocklists", "b", false, NULL },
|
||||
{ 'B', "no-blocklist", "Disable peer blocklists", "B", false, NULL },
|
||||
{ 'd', "downlimit", "Set max download speed in "SPEED_K_STR, "d", true, "<speed>" },
|
||||
{ 'D', "no-downlimit", "Don't limit the download speed", "D", false, NULL },
|
||||
{ 910, "encryption-required", "Encrypt all peer connections", "er", false, NULL },
|
||||
{ 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", false, NULL },
|
||||
{ 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", false, NULL },
|
||||
{ 'f', "finish", "Run a script when the torrent finishes", "f", true, "<script>" },
|
||||
{ 'g', "config-dir", "Where to find configuration files", "g", true, "<path>" },
|
||||
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", false, NULL },
|
||||
{ 'M', "no-portmap", "Disable portmapping", "M", false, NULL },
|
||||
{ 'p', "port", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", true, "<port>" },
|
||||
{ 't', "tos", "Peer socket TOS (0 to 255, default=" TR_DEFAULT_PEER_SOCKET_TOS_STR ")", "t", true, "<tos>" },
|
||||
{ 'u', "uplimit", "Set max upload speed in "SPEED_K_STR, "u", true, "<speed>" },
|
||||
{ 'U', "no-uplimit", "Don't limit the upload speed", "U", false, NULL },
|
||||
{ 'v', "verify", "Verify the specified torrent", "v", false, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", false, NULL },
|
||||
{ 'w', "download-dir", "Where to save downloaded data", "w", true, "<path>" },
|
||||
{ 0, NULL, NULL, NULL, false, NULL }
|
||||
};
|
||||
|
||||
static char const* getUsage(void)
|
||||
|
|
|
@ -98,53 +98,53 @@ static char const* getUsage(void)
|
|||
|
||||
static struct tr_option const options[] =
|
||||
{
|
||||
{ 'a', "allowed", "Allowed IP addresses. (Default: " TR_DEFAULT_RPC_WHITELIST ")", "a", 1, "<list>" },
|
||||
{ 'b', "blocklist", "Enable peer blocklists", "b", 0, NULL },
|
||||
{ 'B', "no-blocklist", "Disable peer blocklists", "B", 0, NULL },
|
||||
{ 'c', "watch-dir", "Where to watch for new .torrent files", "c", 1, "<directory>" },
|
||||
{ 'C', "no-watch-dir", "Disable the watch-dir", "C", 0, NULL },
|
||||
{ 941, "incomplete-dir", "Where to store new torrents until they're complete", NULL, 1, "<directory>" },
|
||||
{ 942, "no-incomplete-dir", "Don't store incomplete torrents in a different location", NULL, 0, NULL },
|
||||
{ 'd', "dump-settings", "Dump the settings and exit", "d", 0, NULL },
|
||||
{ 'e', "logfile", "Dump the log messages to this filename", "e", 1, "<filename>" },
|
||||
{ 'f', "foreground", "Run in the foreground instead of daemonizing", "f", 0, NULL },
|
||||
{ 'g', "config-dir", "Where to look for configuration files", "g", 1, "<path>" },
|
||||
{ 'p', "port", "RPC port (Default: " TR_DEFAULT_RPC_PORT_STR ")", "p", 1, "<port>" },
|
||||
{ 't', "auth", "Require authentication", "t", 0, NULL },
|
||||
{ 'T', "no-auth", "Don't require authentication", "T", 0, NULL },
|
||||
{ 'u', "username", "Set username for authentication", "u", 1, "<username>" },
|
||||
{ 'v', "password", "Set password for authentication", "v", 1, "<password>" },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
{ 810, "log-error", "Show error messages", NULL, 0, NULL },
|
||||
{ 811, "log-info", "Show error and info messages", NULL, 0, NULL },
|
||||
{ 812, "log-debug", "Show error, info, and debug messages", NULL, 0, NULL },
|
||||
{ 'w', "download-dir", "Where to save downloaded data", "w", 1, "<path>" },
|
||||
{ 800, "paused", "Pause all torrents on startup", NULL, 0, NULL },
|
||||
{ 'o', "dht", "Enable distributed hash tables (DHT)", "o", 0, NULL },
|
||||
{ 'O', "no-dht", "Disable distributed hash tables (DHT)", "O", 0, NULL },
|
||||
{ 'y', "lpd", "Enable local peer discovery (LPD)", "y", 0, NULL },
|
||||
{ 'Y', "no-lpd", "Disable local peer discovery (LPD)", "Y", 0, NULL },
|
||||
{ 830, "utp", "Enable uTP for peer connections", NULL, 0, NULL },
|
||||
{ 831, "no-utp", "Disable uTP for peer connections", NULL, 0, NULL },
|
||||
{ 'P', "peerport", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "P", 1, "<port>" },
|
||||
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL },
|
||||
{ 'M', "no-portmap", "Disable portmapping", "M", 0, NULL },
|
||||
{ 'L', "peerlimit-global", "Maximum overall number of peers (Default: " TR_DEFAULT_PEER_LIMIT_GLOBAL_STR ")", "L", 1,
|
||||
{ 'a', "allowed", "Allowed IP addresses. (Default: " TR_DEFAULT_RPC_WHITELIST ")", "a", true, "<list>" },
|
||||
{ 'b', "blocklist", "Enable peer blocklists", "b", false, NULL },
|
||||
{ 'B', "no-blocklist", "Disable peer blocklists", "B", false, NULL },
|
||||
{ 'c', "watch-dir", "Where to watch for new .torrent files", "c", true, "<directory>" },
|
||||
{ 'C', "no-watch-dir", "Disable the watch-dir", "C", false, NULL },
|
||||
{ 941, "incomplete-dir", "Where to store new torrents until they're complete", NULL, true, "<directory>" },
|
||||
{ 942, "no-incomplete-dir", "Don't store incomplete torrents in a different location", NULL, false, NULL },
|
||||
{ 'd', "dump-settings", "Dump the settings and exit", "d", false, NULL },
|
||||
{ 'e', "logfile", "Dump the log messages to this filename", "e", true, "<filename>" },
|
||||
{ 'f', "foreground", "Run in the foreground instead of daemonizing", "f", false, NULL },
|
||||
{ 'g', "config-dir", "Where to look for configuration files", "g", true, "<path>" },
|
||||
{ 'p', "port", "RPC port (Default: " TR_DEFAULT_RPC_PORT_STR ")", "p", true, "<port>" },
|
||||
{ 't', "auth", "Require authentication", "t", false, NULL },
|
||||
{ 'T', "no-auth", "Don't require authentication", "T", false, NULL },
|
||||
{ 'u', "username", "Set username for authentication", "u", true, "<username>" },
|
||||
{ 'v', "password", "Set password for authentication", "v", true, "<password>" },
|
||||
{ 'V', "version", "Show version number and exit", "V", false, NULL },
|
||||
{ 810, "log-error", "Show error messages", NULL, false, NULL },
|
||||
{ 811, "log-info", "Show error and info messages", NULL, false, NULL },
|
||||
{ 812, "log-debug", "Show error, info, and debug messages", NULL, false, NULL },
|
||||
{ 'w', "download-dir", "Where to save downloaded data", "w", true, "<path>" },
|
||||
{ 800, "paused", "Pause all torrents on startup", NULL, false, NULL },
|
||||
{ 'o', "dht", "Enable distributed hash tables (DHT)", "o", false, NULL },
|
||||
{ 'O', "no-dht", "Disable distributed hash tables (DHT)", "O", false, NULL },
|
||||
{ 'y', "lpd", "Enable local peer discovery (LPD)", "y", false, NULL },
|
||||
{ 'Y', "no-lpd", "Disable local peer discovery (LPD)", "Y", false, NULL },
|
||||
{ 830, "utp", "Enable uTP for peer connections", NULL, false, NULL },
|
||||
{ 831, "no-utp", "Disable uTP for peer connections", NULL, false, NULL },
|
||||
{ 'P', "peerport", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "P", true, "<port>" },
|
||||
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", false, NULL },
|
||||
{ 'M', "no-portmap", "Disable portmapping", "M", false, NULL },
|
||||
{ 'L', "peerlimit-global", "Maximum overall number of peers (Default: " TR_DEFAULT_PEER_LIMIT_GLOBAL_STR ")", "L", true,
|
||||
"<limit>" },
|
||||
{ 'l', "peerlimit-torrent", "Maximum number of peers per torrent (Default: " TR_DEFAULT_PEER_LIMIT_TORRENT_STR ")", "l", 1,
|
||||
"<limit>" },
|
||||
{ 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL },
|
||||
{ 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", 0, NULL },
|
||||
{ 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", 0, NULL },
|
||||
{ 'i', "bind-address-ipv4", "Where to listen for peer connections", "i", 1, "<ipv4 addr>" },
|
||||
{ 'I', "bind-address-ipv6", "Where to listen for peer connections", "I", 1, "<ipv6 addr>" },
|
||||
{ 'r', "rpc-bind-address", "Where to listen for RPC connections", "r", 1, "<ip addr>" },
|
||||
{ 'l', "peerlimit-torrent", "Maximum number of peers per torrent (Default: " TR_DEFAULT_PEER_LIMIT_TORRENT_STR ")", "l",
|
||||
true, "<limit>" },
|
||||
{ 910, "encryption-required", "Encrypt all peer connections", "er", false, NULL },
|
||||
{ 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", false, NULL },
|
||||
{ 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", false, NULL },
|
||||
{ 'i', "bind-address-ipv4", "Where to listen for peer connections", "i", true, "<ipv4 addr>" },
|
||||
{ 'I', "bind-address-ipv6", "Where to listen for peer connections", "I", true, "<ipv6 addr>" },
|
||||
{ 'r', "rpc-bind-address", "Where to listen for RPC connections", "r", true, "<ip addr>" },
|
||||
{ 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio",
|
||||
"gsr", 1, "ratio" },
|
||||
"gsr", true, "ratio" },
|
||||
{ 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio",
|
||||
"GSR", 0, NULL },
|
||||
{ 'x', "pid-file", "Enable PID file", "x", 1, "<pid-file>" },
|
||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||
"GSR", false, NULL },
|
||||
{ 'x', "pid-file", "Enable PID file", "x", true, "<pid-file>" },
|
||||
{ 0, NULL, NULL, NULL, false, NULL }
|
||||
};
|
||||
|
||||
static bool reopen_log_file(char const* filename)
|
||||
|
@ -649,7 +649,7 @@ static int daemon_start(void* raw_arg, bool foreground)
|
|||
pid_filename = NULL;
|
||||
tr_variantDictFindStr(settings, key_pidfile, &pid_filename, NULL);
|
||||
|
||||
if (pid_filename != NULL && *pid_filename != '\0')
|
||||
if (!tr_str_is_empty(pid_filename))
|
||||
{
|
||||
tr_error* error = NULL;
|
||||
tr_sys_file_t fp = tr_sys_file_open(pid_filename, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE | TR_SYS_FILE_TRUNCATE, 0666,
|
||||
|
@ -693,7 +693,7 @@ static int daemon_start(void* raw_arg, bool foreground)
|
|||
force_generic = false;
|
||||
}
|
||||
|
||||
if (tr_variantDictFindStr(settings, TR_KEY_watch_dir, &dir, NULL) && dir != NULL && *dir != '\0')
|
||||
if (tr_variantDictFindStr(settings, TR_KEY_watch_dir, &dir, NULL) && !tr_str_is_empty(dir))
|
||||
{
|
||||
tr_logAddInfo("Watching \"%s\" for new .torrent files", dir);
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@ set(VERSION "${TR_USER_AGENT_PREFIX}")
|
|||
set(VERSION_MSI "${TR_VERSION_MAJOR}.${TR_VERSION_MINOR}.0")
|
||||
set(VERSION_FULL "${TR_USER_AGENT_PREFIX} (${TR_VCS_REVISION})")
|
||||
|
||||
set(MSI_FILENAME_VERSION "${VERSION}")
|
||||
if(TR_NIGHTLY_RELEASE)
|
||||
set(MSI_FILENAME_VERSION "${MSI_FILENAME_VERSION}-r${TR_VCS_REVISION}")
|
||||
endif()
|
||||
|
||||
if(NOT TR_THIRD_PARTY_DIR)
|
||||
set(TR_THIRD_PARTY_DIR "$<TARGET_FILE_DIR:OpenSSL::SSL>/..")
|
||||
endif()
|
||||
|
@ -20,6 +25,20 @@ if(NOT TR_QT_DIR)
|
|||
set(TR_QT_DIR "$<TARGET_FILE_DIR:Qt5::Core>/..")
|
||||
endif()
|
||||
|
||||
find_msvc_crt_msm(TR_MSVC_CRT_MSM_FILE)
|
||||
|
||||
if(OPENSSL_VERSION MATCHES "^1[.]1[.]")
|
||||
set(TR_OPENSSL_ARCH)
|
||||
if(ARCH STREQUAL "x64")
|
||||
set(TR_OPENSSL_ARCH "-x64")
|
||||
endif()
|
||||
set(TR_OPENSSL_CRYPTO_NAME "libcrypto-1_1${TR_OPENSSL_ARCH}.dll")
|
||||
set(TR_OPENSSL_SSL_NAME "libssl-1_1${TR_OPENSSL_ARCH}.dll")
|
||||
else()
|
||||
set(TR_OPENSSL_CRYPTO_NAME "libeay32.dll")
|
||||
set(TR_OPENSSL_SSL_NAME "ssleay32.dll")
|
||||
endif()
|
||||
|
||||
set(ICONS_DIR "${CMAKE_SOURCE_DIR}/qt/icons/hicolor")
|
||||
png2ico(Transmission.ico
|
||||
"${ICONS_DIR}/16x16/transmission-qt.png"
|
||||
|
@ -67,12 +86,15 @@ wix_candle(${PROJECT_NAME}_OBJS
|
|||
"WebSrcDir=${WEBSRCDIR}"
|
||||
"TrQmSrcDir=${TRQMSRCDIR}"
|
||||
"QtQmSrcDir=${QTQMSRCDIR}"
|
||||
"MsvcCrtMsmFile=${TR_MSVC_CRT_MSM_FILE}"
|
||||
"OpenSslCryptoName=${TR_OPENSSL_CRYPTO_NAME}"
|
||||
"OpenSslSslName=${TR_OPENSSL_SSL_NAME}"
|
||||
EXTRA_DEPENDS
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/TransmissionConfig.wxi")
|
||||
|
||||
wix_light(${PROJECT_NAME}_OUTPUT
|
||||
NAME
|
||||
transmission-${VERSION}-r${TR_VCS_REVISION}-${ARCH}
|
||||
transmission-${MSI_FILENAME_VERSION}-${ARCH}
|
||||
OBJECTS
|
||||
${${PROJECT_NAME}_OBJS}
|
||||
EXTENSIONS
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<Property Id="DiskPrompt" Value="Transmission $(var.TrVersion) Installation [1]" />
|
||||
|
||||
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||
<Merge Id="VCRedist" SourceFile="$(env.CommonProgramFiles(x86))\Merge Modules\Microsoft_VC140_CRT_$(sys.BUILDARCH).msm" DiskId="1" Language="0" />
|
||||
<Merge Id="VCRedist" SourceFile="$(var.MsvcCrtMsmFile)" DiskId="1" Language="0" />
|
||||
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
|
||||
<Directory Id="INSTALLDIR" Name="Transmission">
|
||||
<Directory Id="WEBINSTALLDIR" Name="web" />
|
||||
|
@ -53,7 +53,7 @@
|
|||
</Directory>
|
||||
|
||||
<Feature Id="CompleteInstall" Title="Transmission" Level="1" AllowAdvertise="no" Display="expand" ConfigurableDirectory="INSTALLDIR">
|
||||
<Feature Id="VCRedist" Title="Visual C++ 14.0 Runtime" Level="1" AllowAdvertise="no" Display="hidden">
|
||||
<Feature Id="VCRedist" Title="Visual C++ Runtime" Level="1" AllowAdvertise="no" Display="hidden">
|
||||
<MergeRef Id="VCRedist" />
|
||||
</Feature>
|
||||
<Feature Id="CommonLibs" Level="1" AllowAdvertise="no" Display="hidden">
|
||||
|
|
|
@ -1,5 +1,44 @@
|
|||
include(CMakeParseArguments)
|
||||
|
||||
function(find_msvc_crt_msm OUTPUT_VAR)
|
||||
if(${OUTPUT_VAR})
|
||||
return()
|
||||
endif()
|
||||
|
||||
message(STATUS "Looking for a CRT MSM:")
|
||||
|
||||
if(NOT MSVC_TOOLSET_VERSION)
|
||||
if(MSVC_VERSION GREATER_EQUAL 1920)
|
||||
set(MSVC_TOOLSET_VERSION 142)
|
||||
elseif(MSVC_VERSION GREATER_EQUAL 1910)
|
||||
set(MSVC_TOOLSET_VERSION 141)
|
||||
elseif(MSVC_VERSION GREATER_EQUAL 1900)
|
||||
set(MSVC_TOOLSET_VERSION 140)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(MSM_FILE "Microsoft_VC${MSVC_TOOLSET_VERSION}_CRT_${ARCH}.msm")
|
||||
message(STATUS " * File name: ${MSM_FILE}")
|
||||
|
||||
set(VC_DIR "${CMAKE_CXX_COMPILER}")
|
||||
while(VC_DIR AND NOT VC_DIR MATCHES "/VC$")
|
||||
get_filename_component(VC_DIR "${VC_DIR}" DIRECTORY)
|
||||
endwhile()
|
||||
message(STATUS " * VC directory: ${VC_DIR}")
|
||||
|
||||
file(GLOB VC_VER_DIRS "${VC_DIR}/Redist/MSVC/*")
|
||||
message(STATUS " * Redist directories: ${VC_VER_DIRS}")
|
||||
|
||||
set(CMN_PF_DIR "CommonProgramFiles(x86)")
|
||||
find_file(${OUTPUT_VAR}
|
||||
NAMES "${MSM_FILE}"
|
||||
PATHS ${VC_VER_DIRS} $ENV{${CMN_PF_DIR}}
|
||||
PATH_SUFFIXES "MergeModules" "Merge Modules")
|
||||
message(STATUS " * Result: ${${OUTPUT_VAR}}")
|
||||
|
||||
set(${OUTPUT_VAR} "${${OUTPUT_VAR}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(png2ico OUTPUT_FILE)
|
||||
if(NOT IS_ABSOLUTE "${OUTPUT_FILE}")
|
||||
set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILE}")
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
<File DiskId="1" KeyPath="yes" Name="libcurl.dll" />
|
||||
</Component>
|
||||
<Component Id="dll.openssl.crypto">
|
||||
<File DiskId="1" KeyPath="yes" Name="libeay32.dll" />
|
||||
<File DiskId="1" KeyPath="yes" Name="$(var.OpenSslCryptoName)" />
|
||||
</Component>
|
||||
<Component Id="dll.openssl.ssl">
|
||||
<File DiskId="1" KeyPath="yes" Name="ssleay32.dll" />
|
||||
<File DiskId="1" KeyPath="yes" Name="$(var.OpenSslSslName)" />
|
||||
</Component>
|
||||
<Component Id="dll.zlib">
|
||||
<File DiskId="1" KeyPath="yes" Name="zlib.dll" />
|
||||
|
|
|
@ -113,14 +113,17 @@
|
|||
</Component>
|
||||
</Directory>
|
||||
|
||||
<Directory Id="QTSTYLESDIR" Name="styles">
|
||||
<Component Id="dll.qt5.plugins.styles.windowsvista">
|
||||
<File DiskId="1" KeyPath="yes" Name="qwindowsvistastyle.dll" />
|
||||
</Component>
|
||||
</Directory>
|
||||
|
||||
</DirectoryRef>
|
||||
<DirectoryRef Id="INSTALLDIR" FileSource="$(var.ThirdPartyDir)\bin">
|
||||
|
||||
<Component Id="dll.dbus">
|
||||
<File DiskId="1" KeyPath="yes" Name="dbus-1-3.dll" />
|
||||
</Component>
|
||||
<Component Id="dll.expat">
|
||||
<File DiskId="1" KeyPath="yes" Name="expat.dll" />
|
||||
<File DiskId="1" KeyPath="yes" Name="dbus-1.dll" />
|
||||
</Component>
|
||||
|
||||
</DirectoryRef>
|
||||
|
@ -137,8 +140,8 @@
|
|||
<ComponentRef Id="dll.qt5.widgets" />
|
||||
<ComponentRef Id="dll.qt5.winextras" />
|
||||
<ComponentRef Id="dll.qt5.plugins.platforms.windows" />
|
||||
<ComponentRef Id="dll.qt5.plugins.styles.windowsvista" />
|
||||
<ComponentRef Id="dll.dbus" />
|
||||
<ComponentRef Id="dll.expat" />
|
||||
<ComponentGroupRef Id="QtClientTranslationsComponents" />
|
||||
<ComponentGroupRef Id="QtTranslationsComponents" />
|
||||
</ComponentGroup>
|
||||
|
|
|
@ -721,7 +721,7 @@ static void refreshInfo(struct DetailsImpl* di, tr_torrent** torrents, int n)
|
|||
mixed_date |= date != infos[i]->dateCreated;
|
||||
}
|
||||
|
||||
gboolean const empty_creator = *creator == '\0';
|
||||
gboolean const empty_creator = tr_str_is_empty(creator);
|
||||
gboolean const empty_date = date == 0;
|
||||
|
||||
if (mixed_date || mixed_creator)
|
||||
|
@ -1079,7 +1079,7 @@ static void refreshInfo(struct DetailsImpl* di, tr_torrent** torrents, int n)
|
|||
str = is_uniform ? baseline : mixed;
|
||||
}
|
||||
|
||||
if (str == NULL || *str == '\0')
|
||||
if (tr_str_is_empty(str))
|
||||
{
|
||||
str = _("No errors");
|
||||
}
|
||||
|
@ -1760,7 +1760,7 @@ static gboolean onPeerViewQueryTooltip(GtkWidget* widget, gint x, gint y, gboole
|
|||
g_string_append_printf(gstr, "<b>%s</b>\n%s\n \n", markup, addr);
|
||||
g_free(markup);
|
||||
|
||||
for (char const* pch = flagstr; pch != NULL && *pch != '\0'; ++pch)
|
||||
for (char const* pch = flagstr; !tr_str_is_empty(pch); ++pch)
|
||||
{
|
||||
char const* s = NULL;
|
||||
|
||||
|
@ -2515,7 +2515,7 @@ static void on_edit_trackers_response(GtkDialog* dialog, int response, gpointer
|
|||
{
|
||||
char* const str = tracker_strings[i];
|
||||
|
||||
if (*str == '\0')
|
||||
if (tr_str_is_empty(str))
|
||||
{
|
||||
++tier;
|
||||
}
|
||||
|
@ -2661,7 +2661,7 @@ static void on_add_tracker_response(GtkDialog* dialog, int response, gpointer gd
|
|||
char* url = g_strdup(gtk_entry_get_text(GTK_ENTRY(e)));
|
||||
g_strstrip(url);
|
||||
|
||||
if (url != NULL && *url != '\0')
|
||||
if (!tr_str_is_empty(url))
|
||||
{
|
||||
if (tr_urlIsValidTracker(url))
|
||||
{
|
||||
|
|
|
@ -679,10 +679,10 @@ static gboolean onRowActivated(GtkTreeView* view, GtkTreePath* path, GtkTreeView
|
|||
g_free(filename);
|
||||
filename = tmp;
|
||||
}
|
||||
while (filename != NULL && *filename != '\0' && !g_file_test(filename, G_FILE_TEST_EXISTS));
|
||||
while (!tr_str_is_empty(filename) && !g_file_test(filename, G_FILE_TEST_EXISTS));
|
||||
}
|
||||
|
||||
if ((handled = filename != NULL && *filename != '\0'))
|
||||
if ((handled = !tr_str_is_empty(filename)))
|
||||
{
|
||||
gtr_open_file(filename);
|
||||
}
|
||||
|
|
|
@ -703,7 +703,7 @@ static gboolean testText(tr_torrent const* tor, char const* key)
|
|||
{
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (key == NULL || *key == '\0')
|
||||
if (tr_str_is_empty(key))
|
||||
{
|
||||
ret = TRUE;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ void hig_workarea_add_wide_control(GtkWidget* t, guint* row, GtkWidget* w)
|
|||
gtk_grid_attach(GTK_GRID(t), w, 0, *row, 2, 1);
|
||||
++*row;
|
||||
}
|
||||
|
||||
void hig_workarea_add_wide_tall_control(GtkWidget* t, guint* row, GtkWidget* w)
|
||||
{
|
||||
gtk_widget_set_hexpand(w, TRUE);
|
||||
|
|
|
@ -317,6 +317,7 @@ static void register_magnet_link_handler(void)
|
|||
|
||||
g_clear_object(&app);
|
||||
}
|
||||
|
||||
static void ensure_magnet_handler_exists(void)
|
||||
{
|
||||
if (!has_magnet_link_handler())
|
||||
|
|
|
@ -252,7 +252,7 @@ static void onResponse(GtkDialog* d, int response, gpointer user_data)
|
|||
{
|
||||
char* const str = tracker_strings[i];
|
||||
|
||||
if (*str == '\0')
|
||||
if (tr_str_is_empty(str))
|
||||
{
|
||||
++tier;
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ static void getStatusString(GString* gstr, tr_torrent const* tor, tr_stat const*
|
|||
char buf[256];
|
||||
getShortTransferString(tor, st, uploadSpeed_KBps, downloadSpeed_KBps, buf, sizeof(buf));
|
||||
|
||||
if (*buf != '\0')
|
||||
if (!tr_str_is_empty(buf))
|
||||
{
|
||||
g_string_append_printf(gstr, " - %s", buf);
|
||||
}
|
||||
|
|
|
@ -1771,7 +1771,7 @@ static gboolean core_read_rpc_response_idle(void* vresponse)
|
|||
|
||||
if (data != NULL)
|
||||
{
|
||||
if (data->response_func)
|
||||
if (data->response_func != NULL)
|
||||
{
|
||||
(*data->response_func)(data->core, response, data->response_func_user_data);
|
||||
}
|
||||
|
|
|
@ -422,6 +422,7 @@ static void onRatioToggled(GtkCheckMenuItem* check, gpointer vp)
|
|||
gtr_core_set_pref_bool(p->core, TR_KEY_ratio_limit_enabled, f);
|
||||
}
|
||||
}
|
||||
|
||||
static void onRatioSet(GtkCheckMenuItem* check, gpointer vp)
|
||||
{
|
||||
PrivateData* p = vp;
|
||||
|
|
|
@ -269,7 +269,7 @@ if(ICONV_FOUND)
|
|||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(${TR_NAME} shlwapi)
|
||||
target_link_libraries(${TR_NAME} crypt32 shlwapi)
|
||||
endif()
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
|
|
|
@ -94,14 +94,14 @@ static char* announce_url_new(tr_session const* session, tr_announce_request con
|
|||
|
||||
str = get_event_string(req);
|
||||
|
||||
if (str != NULL && *str != '\0')
|
||||
if (!tr_str_is_empty(str))
|
||||
{
|
||||
evbuffer_add_printf(buf, "&event=%s", str);
|
||||
}
|
||||
|
||||
str = req->tracker_id_str;
|
||||
|
||||
if (str != NULL && *str != '\0')
|
||||
if (!tr_str_is_empty(str))
|
||||
{
|
||||
evbuffer_add_printf(buf, "&trackerid=%s", str);
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ static struct tr_scrape_info* tr_announcerGetScrapeInfo(struct tr_announcer* ann
|
|||
{
|
||||
struct tr_scrape_info* info = NULL;
|
||||
|
||||
if (url != NULL && *url != '\0')
|
||||
if (!tr_str_is_empty(url))
|
||||
{
|
||||
bool found;
|
||||
struct tr_scrape_info const key = { .url = (char*)url };
|
||||
|
@ -1547,7 +1547,7 @@ static void on_scrape_done(tr_scrape_response const* response, void* vsession)
|
|||
}
|
||||
}
|
||||
|
||||
if (announcer)
|
||||
if (announcer != NULL)
|
||||
{
|
||||
++announcer->slotsAvailable;
|
||||
}
|
||||
|
|
|
@ -378,7 +378,7 @@ void tr_bitfieldSetRaw(tr_bitfield* b, void const* bits, size_t byte_count, bool
|
|||
TR_ASSERT(excess_bit_count >= 0);
|
||||
TR_ASSERT(excess_bit_count <= 7);
|
||||
|
||||
if (excess_bit_count)
|
||||
if (excess_bit_count != 0)
|
||||
{
|
||||
b->bits[b->alloc_count - 1] &= 0xff << excess_bit_count;
|
||||
}
|
||||
|
|
|
@ -639,7 +639,7 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
|
|||
tr_snprintf(buf, buflen, "Baidu Netdisk");
|
||||
}
|
||||
|
||||
if (*buf != '\0')
|
||||
if (!tr_str_is_empty(buf))
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
|
|||
strint(id + 5, 2), getMnemonicEnd(id[7]));
|
||||
}
|
||||
|
||||
if (*buf != '\0')
|
||||
if (!tr_str_is_empty(buf))
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
|
|||
mainline_style(buf, buflen, "Queen Bee", id);
|
||||
}
|
||||
|
||||
if (*buf != '\0')
|
||||
if (!tr_str_is_empty(buf))
|
||||
{
|
||||
return buf;
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
|
|||
}
|
||||
|
||||
/* Shad0w-style */
|
||||
if (*buf == '\0')
|
||||
if (tr_str_is_empty(buf))
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
|
@ -856,7 +856,7 @@ char* tr_clientForId(char* buf, size_t buflen, void const* id_in)
|
|||
}
|
||||
|
||||
/* No match */
|
||||
if (*buf == '\0')
|
||||
if (tr_str_is_empty(buf))
|
||||
{
|
||||
char out[32];
|
||||
char* walk = out;
|
||||
|
|
|
@ -120,7 +120,7 @@ void tr_cpBlockAdd(tr_completion* cp, tr_block_index_t block)
|
|||
cp->sizeNow += tr_torBlockCountBytes(tor, block);
|
||||
|
||||
cp->haveValidIsDirty = true;
|
||||
cp->sizeWhenDoneIsDirty |= tor->info.pieces[piece].dnd;
|
||||
cp->sizeWhenDoneIsDirty = cp->sizeWhenDoneIsDirty || tor->info.pieces[piece].dnd;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#define tr_rc4_ctx_t tr_rc4_ctx_t_
|
||||
#define tr_dh_ctx_t tr_dh_ctx_t_
|
||||
#define tr_dh_secret_t tr_dh_secret_t_
|
||||
#define tr_ssl_ctx_t tr_ssl_ctx_t_
|
||||
#define tr_x509_store_t tr_x509_store_t_
|
||||
#define tr_x509_cert_t tr_x509_cert_t_
|
||||
#define tr_crypto tr_crypto_
|
||||
#define tr_cryptoConstruct tr_cryptoConstruct_
|
||||
#define tr_cryptoDestruct tr_cryptoDestruct_
|
||||
|
@ -47,6 +50,10 @@
|
|||
#define tr_dh_secret_derive tr_dh_secret_derive_
|
||||
#define tr_dh_secret_free tr_dh_secret_free_
|
||||
#define tr_dh_align_key tr_dh_align_key_
|
||||
#define tr_ssl_get_x509_store tr_ssl_get_x509_store_
|
||||
#define tr_x509_store_add tr_x509_store_add_
|
||||
#define tr_x509_cert_new tr_x509_cert_new_
|
||||
#define tr_x509_cert_free tr_x509_cert_free_
|
||||
#define tr_rand_int tr_rand_int_
|
||||
#define tr_rand_int_weak tr_rand_int_weak_
|
||||
#define tr_rand_buffer tr_rand_buffer_
|
||||
|
@ -76,6 +83,9 @@
|
|||
#undef tr_rc4_ctx_t
|
||||
#undef tr_dh_ctx_t
|
||||
#undef tr_dh_secret_t
|
||||
#undef tr_ssl_ctx_t
|
||||
#undef tr_x509_store_t
|
||||
#undef tr_x509_cert_t
|
||||
#undef tr_crypto
|
||||
#undef tr_cryptoConstruct
|
||||
#undef tr_cryptoDestruct
|
||||
|
@ -104,6 +114,10 @@
|
|||
#undef tr_dh_secret_derive
|
||||
#undef tr_dh_secret_free
|
||||
#undef tr_dh_align_key
|
||||
#undef tr_ssl_get_x509_store
|
||||
#undef tr_x509_store_add
|
||||
#undef tr_x509_cert_new
|
||||
#undef tr_x509_cert_free
|
||||
#undef tr_rand_int
|
||||
#undef tr_rand_int_weak
|
||||
#undef tr_rand_buffer
|
||||
|
@ -126,6 +140,9 @@
|
|||
#define tr_rc4_ctx_t_ tr_rc4_ctx_t
|
||||
#define tr_dh_ctx_t_ tr_dh_ctx_t
|
||||
#define tr_dh_secret_t_ tr_dh_secret_t
|
||||
#define tr_ssl_ctx_t_ tr_ssl_ctx_t
|
||||
#define tr_x509_store_t_ tr_x509_store_t
|
||||
#define tr_x509_cert_t_ tr_x509_cert_t
|
||||
#define tr_crypto_ tr_crypto
|
||||
#define tr_cryptoConstruct_ tr_cryptoConstruct
|
||||
#define tr_cryptoDestruct_ tr_cryptoDestruct
|
||||
|
@ -154,6 +171,10 @@
|
|||
#define tr_dh_secret_derive_ tr_dh_secret_derive
|
||||
#define tr_dh_secret_free_ tr_dh_secret_free
|
||||
#define tr_dh_align_key_ tr_dh_align_key
|
||||
#define tr_ssl_get_x509_store_ tr_ssl_get_x509_store
|
||||
#define tr_x509_store_add_ tr_x509_store_add
|
||||
#define tr_x509_cert_new_ tr_x509_cert_new
|
||||
#define tr_x509_cert_free_ tr_x509_cert_free
|
||||
#define tr_rand_int_ tr_rand_int
|
||||
#define tr_rand_int_weak_ tr_rand_int_weak
|
||||
#define tr_rand_buffer_ tr_rand_buffer
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "utils.h"
|
||||
|
||||
#define TR_CRYPTO_DH_SECRET_FALLBACK
|
||||
#define TR_CRYPTO_X509_FALLBACK
|
||||
#include "crypto-utils-fallback.c"
|
||||
|
||||
struct tr_dh_ctx
|
||||
|
|
|
@ -60,3 +60,35 @@ void tr_dh_secret_free(tr_dh_secret_t handle)
|
|||
}
|
||||
|
||||
#endif /* TR_CRYPTO_DH_SECRET_FALLBACK */
|
||||
|
||||
#ifdef TR_CRYPTO_X509_FALLBACK
|
||||
|
||||
tr_x509_store_t tr_ssl_get_x509_store(tr_ssl_ctx_t handle)
|
||||
{
|
||||
(void)handle;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool tr_x509_store_add(tr_x509_store_t handle, tr_x509_cert_t cert)
|
||||
{
|
||||
(void)handle;
|
||||
(void)cert;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
tr_x509_cert_t tr_x509_cert_new(void const* der, size_t der_length)
|
||||
{
|
||||
(void)der;
|
||||
(void)der_length;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void tr_x509_cert_free(tr_x509_cert_t handle)
|
||||
{
|
||||
(void)handle;
|
||||
}
|
||||
|
||||
#endif /* TR_CRYPTO_X509_FALLBACK */
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
#include <openssl/dh.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/x509.h>
|
||||
|
||||
#include "transmission.h"
|
||||
#include "crypto-utils.h"
|
||||
|
@ -309,7 +311,7 @@ tr_dh_ctx_t tr_dh_new(uint8_t const* prime_num, size_t prime_num_length, uint8_t
|
|||
p = BN_bin2bn(prime_num, prime_num_length, NULL);
|
||||
g = BN_bin2bn(generator_num, generator_num_length, NULL);
|
||||
|
||||
if (!check_pointer(p) || !check_pointer(g) || !DH_set0_pqg(handle, p, NULL, g))
|
||||
if (!check_pointer(p) || !check_pointer(g) || DH_set0_pqg(handle, p, NULL, g) == 0)
|
||||
{
|
||||
BN_free(p);
|
||||
BN_free(g);
|
||||
|
@ -400,6 +402,52 @@ tr_dh_secret_t tr_dh_agree(tr_dh_ctx_t handle, uint8_t const* other_public_key,
|
|||
****
|
||||
***/
|
||||
|
||||
tr_x509_store_t tr_ssl_get_x509_store(tr_ssl_ctx_t handle)
|
||||
{
|
||||
if (handle == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SSL_CTX_get_cert_store(handle);
|
||||
}
|
||||
|
||||
bool tr_x509_store_add(tr_x509_store_t handle, tr_x509_cert_t cert)
|
||||
{
|
||||
TR_ASSERT(handle != NULL);
|
||||
TR_ASSERT(cert != NULL);
|
||||
|
||||
return check_result(X509_STORE_add_cert(handle, cert));
|
||||
}
|
||||
|
||||
tr_x509_cert_t tr_x509_cert_new(void const* der, size_t der_length)
|
||||
{
|
||||
TR_ASSERT(der != NULL);
|
||||
|
||||
X509* const ret = d2i_X509(NULL, (unsigned char const**)&der, der_length);
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
log_error();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void tr_x509_cert_free(tr_x509_cert_t handle)
|
||||
{
|
||||
if (handle == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
X509_free(handle);
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
bool tr_rand_buffer(void* buffer, size_t length)
|
||||
{
|
||||
TR_ASSERT(buffer != NULL);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "utils.h"
|
||||
|
||||
#define TR_CRYPTO_DH_SECRET_FALLBACK
|
||||
#define TR_CRYPTO_X509_FALLBACK
|
||||
#include "crypto-utils-fallback.c"
|
||||
|
||||
/***
|
||||
|
|
|
@ -33,6 +33,12 @@ typedef void* tr_rc4_ctx_t;
|
|||
typedef void* tr_dh_ctx_t;
|
||||
/** @brief Opaque DH secret key type. */
|
||||
typedef void* tr_dh_secret_t;
|
||||
/** @brief Opaque SSL context type. */
|
||||
typedef void* tr_ssl_ctx_t;
|
||||
/** @brief Opaque X509 certificate store type. */
|
||||
typedef void* tr_x509_store_t;
|
||||
/** @brief Opaque X509 certificate type. */
|
||||
typedef void* tr_x509_cert_t;
|
||||
|
||||
/**
|
||||
* @brief Generate a SHA1 hash from one or more chunks of memory.
|
||||
|
@ -112,6 +118,26 @@ void tr_dh_secret_free(tr_dh_secret_t handle);
|
|||
*/
|
||||
void tr_dh_align_key(uint8_t* key_buffer, size_t key_size, size_t buffer_size);
|
||||
|
||||
/**
|
||||
* @brief Get X509 certificate store from SSL context.
|
||||
*/
|
||||
tr_x509_store_t tr_ssl_get_x509_store(tr_ssl_ctx_t handle);
|
||||
|
||||
/**
|
||||
* @brief Add certificate to X509 certificate store.
|
||||
*/
|
||||
bool tr_x509_store_add(tr_x509_store_t handle, tr_x509_cert_t cert);
|
||||
|
||||
/**
|
||||
* @brief Allocate and initialize new X509 certificate from DER-encoded buffer.
|
||||
*/
|
||||
tr_x509_cert_t tr_x509_cert_new(void const* der_data, size_t der_data_size);
|
||||
|
||||
/**
|
||||
* @brief Free X509 certificate returned by @ref tr_x509_cert_new.
|
||||
*/
|
||||
void tr_x509_cert_free(tr_x509_cert_t handle);
|
||||
|
||||
/**
|
||||
* @brief Returns a random number in the range of [0...upper_bound).
|
||||
*/
|
||||
|
|
|
@ -395,7 +395,7 @@ static void ensureSessionFdInfoExists(tr_session* session)
|
|||
/* set the open-file limit to the largest safe size wrt FD_SETSIZE */
|
||||
struct rlimit limit;
|
||||
|
||||
if (!getrlimit(RLIMIT_NOFILE, &limit))
|
||||
if (getrlimit(RLIMIT_NOFILE, &limit) == 0)
|
||||
{
|
||||
int const old_limit = (int)limit.rlim_cur;
|
||||
int const new_limit = MIN(limit.rlim_max, FD_SETSIZE);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h> /* O_LARGEFILE, posix_fadvise(), [posix_]fallocate() */
|
||||
#include <fcntl.h> /* O_LARGEFILE, posix_fadvise(), [posix_]fallocate(), fcntl() */
|
||||
#include <libgen.h> /* basename(), dirname() */
|
||||
#include <limits.h> /* PATH_MAX */
|
||||
#include <stdio.h>
|
||||
|
@ -487,28 +487,28 @@ tr_sys_file_t tr_sys_file_open(char const* path, int flags, int permissions, tr_
|
|||
{
|
||||
native_flags |= O_RDWR;
|
||||
}
|
||||
else if (flags & TR_SYS_FILE_READ)
|
||||
else if ((flags & TR_SYS_FILE_READ) != 0)
|
||||
{
|
||||
native_flags |= O_RDONLY;
|
||||
}
|
||||
else if (flags & TR_SYS_FILE_WRITE)
|
||||
else if ((flags & TR_SYS_FILE_WRITE) != 0)
|
||||
{
|
||||
native_flags |= O_WRONLY;
|
||||
}
|
||||
|
||||
native_flags |=
|
||||
(flags & TR_SYS_FILE_CREATE ? O_CREAT : 0) |
|
||||
(flags & TR_SYS_FILE_CREATE_NEW ? O_CREAT | O_EXCL : 0) |
|
||||
(flags & TR_SYS_FILE_APPEND ? O_APPEND : 0) |
|
||||
(flags & TR_SYS_FILE_TRUNCATE ? O_TRUNC : 0) |
|
||||
(flags & TR_SYS_FILE_SEQUENTIAL ? O_SEQUENTIAL : 0) |
|
||||
((flags & TR_SYS_FILE_CREATE) != 0 ? O_CREAT : 0) |
|
||||
((flags & TR_SYS_FILE_CREATE_NEW) != 0 ? O_CREAT | O_EXCL : 0) |
|
||||
((flags & TR_SYS_FILE_APPEND) != 0 ? O_APPEND : 0) |
|
||||
((flags & TR_SYS_FILE_TRUNCATE) != 0 ? O_TRUNC : 0) |
|
||||
((flags & TR_SYS_FILE_SEQUENTIAL) != 0 ? O_SEQUENTIAL : 0) |
|
||||
O_BINARY | O_LARGEFILE | O_CLOEXEC;
|
||||
|
||||
ret = open(path, native_flags, permissions);
|
||||
|
||||
if (ret != TR_BAD_SYS_FILE)
|
||||
{
|
||||
if (flags & TR_SYS_FILE_SEQUENTIAL)
|
||||
if ((flags & TR_SYS_FILE_SEQUENTIAL) != 0)
|
||||
{
|
||||
set_file_for_single_pass(ret);
|
||||
}
|
||||
|
@ -985,6 +985,41 @@ bool tr_sys_file_lock(tr_sys_file_t handle, int operation, tr_error** error)
|
|||
!!(operation & TR_SYS_FILE_LOCK_UN) == 1);
|
||||
|
||||
bool ret;
|
||||
|
||||
#if defined(F_OFD_SETLK)
|
||||
|
||||
struct flock fl = { 0 };
|
||||
|
||||
switch (operation & (TR_SYS_FILE_LOCK_SH | TR_SYS_FILE_LOCK_EX | TR_SYS_FILE_LOCK_UN))
|
||||
{
|
||||
case TR_SYS_FILE_LOCK_SH:
|
||||
fl.l_type = F_RDLCK;
|
||||
break;
|
||||
|
||||
case TR_SYS_FILE_LOCK_EX:
|
||||
fl.l_type = F_WRLCK;
|
||||
break;
|
||||
|
||||
case TR_SYS_FILE_LOCK_UN:
|
||||
fl.l_type = F_UNLCK;
|
||||
break;
|
||||
}
|
||||
|
||||
fl.l_whence = SEEK_SET;
|
||||
|
||||
do
|
||||
{
|
||||
ret = fcntl(handle, (operation & TR_SYS_FILE_LOCK_NB) != 0 ? F_OFD_SETLK : F_OFD_SETLKW, &fl) != -1;
|
||||
}
|
||||
while (!ret && errno == EINTR);
|
||||
|
||||
if (!ret && errno == EAGAIN)
|
||||
{
|
||||
errno = EWOULDBLOCK;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_FLOCK)
|
||||
|
||||
int native_operation = 0;
|
||||
|
||||
if ((operation & TR_SYS_FILE_LOCK_SH) != 0)
|
||||
|
@ -1007,7 +1042,21 @@ bool tr_sys_file_lock(tr_sys_file_t handle, int operation, tr_error** error)
|
|||
native_operation |= LOCK_UN;
|
||||
}
|
||||
|
||||
ret = flock(handle, native_operation) != -1;
|
||||
do
|
||||
{
|
||||
ret = flock(handle, native_operation) != -1;
|
||||
}
|
||||
while (!ret && errno == EINTR);
|
||||
|
||||
#else
|
||||
|
||||
(void)handle;
|
||||
(void)operation;
|
||||
|
||||
errno = ENOSYS;
|
||||
ret = false;
|
||||
|
||||
#endif
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
|
|
|
@ -87,11 +87,11 @@ static void stat_to_sys_path_info(DWORD attributes, DWORD size_low, DWORD size_h
|
|||
TR_ASSERT(mtime != NULL);
|
||||
TR_ASSERT(info != NULL);
|
||||
|
||||
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||
{
|
||||
info->type = TR_SYS_PATH_IS_DIRECTORY;
|
||||
}
|
||||
else if (!(attributes & (FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_REPARSE_POINT | FILE_ATTRIBUTE_VIRTUAL)))
|
||||
else if ((attributes & (FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_REPARSE_POINT | FILE_ATTRIBUTE_VIRTUAL)) == 0)
|
||||
{
|
||||
info->type = TR_SYS_PATH_IS_FILE;
|
||||
}
|
||||
|
@ -278,8 +278,7 @@ static bool create_dir(char const* path, int flags, int permissions, bool okay_i
|
|||
{
|
||||
DWORD const attributes = GetFileAttributesW(wide_path);
|
||||
|
||||
if (attributes != INVALID_FILE_ATTRIBUTES &&
|
||||
(attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||
if (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
|
@ -357,7 +356,7 @@ bool tr_sys_path_exists(char const* path, tr_error** error)
|
|||
|
||||
if (attributes != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
if (attributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||
if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0)
|
||||
{
|
||||
handle = CreateFileW(wide_path, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||
ret = handle != INVALID_HANDLE_VALUE;
|
||||
|
@ -595,7 +594,7 @@ cleanup:
|
|||
|
||||
char* tr_sys_path_basename(char const* path, tr_error** error)
|
||||
{
|
||||
if (path == NULL || path[0] == '\0')
|
||||
if (tr_str_is_empty(path))
|
||||
{
|
||||
return tr_strdup(".");
|
||||
}
|
||||
|
@ -635,7 +634,7 @@ char* tr_sys_path_basename(char const* path, tr_error** error)
|
|||
|
||||
char* tr_sys_path_dirname(char const* path, tr_error** error)
|
||||
{
|
||||
if (path == NULL || path[0] == '\0')
|
||||
if (tr_str_is_empty(path))
|
||||
{
|
||||
return tr_strdup(".");
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ static uint32_t getCryptoSelect(tr_handshake const* handshake, uint32_t crypto_p
|
|||
|
||||
for (int i = 0; i < nChoices; ++i)
|
||||
{
|
||||
if (crypto_provide & choices[i])
|
||||
if ((crypto_provide & choices[i]) != 0)
|
||||
{
|
||||
return choices[i];
|
||||
}
|
||||
|
@ -837,7 +837,7 @@ static ReadState readCryptoProvide(tr_handshake* handshake, struct evbuffer* inb
|
|||
obfuscatedTorrentHash[i] = req2[i] ^ req3[i];
|
||||
}
|
||||
|
||||
if ((tor = tr_torrentFindFromObfuscatedHash(handshake->session, obfuscatedTorrentHash)))
|
||||
if ((tor = tr_torrentFindFromObfuscatedHash(handshake->session, obfuscatedTorrentHash)) != NULL)
|
||||
{
|
||||
bool const clientIsSeed = tr_torrentIsSeed(tor);
|
||||
bool const peerIsSeed = tr_peerMgrPeerIsSeed(tor, tr_peerIoGetAddress(handshake->io, NULL));
|
||||
|
|
|
@ -163,7 +163,7 @@ static void* tr_list_remove_node(tr_list** list, tr_list* node)
|
|||
*list = next;
|
||||
}
|
||||
|
||||
data = node ? node->data : NULL;
|
||||
data = node != NULL ? node->data : NULL;
|
||||
node_free(node);
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ static int myQueueLength = 0;
|
|||
#ifndef _WIN32
|
||||
|
||||
/* make null versions of these win32 functions */
|
||||
static inline int IsDebuggerPresent(void)
|
||||
static inline bool IsDebuggerPresent(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ bool tr_logGetDeepEnabled(void)
|
|||
|
||||
if (deepLoggingIsActive < 0)
|
||||
{
|
||||
deepLoggingIsActive = IsDebuggerPresent() || tr_logGetFile() != TR_BAD_SYS_FILE;
|
||||
deepLoggingIsActive = (int8_t)(IsDebuggerPresent() || tr_logGetFile() != TR_BAD_SYS_FILE);
|
||||
}
|
||||
|
||||
return deepLoggingIsActive != 0;
|
||||
|
@ -246,7 +246,7 @@ void tr_logAddMessage(char const* file, int line, tr_log_level level, char const
|
|||
|
||||
#endif
|
||||
|
||||
if (*buf != '\0')
|
||||
if (!tr_str_is_empty(buf))
|
||||
{
|
||||
if (tr_logGetQueueEnabled())
|
||||
{
|
||||
|
|
|
@ -122,7 +122,7 @@ tr_magnet_info* tr_magnetParse(char const* uri)
|
|||
|
||||
if (uri != NULL && strncmp(uri, "magnet:?", 8) == 0)
|
||||
{
|
||||
for (char const* walk = uri + 8; walk != NULL && *walk != '\0';)
|
||||
for (char const* walk = uri + 8; !tr_str_is_empty(walk);)
|
||||
{
|
||||
char const* key = walk;
|
||||
char const* delim = strchr(key, '=');
|
||||
|
|
|
@ -281,7 +281,7 @@ static uint8_t* getHashInfo(tr_metainfo_builder* b)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
while (totalRemain)
|
||||
while (totalRemain != 0)
|
||||
{
|
||||
TR_ASSERT(b->pieceIndex < b->pieceCount);
|
||||
|
||||
|
@ -376,7 +376,7 @@ static void getFileInfo(char const* topFile, tr_metainfo_builder_file const* fil
|
|||
|
||||
while ((token = tr_strsep(&walk, TR_PATH_DELIMITER_STR)) != NULL)
|
||||
{
|
||||
if (*token != '\0')
|
||||
if (!tr_str_is_empty(token))
|
||||
{
|
||||
tr_variantListAddStr(uninitialized_path, token);
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ static void tr_realMakeMetaInfo(tr_metainfo_builder* builder)
|
|||
|
||||
if (builder->result == TR_MAKEMETA_OK && !builder->abortFlag)
|
||||
{
|
||||
if (builder->comment != NULL && *builder->comment != '\0')
|
||||
if (!tr_str_is_empty(builder->comment))
|
||||
{
|
||||
tr_variantDictAddStr(&top, TR_KEY_comment, builder->comment);
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ void tr_makeMetaInfo(tr_metainfo_builder* builder, char const* outputFile, tr_tr
|
|||
builder->comment = tr_strdup(comment);
|
||||
builder->isPrivate = isPrivate;
|
||||
|
||||
if (outputFile != NULL && *outputFile != '\0')
|
||||
if (!tr_str_is_empty(outputFile))
|
||||
{
|
||||
builder->outputFile = tr_strdup(outputFile);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "libtransmission-test.h"
|
||||
|
||||
#include "transmission.h"
|
||||
#include "metainfo.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -66,16 +67,16 @@ static int test_metainfo(void)
|
|||
{ 0, TR_PARSE_OK, BEFORE_PATH "0:5:a.txt" AFTER_PATH },
|
||||
{ 0, TR_PARSE_ERR, BEFORE_PATH "0:0:" AFTER_PATH },
|
||||
|
||||
/* don't allow path components in a filename */
|
||||
{ 0, TR_PARSE_ERR, BEFORE_PATH "7:a/a.txt" AFTER_PATH },
|
||||
/* allow path separators in a filename (replaced with '_') */
|
||||
{ 0, TR_PARSE_OK, BEFORE_PATH "7:a/a.txt" AFTER_PATH },
|
||||
|
||||
/* fail on "." components */
|
||||
{ 0, TR_PARSE_ERR, BEFORE_PATH "1:.5:a.txt" AFTER_PATH },
|
||||
{ 0, TR_PARSE_ERR, BEFORE_PATH "5:a.txt1:." AFTER_PATH },
|
||||
/* allow "." components (skipped) */
|
||||
{ 0, TR_PARSE_OK, BEFORE_PATH "1:.5:a.txt" AFTER_PATH },
|
||||
{ 0, TR_PARSE_OK, BEFORE_PATH "5:a.txt1:." AFTER_PATH },
|
||||
|
||||
/* fail on ".." components */
|
||||
{ 0, TR_PARSE_ERR, BEFORE_PATH "2:..5:a.txt" AFTER_PATH },
|
||||
{ 0, TR_PARSE_ERR, BEFORE_PATH "5:a.txt2:.." AFTER_PATH },
|
||||
/* allow ".." components (replaced with "__") */
|
||||
{ 0, TR_PARSE_OK, BEFORE_PATH "2:..5:a.txt" AFTER_PATH },
|
||||
{ 0, TR_PARSE_OK, BEFORE_PATH "5:a.txt2:.." AFTER_PATH },
|
||||
|
||||
/* fail on empty string */
|
||||
{ EILSEQ, TR_PARSE_ERR, "" }
|
||||
|
@ -101,12 +102,78 @@ static int test_metainfo(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int test_sanitize(void)
|
||||
{
|
||||
struct
|
||||
{
|
||||
char const* str;
|
||||
size_t len;
|
||||
char const* expected_result;
|
||||
bool expected_is_adjusted;
|
||||
}
|
||||
const test_data[] =
|
||||
{
|
||||
/* skipped */
|
||||
{ "", 0, NULL, false },
|
||||
{ ".", 1, NULL, false },
|
||||
{ "..", 2, NULL, true },
|
||||
{ ".....", 5, NULL, false },
|
||||
{ " ", 2, NULL, false },
|
||||
{ " . ", 3, NULL, false },
|
||||
{ ". . .", 5, NULL, false },
|
||||
/* replaced with '_' */
|
||||
{ "/", 1, "_", true },
|
||||
{ "////", 4, "____", true },
|
||||
{ "\\\\", 2, "__", true },
|
||||
{ "/../", 4, "_.._", true },
|
||||
{ "foo<bar:baz/boo", 15, "foo_bar_baz_boo", true },
|
||||
{ "t\0e\x01s\tt\ri\nn\fg", 13, "t_e_s_t_i_n_g", true },
|
||||
/* appended with '_' */
|
||||
{ "con", 3, "con_", true },
|
||||
{ "cOm4", 4, "cOm4_", true },
|
||||
{ "LPt9.txt", 8, "LPt9_.txt", true },
|
||||
{ "NUL.tar.gz", 10, "NUL_.tar.gz", true },
|
||||
/* trimmed */
|
||||
{ " foo", 4, "foo", true },
|
||||
{ "foo ", 4, "foo", true },
|
||||
{ " foo ", 5, "foo", true },
|
||||
{ "foo.", 4, "foo", true },
|
||||
{ "foo...", 6, "foo", true },
|
||||
{ " foo... ", 8, "foo", true },
|
||||
/* unmodified */
|
||||
{ "foo", 3, "foo", false },
|
||||
{ ".foo", 4, ".foo", false },
|
||||
{ "..foo", 5, "..foo", false },
|
||||
{ "foo.bar.baz", 11, "foo.bar.baz", false },
|
||||
{ "null", 4, "null", false },
|
||||
{ "compass", 7, "compass", false }
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < TR_N_ELEMENTS(test_data); ++i)
|
||||
{
|
||||
bool is_adjusted;
|
||||
char* const result = tr_metainfo_sanitize_path_component(test_data[i].str, test_data[i].len, &is_adjusted);
|
||||
|
||||
check_str(result, ==, test_data[i].expected_result);
|
||||
|
||||
if (test_data[i].expected_result != NULL)
|
||||
{
|
||||
check_bool(is_adjusted, ==, test_data[i].expected_is_adjusted);
|
||||
}
|
||||
|
||||
tr_free(result);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
testFunc const tests[] =
|
||||
{
|
||||
test_magnet_link,
|
||||
test_metainfo
|
||||
test_metainfo,
|
||||
test_sanitize
|
||||
};
|
||||
|
||||
return runTests(tests, NUM_TESTS(tests));
|
||||
|
|
|
@ -86,21 +86,90 @@ static char* getTorrentFilename(tr_session const* session, tr_info const* inf, e
|
|||
****
|
||||
***/
|
||||
|
||||
static bool path_component_is_suspicious(char const* component)
|
||||
char* tr_metainfo_sanitize_path_component(char const* str, size_t len, bool* is_adjusted)
|
||||
{
|
||||
return component == NULL || strpbrk(component, PATH_DELIMITER_CHARS) != NULL || strcmp(component, ".") == 0 ||
|
||||
strcmp(component, "..") == 0;
|
||||
if (len == 0 || (len == 1 && str[0] == '.'))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*is_adjusted = false;
|
||||
|
||||
/* https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file */
|
||||
char const* const reserved_chars = "<>:\"/\\|?*";
|
||||
char const* const reserved_names[] =
|
||||
{
|
||||
"CON", "PRN", "AUX", "NUL",
|
||||
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
|
||||
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"
|
||||
};
|
||||
|
||||
char* const ret = tr_new(char, len + 2);
|
||||
memcpy(ret, str, len);
|
||||
ret[len] = '\0';
|
||||
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
{
|
||||
if (strchr(reserved_chars, ret[i]) != NULL || (unsigned char)ret[i] < 0x20)
|
||||
{
|
||||
ret[i] = '_';
|
||||
*is_adjusted = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < TR_N_ELEMENTS(reserved_names); ++i)
|
||||
{
|
||||
size_t const reserved_name_len = strlen(reserved_names[i]);
|
||||
if (evutil_ascii_strncasecmp(ret, reserved_names[i], reserved_name_len) != 0 ||
|
||||
(ret[reserved_name_len] != '\0' && ret[reserved_name_len] != '.'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
memmove(&ret[reserved_name_len + 1], &ret[reserved_name_len], len - reserved_name_len + 1);
|
||||
ret[reserved_name_len] = '_';
|
||||
*is_adjusted = true;
|
||||
++len;
|
||||
break;
|
||||
}
|
||||
|
||||
size_t start_pos = 0;
|
||||
size_t end_pos = len;
|
||||
|
||||
while (start_pos < len && ret[start_pos] == ' ')
|
||||
{
|
||||
++start_pos;
|
||||
}
|
||||
|
||||
while (end_pos > start_pos && (ret[end_pos - 1] == ' ' || ret[end_pos - 1] == '.'))
|
||||
{
|
||||
--end_pos;
|
||||
}
|
||||
|
||||
if (start_pos == end_pos)
|
||||
{
|
||||
tr_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (start_pos != 0 || end_pos != len)
|
||||
{
|
||||
len = end_pos - start_pos;
|
||||
memmove(ret, &ret[start_pos], len);
|
||||
ret[len] = '\0';
|
||||
*is_adjusted = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool getfile(char** setme, char const* root, tr_variant* path, struct evbuffer* buf)
|
||||
static bool getfile(char** setme, bool* is_adjusted, char const* root, tr_variant* path, struct evbuffer* buf)
|
||||
{
|
||||
/* root's already been checked by caller */
|
||||
TR_ASSERT(!path_component_is_suspicious(root));
|
||||
|
||||
bool success = false;
|
||||
size_t root_len = 0;
|
||||
|
||||
*setme = NULL;
|
||||
*is_adjusted = false;
|
||||
|
||||
if (tr_variantIsList(path))
|
||||
{
|
||||
|
@ -114,19 +183,25 @@ static bool getfile(char** setme, char const* root, tr_variant* path, struct evb
|
|||
size_t len;
|
||||
char const* str;
|
||||
|
||||
if (!tr_variantGetStr(tr_variantListChild(path, i), &str, &len) || path_component_is_suspicious(str))
|
||||
if (!tr_variantGetStr(tr_variantListChild(path, i), &str, &len))
|
||||
{
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*str == '\0')
|
||||
bool is_component_adjusted;
|
||||
char* final_str = tr_metainfo_sanitize_path_component(str, len, &is_component_adjusted);
|
||||
if (final_str == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
*is_adjusted = *is_adjusted || is_component_adjusted;
|
||||
|
||||
evbuffer_add(buf, TR_PATH_DELIMITER_STR, 1);
|
||||
evbuffer_add(buf, str, len);
|
||||
evbuffer_add(buf, final_str, strlen(final_str));
|
||||
|
||||
tr_free(final_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,8 +212,15 @@ static bool getfile(char** setme, char const* root, tr_variant* path, struct evb
|
|||
|
||||
if (success)
|
||||
{
|
||||
*setme = tr_utf8clean((char*)evbuffer_pullup(buf, -1), evbuffer_get_length(buf));
|
||||
/* fprintf(stderr, "[%s]\n", *setme); */
|
||||
char const* const buf_data = (char*)evbuffer_pullup(buf, -1);
|
||||
size_t const buf_len = evbuffer_get_length(buf);
|
||||
|
||||
*setme = tr_utf8clean(buf_data, buf_len);
|
||||
|
||||
if (!*is_adjusted)
|
||||
{
|
||||
*is_adjusted = buf_len != strlen(*setme) || strncmp(buf_data, *setme, buf_len) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -150,15 +232,18 @@ static char const* parseFiles(tr_info* inf, tr_variant* files, tr_variant const*
|
|||
|
||||
inf->totalSize = 0;
|
||||
|
||||
bool is_root_adjusted;
|
||||
char* const root_name = tr_metainfo_sanitize_path_component(inf->name, strlen(inf->name), &is_root_adjusted);
|
||||
if (root_name == NULL)
|
||||
{
|
||||
return "path";
|
||||
}
|
||||
|
||||
char const* result = NULL;
|
||||
|
||||
if (tr_variantIsList(files)) /* multi-file mode */
|
||||
{
|
||||
struct evbuffer* buf;
|
||||
char const* result;
|
||||
|
||||
if (path_component_is_suspicious(inf->name))
|
||||
{
|
||||
return "path";
|
||||
}
|
||||
|
||||
buf = evbuffer_new();
|
||||
result = NULL;
|
||||
|
@ -189,7 +274,8 @@ static char const* parseFiles(tr_info* inf, tr_variant* files, tr_variant const*
|
|||
}
|
||||
}
|
||||
|
||||
if (!getfile(&inf->files[i].name, inf->name, path, buf))
|
||||
bool is_file_adjusted;
|
||||
if (!getfile(&inf->files[i].name, &is_file_adjusted, root_name, path, buf))
|
||||
{
|
||||
result = "path";
|
||||
break;
|
||||
|
@ -202,32 +288,29 @@ static char const* parseFiles(tr_info* inf, tr_variant* files, tr_variant const*
|
|||
}
|
||||
|
||||
inf->files[i].length = len;
|
||||
inf->files[i].is_renamed = is_root_adjusted || is_file_adjusted;
|
||||
inf->totalSize += len;
|
||||
}
|
||||
|
||||
evbuffer_free(buf);
|
||||
return result;
|
||||
}
|
||||
else if (tr_variantGetInt(length, &len)) /* single-file mode */
|
||||
{
|
||||
if (path_component_is_suspicious(inf->name))
|
||||
{
|
||||
return "path";
|
||||
}
|
||||
|
||||
inf->isFolder = false;
|
||||
inf->fileCount = 1;
|
||||
inf->files = tr_new0(tr_file, 1);
|
||||
inf->files[0].name = tr_strdup(inf->name);
|
||||
inf->files[0].name = tr_strdup(root_name);
|
||||
inf->files[0].length = len;
|
||||
inf->files[0].is_renamed = is_root_adjusted;
|
||||
inf->totalSize += len;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "length";
|
||||
result = "length";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
tr_free(root_name);
|
||||
return result;
|
||||
}
|
||||
|
||||
static char* tr_convertAnnounceToScrape(char const* announce)
|
||||
|
@ -538,7 +621,7 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
|||
}
|
||||
}
|
||||
|
||||
if (str == NULL || *str == '\0')
|
||||
if (tr_str_is_empty(str))
|
||||
{
|
||||
return "name";
|
||||
}
|
||||
|
|
|
@ -30,3 +30,6 @@ char* tr_metainfoGetBasename(tr_info const*, enum tr_metainfo_basename_format fo
|
|||
|
||||
void tr_metainfoMigrateFile(tr_session const* session, tr_info const* info, enum tr_metainfo_basename_format old_format,
|
||||
enum tr_metainfo_basename_format new_format);
|
||||
|
||||
/** @brief Private function that's exposed here only for unit tests */
|
||||
char* tr_metainfo_sanitize_path_component(char const* str, size_t len, bool* is_adjusted);
|
||||
|
|
|
@ -431,7 +431,7 @@ error:
|
|||
|
||||
static void maybeSetCongestionAlgorithm(tr_socket_t socket, char const* algorithm)
|
||||
{
|
||||
if (algorithm != NULL && *algorithm != '\0')
|
||||
if (!tr_str_is_empty(algorithm))
|
||||
{
|
||||
tr_netSetCongestionControl(socket, algorithm);
|
||||
}
|
||||
|
@ -1109,7 +1109,7 @@ static inline void processBuffer(tr_crypto* crypto, struct evbuffer* buffer, siz
|
|||
TR_ASSERT(size >= iovec.iov_len);
|
||||
size -= iovec.iov_len;
|
||||
}
|
||||
while (!evbuffer_ptr_set(buffer, &pos, iovec.iov_len, EVBUFFER_PTR_ADD));
|
||||
while (evbuffer_ptr_set(buffer, &pos, iovec.iov_len, EVBUFFER_PTR_ADD) == 0);
|
||||
|
||||
TR_ASSERT(size == 0);
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ static inline void swarmUnlock(tr_swarm* swarm)
|
|||
|
||||
#ifdef TR_ENABLE_ASSERTS
|
||||
|
||||
static inline int swarmIsLocked(tr_swarm const* swarm)
|
||||
static inline bool swarmIsLocked(tr_swarm const* swarm)
|
||||
{
|
||||
return tr_sessionIsLocked(swarm->manager->session);
|
||||
}
|
||||
|
@ -410,8 +410,8 @@ static bool peerIsInUse(tr_swarm const* cs, struct peer_atom const* atom)
|
|||
|
||||
TR_ASSERT(swarmIsLocked(s));
|
||||
|
||||
return atom->peer != NULL || getExistingHandshake(&s->outgoingHandshakes, &atom->addr) ||
|
||||
getExistingHandshake(&s->manager->incomingHandshakes, &atom->addr);
|
||||
return atom->peer != NULL || getExistingHandshake(&s->outgoingHandshakes, &atom->addr) != NULL ||
|
||||
getExistingHandshake(&s->manager->incomingHandshakes, &atom->addr) != NULL;
|
||||
}
|
||||
|
||||
static inline bool replicationExists(tr_swarm const* s)
|
||||
|
@ -587,10 +587,10 @@ static bool isAtomBlocklisted(tr_session* session, struct peer_atom* atom)
|
|||
{
|
||||
if (atom->blocklisted < 0)
|
||||
{
|
||||
atom->blocklisted = tr_sessionIsAddressBlocked(session, &atom->addr);
|
||||
atom->blocklisted = (int8_t)tr_sessionIsAddressBlocked(session, &atom->addr);
|
||||
}
|
||||
|
||||
return atom->blocklisted;
|
||||
return atom->blocklisted != 0;
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -3564,7 +3564,7 @@ static void closePeer(tr_swarm* s, tr_peer* peer)
|
|||
/* if we transferred piece data, then they might be good peers,
|
||||
so reset their `numFails' weight to zero. otherwise we connected
|
||||
to them fruitlessly, so mark it as another fail */
|
||||
if (atom->piece_data_time)
|
||||
if (atom->piece_data_time != 0)
|
||||
{
|
||||
tordbg(s, "resetting atom %s numFails to 0", tr_atomAddrStr(atom));
|
||||
atom->numFails = 0;
|
||||
|
|
|
@ -186,7 +186,7 @@ struct tr_peerMsgs
|
|||
|
||||
int prefetchCount;
|
||||
|
||||
int is_active[2];
|
||||
bool is_active[2];
|
||||
|
||||
/* how long the outMessages batch should be allowed to grow before
|
||||
* it's flushed -- some messages (like requests >:) should be sent
|
||||
|
@ -402,7 +402,7 @@ static void protocolSendAllowedFast(tr_peerMsgs* msgs, uint32_t pieceIndex)
|
|||
|
||||
#endif
|
||||
|
||||
static void protocolSendChoke(tr_peerMsgs* msgs, int choke)
|
||||
static void protocolSendChoke(tr_peerMsgs* msgs, bool choke)
|
||||
{
|
||||
struct evbuffer* out = msgs->outMessages;
|
||||
|
||||
|
@ -908,7 +908,7 @@ static void sendLtepHandshake(tr_peerMsgs* msgs)
|
|||
}
|
||||
|
||||
tr_variantInitDict(&val, 8);
|
||||
tr_variantDictAddInt(&val, TR_KEY_e, getSession(msgs)->encryptionMode != TR_CLEAR_PREFERRED);
|
||||
tr_variantDictAddBool(&val, TR_KEY_e, getSession(msgs)->encryptionMode != TR_CLEAR_PREFERRED);
|
||||
|
||||
if (ipv6 != NULL)
|
||||
{
|
||||
|
@ -922,7 +922,7 @@ static void sendLtepHandshake(tr_peerMsgs* msgs)
|
|||
|
||||
tr_variantDictAddInt(&val, TR_KEY_p, tr_sessionGetPublicPeerPort(getSession(msgs)));
|
||||
tr_variantDictAddInt(&val, TR_KEY_reqq, REQQ);
|
||||
tr_variantDictAddInt(&val, TR_KEY_upload_only, tr_torrentIsSeed(msgs->torrent));
|
||||
tr_variantDictAddBool(&val, TR_KEY_upload_only, tr_torrentIsSeed(msgs->torrent));
|
||||
tr_variantDictAddQuark(&val, TR_KEY_v, version_quark);
|
||||
|
||||
if (allow_metadata_xfer || allow_pex)
|
||||
|
@ -1656,7 +1656,7 @@ static int readBtMessage(tr_peerMsgs* msgs, struct evbuffer* inbuf, size_t inlen
|
|||
|
||||
if (msgs->dht_port > 0)
|
||||
{
|
||||
tr_dhtAddNode(getSession(msgs), tr_peerAddress(&msgs->peer), msgs->dht_port, 0);
|
||||
tr_dhtAddNode(getSession(msgs), tr_peerAddress(&msgs->peer), msgs->dht_port, false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1817,7 +1817,7 @@ static int clientGotBlock(tr_peerMsgs* msgs, struct evbuffer* data, struct peer_
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int peerPulse(void* vmsgs);
|
||||
static void peerPulse(void* vmsgs);
|
||||
|
||||
static void didWrite(tr_peerIo* io, size_t bytesWritten, bool wasPieceData, void* vmsgs)
|
||||
{
|
||||
|
@ -1878,7 +1878,7 @@ static ReadState canRead(tr_peerIo* io, void* vmsgs, size_t* piece)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int tr_peerMsgsIsReadingBlock(tr_peerMsgs const* msgs, tr_block_index_t block)
|
||||
bool tr_peerMsgsIsReadingBlock(tr_peerMsgs const* msgs, tr_block_index_t block)
|
||||
{
|
||||
if (msgs->state != AWAITING_BT_PIECE)
|
||||
{
|
||||
|
@ -2105,7 +2105,7 @@ static size_t fillOutputBuffer(tr_peerMsgs* msgs, time_t now)
|
|||
|
||||
if (requestIsValid(msgs, &req) && tr_torrentPieceIsComplete(msgs->torrent, req.index))
|
||||
{
|
||||
int err;
|
||||
bool err;
|
||||
uint32_t const msglen = 4 + 1 + 4 + 4 + req.length;
|
||||
struct evbuffer* out;
|
||||
struct evbuffer_iovec iovec[1];
|
||||
|
@ -2120,21 +2120,23 @@ static size_t fillOutputBuffer(tr_peerMsgs* msgs, time_t now)
|
|||
|
||||
evbuffer_reserve_space(out, req.length, iovec, 1);
|
||||
err = tr_cacheReadBlock(getSession(msgs)->cache, msgs->torrent, req.index, req.offset, req.length,
|
||||
iovec[0].iov_base);
|
||||
iovec[0].iov_base) != 0;
|
||||
iovec[0].iov_len = req.length;
|
||||
evbuffer_commit_space(out, iovec, 1);
|
||||
|
||||
/* check the piece if it needs checking... */
|
||||
if (err == 0 && tr_torrentPieceNeedsCheck(msgs->torrent, req.index))
|
||||
if (!err && tr_torrentPieceNeedsCheck(msgs->torrent, req.index))
|
||||
{
|
||||
if ((err = !tr_torrentCheckPiece(msgs->torrent, req.index)) != 0)
|
||||
err = !tr_torrentCheckPiece(msgs->torrent, req.index);
|
||||
|
||||
if (err)
|
||||
{
|
||||
tr_torrentSetLocalError(msgs->torrent, _("Please Verify Local Data! Piece #%zu is corrupt."),
|
||||
(size_t)req.index);
|
||||
}
|
||||
}
|
||||
|
||||
if (err != 0)
|
||||
if (err)
|
||||
{
|
||||
if (fext)
|
||||
{
|
||||
|
@ -2154,7 +2156,7 @@ static size_t fillOutputBuffer(tr_peerMsgs* msgs, time_t now)
|
|||
|
||||
evbuffer_free(out);
|
||||
|
||||
if (err != 0)
|
||||
if (err)
|
||||
{
|
||||
bytesWritten = 0;
|
||||
msgs = NULL;
|
||||
|
@ -2185,7 +2187,7 @@ static size_t fillOutputBuffer(tr_peerMsgs* msgs, time_t now)
|
|||
return bytesWritten;
|
||||
}
|
||||
|
||||
static int peerPulse(void* vmsgs)
|
||||
static void peerPulse(void* vmsgs)
|
||||
{
|
||||
tr_peerMsgs* msgs = vmsgs;
|
||||
time_t const now = tr_time();
|
||||
|
@ -2204,8 +2206,6 @@ static int peerPulse(void* vmsgs)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true; /* loop forever */
|
||||
}
|
||||
|
||||
void tr_peerMsgsPulse(tr_peerMsgs* msgs)
|
||||
|
@ -2755,7 +2755,7 @@ tr_peerMsgs* tr_peerMsgsNew(struct tr_torrent* torrent, struct tr_peerIo* io, tr
|
|||
/* Only send PORT over IPv6 when the IPv6 DHT is running (BEP-32). */
|
||||
struct tr_address const* addr = tr_peerIoGetAddress(m->io, NULL);
|
||||
|
||||
if (addr->type == TR_AF_INET || tr_globalIPv6())
|
||||
if (addr->type == TR_AF_INET || tr_globalIPv6() != NULL)
|
||||
{
|
||||
protocolSendPort(m, tr_dhtPort(torrent->session));
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ bool tr_peerMsgsIsIncomingConnection(tr_peerMsgs const* msgs);
|
|||
|
||||
void tr_peerMsgsSetChoke(tr_peerMsgs* msgs, bool peerIsChoked);
|
||||
|
||||
int tr_peerMsgsIsReadingBlock(tr_peerMsgs const* msgs, tr_block_index_t block);
|
||||
bool tr_peerMsgsIsReadingBlock(tr_peerMsgs const* msgs, tr_block_index_t block);
|
||||
|
||||
void tr_peerMsgsSetInterested(tr_peerMsgs* msgs, bool clientIsInterested);
|
||||
|
||||
|
|
|
@ -325,12 +325,9 @@ static int64_t getquota(char const* device)
|
|||
int64_t spaceused;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
|
||||
|
||||
if (quotactl(device, QCMD(Q_GETQUOTA, USRQUOTA), getuid(), (caddr_t)&dq) == 0)
|
||||
{
|
||||
|
||||
#elif defined(__sun)
|
||||
|
||||
struct quotctl op;
|
||||
int fd = open(device, O_RDONLY);
|
||||
|
||||
|
@ -346,14 +343,10 @@ static int64_t getquota(char const* device)
|
|||
if (ioctl(fd, Q_QUOTACTL, &op) == 0)
|
||||
{
|
||||
close(fd);
|
||||
|
||||
#else
|
||||
|
||||
if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device, getuid(), (caddr_t)&dq) == 0)
|
||||
{
|
||||
|
||||
#endif
|
||||
|
||||
if (dq.dqb_bsoftlimit > 0)
|
||||
{
|
||||
/* Use soft limit first */
|
||||
|
|
|
@ -328,7 +328,7 @@ char const* tr_getDefaultConfigDir(char const* appname)
|
|||
{
|
||||
static char* s = NULL;
|
||||
|
||||
if (appname == NULL || *appname == '\0')
|
||||
if (tr_str_is_empty(appname))
|
||||
{
|
||||
appname = "Transmission";
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ char const* tr_getDefaultDownloadDir(void)
|
|||
/* figure out where to look for user-dirs.dirs */
|
||||
config_home = tr_env_get_string("XDG_CONFIG_HOME", NULL);
|
||||
|
||||
if (config_home != NULL && *config_home != '\0')
|
||||
if (!tr_str_is_empty(config_home))
|
||||
{
|
||||
config_file = tr_buildPath(config_home, "user-dirs.dirs", NULL);
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ char const* tr_getWebClientDir(tr_session const* session UNUSED)
|
|||
/* XDG_DATA_HOME should be the first in the list of candidates */
|
||||
tmp = tr_env_get_string("XDG_DATA_HOME", NULL);
|
||||
|
||||
if (tmp != NULL && *tmp != '\0')
|
||||
if (!tr_str_is_empty(tmp))
|
||||
{
|
||||
tr_list_append(&candidates, tmp);
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ char const* tr_getWebClientDir(tr_session const* session UNUSED)
|
|||
tr_free(xdg);
|
||||
tmp = buf;
|
||||
|
||||
while (tmp != NULL && *tmp != '\0')
|
||||
while (!tr_str_is_empty(tmp))
|
||||
{
|
||||
char const* end = strchr(tmp, ':');
|
||||
|
||||
|
@ -609,7 +609,7 @@ char const* tr_getWebClientDir(tr_session const* session UNUSED)
|
|||
|
||||
tmp = (char*)end + 1;
|
||||
}
|
||||
else if (tmp != NULL && *tmp != '\0')
|
||||
else if (!tr_str_is_empty(tmp))
|
||||
{
|
||||
tr_list_append(&candidates, tr_strdup(tmp));
|
||||
break;
|
||||
|
|
|
@ -159,7 +159,7 @@ static void saveDND(tr_variant* dict, tr_torrent const* tor)
|
|||
|
||||
for (tr_file_index_t i = 0; i < n; ++i)
|
||||
{
|
||||
tr_variantListAddInt(list, inf->files[i].dnd ? 1 : 0);
|
||||
tr_variantListAddBool(list, inf->files[i].dnd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ static uint64_t loadDND(tr_variant* dict, tr_torrent* tor)
|
|||
|
||||
if (tr_variantDictFindList(dict, TR_KEY_dnd, &list) && tr_variantListSize(list) == n)
|
||||
{
|
||||
int64_t tmp;
|
||||
bool tmp;
|
||||
tr_file_index_t* dl = tr_new(tr_file_index_t, n);
|
||||
tr_file_index_t* dnd = tr_new(tr_file_index_t, n);
|
||||
tr_file_index_t dlCount = 0;
|
||||
|
@ -179,7 +179,7 @@ static uint64_t loadDND(tr_variant* dict, tr_torrent* tor)
|
|||
|
||||
for (tr_file_index_t i = 0; i < n; ++i)
|
||||
{
|
||||
if (tr_variantGetInt(tr_variantListChild(list, i), &tmp) && tmp != 0)
|
||||
if (tr_variantGetBool(tr_variantListChild(list, i), &tmp) && tmp)
|
||||
{
|
||||
dnd[dndCount++] = i;
|
||||
}
|
||||
|
@ -847,7 +847,7 @@ static uint64_t loadFromFile(tr_torrent* tor, uint64_t fieldsToLoad, bool* didRe
|
|||
}
|
||||
|
||||
if ((fieldsToLoad & (TR_FR_PROGRESS | TR_FR_DOWNLOAD_DIR)) != 0 &&
|
||||
tr_variantDictFindStr(&top, TR_KEY_destination, &str, &len) && str != NULL && *str != '\0')
|
||||
tr_variantDictFindStr(&top, TR_KEY_destination, &str, &len) && !tr_str_is_empty(str))
|
||||
{
|
||||
bool const is_current_dir = tor->currentDir == tor->downloadDir;
|
||||
tr_free(tor->downloadDir);
|
||||
|
@ -862,7 +862,7 @@ static uint64_t loadFromFile(tr_torrent* tor, uint64_t fieldsToLoad, bool* didRe
|
|||
}
|
||||
|
||||
if ((fieldsToLoad & (TR_FR_PROGRESS | TR_FR_INCOMPLETE_DIR)) != 0 &&
|
||||
tr_variantDictFindStr(&top, TR_KEY_incomplete_dir, &str, &len) && str != NULL && *str != '\0')
|
||||
tr_variantDictFindStr(&top, TR_KEY_incomplete_dir, &str, &len) && !tr_str_is_empty(str))
|
||||
{
|
||||
bool const is_current_dir = tor->currentDir == tor->incompleteDir;
|
||||
tr_free(tor->incompleteDir);
|
||||
|
@ -1024,7 +1024,7 @@ static uint64_t setFromCtor(tr_torrent* tor, uint64_t fields, tr_ctor const* cto
|
|||
{
|
||||
char const* path;
|
||||
|
||||
if (tr_ctorGetDownloadDir(ctor, mode, &path) && path != NULL && *path != '\0')
|
||||
if (tr_ctorGetDownloadDir(ctor, mode, &path) && !tr_str_is_empty(path))
|
||||
{
|
||||
ret |= TR_FR_DOWNLOAD_DIR;
|
||||
tr_free(tor->downloadDir);
|
||||
|
|
|
@ -430,7 +430,7 @@ static void handle_web_client(struct evhttp_request* req, struct tr_rpc_server*
|
|||
{
|
||||
char const* webClientDir = tr_getWebClientDir(server->session);
|
||||
|
||||
if (webClientDir == NULL || *webClientDir == '\0')
|
||||
if (tr_str_is_empty(webClientDir))
|
||||
{
|
||||
send_simple_response(req, HTTP_NOTFOUND,
|
||||
"<p>Couldn't find Transmission's web interface files!</p>"
|
||||
|
@ -461,7 +461,7 @@ static void handle_web_client(struct evhttp_request* req, struct tr_rpc_server*
|
|||
else
|
||||
{
|
||||
char* filename = tr_strdup_printf("%s%s%s", webClientDir, TR_PATH_DELIMITER_STR,
|
||||
*subpath != '\0' ? subpath : "index.html");
|
||||
tr_str_is_empty(subpath) ? "index.html" : subpath);
|
||||
serve_file(req, server, filename);
|
||||
tr_free(filename);
|
||||
}
|
||||
|
@ -938,7 +938,7 @@ static void tr_rpcSetList(char const* whitelistStr, tr_list** list)
|
|||
}
|
||||
|
||||
/* build the new whitelist entries */
|
||||
for (char const* walk = whitelistStr; walk != NULL && *walk != '\0';)
|
||||
for (char const* walk = whitelistStr; !tr_str_is_empty(walk);)
|
||||
{
|
||||
char const* delimiters = " ,;";
|
||||
size_t const len = strcspn(walk, delimiters);
|
||||
|
|
|
@ -489,7 +489,7 @@ static void addTrackerStats(tr_tracker_stat const* st, int n, tr_variant* list)
|
|||
tr_variantDictAddInt(d, TR_KEY_lastScrapeStartTime, s->lastScrapeStartTime);
|
||||
tr_variantDictAddBool(d, TR_KEY_lastScrapeSucceeded, s->lastScrapeSucceeded);
|
||||
tr_variantDictAddInt(d, TR_KEY_lastScrapeTime, s->lastScrapeTime);
|
||||
tr_variantDictAddInt(d, TR_KEY_lastScrapeTimedOut, s->lastScrapeTimedOut);
|
||||
tr_variantDictAddBool(d, TR_KEY_lastScrapeTimedOut, s->lastScrapeTimedOut);
|
||||
tr_variantDictAddInt(d, TR_KEY_leecherCount, s->leecherCount);
|
||||
tr_variantDictAddInt(d, TR_KEY_nextAnnounceTime, s->nextAnnounceTime);
|
||||
tr_variantDictAddInt(d, TR_KEY_nextScrapeTime, s->nextScrapeTime);
|
||||
|
@ -552,7 +552,7 @@ static void addField(tr_torrent* const tor, tr_info const* const inf, tr_stat co
|
|||
break;
|
||||
|
||||
case TR_KEY_comment:
|
||||
tr_variantDictAddStr(d, key, inf->comment ? inf->comment : "");
|
||||
tr_variantDictAddStr(d, key, inf->comment != NULL ? inf->comment : "");
|
||||
break;
|
||||
|
||||
case TR_KEY_corruptEver:
|
||||
|
@ -560,7 +560,7 @@ static void addField(tr_torrent* const tor, tr_info const* const inf, tr_stat co
|
|||
break;
|
||||
|
||||
case TR_KEY_creator:
|
||||
tr_variantDictAddStr(d, key, inf->creator ? inf->creator : "");
|
||||
tr_variantDictAddStr(d, key, inf->creator != NULL ? inf->creator : "");
|
||||
break;
|
||||
|
||||
case TR_KEY_dateCreated:
|
||||
|
@ -960,7 +960,7 @@ static char const* setLabels(tr_torrent* tor, tr_variant* list)
|
|||
{
|
||||
char* label = tr_strndup(str, str_len);
|
||||
tr_strstrip(label);
|
||||
if (*label == '\0')
|
||||
if (tr_str_is_empty(label))
|
||||
{
|
||||
errmsg = "labels cannot be empty";
|
||||
}
|
||||
|
@ -1082,7 +1082,7 @@ static char const* setFileDLs(tr_torrent* tor, bool do_download, tr_variant* lis
|
|||
}
|
||||
}
|
||||
|
||||
if (fileCount)
|
||||
if (fileCount != 0)
|
||||
{
|
||||
tr_torrentSetFileDLs(tor, files, fileCount, do_download);
|
||||
}
|
||||
|
@ -1641,7 +1641,7 @@ static void gotNewBlocklist(tr_session* session, bool did_connect UNUSED, bool d
|
|||
|
||||
tr_sys_file_close(fd, NULL);
|
||||
|
||||
if (*result != '\0')
|
||||
if (!tr_str_is_empty(result))
|
||||
{
|
||||
tr_logAddError("%s", result);
|
||||
}
|
||||
|
|
|
@ -487,7 +487,7 @@ bool tr_sessionLoadSettings(tr_variant* dict, char const* configDir, char const*
|
|||
tr_variantFree(&oldDict);
|
||||
|
||||
/* if caller didn't specify a config dir, use the default */
|
||||
if (configDir == NULL || *configDir == '\0')
|
||||
if (tr_str_is_empty(configDir))
|
||||
{
|
||||
configDir = tr_getDefaultConfigDir(appName);
|
||||
}
|
||||
|
@ -2021,7 +2021,7 @@ static void sessionCloseImpl(void* vsession)
|
|||
sessionCloseImplStart(session);
|
||||
}
|
||||
|
||||
static int deadlineReached(time_t const deadline)
|
||||
static bool deadlineReached(time_t const deadline)
|
||||
{
|
||||
return time(NULL) >= deadline;
|
||||
}
|
||||
|
@ -2393,7 +2393,7 @@ bool tr_sessionIsPortForwardingEnabled(tr_session const* session)
|
|||
****
|
||||
***/
|
||||
|
||||
static int tr_stringEndsWith(char const* str, char const* end)
|
||||
static bool tr_stringEndsWith(char const* str, char const* end)
|
||||
{
|
||||
size_t const slen = strlen(str);
|
||||
size_t const elen = strlen(end);
|
||||
|
|
|
@ -133,7 +133,7 @@ void tr_statsInit(tr_session* session)
|
|||
|
||||
static struct tr_stats_handle* getStats(tr_session const* session)
|
||||
{
|
||||
return session ? session->sessionStats : NULL;
|
||||
return session != NULL ? session->sessionStats : NULL;
|
||||
}
|
||||
|
||||
void tr_statsSaveDirty(tr_session* session)
|
||||
|
|
|
@ -141,7 +141,7 @@ bool tr_spawn_async(char* const* cmd, char* const* env, char const* work_dir, tr
|
|||
return false;
|
||||
}
|
||||
|
||||
if (fcntl(pipe_fds[1], F_SETFD, fcntl(pipe_fds[1], F_GETFD) | FD_CLOEXEC))
|
||||
if (fcntl(pipe_fds[1], F_SETFD, fcntl(pipe_fds[1], F_GETFD) | FD_CLOEXEC) == -1)
|
||||
{
|
||||
set_system_error(error, errno, "Call to fcntl()");
|
||||
close(pipe_fds[0]);
|
||||
|
|
|
@ -253,7 +253,7 @@ static void append_argument(char** arguments, char const* argument)
|
|||
(*arguments)[arguments_len++] = ' ';
|
||||
}
|
||||
|
||||
if (argument[0] != '\0' && strpbrk(argument, " \t\n\v\"") == NULL)
|
||||
if (!tr_str_is_empty(argument) && strpbrk(argument, " \t\n\v\"") == NULL)
|
||||
{
|
||||
*arguments = tr_renew(char, *arguments, arguments_len + argument_len + 2);
|
||||
strcpy(*arguments + arguments_len, argument);
|
||||
|
|
|
@ -86,7 +86,7 @@ int tr_ctorSetMetainfo(tr_ctor* ctor, uint8_t const* metainfo, size_t len)
|
|||
|
||||
clearMetainfo(ctor);
|
||||
err = tr_variantFromBenc(&ctor->metainfo, metainfo, len);
|
||||
ctor->isSet_metainfo = !err;
|
||||
ctor->isSet_metainfo = err == 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ int tr_ctorSetMetainfoFromFile(tr_ctor* ctor, char const* filename)
|
|||
}
|
||||
}
|
||||
|
||||
if (name == NULL || *name == '\0')
|
||||
if (tr_str_is_empty(name))
|
||||
{
|
||||
char* base = tr_sys_path_basename(filename, NULL);
|
||||
|
||||
|
@ -338,7 +338,7 @@ void tr_ctorSetDownloadDir(tr_ctor* ctor, tr_ctorMode mode, char const* director
|
|||
args->downloadDir = NULL;
|
||||
args->isSet_downloadDir = false;
|
||||
|
||||
if (directory != NULL && *directory != '\0')
|
||||
if (!tr_str_is_empty(directory))
|
||||
{
|
||||
args->isSet_downloadDir = true;
|
||||
args->downloadDir = tr_strdup(directory);
|
||||
|
|
|
@ -305,7 +305,7 @@ void tr_torrentSetMetadataPiece(tr_torrent* tor, int piece, void const* data, in
|
|||
memset(&info, 0, sizeof(tr_info));
|
||||
success = tr_metainfoParse(tor->session, &newMetainfo, &info, &hasInfo, &infoDictLength);
|
||||
|
||||
if (success && !tr_getBlockSize(info.pieceSize))
|
||||
if (success && tr_getBlockSize(info.pieceSize) == 0)
|
||||
{
|
||||
tr_torrentSetLocalError(tor, "%s", _("Magnet torrent's metadata is not usable"));
|
||||
tr_metainfoFree(&info);
|
||||
|
@ -418,7 +418,7 @@ char* tr_torrentInfoGetMagnetLink(tr_info const* inf)
|
|||
|
||||
name = inf->name;
|
||||
|
||||
if (name != NULL && *name != '\0')
|
||||
if (!tr_str_is_empty(name))
|
||||
{
|
||||
evbuffer_add_printf(s, "%s", "&dn=");
|
||||
tr_http_escape(s, name, TR_BAD_SIZE, true);
|
||||
|
|
|
@ -94,7 +94,7 @@ tr_torrent* tr_torrentFindFromHashString(tr_session* session, char const* str)
|
|||
|
||||
while ((tor = tr_torrentNext(session, tor)) != NULL)
|
||||
{
|
||||
if (!evutil_ascii_strcasecmp(str, tor->info.hashString))
|
||||
if (evutil_ascii_strcasecmp(str, tor->info.hashString) == 0)
|
||||
{
|
||||
return tor;
|
||||
}
|
||||
|
@ -235,6 +235,7 @@ unsigned char const* tr_torrentGetPeerId(tr_torrent* tor)
|
|||
|
||||
return tor->peer_id;
|
||||
}
|
||||
|
||||
/***
|
||||
**** PER-TORRENT UL / DL SPEEDS
|
||||
***/
|
||||
|
@ -1099,7 +1100,7 @@ static tr_parse_result torrentParseImpl(tr_ctor const* ctor, tr_info* setmeInfo,
|
|||
result = TR_PARSE_ERR;
|
||||
}
|
||||
|
||||
if (didParse && hasInfo && !tr_getBlockSize(setmeInfo->pieceSize))
|
||||
if (didParse && hasInfo && tr_getBlockSize(setmeInfo->pieceSize) == 0)
|
||||
{
|
||||
result = TR_PARSE_ERR;
|
||||
}
|
||||
|
@ -1417,7 +1418,7 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
s->haveUnchecked = tr_torrentHaveTotal(tor) - s->haveValid;
|
||||
s->desiredAvailable = tr_peerMgrGetDesiredAvailable(tor);
|
||||
|
||||
s->ratio = tr_getRatio(s->uploadedEver, s->downloadedEver ? s->downloadedEver : s->haveValid);
|
||||
s->ratio = tr_getRatio(s->uploadedEver, s->downloadedEver != 0 ? s->downloadedEver : s->haveValid);
|
||||
|
||||
seedRatioApplies = tr_torrentGetSeedRatioBytes(tor, &seedRatioBytesLeft, &seedRatioBytesGoal);
|
||||
|
||||
|
@ -2233,7 +2234,7 @@ static void get_local_time_str(char* const buffer, size_t const buffer_len)
|
|||
|
||||
static void torrentCallScript(tr_torrent const* tor, char const* script)
|
||||
{
|
||||
if (script == NULL || *script == '\0')
|
||||
if (tr_str_is_empty(script))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2421,13 +2422,13 @@ tr_priority_t* tr_torrentGetFilePriorities(tr_torrent const* tor)
|
|||
*** File DND
|
||||
**/
|
||||
|
||||
static void setFileDND(tr_torrent* tor, tr_file_index_t fileIndex, int doDownload)
|
||||
static void setFileDND(tr_torrent* tor, tr_file_index_t fileIndex, bool doDownload)
|
||||
{
|
||||
int8_t const dnd = !doDownload;
|
||||
bool const dnd = !doDownload;
|
||||
tr_piece_index_t firstPiece;
|
||||
int8_t firstPieceDND;
|
||||
bool firstPieceDND;
|
||||
tr_piece_index_t lastPiece;
|
||||
int8_t lastPieceDND;
|
||||
bool lastPieceDND;
|
||||
tr_file* file = &tor->info.files[fileIndex];
|
||||
|
||||
file->dnd = dnd;
|
||||
|
@ -2488,7 +2489,6 @@ static void setFileDND(tr_torrent* tor, tr_file_index_t fileIndex, int doDownloa
|
|||
|
||||
void tr_torrentInitFileDLs(tr_torrent* tor, tr_file_index_t const* files, tr_file_index_t fileCount, bool doDownload)
|
||||
{
|
||||
|
||||
TR_ASSERT(tr_isTorrent(tor));
|
||||
|
||||
tr_torrentLock(tor);
|
||||
|
@ -3794,8 +3794,8 @@ void tr_torrentSetQueueStartCallback(tr_torrent* torrent, void (* callback)(tr_t
|
|||
|
||||
static bool renameArgsAreValid(char const* oldpath, char const* newname)
|
||||
{
|
||||
return oldpath != NULL && *oldpath != '\0' && newname != NULL && *newname != '\0' && strcmp(newname, ".") != 0 &&
|
||||
strcmp(newname, "..") != 0 && strchr(newname, TR_PATH_DELIMITER) == NULL;
|
||||
return !tr_str_is_empty(oldpath) && !tr_str_is_empty(newname) && strcmp(newname, ".") != 0 && strcmp(newname, "..") != 0 &&
|
||||
strchr(newname, TR_PATH_DELIMITER) == NULL;
|
||||
}
|
||||
|
||||
static tr_file_index_t* renameFindAffectedFiles(tr_torrent* tor, char const* oldpath, size_t* setme_n)
|
||||
|
|
|
@ -681,12 +681,12 @@ static void callback(void* ignore UNUSED, int event, unsigned char const* info_h
|
|||
if (event == DHT_EVENT_SEARCH_DONE)
|
||||
{
|
||||
tr_logAddTorInfo(tor, "%s", "IPv4 DHT announce done");
|
||||
tor->dhtAnnounceInProgress = 0;
|
||||
tor->dhtAnnounceInProgress = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_logAddTorInfo(tor, "%s", "IPv6 DHT announce done");
|
||||
tor->dhtAnnounce6InProgress = 0;
|
||||
tor->dhtAnnounce6InProgress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -761,14 +761,14 @@ void tr_dhtUpkeep(tr_session* session)
|
|||
|
||||
if (tor->dhtAnnounceAt <= now)
|
||||
{
|
||||
int const rc = tr_dhtAnnounce(tor, AF_INET, 1);
|
||||
int const rc = tr_dhtAnnounce(tor, AF_INET, true);
|
||||
|
||||
tor->dhtAnnounceAt = now + ((rc == 0) ? 5 + tr_rand_int_weak(5) : 25 * 60 + tr_rand_int_weak(3 * 60));
|
||||
}
|
||||
|
||||
if (tor->dhtAnnounce6At <= now)
|
||||
{
|
||||
int const rc = tr_dhtAnnounce(tor, AF_INET6, 1);
|
||||
int const rc = tr_dhtAnnounce(tor, AF_INET6, true);
|
||||
|
||||
tor->dhtAnnounce6At = now + ((rc == 0) ? 5 + tr_rand_int_weak(5) : 25 * 60 + tr_rand_int_weak(3 * 60));
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
|
||||
static struct tr_option const options[] =
|
||||
{
|
||||
{ 'p', "private", "Allow this torrent to only be used with the specified tracker(s)", "p", 0, NULL },
|
||||
{ 'o', "outfile", "Save the generated .torrent to this filename", "o", 1, "<file>" },
|
||||
{ 's', "piecesize", "Set how many KiB each piece should be, overriding the preferred default", "s", 1, "<size in KiB>" },
|
||||
{ 'c', "comment", "Add a comment", "c", 1, "<comment>" },
|
||||
{ 't', "tracker", "Add a tracker's announce URL", "t", 1, "<url>" },
|
||||
{ 'q', "pooka", "Pooka", "pk", 0, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||
{ 'p', "private", "Allow this torrent to only be used with the specified tracker(s)", "p", false, NULL },
|
||||
{ 'o', "outfile", "Save the generated .torrent to this filename", "o", true, "<file>" },
|
||||
{ 's', "piecesize", "Set how many KiB each piece should be, overriding the preferred default", "s", true, "<size in KiB>" },
|
||||
{ 'c', "comment", "Add a comment", "c", true, "<comment>" },
|
||||
{ 't', "tracker", "Add a tracker's announce URL", "t", true, "<url>" },
|
||||
{ 'q', "pooka", "Pooka", "pk", false, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", false, NULL },
|
||||
{ 0, NULL, NULL, NULL, false, NULL }
|
||||
};
|
||||
|
||||
static int run_test(int argc, char const** argv, int expected_n, int* expected_c, char const** expected_optarg)
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
#include <stdlib.h> /* exit() */
|
||||
#include <string.h>
|
||||
|
||||
#include "transmission.h"
|
||||
#include "tr-getopt.h"
|
||||
#include "tr-macros.h"
|
||||
#include "utils.h"
|
||||
|
||||
int tr_optind = 1;
|
||||
|
||||
|
@ -67,8 +69,8 @@ static void getopts_usage_line(tr_option const* opt, int longWidth, int shortWid
|
|||
int const d_width = 80 - d_indent;
|
||||
char const* d = opt->description;
|
||||
|
||||
printf(" %s%-*s %s%-*s %-*s ", (shortName != NULL && *shortName != '\0') ? "-" : " ", shortWidth, shortName,
|
||||
(longName != NULL && *longName != '\0') ? "--" : " ", longWidth, longName, argWidth, arg);
|
||||
printf(" %s%-*s %s%-*s %-*s ", tr_str_is_empty(shortName) ? " " : "-", shortWidth, shortName,
|
||||
tr_str_is_empty(longName) ? " " : "--", longWidth, longName, argWidth, arg);
|
||||
len = get_next_line_len(d, d_width);
|
||||
printf("%*.*s\n", len, len, d);
|
||||
|
||||
|
@ -127,7 +129,7 @@ void tr_getopt_usage(char const* progName, char const* description, struct tr_op
|
|||
help.longName = "help";
|
||||
help.description = "Display this help page and exit";
|
||||
help.shortName = "h";
|
||||
help.has_arg = 0;
|
||||
help.has_arg = false;
|
||||
maxWidth(&help, &longWidth, &shortWidth, &argWidth);
|
||||
|
||||
if (description == NULL)
|
||||
|
|
|
@ -27,7 +27,7 @@ typedef struct tr_option
|
|||
char const* longName; /* --long-form */
|
||||
char const* description; /* option's description for tr_getopt_usage() */
|
||||
char const* shortName; /* short form */
|
||||
int has_arg; /* 0 for no argument, 1 for argument */
|
||||
bool has_arg; /* 0 for no argument, 1 for argument */
|
||||
char const* argName; /* argument's description for tr_getopt_usage() */
|
||||
}
|
||||
tr_option;
|
||||
|
|
|
@ -466,6 +466,7 @@ UNUSED static inline void lpd_consistencyCheck(void)
|
|||
* as interfaces to the rest of the lib remain compatible with char* strings. */
|
||||
TR_STATIC_ASSERT(sizeof(lpd_torStaticType->info.hashString[0]) == sizeof(char), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @endcond */
|
||||
|
||||
|
|
|
@ -1574,8 +1574,8 @@ typedef struct tr_file
|
|||
uint64_t length; /* Length of the file, in bytes */
|
||||
char* name; /* Path to the file */
|
||||
int8_t priority; /* TR_PRI_HIGH, _NORMAL, or _LOW */
|
||||
int8_t dnd; /* "do not download" flag */
|
||||
int8_t is_renamed; /* true if we're using a different path from the one in the metainfo; ie, if the user has renamed it */
|
||||
bool dnd; /* "do not download" flag */
|
||||
bool is_renamed; /* true if we're using a different path from the one in the metainfo; ie, if the user has renamed it */
|
||||
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 */
|
||||
|
@ -1588,7 +1588,7 @@ typedef 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 */
|
||||
int8_t dnd; /* "do not download" flag */
|
||||
bool dnd; /* "do not download" flag */
|
||||
}
|
||||
tr_piece;
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ int tr_upnpPulse(tr_upnp* handle, int port, bool isEnabled, bool doPortCheck)
|
|||
|
||||
if (handle->urls.controlURL == NULL)
|
||||
{
|
||||
handle->isMapped = 0;
|
||||
handle->isMapped = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -192,7 +192,7 @@ char const* tr_strip_positional_args(char const* str)
|
|||
|
||||
out = buf;
|
||||
|
||||
for (; str != NULL && *str != '\0'; ++str)
|
||||
for (; !tr_str_is_empty(str); ++str)
|
||||
{
|
||||
*out++ = *str;
|
||||
|
||||
|
@ -363,7 +363,7 @@ int64_t tr_getDirFreeSpace(char const* dir)
|
|||
{
|
||||
int64_t free_space;
|
||||
|
||||
if (dir == NULL || *dir == '\0')
|
||||
if (tr_str_is_empty(dir))
|
||||
{
|
||||
errno = EINVAL;
|
||||
free_space = -1;
|
||||
|
@ -636,7 +636,7 @@ bool tr_str_has_suffix(char const* str, char const* suffix)
|
|||
return false;
|
||||
}
|
||||
|
||||
return !evutil_ascii_strncasecmp(str + str_len - suffix_len, suffix, suffix_len);
|
||||
return evutil_ascii_strncasecmp(str + str_len - suffix_len, suffix, suffix_len) == 0;
|
||||
}
|
||||
|
||||
/****
|
||||
|
@ -1526,7 +1526,7 @@ int* tr_parseNumberRange(char const* str_in, size_t len, int* setmeCount)
|
|||
|
||||
walk = str;
|
||||
|
||||
while (walk != NULL && *walk != '\0' && success)
|
||||
while (!tr_str_is_empty(walk) && success)
|
||||
{
|
||||
struct number_range range;
|
||||
char const* pch = strchr(walk, ',');
|
||||
|
@ -2110,7 +2110,7 @@ int tr_env_get_int(char const* key, int default_value)
|
|||
|
||||
char const* value = getenv(key);
|
||||
|
||||
if (value != NULL && *value != '\0')
|
||||
if (!tr_str_is_empty(value))
|
||||
{
|
||||
return atoi(value);
|
||||
}
|
||||
|
|
|
@ -202,6 +202,11 @@ char* tr_strdup(void const* in);
|
|||
*/
|
||||
int tr_strcmp0(char const* str1, char const* str2);
|
||||
|
||||
static inline bool tr_str_is_empty(char const* value)
|
||||
{
|
||||
return value == NULL || *value == '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief like memcmp() but gracefully handles NULL pointers
|
||||
*/
|
||||
|
@ -243,6 +248,9 @@ bool tr_str_has_suffix(char const* str, char const* suffix);
|
|||
/** @brief Portability wrapper for memmem() that uses the system implementation if available */
|
||||
char const* tr_memmem(char const* haystack, size_t haystack_len, char const* needle, size_t needle_len);
|
||||
|
||||
/** @brief Portability wrapper for strcasestr() that uses the system implementation if available */
|
||||
char const* tr_strcasestr(char const* haystack, char const* needle);
|
||||
|
||||
/** @brief Portability wrapper for strsep() that uses the system implementation if available */
|
||||
char* tr_strsep(char** str, char const* delim);
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ static void stripWhitespace(char* in)
|
|||
{
|
||||
char* out = in;
|
||||
|
||||
for (; in != NULL && *in != '\0'; ++in)
|
||||
for (; !tr_str_is_empty(in); ++in)
|
||||
{
|
||||
if (!isspace(*in))
|
||||
{
|
||||
|
|
|
@ -976,7 +976,7 @@ static void tr_variantListCopy(tr_variant* target, tr_variant const* src)
|
|||
{
|
||||
if (tr_variantIsBool(val))
|
||||
{
|
||||
bool boolVal = 0;
|
||||
bool boolVal = false;
|
||||
tr_variantGetBool(val, &boolVal);
|
||||
tr_variantListAddBool(target, boolVal);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <string.h> /* strlen(), strstr() */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <sys/select.h>
|
||||
|
@ -19,6 +21,7 @@
|
|||
#include <event2/buffer.h>
|
||||
|
||||
#include "transmission.h"
|
||||
#include "crypto-utils.h"
|
||||
#include "file.h"
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
|
@ -149,6 +152,67 @@ static int sockoptfunction(void* vtask, curl_socket_t fd, curlsocktype purpose U
|
|||
|
||||
#endif
|
||||
|
||||
static CURLcode ssl_context_func(CURL* curl, void* ssl_ctx, void* user_data)
|
||||
{
|
||||
(void)curl;
|
||||
(void)user_data;
|
||||
|
||||
tr_x509_store_t const cert_store = tr_ssl_get_x509_store(ssl_ctx);
|
||||
if (cert_store == NULL)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
curl_version_info_data const* const curl_ver = curl_version_info(CURLVERSION_NOW);
|
||||
if (curl_ver->age >= 0 && strncmp(curl_ver->ssl_version, "Schannel", 8) == 0)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static LPCWSTR const sys_store_names[] =
|
||||
{
|
||||
L"CA",
|
||||
L"ROOT"
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < TR_N_ELEMENTS(sys_store_names); ++i)
|
||||
{
|
||||
HCERTSTORE const sys_cert_store = CertOpenSystemStoreW(0, sys_store_names[i]);
|
||||
if (sys_cert_store == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PCCERT_CONTEXT sys_cert = NULL;
|
||||
|
||||
while (true)
|
||||
{
|
||||
sys_cert = CertFindCertificateInStore(sys_cert_store, X509_ASN_ENCODING, 0, CERT_FIND_ANY, NULL, sys_cert);
|
||||
if (sys_cert == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
tr_x509_cert_t const cert = tr_x509_cert_new(sys_cert->pbCertEncoded, sys_cert->cbCertEncoded);
|
||||
if (cert == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
tr_x509_store_add(cert_store, cert);
|
||||
tr_x509_cert_free(cert);
|
||||
}
|
||||
|
||||
CertCloseStore(sys_cert_store, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static long getTimeoutFromURL(struct tr_web_task const* task)
|
||||
{
|
||||
long timeout;
|
||||
|
@ -201,6 +265,10 @@ static CURL* createEasy(tr_session* s, struct tr_web* web, struct tr_web_task* t
|
|||
{
|
||||
curl_easy_setopt(e, CURLOPT_CAINFO, web->curl_ca_bundle);
|
||||
}
|
||||
else
|
||||
{
|
||||
curl_easy_setopt(e, CURLOPT_SSL_CTX_FUNCTION, ssl_context_func);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -367,7 +367,7 @@ static void web_response_func(tr_session* session, bool did_connect UNUSED, bool
|
|||
tr_webseed* w;
|
||||
tr_torrent* tor;
|
||||
struct tr_webseed_task* t = vtask;
|
||||
int const success = (response_code == 206);
|
||||
bool const success = response_code == 206;
|
||||
|
||||
if (t->dead)
|
||||
{
|
||||
|
@ -486,7 +486,7 @@ static void task_request_next_chunk(struct tr_webseed_task* t)
|
|||
file = &inf->files[file_index];
|
||||
this_pass = MIN(remain, file->length - file_offset);
|
||||
|
||||
if (!urls[file_index])
|
||||
if (urls[file_index] == NULL)
|
||||
{
|
||||
urls[file_index] = evbuffer_free_to_str(make_url(t->webseed, file), NULL);
|
||||
}
|
||||
|
|
|
@ -46,14 +46,14 @@ QLatin1String const MY_READABLE_NAME("transmission-qt");
|
|||
|
||||
tr_option const opts[] =
|
||||
{
|
||||
{ 'g', "config-dir", "Where to look for configuration files", "g", 1, "<path>" },
|
||||
{ 'm', "minimized", "Start minimized in system tray", "m", 0, nullptr },
|
||||
{ 'p', "port", "Port to use when connecting to an existing session", "p", 1, "<port>" },
|
||||
{ 'r', "remote", "Connect to an existing session at the specified hostname", "r", 1, "<host>" },
|
||||
{ 'u', "username", "Username to use when connecting to an existing session", "u", 1, "<username>" },
|
||||
{ 'v', "version", "Show version number and exit", "v", 0, nullptr },
|
||||
{ 'w', "password", "Password to use when connecting to an existing session", "w", 1, "<password>" },
|
||||
{ 0, nullptr, nullptr, nullptr, 0, nullptr }
|
||||
{ 'g', "config-dir", "Where to look for configuration files", "g", true, "<path>" },
|
||||
{ 'm', "minimized", "Start minimized in system tray", "m", false, nullptr },
|
||||
{ 'p', "port", "Port to use when connecting to an existing session", "p", true, "<port>" },
|
||||
{ 'r', "remote", "Connect to an existing session at the specified hostname", "r", true, "<host>" },
|
||||
{ 'u', "username", "Username to use when connecting to an existing session", "u", true, "<username>" },
|
||||
{ 'v', "version", "Show version number and exit", "v", false, nullptr },
|
||||
{ 'w', "password", "Password to use when connecting to an existing session", "w", true, "<password>" },
|
||||
{ 0, nullptr, nullptr, nullptr, false, nullptr }
|
||||
};
|
||||
|
||||
char const* getUsage()
|
||||
|
|
|
@ -1237,11 +1237,13 @@ void DetailsDialog::onHonorsSessionLimitsToggled(bool val)
|
|||
mySession.torrentSet(myIds, TR_KEY_honorsSessionLimits, val);
|
||||
getNewData();
|
||||
}
|
||||
|
||||
void DetailsDialog::onDownloadLimitedToggled(bool val)
|
||||
{
|
||||
mySession.torrentSet(myIds, TR_KEY_downloadLimited, val);
|
||||
getNewData();
|
||||
}
|
||||
|
||||
void DetailsDialog::onSpinBoxEditingFinished()
|
||||
{
|
||||
QObject const* spin = sender();
|
||||
|
|
|
@ -416,6 +416,7 @@ void FilterBar::recountSoon()
|
|||
myRecountTimer->start(800);
|
||||
}
|
||||
}
|
||||
|
||||
void FilterBar::recount()
|
||||
{
|
||||
QAbstractItemModel* model = myActivityCombo->model();
|
||||
|
|
|
@ -1360,7 +1360,7 @@ void MainWindow::removeTorrents(bool const deleteFiles)
|
|||
tr("Delete these %Ln torrent(s)' downloaded files?", nullptr, count);
|
||||
}
|
||||
|
||||
if (!incomplete && !connected)
|
||||
if (incomplete == 0 && connected == 0)
|
||||
{
|
||||
secondary_text = count == 1 ?
|
||||
tr("Once removed, continuing the transfer will require the torrent file or magnet link.") :
|
||||
|
|
|
@ -296,6 +296,7 @@ qulonglong Torrent::getSize(int i) const
|
|||
|
||||
return myValues[i].toULongLong();
|
||||
}
|
||||
|
||||
double Torrent::getDouble(int i) const
|
||||
{
|
||||
assert(0 <= i && i < PROPERTY_COUNT);
|
||||
|
@ -303,6 +304,7 @@ double Torrent::getDouble(int i) const
|
|||
|
||||
return myValues[i].toDouble();
|
||||
}
|
||||
|
||||
QString Torrent::getString(int i) const
|
||||
{
|
||||
assert(0 <= i && i < PROPERTY_COUNT);
|
||||
|
@ -310,6 +312,7 @@ QString Torrent::getString(int i) const
|
|||
|
||||
return myValues[i].toString();
|
||||
}
|
||||
|
||||
QIcon Torrent::getIcon(int i) const
|
||||
{
|
||||
assert(0 <= i && i < PROPERTY_COUNT);
|
||||
|
|
|
@ -45,6 +45,7 @@ namespace
|
|||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void addAssociatedFileIcon(QFileInfo const& fileInfo, UINT iconSize, QIcon& icon)
|
||||
{
|
||||
QString const pixmapCacheKey = QLatin1String("tr_file_ext_") + QString::number(iconSize) + QLatin1Char('_') +
|
||||
|
@ -76,6 +77,7 @@ void addAssociatedFileIcon(QFileInfo const& fileInfo, UINT iconSize, QIcon& icon
|
|||
icon.addPixmap(pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool isSlashChar(QChar const& c)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
@ -21,7 +21,6 @@
|
|||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id: curlbuild.h.in,v 1.8 2009-04-29 15:15:38 yangtse Exp $
|
||||
***************************************************************************/
|
||||
|
||||
/* ================================================================ */
|
||||
|
@ -60,52 +59,52 @@
|
|||
/* ================================================================ */
|
||||
|
||||
#ifdef CURL_SIZEOF_LONG
|
||||
# error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h"
|
||||
#error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
# error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
|
||||
#error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_SIZEOF_CURL_SOCKLEN_T
|
||||
# error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
|
||||
#error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||
# error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
#error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_FORMAT_CURL_OFF_T
|
||||
# error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
#error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_FORMAT_CURL_OFF_TU
|
||||
# error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h"
|
||||
#error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_FORMAT_OFF_T
|
||||
# error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h"
|
||||
#error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_SIZEOF_CURL_OFF_T
|
||||
# error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
#error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_SUFFIX_CURL_OFF_T
|
||||
# error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
#error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CURL_SUFFIX_CURL_OFF_TU
|
||||
# error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h"
|
||||
#error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h"
|
||||
Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined
|
||||
#endif
|
||||
|
||||
|
@ -153,12 +152,19 @@
|
|||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file sys/poll.h must be included by the external interface. */
|
||||
/* #undef CURL_PULL_SYS_POLL_H */
|
||||
#ifdef CURL_PULL_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#ifdef __LP64__
|
||||
#define CURL_SIZEOF_LONG 8
|
||||
#else /* !__LP64__ */
|
||||
#else
|
||||
#define CURL_SIZEOF_LONG 4
|
||||
#endif /* __LP64__ */
|
||||
#endif
|
||||
|
||||
/* Integral data type used for curl_socklen_t. */
|
||||
#define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
@ -20,7 +20,6 @@
|
|||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id: curlrules.h,v 1.7 2009-10-27 16:56:20 yangtse Exp $
|
||||
***************************************************************************/
|
||||
|
||||
/* ================================================================ */
|
||||
|
@ -187,11 +186,11 @@ typedef char
|
|||
/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
/*
|
||||
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
||||
* these to be visible and exported by the external libcurl interface API,
|
||||
* while also making them visible to the library internals, simply including
|
||||
* setup.h, without actually needing to include curl.h internally.
|
||||
* curl_setup.h, without actually needing to include curl.h internally.
|
||||
* If some day this section would grow big enough, all this should be moved
|
||||
* to its own header file.
|
||||
*/
|
||||
|
@ -217,14 +216,23 @@ typedef char
|
|||
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
||||
*/
|
||||
|
||||
#ifdef CURL_ISOCPP
|
||||
# define __CURL_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
||||
# define __CURL_OFF_T_C_HLPR2(x) x
|
||||
# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
|
||||
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
|
||||
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
|
||||
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
||||
#else
|
||||
# define __CURL_OFF_T_C_HELPER2(Val,Suffix) Val/**/Suffix
|
||||
# ifdef CURL_ISOCPP
|
||||
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
||||
# else
|
||||
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
||||
# endif
|
||||
# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
|
||||
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||
#endif
|
||||
#define __CURL_OFF_T_C_HELPER1(Val,Suffix) __CURL_OFF_T_C_HELPER2(Val,Suffix)
|
||||
#define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HELPER1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||
#define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HELPER1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||
|
||||
/*
|
||||
* Get rid of macros private to this header file.
|
||||
|
@ -240,10 +248,15 @@ typedef char
|
|||
#undef CURL_PULL_WS2TCPIP_H
|
||||
#undef CURL_PULL_SYS_TYPES_H
|
||||
#undef CURL_PULL_SYS_SOCKET_H
|
||||
#undef CURL_PULL_SYS_POLL_H
|
||||
#undef CURL_PULL_STDINT_H
|
||||
#undef CURL_PULL_INTTYPES_H
|
||||
|
||||
#undef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
#undef CURL_TYPEOF_CURL_OFF_T
|
||||
|
||||
#ifdef CURL_NO_OLDIES
|
||||
#undef CURL_FORMAT_OFF_T /* not required since 7.19.0 - obsoleted in 7.20.0 */
|
||||
#endif
|
||||
|
||||
#endif /* __CURL_CURLRULES_H */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
@ -20,24 +20,23 @@
|
|||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id: curlver.h,v 1.48 2009-08-12 11:24:52 bagder Exp $
|
||||
***************************************************************************/
|
||||
|
||||
/* This header file contains nothing but libcurl version info, generated by
|
||||
a script at release-time. This was made its own header file in 7.11.2 */
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2009 Daniel Stenberg, <daniel@haxx.se>."
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2014 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.19.7"
|
||||
#define LIBCURL_VERSION "7.37.1"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 19
|
||||
#define LIBCURL_VERSION_PATCH 7
|
||||
#define LIBCURL_VERSION_MINOR 37
|
||||
#define LIBCURL_VERSION_PATCH 1
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
||||
|
@ -54,17 +53,17 @@
|
|||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x071307
|
||||
#define LIBCURL_VERSION_NUM 0x072501
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
* timestamp is not stored in CVS, as the timestamp is properly set in the
|
||||
* timestamp is not stored in git, as the timestamp is properly set in the
|
||||
* tarballs by the maketgz script.
|
||||
*
|
||||
* The format of the date should follow this template:
|
||||
*
|
||||
* "Mon Feb 12 11:35:33 UTC 2007"
|
||||
*/
|
||||
#define LIBCURL_TIMESTAMP "Wed Nov 4 12:34:59 UTC 2009"
|
||||
#define LIBCURL_TIMESTAMP "Wed Jul 16 14:37:07 UTC 2014"
|
||||
|
||||
#endif /* __CURL_CURLVER_H */
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id: easy.h,v 1.14 2008-05-12 21:43:28 bagder Exp $
|
||||
***************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -54,8 +53,8 @@ CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
|||
*
|
||||
* Creates a new curl session handle with the same options set for the handle
|
||||
* passed in. Duplicating a handle could only be a matter of cloning data and
|
||||
* options, internal state info and things like persistant connections cannot
|
||||
* be transfered. It is useful in multithreaded applications when you can run
|
||||
* options, internal state info and things like persistent connections cannot
|
||||
* be transferred. It is useful in multithreaded applications when you can run
|
||||
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||
* curl_easy_setopt() invokes in every thread.
|
||||
*/
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
@ -20,7 +20,6 @@
|
|||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id: mprintf.h,v 1.16 2008-05-20 10:21:50 patrickm Exp $
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
@ -59,7 +58,7 @@ CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
|||
# define printf curl_mprintf
|
||||
# define fprintf curl_mfprintf
|
||||
#ifdef CURLDEBUG
|
||||
/* When built with CURLDEBUG we define away the sprintf() functions since we
|
||||
/* When built with CURLDEBUG we define away the sprintf functions since we
|
||||
don't want internal code to be using them */
|
||||
# define sprintf sprintf_was_used
|
||||
# define vsprintf vsprintf_was_used
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
@ -20,7 +20,6 @@
|
|||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id: multi.h,v 1.45 2008-05-20 10:21:50 patrickm Exp $
|
||||
***************************************************************************/
|
||||
/*
|
||||
This is an "external" header file. Don't give away any internals here!
|
||||
|
@ -49,6 +48,8 @@
|
|||
*/
|
||||
#include "curl.h"
|
||||
|
||||
#include <Availability.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -65,6 +66,8 @@ typedef enum {
|
|||
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
|
||||
attempted to get added - again */
|
||||
CURLM_LAST
|
||||
} CURLMcode;
|
||||
|
||||
|
@ -90,6 +93,19 @@ struct CURLMsg {
|
|||
};
|
||||
typedef struct CURLMsg CURLMsg;
|
||||
|
||||
/* Based on poll(2) structure and values.
|
||||
* We don't use pollfd and POLL* constants explicitly
|
||||
* to cover platforms without poll(). */
|
||||
#define CURL_WAIT_POLLIN 0x0001
|
||||
#define CURL_WAIT_POLLPRI 0x0002
|
||||
#define CURL_WAIT_POLLOUT 0x0004
|
||||
|
||||
struct curl_waitfd {
|
||||
curl_socket_t fd;
|
||||
short events;
|
||||
short revents; /* not supported yet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Name: curl_multi_init()
|
||||
*
|
||||
|
@ -134,6 +150,21 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
|||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wait()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0)
|
||||
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_perform()
|
||||
*
|
||||
|
@ -312,6 +343,31 @@ typedef enum {
|
|||
/* maximum number of entries in the connection cache */
|
||||
CINIT(MAXCONNECTS, LONG, 6),
|
||||
|
||||
/* maximum number of (pipelining) connections to one host */
|
||||
CINIT(MAX_HOST_CONNECTIONS, LONG, 7),
|
||||
|
||||
/* maximum number of requests in a pipeline */
|
||||
CINIT(MAX_PIPELINE_LENGTH, LONG, 8),
|
||||
|
||||
/* a connection with a content-length longer than this
|
||||
will not be considered for pipelining */
|
||||
CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9),
|
||||
|
||||
/* a connection with a chunk length longer than this
|
||||
will not be considered for pipelining */
|
||||
CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10),
|
||||
|
||||
/* a list of site names(+port) that are blacklisted from
|
||||
pipelining */
|
||||
CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11),
|
||||
|
||||
/* a list of server types that are blacklisted from
|
||||
pipelining */
|
||||
CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12),
|
||||
|
||||
/* maximum number of open connections in total */
|
||||
CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),
|
||||
|
||||
CURLMOPT_LASTENTRY /* the last unused */
|
||||
} CURLMoption;
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#ifndef __STDC_HEADERS_H
|
||||
#define __STDC_HEADERS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
|
@ -20,7 +20,6 @@
|
|||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id: stdcheaders.h,v 1.9 2009-05-18 12:25:45 yangtse Exp $
|
||||
***************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -31,4 +30,4 @@ size_t fwrite (const void *, size_t, size_t, FILE *);
|
|||
int strcasecmp(const char *, const char *);
|
||||
int strncasecmp(const char *, const char *, size_t);
|
||||
|
||||
#endif
|
||||
#endif /* __STDC_HEADERS_H */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
@ -20,69 +20,88 @@
|
|||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* $Id: typecheck-gcc.h,v 1.9 2009-01-25 23:26:31 bagder Exp $
|
||||
***************************************************************************/
|
||||
|
||||
/* wraps curl_easy_setopt() with typechecking */
|
||||
|
||||
/* To add a new kind of warning, add an
|
||||
* if(_curl_is_sometype_option(_curl_opt) && ! _curl_is_sometype(value))
|
||||
* _curl_easy_setopt_err_sometype();
|
||||
* if(_curl_is_sometype_option(_curl_opt))
|
||||
* if(!_curl_is_sometype(value))
|
||||
* _curl_easy_setopt_err_sometype();
|
||||
* block and define _curl_is_sometype_option, _curl_is_sometype and
|
||||
* _curl_easy_setopt_err_sometype below
|
||||
*
|
||||
* NOTE: We use two nested 'if' statements here instead of the && operator, in
|
||||
* order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
|
||||
* when compiling with -Wlogical-op.
|
||||
*
|
||||
* To add an option that uses the same type as an existing option, you'll just
|
||||
* need to extend the appropriate _curl_*_option macro
|
||||
*/
|
||||
#define curl_easy_setopt(handle, option, value) \
|
||||
__extension__ ({ \
|
||||
__typeof__ (option) _curl_opt = option; \
|
||||
if (__builtin_constant_p(_curl_opt)) { \
|
||||
if (_curl_is_long_option(_curl_opt) && !_curl_is_long(value)) \
|
||||
_curl_easy_setopt_err_long(); \
|
||||
if (_curl_is_off_t_option(_curl_opt) && !_curl_is_off_t(value)) \
|
||||
_curl_easy_setopt_err_curl_off_t(); \
|
||||
if (_curl_is_string_option(_curl_opt) && !_curl_is_string(value)) \
|
||||
_curl_easy_setopt_err_string(); \
|
||||
if (_curl_is_write_cb_option(_curl_opt) && !_curl_is_write_cb(value)) \
|
||||
_curl_easy_setopt_err_write_callback(); \
|
||||
if ((_curl_opt) == CURLOPT_READFUNCTION && !_curl_is_read_cb(value)) \
|
||||
_curl_easy_setopt_err_read_cb(); \
|
||||
if ((_curl_opt) == CURLOPT_IOCTLFUNCTION && !_curl_is_ioctl_cb(value)) \
|
||||
_curl_easy_setopt_err_ioctl_cb(); \
|
||||
if ((_curl_opt) == CURLOPT_SOCKOPTFUNCTION && !_curl_is_sockopt_cb(value))\
|
||||
_curl_easy_setopt_err_sockopt_cb(); \
|
||||
if ((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION && \
|
||||
!_curl_is_opensocket_cb(value)) \
|
||||
_curl_easy_setopt_err_opensocket_cb(); \
|
||||
if ((_curl_opt) == CURLOPT_PROGRESSFUNCTION && \
|
||||
!_curl_is_progress_cb(value)) \
|
||||
_curl_easy_setopt_err_progress_cb(); \
|
||||
if ((_curl_opt) == CURLOPT_DEBUGFUNCTION && !_curl_is_debug_cb(value)) \
|
||||
_curl_easy_setopt_err_debug_cb(); \
|
||||
if ((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION && \
|
||||
!_curl_is_ssl_ctx_cb(value)) \
|
||||
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
||||
if (_curl_is_conv_cb_option(_curl_opt) && !_curl_is_conv_cb(value)) \
|
||||
_curl_easy_setopt_err_conv_cb(); \
|
||||
if ((_curl_opt) == CURLOPT_SEEKFUNCTION && !_curl_is_seek_cb(value)) \
|
||||
_curl_easy_setopt_err_seek_cb(); \
|
||||
if (_curl_is_cb_data_option(_curl_opt) && !_curl_is_cb_data(value)) \
|
||||
_curl_easy_setopt_err_cb_data(); \
|
||||
if ((_curl_opt) == CURLOPT_ERRORBUFFER && !_curl_is_error_buffer(value)) \
|
||||
_curl_easy_setopt_err_error_buffer(); \
|
||||
if ((_curl_opt) == CURLOPT_STDERR && !_curl_is_FILE(value)) \
|
||||
_curl_easy_setopt_err_FILE(); \
|
||||
if (_curl_is_postfields_option(_curl_opt) && !_curl_is_postfields(value)) \
|
||||
_curl_easy_setopt_err_postfields(); \
|
||||
if ((_curl_opt) == CURLOPT_HTTPPOST && \
|
||||
!_curl_is_arr((value), struct curl_httppost)) \
|
||||
_curl_easy_setopt_err_curl_httpost(); \
|
||||
if (_curl_is_slist_option(_curl_opt) && \
|
||||
!_curl_is_arr((value), struct curl_slist)) \
|
||||
_curl_easy_setopt_err_curl_slist(); \
|
||||
if ((_curl_opt) == CURLOPT_SHARE && !_curl_is_ptr((value), CURLSH)) \
|
||||
_curl_easy_setopt_err_CURLSH(); \
|
||||
if(__builtin_constant_p(_curl_opt)) { \
|
||||
if(_curl_is_long_option(_curl_opt)) \
|
||||
if(!_curl_is_long(value)) \
|
||||
_curl_easy_setopt_err_long(); \
|
||||
if(_curl_is_off_t_option(_curl_opt)) \
|
||||
if(!_curl_is_off_t(value)) \
|
||||
_curl_easy_setopt_err_curl_off_t(); \
|
||||
if(_curl_is_string_option(_curl_opt)) \
|
||||
if(!_curl_is_string(value)) \
|
||||
_curl_easy_setopt_err_string(); \
|
||||
if(_curl_is_write_cb_option(_curl_opt)) \
|
||||
if(!_curl_is_write_cb(value)) \
|
||||
_curl_easy_setopt_err_write_callback(); \
|
||||
if((_curl_opt) == CURLOPT_READFUNCTION) \
|
||||
if(!_curl_is_read_cb(value)) \
|
||||
_curl_easy_setopt_err_read_cb(); \
|
||||
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
|
||||
if(!_curl_is_ioctl_cb(value)) \
|
||||
_curl_easy_setopt_err_ioctl_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
|
||||
if(!_curl_is_sockopt_cb(value)) \
|
||||
_curl_easy_setopt_err_sockopt_cb(); \
|
||||
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
|
||||
if(!_curl_is_opensocket_cb(value)) \
|
||||
_curl_easy_setopt_err_opensocket_cb(); \
|
||||
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
|
||||
if(!_curl_is_progress_cb(value)) \
|
||||
_curl_easy_setopt_err_progress_cb(); \
|
||||
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
|
||||
if(!_curl_is_debug_cb(value)) \
|
||||
_curl_easy_setopt_err_debug_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
|
||||
if(!_curl_is_ssl_ctx_cb(value)) \
|
||||
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
||||
if(_curl_is_conv_cb_option(_curl_opt)) \
|
||||
if(!_curl_is_conv_cb(value)) \
|
||||
_curl_easy_setopt_err_conv_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
|
||||
if(!_curl_is_seek_cb(value)) \
|
||||
_curl_easy_setopt_err_seek_cb(); \
|
||||
if(_curl_is_cb_data_option(_curl_opt)) \
|
||||
if(!_curl_is_cb_data(value)) \
|
||||
_curl_easy_setopt_err_cb_data(); \
|
||||
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
|
||||
if(!_curl_is_error_buffer(value)) \
|
||||
_curl_easy_setopt_err_error_buffer(); \
|
||||
if((_curl_opt) == CURLOPT_STDERR) \
|
||||
if(!_curl_is_FILE(value)) \
|
||||
_curl_easy_setopt_err_FILE(); \
|
||||
if(_curl_is_postfields_option(_curl_opt)) \
|
||||
if(!_curl_is_postfields(value)) \
|
||||
_curl_easy_setopt_err_postfields(); \
|
||||
if((_curl_opt) == CURLOPT_HTTPPOST) \
|
||||
if(!_curl_is_arr((value), struct curl_httppost)) \
|
||||
_curl_easy_setopt_err_curl_httpost(); \
|
||||
if(_curl_is_slist_option(_curl_opt)) \
|
||||
if(!_curl_is_arr((value), struct curl_slist)) \
|
||||
_curl_easy_setopt_err_curl_slist(); \
|
||||
if((_curl_opt) == CURLOPT_SHARE) \
|
||||
if(!_curl_is_ptr((value), CURLSH)) \
|
||||
_curl_easy_setopt_err_CURLSH(); \
|
||||
} \
|
||||
curl_easy_setopt(handle, _curl_opt, value); \
|
||||
})
|
||||
|
@ -92,16 +111,19 @@ __extension__ ({ \
|
|||
#define curl_easy_getinfo(handle, info, arg) \
|
||||
__extension__ ({ \
|
||||
__typeof__ (info) _curl_info = info; \
|
||||
if (__builtin_constant_p(_curl_info)) { \
|
||||
if (_curl_is_string_info(_curl_info) && !_curl_is_arr((arg), char *)) \
|
||||
_curl_easy_getinfo_err_string(); \
|
||||
if (_curl_is_long_info(_curl_info) && !_curl_is_arr((arg), long)) \
|
||||
_curl_easy_getinfo_err_long(); \
|
||||
if (_curl_is_double_info(_curl_info) && !_curl_is_arr((arg), double)) \
|
||||
_curl_easy_getinfo_err_double(); \
|
||||
if (_curl_is_slist_info(_curl_info) && \
|
||||
!_curl_is_arr((arg), struct curl_slist *)) \
|
||||
_curl_easy_getinfo_err_curl_slist(); \
|
||||
if(__builtin_constant_p(_curl_info)) { \
|
||||
if(_curl_is_string_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), char *)) \
|
||||
_curl_easy_getinfo_err_string(); \
|
||||
if(_curl_is_long_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), long)) \
|
||||
_curl_easy_getinfo_err_long(); \
|
||||
if(_curl_is_double_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), double)) \
|
||||
_curl_easy_getinfo_err_double(); \
|
||||
if(_curl_is_slist_info(_curl_info)) \
|
||||
if(!_curl_is_arr((arg), struct curl_slist *)) \
|
||||
_curl_easy_getinfo_err_curl_slist(); \
|
||||
} \
|
||||
curl_easy_getinfo(handle, _curl_info, arg); \
|
||||
})
|
||||
|
@ -119,15 +141,17 @@ __extension__ ({ \
|
|||
|
||||
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
|
||||
#define _CURL_WARNING(id, message) \
|
||||
static void __attribute__((warning(message))) __attribute__((unused)) \
|
||||
__attribute__((noinline)) id(void) { __asm__(""); }
|
||||
static void __attribute__((__warning__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) { __asm__(""); }
|
||||
|
||||
_CURL_WARNING(_curl_easy_setopt_err_long,
|
||||
"curl_easy_setopt expects a long argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_curl_off_t,
|
||||
"curl_easy_setopt expects a curl_off_t argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_string,
|
||||
"curl_easy_setopt expects a string (char* or char[]) argument for this option"
|
||||
"curl_easy_setopt expects a "
|
||||
"string (char* or char[]) argument for this option"
|
||||
)
|
||||
_CURL_WARNING(_curl_easy_setopt_err_write_callback,
|
||||
"curl_easy_setopt expects a curl_write_callback argument for this option")
|
||||
|
@ -138,7 +162,8 @@ _CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
|
|||
_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,
|
||||
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,
|
||||
"curl_easy_setopt expects a curl_opensocket_callback argument for this option"
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_opensocket_callback argument for this option"
|
||||
)
|
||||
_CURL_WARNING(_curl_easy_setopt_err_progress_cb,
|
||||
"curl_easy_setopt expects a curl_progress_callback argument for this option")
|
||||
|
@ -151,9 +176,11 @@ _CURL_WARNING(_curl_easy_setopt_err_conv_cb,
|
|||
_CURL_WARNING(_curl_easy_setopt_err_seek_cb,
|
||||
"curl_easy_setopt expects a curl_seek_callback argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_cb_data,
|
||||
"curl_easy_setopt expects a private data pointer as argument for this option")
|
||||
"curl_easy_setopt expects a "
|
||||
"private data pointer as argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_error_buffer,
|
||||
"curl_easy_setopt expects a char buffer of CURL_ERROR_SIZE as argument for this option")
|
||||
"curl_easy_setopt expects a "
|
||||
"char buffer of CURL_ERROR_SIZE as argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_FILE,
|
||||
"curl_easy_setopt expects a FILE* argument for this option")
|
||||
_CURL_WARNING(_curl_easy_setopt_err_postfields,
|
||||
|
@ -202,7 +229,7 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
|||
(option) == CURLOPT_PROXYUSERNAME || \
|
||||
(option) == CURLOPT_PROXYPASSWORD || \
|
||||
(option) == CURLOPT_NOPROXY || \
|
||||
(option) == CURLOPT_ENCODING || \
|
||||
(option) == CURLOPT_ACCEPT_ENCODING || \
|
||||
(option) == CURLOPT_REFERER || \
|
||||
(option) == CURLOPT_USERAGENT || \
|
||||
(option) == CURLOPT_COOKIE || \
|
||||
|
@ -231,6 +258,18 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
|||
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
|
||||
(option) == CURLOPT_CRLFILE || \
|
||||
(option) == CURLOPT_ISSUERCERT || \
|
||||
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
|
||||
(option) == CURLOPT_SSH_KNOWNHOSTS || \
|
||||
(option) == CURLOPT_MAIL_FROM || \
|
||||
(option) == CURLOPT_RTSP_SESSION_ID || \
|
||||
(option) == CURLOPT_RTSP_STREAM_URI || \
|
||||
(option) == CURLOPT_RTSP_TRANSPORT || \
|
||||
(option) == CURLOPT_XOAUTH2_BEARER || \
|
||||
(option) == CURLOPT_DNS_SERVERS || \
|
||||
(option) == CURLOPT_DNS_INTERFACE || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP4 || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP6 || \
|
||||
(option) == CURLOPT_LOGIN_OPTIONS || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a curl_write_callback argument */
|
||||
|
@ -252,11 +291,15 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
|||
(option) == CURLOPT_SOCKOPTDATA || \
|
||||
(option) == CURLOPT_OPENSOCKETDATA || \
|
||||
(option) == CURLOPT_PROGRESSDATA || \
|
||||
(option) == CURLOPT_WRITEHEADER || \
|
||||
(option) == CURLOPT_HEADERDATA || \
|
||||
(option) == CURLOPT_DEBUGDATA || \
|
||||
(option) == CURLOPT_SSL_CTX_DATA || \
|
||||
(option) == CURLOPT_SEEKDATA || \
|
||||
(option) == CURLOPT_PRIVATE || \
|
||||
(option) == CURLOPT_SSH_KEYDATA || \
|
||||
(option) == CURLOPT_INTERLEAVEDATA || \
|
||||
(option) == CURLOPT_CHUNK_DATA || \
|
||||
(option) == CURLOPT_FNMATCH_DATA || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a POST data argument (void* or char*) */
|
||||
|
@ -273,6 +316,7 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
|||
(option) == CURLOPT_POSTQUOTE || \
|
||||
(option) == CURLOPT_PREQUOTE || \
|
||||
(option) == CURLOPT_TELNETOPTIONS || \
|
||||
(option) == CURLOPT_MAIL_RCPT || \
|
||||
0)
|
||||
|
||||
/* groups of curl_easy_getinfo infos that take the same type of argument */
|
||||
|
@ -355,7 +399,8 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
|
|||
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
|
||||
/* XXX: also check size of an char[] array? */
|
||||
#define _curl_is_error_buffer(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
||||
(_curl_is_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char[]))
|
||||
|
||||
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
|
||||
|
@ -448,7 +493,8 @@ typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
|
|||
typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t,
|
||||
curlsocktype);
|
||||
|
||||
/* evaluates to true if expr is of type curl_opensocket_callback or "similar" */
|
||||
/* evaluates to true if expr is of type curl_opensocket_callback or
|
||||
"similar" */
|
||||
#define _curl_is_opensocket_cb(expr) \
|
||||
(_curl_is_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\
|
||||
|
@ -483,7 +529,11 @@ typedef int (_curl_progress_callback2)(const void *,
|
|||
_curl_callback_compatible((expr), _curl_debug_callback1) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback2) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback3) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback4))
|
||||
_curl_callback_compatible((expr), _curl_debug_callback4) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback5) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback6) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback7) || \
|
||||
_curl_callback_compatible((expr), _curl_debug_callback8))
|
||||
typedef int (_curl_debug_callback1) (CURL *,
|
||||
curl_infotype, char *, size_t, void *);
|
||||
typedef int (_curl_debug_callback2) (CURL *,
|
||||
|
@ -492,6 +542,14 @@ typedef int (_curl_debug_callback3) (CURL *,
|
|||
curl_infotype, const char *, size_t, void *);
|
||||
typedef int (_curl_debug_callback4) (CURL *,
|
||||
curl_infotype, const char *, size_t, const void *);
|
||||
typedef int (_curl_debug_callback5) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, void *);
|
||||
typedef int (_curl_debug_callback6) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, const void *);
|
||||
typedef int (_curl_debug_callback7) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, void *);
|
||||
typedef int (_curl_debug_callback8) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
|
||||
/* this is getting even messier... */
|
||||
|
@ -517,7 +575,8 @@ typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *);
|
|||
typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);
|
||||
typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);
|
||||
typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);
|
||||
typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, const void *);
|
||||
typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,
|
||||
const void *);
|
||||
#else
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
/* not used */
|
Binary file not shown.
|
@ -27,9 +27,9 @@
|
|||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x009081dfL
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8zc-fips 19 Mar 2015"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8zd-fips 8 Jan 2015"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8zc 19 Mar 2015"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 0.9.8zd 8 Jan 2015"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
libssl.0.9.8.dylib
|
|
@ -1,4 +1,4 @@
|
|||
# Uncrustify-0.68_f
|
||||
# Uncrustify-0.69.0_f
|
||||
newlines = auto
|
||||
input_tab_size = 8
|
||||
output_tab_size = 8
|
||||
|
@ -56,6 +56,7 @@ sp_before_template_paren = ignore
|
|||
sp_template_angle = remove
|
||||
sp_before_angle = remove
|
||||
sp_inside_angle = remove
|
||||
sp_inside_angle_empty = ignore
|
||||
sp_angle_colon = remove
|
||||
sp_after_angle = remove
|
||||
sp_angle_paren = remove
|
||||
|
@ -91,7 +92,10 @@ sp_between_mdatype_commas = ignore
|
|||
sp_paren_comma = force
|
||||
sp_before_ellipsis = remove
|
||||
sp_type_ellipsis = remove
|
||||
sp_type_question = ignore
|
||||
sp_paren_ellipsis = remove
|
||||
sp_paren_qualifier = ignore
|
||||
sp_paren_noexcept = ignore
|
||||
sp_after_class_colon = ignore
|
||||
sp_before_class_colon = force
|
||||
sp_after_constr_colon = ignore
|
||||
|
@ -145,6 +149,7 @@ sp_throw_paren = force
|
|||
sp_after_throw = force
|
||||
sp_catch_paren = force
|
||||
sp_oc_catch_paren = ignore
|
||||
sp_oc_classname_paren = ignore
|
||||
sp_version_paren = ignore
|
||||
sp_scope_paren = ignore
|
||||
sp_super_paren = remove
|
||||
|
@ -219,6 +224,7 @@ sp_num_before_tr_emb_cmt = 1
|
|||
sp_annotation_paren = ignore
|
||||
sp_skip_vbrace_tokens = false
|
||||
sp_after_noexcept = remove
|
||||
sp_vala_after_translation = ignore
|
||||
force_tab_after_define = false
|
||||
indent_columns = 4
|
||||
indent_continue = 4
|
||||
|
@ -272,6 +278,7 @@ indent_switch_pp = true
|
|||
indent_case_shift = 0
|
||||
indent_case_brace = 4
|
||||
indent_col1_comment = false
|
||||
indent_col1_multi_string_literal = false
|
||||
indent_label = 1
|
||||
indent_access_spec = 1
|
||||
indent_access_spec_body = false
|
||||
|
@ -331,13 +338,6 @@ nl_assign_brace = force
|
|||
nl_assign_square = ignore
|
||||
nl_tsquare_brace = ignore
|
||||
nl_after_square_assign = ignore
|
||||
nl_func_var_def_blk = 0
|
||||
nl_typedef_blk_start = 0
|
||||
nl_typedef_blk_end = 0
|
||||
nl_typedef_blk_in = 0
|
||||
nl_var_def_blk_start = 0
|
||||
nl_var_def_blk_end = 0
|
||||
nl_var_def_blk_in = 0
|
||||
nl_fcall_brace = ignore
|
||||
nl_enum_brace = force
|
||||
nl_enum_class = ignore
|
||||
|
@ -415,11 +415,13 @@ nl_func_def_end_multi_line = false
|
|||
nl_func_decl_empty = remove
|
||||
nl_func_def_empty = remove
|
||||
nl_func_call_empty = remove
|
||||
nl_func_call_start = ignore
|
||||
nl_func_call_start_multi_line = false
|
||||
nl_func_call_args_multi_line = false
|
||||
nl_func_call_end_multi_line = false
|
||||
nl_oc_msg_args = false
|
||||
nl_fdef_brace = force
|
||||
nl_fdef_brace_cond = ignore
|
||||
nl_cpp_ldef_brace = force
|
||||
nl_return_expr = remove
|
||||
nl_after_semicolon = true
|
||||
|
@ -450,10 +452,12 @@ nl_before_synchronized = ignore
|
|||
nl_after_synchronized = force
|
||||
nl_before_do = ignore
|
||||
nl_after_do = force
|
||||
nl_before_return = false
|
||||
nl_after_return = false
|
||||
nl_ds_struct_enum_cmt = false
|
||||
nl_ds_struct_enum_close_brace = false
|
||||
nl_class_colon = ignore
|
||||
nl_constr_colon = ignore
|
||||
nl_constr_colon = force
|
||||
nl_namespace_two_to_one_liner = false
|
||||
nl_create_if_one_liner = false
|
||||
nl_create_for_one_liner = false
|
||||
|
@ -473,17 +477,24 @@ nl_after_func_proto_group = 0
|
|||
nl_after_func_class_proto = 0
|
||||
nl_after_func_class_proto_group = 0
|
||||
nl_class_leave_one_liner_groups = false
|
||||
nl_after_func_body = 0
|
||||
nl_after_func_body_class = 0
|
||||
nl_after_func_body = 2
|
||||
nl_after_func_body_class = 2
|
||||
nl_after_func_body_one_liner = 0
|
||||
nl_func_var_def_blk = 0
|
||||
nl_typedef_blk_start = 0
|
||||
nl_typedef_blk_end = 0
|
||||
nl_typedef_blk_in = 0
|
||||
nl_var_def_blk_start = 0
|
||||
nl_var_def_blk_end = 0
|
||||
nl_var_def_blk_in = 0
|
||||
nl_before_block_comment = 0
|
||||
nl_before_c_comment = 0
|
||||
nl_before_cpp_comment = 0
|
||||
nl_after_multiline_comment = false
|
||||
nl_after_label_colon = false
|
||||
nl_after_struct = 0
|
||||
nl_before_class = 0
|
||||
nl_after_class = 0
|
||||
nl_after_struct = 1
|
||||
nl_before_class = 2
|
||||
nl_after_class = 2
|
||||
nl_before_access_spec = 2
|
||||
nl_after_access_spec = 1
|
||||
nl_comment_func_def = 0
|
||||
|
@ -492,11 +503,9 @@ nl_around_cs_property = 0
|
|||
nl_between_get_set = 0
|
||||
nl_property_brace = ignore
|
||||
nl_inside_namespace = 2
|
||||
eat_blanks_after_open_brace = false
|
||||
eat_blanks_before_close_brace = false
|
||||
eat_blanks_after_open_brace = true
|
||||
eat_blanks_before_close_brace = true
|
||||
nl_remove_extra_newlines = 0
|
||||
nl_before_return = false
|
||||
nl_after_return = false
|
||||
nl_after_annotation = ignore
|
||||
nl_between_annotation = ignore
|
||||
pos_arith = trail
|
||||
|
@ -523,6 +532,9 @@ align_func_params = false
|
|||
align_func_params_span = 0
|
||||
align_func_params_thresh = 0
|
||||
align_func_params_gap = 0
|
||||
align_constr_value_span = 0
|
||||
align_constr_value_thresh = 0
|
||||
align_constr_value_gap = 0
|
||||
align_same_func_call_params = false
|
||||
align_same_func_call_params_span = 0
|
||||
align_same_func_call_params_thresh = 0
|
||||
|
@ -536,6 +548,7 @@ align_var_def_colon_gap = 0
|
|||
align_var_def_attribute = false
|
||||
align_var_def_inline = false
|
||||
align_assign_span = 0
|
||||
align_assign_func_proto_span = 0
|
||||
align_assign_thresh = 0
|
||||
align_assign_decl_func = 0
|
||||
align_enum_equ_span = 0
|
||||
|
@ -547,17 +560,18 @@ align_var_struct_span = 0
|
|||
align_var_struct_thresh = 0
|
||||
align_var_struct_gap = 0
|
||||
align_struct_init_span = 0
|
||||
align_typedef_gap = 0
|
||||
align_typedef_span = 0
|
||||
align_typedef_gap = 0
|
||||
align_typedef_func = 0
|
||||
align_typedef_star_style = 0
|
||||
align_typedef_amp_style = 0
|
||||
align_right_cmt_span = 0
|
||||
align_right_cmt_gap = 0
|
||||
align_right_cmt_mix = false
|
||||
align_right_cmt_same_level = false
|
||||
align_right_cmt_gap = 0
|
||||
align_right_cmt_at_col = 0
|
||||
align_func_proto_span = 0
|
||||
align_func_proto_thresh = 0
|
||||
align_func_proto_gap = 0
|
||||
align_on_operator = false
|
||||
align_mix_var_proto = false
|
||||
|
@ -567,8 +581,8 @@ align_single_line_brace_gap = 0
|
|||
align_oc_msg_spec_span = 0
|
||||
align_nl_cont = false
|
||||
align_pp_define_together = false
|
||||
align_pp_define_gap = 0
|
||||
align_pp_define_span = 0
|
||||
align_pp_define_gap = 0
|
||||
align_left_shift = true
|
||||
align_asm_colon = false
|
||||
align_oc_msg_colon_span = 0
|
||||
|
@ -659,5 +673,5 @@ warn_level_tabs_found_in_verbatim_string_literals = 2
|
|||
type PtrArrayCompareFunc
|
||||
type SIZE_T
|
||||
type tr_session
|
||||
# option(s) with 'not default' value: 218
|
||||
# option(s) with 'not default' value: 226
|
||||
#
|
||||
|
|
|
@ -34,13 +34,13 @@ static uint32_t piecesize_kib = 0;
|
|||
|
||||
static tr_option options[] =
|
||||
{
|
||||
{ 'p', "private", "Allow this torrent to only be used with the specified tracker(s)", "p", 0, NULL },
|
||||
{ 'o', "outfile", "Save the generated .torrent to this filename", "o", 1, "<file>" },
|
||||
{ 's', "piecesize", "Set how many KiB each piece should be, overriding the preferred default", "s", 1, "<size in KiB>" },
|
||||
{ 'c', "comment", "Add a comment", "c", 1, "<comment>" },
|
||||
{ 't', "tracker", "Add a tracker's announce URL", "t", 1, "<url>" },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||
{ 'p', "private", "Allow this torrent to only be used with the specified tracker(s)", "p", false, NULL },
|
||||
{ 'o', "outfile", "Save the generated .torrent to this filename", "o", true, "<file>" },
|
||||
{ 's', "piecesize", "Set how many KiB each piece should be, overriding the preferred default", "s", true, "<size in KiB>" },
|
||||
{ 'c', "comment", "Add a comment", "c", true, "<comment>" },
|
||||
{ 't', "tracker", "Add a tracker's announce URL", "t", true, "<url>" },
|
||||
{ 'V', "version", "Show version number and exit", "V", false, NULL },
|
||||
{ 0, NULL, NULL, NULL, false, NULL }
|
||||
};
|
||||
|
||||
static char const* getUsage(void)
|
||||
|
|
10
utils/edit.c
10
utils/edit.c
|
@ -30,11 +30,11 @@ static char const* replace[2] = { NULL, NULL };
|
|||
|
||||
static tr_option options[] =
|
||||
{
|
||||
{ 'a', "add", "Add a tracker's announce URL", "a", 1, "<url>" },
|
||||
{ 'd', "delete", "Delete a tracker's announce URL", "d", 1, "<url>" },
|
||||
{ 'r', "replace", "Search and replace a substring in the announce URLs", "r", 1, "<old> <new>" },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||
{ 'a', "add", "Add a tracker's announce URL", "a", true, "<url>" },
|
||||
{ 'd', "delete", "Delete a tracker's announce URL", "d", true, "<url>" },
|
||||
{ 'r', "replace", "Search and replace a substring in the announce URLs", "r", true, "<old> <new>" },
|
||||
{ 'V', "version", "Show version number and exit", "V", false, NULL },
|
||||
{ 0, NULL, NULL, NULL, false, NULL }
|
||||
};
|
||||
|
||||
static char const* getUsage(void)
|
||||
|
|
199
utils/remote.c
199
utils/remote.c
|
@ -258,97 +258,98 @@ static char const* getUsage(void)
|
|||
|
||||
static tr_option opts[] =
|
||||
{
|
||||
{ 'a', "add", "Add torrent files by filename or URL", "a", 0, NULL },
|
||||
{ 970, "alt-speed", "Use the alternate Limits", "as", 0, NULL },
|
||||
{ 971, "no-alt-speed", "Don't use the alternate Limits", "AS", 0, NULL },
|
||||
{ 972, "alt-speed-downlimit", "max alternate download speed (in "SPEED_K_STR ")", "asd", 1, "<speed>" },
|
||||
{ 973, "alt-speed-uplimit", "max alternate upload speed (in "SPEED_K_STR ")", "asu", 1, "<speed>" },
|
||||
{ 974, "alt-speed-scheduler", "Use the scheduled on/off times", "asc", 0, NULL },
|
||||
{ 975, "no-alt-speed-scheduler", "Don't use the scheduled on/off times", "ASC", 0, NULL },
|
||||
{ 976, "alt-speed-time-begin", "Time to start using the alt speed limits (in hhmm)", NULL, 1, "<time>" },
|
||||
{ 977, "alt-speed-time-end", "Time to stop using the alt speed limits (in hhmm)", NULL, 1, "<time>" },
|
||||
{ 978, "alt-speed-days", "Numbers for any/all days of the week - eg. \"1-7\"", NULL, 1, "<days>" },
|
||||
{ 963, "blocklist-update", "Blocklist update", NULL, 0, NULL },
|
||||
{ 'c', "incomplete-dir", "Where to store new torrents until they're complete", "c", 1, "<dir>" },
|
||||
{ 'C', "no-incomplete-dir", "Don't store incomplete torrents in a different location", "C", 0, NULL },
|
||||
{ 'b', "debug", "Print debugging information", "b", 0, NULL },
|
||||
{ 'd', "downlimit", "Set the max download speed in "SPEED_K_STR " for the current torrent(s) or globally", "d", 1,
|
||||
{ 'a', "add", "Add torrent files by filename or URL", "a", false, NULL },
|
||||
{ 970, "alt-speed", "Use the alternate Limits", "as", false, NULL },
|
||||
{ 971, "no-alt-speed", "Don't use the alternate Limits", "AS", false, NULL },
|
||||
{ 972, "alt-speed-downlimit", "max alternate download speed (in "SPEED_K_STR ")", "asd", true, "<speed>" },
|
||||
{ 973, "alt-speed-uplimit", "max alternate upload speed (in "SPEED_K_STR ")", "asu", true, "<speed>" },
|
||||
{ 974, "alt-speed-scheduler", "Use the scheduled on/off times", "asc", false, NULL },
|
||||
{ 975, "no-alt-speed-scheduler", "Don't use the scheduled on/off times", "ASC", false, NULL },
|
||||
{ 976, "alt-speed-time-begin", "Time to start using the alt speed limits (in hhmm)", NULL, true, "<time>" },
|
||||
{ 977, "alt-speed-time-end", "Time to stop using the alt speed limits (in hhmm)", NULL, true, "<time>" },
|
||||
{ 978, "alt-speed-days", "Numbers for any/all days of the week - eg. \"1-7\"", NULL, true, "<days>" },
|
||||
{ 963, "blocklist-update", "Blocklist update", NULL, false, NULL },
|
||||
{ 'c', "incomplete-dir", "Where to store new torrents until they're complete", "c", true, "<dir>" },
|
||||
{ 'C', "no-incomplete-dir", "Don't store incomplete torrents in a different location", "C", false, NULL },
|
||||
{ 'b', "debug", "Print debugging information", "b", false, NULL },
|
||||
{ 'd', "downlimit", "Set the max download speed in "SPEED_K_STR " for the current torrent(s) or globally", "d", true,
|
||||
"<speed>" },
|
||||
{ 'D', "no-downlimit", "Disable max download speed for the current torrent(s) or globally", "D", 0, NULL },
|
||||
{ 'e', "cache", "Set the maximum size of the session's memory cache (in " MEM_M_STR ")", "e", 1, "<size>" },
|
||||
{ 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL },
|
||||
{ 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", 0, NULL },
|
||||
{ 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", 0, NULL },
|
||||
{ 850, "exit", "Tell the transmission session to shut down", NULL, 0, NULL },
|
||||
{ 940, "files", "List the current torrent(s)' files", "f", 0, NULL },
|
||||
{ 'g', "get", "Mark files for download", "g", 1, "<files>" },
|
||||
{ 'G', "no-get", "Mark files for not downloading", "G", 1, "<files>" },
|
||||
{ 'i', "info", "Show the current torrent(s)' details", "i", 0, NULL },
|
||||
{ 940, "info-files", "List the current torrent(s)' files", "if", 0, NULL },
|
||||
{ 941, "info-peers", "List the current torrent(s)' peers", "ip", 0, NULL },
|
||||
{ 942, "info-pieces", "List the current torrent(s)' pieces", "ic", 0, NULL },
|
||||
{ 943, "info-trackers", "List the current torrent(s)' trackers", "it", 0, NULL },
|
||||
{ 920, "session-info", "Show the session's details", "si", 0, NULL },
|
||||
{ 921, "session-stats", "Show the session's statistics", "st", 0, NULL },
|
||||
{ 'l', "list", "List all torrents", "l", 0, NULL },
|
||||
{ 'L', "labels", "Set the current torrents' labels", "L", 1, "<label[,label...]>" },
|
||||
{ 960, "move", "Move current torrent's data to a new folder", NULL, 1, "<path>" },
|
||||
{ 961, "find", "Tell Transmission where to find a torrent's data", NULL, 1, "<path>" },
|
||||
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL },
|
||||
{ 'M', "no-portmap", "Disable portmapping", "M", 0, NULL },
|
||||
{ 'n', "auth", "Set username and password", "n", 1, "<user:pw>" },
|
||||
{ 810, "authenv", "Set authentication info from the TR_AUTH environment variable (user:pw)", "ne", 0, NULL },
|
||||
{ 'N', "netrc", "Set authentication info from a .netrc file", "N", 1, "<file>" },
|
||||
{ 820, "ssl", "Use SSL when talking to daemon", NULL, 0, NULL },
|
||||
{ 'o', "dht", "Enable distributed hash tables (DHT)", "o", 0, NULL },
|
||||
{ 'O', "no-dht", "Disable distributed hash tables (DHT)", "O", 0, NULL },
|
||||
{ 'p', "port", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", 1, "<port>" },
|
||||
{ 962, "port-test", "Port testing", "pt", 0, NULL },
|
||||
{ 'P', "random-port", "Random port for incoming peers", "P", 0, NULL },
|
||||
{ 900, "priority-high", "Try to download these file(s) first", "ph", 1, "<files>" },
|
||||
{ 901, "priority-normal", "Try to download these file(s) normally", "pn", 1, "<files>" },
|
||||
{ 902, "priority-low", "Try to download these file(s) last", "pl", 1, "<files>" },
|
||||
{ 700, "bandwidth-high", "Give this torrent first chance at available bandwidth", "Bh", 0, NULL },
|
||||
{ 701, "bandwidth-normal", "Give this torrent bandwidth left over by high priority torrents", "Bn", 0, NULL },
|
||||
{ 702, "bandwidth-low", "Give this torrent bandwidth left over by high and normal priority torrents", "Bl", 0, NULL },
|
||||
{ 600, "reannounce", "Reannounce the current torrent(s)", NULL, 0, NULL },
|
||||
{ 'r', "remove", "Remove the current torrent(s)", "r", 0, NULL },
|
||||
{ 930, "peers", "Set the maximum number of peers for the current torrent(s) or globally", "pr", 1, "<max>" },
|
||||
{ 840, "remove-and-delete", "Remove the current torrent(s) and delete local data", "rad", 0, NULL },
|
||||
{ 800, "torrent-done-script", "Specify a script to run when a torrent finishes", NULL, 1, "<file>" },
|
||||
{ 801, "no-torrent-done-script", "Don't run a script when torrents finish", NULL, 0, NULL },
|
||||
{ 950, "seedratio", "Let the current torrent(s) seed until a specific ratio", "sr", 1, "ratio" },
|
||||
{ 951, "seedratio-default", "Let the current torrent(s) use the global seedratio settings", "srd", 0, NULL },
|
||||
{ 952, "no-seedratio", "Let the current torrent(s) seed regardless of ratio", "SR", 0, NULL },
|
||||
{ 'D', "no-downlimit", "Disable max download speed for the current torrent(s) or globally", "D", false, NULL },
|
||||
{ 'e', "cache", "Set the maximum size of the session's memory cache (in " MEM_M_STR ")", "e", true, "<size>" },
|
||||
{ 910, "encryption-required", "Encrypt all peer connections", "er", false, NULL },
|
||||
{ 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", false, NULL },
|
||||
{ 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", false, NULL },
|
||||
{ 850, "exit", "Tell the transmission session to shut down", NULL, false, NULL },
|
||||
{ 940, "files", "List the current torrent(s)' files", "f", false, NULL },
|
||||
{ 'g', "get", "Mark files for download", "g", true, "<files>" },
|
||||
{ 'G', "no-get", "Mark files for not downloading", "G", true, "<files>" },
|
||||
{ 'i', "info", "Show the current torrent(s)' details", "i", false, NULL },
|
||||
{ 940, "info-files", "List the current torrent(s)' files", "if", false, NULL },
|
||||
{ 941, "info-peers", "List the current torrent(s)' peers", "ip", false, NULL },
|
||||
{ 942, "info-pieces", "List the current torrent(s)' pieces", "ic", false, NULL },
|
||||
{ 943, "info-trackers", "List the current torrent(s)' trackers", "it", false, NULL },
|
||||
{ 920, "session-info", "Show the session's details", "si", false, NULL },
|
||||
{ 921, "session-stats", "Show the session's statistics", "st", false, NULL },
|
||||
{ 'l', "list", "List all torrents", "l", false, NULL },
|
||||
{ 'L', "labels", "Set the current torrents' labels", "L", true, "<label[,label...]>" },
|
||||
{ 960, "move", "Move current torrent's data to a new folder", NULL, true, "<path>" },
|
||||
{ 961, "find", "Tell Transmission where to find a torrent's data", NULL, true, "<path>" },
|
||||
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", false, NULL },
|
||||
{ 'M', "no-portmap", "Disable portmapping", "M", false, NULL },
|
||||
{ 'n', "auth", "Set username and password", "n", true, "<user:pw>" },
|
||||
{ 810, "authenv", "Set authentication info from the TR_AUTH environment variable (user:pw)", "ne", false, NULL },
|
||||
{ 'N', "netrc", "Set authentication info from a .netrc file", "N", true, "<file>" },
|
||||
{ 820, "ssl", "Use SSL when talking to daemon", NULL, false, NULL },
|
||||
{ 'o', "dht", "Enable distributed hash tables (DHT)", "o", false, NULL },
|
||||
{ 'O', "no-dht", "Disable distributed hash tables (DHT)", "O", false, NULL },
|
||||
{ 'p', "port", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", true, "<port>" },
|
||||
{ 962, "port-test", "Port testing", "pt", false, NULL },
|
||||
{ 'P', "random-port", "Random port for incoming peers", "P", false, NULL },
|
||||
{ 900, "priority-high", "Try to download these file(s) first", "ph", true, "<files>" },
|
||||
{ 901, "priority-normal", "Try to download these file(s) normally", "pn", true, "<files>" },
|
||||
{ 902, "priority-low", "Try to download these file(s) last", "pl", true, "<files>" },
|
||||
{ 700, "bandwidth-high", "Give this torrent first chance at available bandwidth", "Bh", false, NULL },
|
||||
{ 701, "bandwidth-normal", "Give this torrent bandwidth left over by high priority torrents", "Bn", false, NULL },
|
||||
{ 702, "bandwidth-low", "Give this torrent bandwidth left over by high and normal priority torrents", "Bl", false, NULL },
|
||||
{ 600, "reannounce", "Reannounce the current torrent(s)", NULL, false, NULL },
|
||||
{ 'r', "remove", "Remove the current torrent(s)", "r", false, NULL },
|
||||
{ 930, "peers", "Set the maximum number of peers for the current torrent(s) or globally", "pr", true, "<max>" },
|
||||
{ 840, "remove-and-delete", "Remove the current torrent(s) and delete local data", "rad", false, NULL },
|
||||
{ 800, "torrent-done-script", "Specify a script to run when a torrent finishes", NULL, true, "<file>" },
|
||||
{ 801, "no-torrent-done-script", "Don't run a script when torrents finish", NULL, false, NULL },
|
||||
{ 950, "seedratio", "Let the current torrent(s) seed until a specific ratio", "sr", true, "ratio" },
|
||||
{ 951, "seedratio-default", "Let the current torrent(s) use the global seedratio settings", "srd", false, NULL },
|
||||
{ 952, "no-seedratio", "Let the current torrent(s) seed regardless of ratio", "SR", false, NULL },
|
||||
{ 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio",
|
||||
"gsr", 1, "ratio" },
|
||||
"gsr", true, "ratio" },
|
||||
{ 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio",
|
||||
"GSR", 0, NULL },
|
||||
{ 710, "tracker-add", "Add a tracker to a torrent", "td", 1, "<tracker>" },
|
||||
{ 712, "tracker-remove", "Remove a tracker from a torrent", "tr", 1, "<trackerId>" },
|
||||
{ 's', "start", "Start the current torrent(s)", "s", 0, NULL },
|
||||
{ 'S', "stop", "Stop the current torrent(s)", "S", 0, NULL },
|
||||
{ 't', "torrent", "Set the current torrent(s)", "t", 1, "<torrent>" },
|
||||
{ 990, "start-paused", "Start added torrents paused", NULL, 0, NULL },
|
||||
{ 991, "no-start-paused", "Start added torrents unpaused", NULL, 0, NULL },
|
||||
{ 992, "trash-torrent", "Delete torrents after adding", NULL, 0, NULL },
|
||||
{ 993, "no-trash-torrent", "Do not delete torrents after adding", NULL, 0, NULL },
|
||||
{ 984, "honor-session", "Make the current torrent(s) honor the session limits", "hl", 0, NULL },
|
||||
{ 985, "no-honor-session", "Make the current torrent(s) not honor the session limits", "HL", 0, NULL },
|
||||
{ 'u', "uplimit", "Set the max upload speed in "SPEED_K_STR " for the current torrent(s) or globally", "u", 1, "<speed>" },
|
||||
{ 'U', "no-uplimit", "Disable max upload speed for the current torrent(s) or globally", "U", 0, NULL },
|
||||
{ 830, "utp", "Enable uTP for peer connections", NULL, 0, NULL },
|
||||
{ 831, "no-utp", "Disable uTP for peer connections", NULL, 0, NULL },
|
||||
{ 'v', "verify", "Verify the current torrent(s)", "v", 0, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
"GSR", false, NULL },
|
||||
{ 710, "tracker-add", "Add a tracker to a torrent", "td", true, "<tracker>" },
|
||||
{ 712, "tracker-remove", "Remove a tracker from a torrent", "tr", true, "<trackerId>" },
|
||||
{ 's', "start", "Start the current torrent(s)", "s", false, NULL },
|
||||
{ 'S', "stop", "Stop the current torrent(s)", "S", false, NULL },
|
||||
{ 't', "torrent", "Set the current torrent(s)", "t", true, "<torrent>" },
|
||||
{ 990, "start-paused", "Start added torrents paused", NULL, false, NULL },
|
||||
{ 991, "no-start-paused", "Start added torrents unpaused", NULL, false, NULL },
|
||||
{ 992, "trash-torrent", "Delete torrents after adding", NULL, false, NULL },
|
||||
{ 993, "no-trash-torrent", "Do not delete torrents after adding", NULL, false, NULL },
|
||||
{ 984, "honor-session", "Make the current torrent(s) honor the session limits", "hl", false, NULL },
|
||||
{ 985, "no-honor-session", "Make the current torrent(s) not honor the session limits", "HL", false, NULL },
|
||||
{ 'u', "uplimit", "Set the max upload speed in "SPEED_K_STR " for the current torrent(s) or globally", "u", true,
|
||||
"<speed>" },
|
||||
{ 'U', "no-uplimit", "Disable max upload speed for the current torrent(s) or globally", "U", false, NULL },
|
||||
{ 830, "utp", "Enable uTP for peer connections", NULL, false, NULL },
|
||||
{ 831, "no-utp", "Disable uTP for peer connections", NULL, false, NULL },
|
||||
{ 'v', "verify", "Verify the current torrent(s)", "v", false, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", false, NULL },
|
||||
{ 'w', "download-dir", "When used in conjunction with --add, set the new torrent's download folder. "
|
||||
"Otherwise, set the default download folder", "w", 1, "<path>" },
|
||||
{ 'x', "pex", "Enable peer exchange (PEX)", "x", 0, NULL },
|
||||
{ 'X', "no-pex", "Disable peer exchange (PEX)", "X", 0, NULL },
|
||||
{ 'y', "lpd", "Enable local peer discovery (LPD)", "y", 0, NULL },
|
||||
{ 'Y', "no-lpd", "Disable local peer discovery (LPD)", "Y", 0, NULL },
|
||||
{ 941, "peer-info", "List the current torrent(s)' peers", "pi", 0, NULL },
|
||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||
"Otherwise, set the default download folder", "w", true, "<path>" },
|
||||
{ 'x', "pex", "Enable peer exchange (PEX)", "x", false, NULL },
|
||||
{ 'X', "no-pex", "Disable peer exchange (PEX)", "X", false, NULL },
|
||||
{ 'y', "lpd", "Enable local peer discovery (LPD)", "y", false, NULL },
|
||||
{ 'Y', "no-lpd", "Disable local peer discovery (LPD)", "Y", false, NULL },
|
||||
{ 941, "peer-info", "List the current torrent(s)' peers", "pi", false, NULL },
|
||||
{ 0, NULL, NULL, NULL, false, NULL }
|
||||
};
|
||||
|
||||
static void showUsage(void)
|
||||
|
@ -525,7 +526,7 @@ static int getOptMode(int val)
|
|||
}
|
||||
}
|
||||
|
||||
static bool debug = 0;
|
||||
static bool debug = false;
|
||||
static char* auth = NULL;
|
||||
static char* netrc = NULL;
|
||||
static char* sessionId = NULL;
|
||||
|
@ -548,11 +549,11 @@ static char* getEncodedMetainfo(char const* filename)
|
|||
|
||||
static void addIdArg(tr_variant* args, char const* id, char const* fallback)
|
||||
{
|
||||
if (id == NULL || *id == '\0')
|
||||
if (tr_str_is_empty(id))
|
||||
{
|
||||
id = fallback;
|
||||
|
||||
if (id == NULL || *id == '\0')
|
||||
if (tr_str_is_empty(id))
|
||||
{
|
||||
fprintf(stderr, "No torrent specified! Please use the -t option first.\n");
|
||||
id = "-1"; /* no torrent will have this ID, so will act as a no-op */
|
||||
|
@ -666,7 +667,7 @@ static void addLabels(tr_variant* args, char const* arg)
|
|||
while ((token = tr_strsep(&argcpy, ",")) != NULL)
|
||||
{
|
||||
tr_strstrip(token);
|
||||
if (*token != '\0')
|
||||
if (!tr_str_is_empty(token))
|
||||
{
|
||||
tr_variantListAddStr(labels, token);
|
||||
}
|
||||
|
@ -679,7 +680,7 @@ static void addFiles(tr_variant* args, tr_quark const key, char const* arg)
|
|||
{
|
||||
tr_variant* files = tr_variantDictAddList(args, key, 100);
|
||||
|
||||
if (*arg == '\0')
|
||||
if (tr_str_is_empty(arg))
|
||||
{
|
||||
fprintf(stderr, "No files specified!\n");
|
||||
arg = "-1"; /* no file will have this index, so should be a no-op */
|
||||
|
@ -1058,7 +1059,7 @@ static void printDetails(tr_variant* top)
|
|||
printf(" Corrupt DL: %s\n", buf);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindStr(t, TR_KEY_errorString, &str, NULL) && str != NULL && *str != '\0' &&
|
||||
if (tr_variantDictFindStr(t, TR_KEY_errorString, &str, NULL) && !tr_str_is_empty(str) &&
|
||||
tr_variantDictFindInt(t, TR_KEY_error, &i) && i != 0)
|
||||
{
|
||||
switch (i)
|
||||
|
@ -1150,12 +1151,12 @@ static void printDetails(tr_variant* top)
|
|||
printf(" Public torrent: %s\n", (boolVal ? "No" : "Yes"));
|
||||
}
|
||||
|
||||
if (tr_variantDictFindStr(t, TR_KEY_comment, &str, NULL) && str != NULL && *str != '\0')
|
||||
if (tr_variantDictFindStr(t, TR_KEY_comment, &str, NULL) && !tr_str_is_empty(str))
|
||||
{
|
||||
printf(" Comment: %s\n", str);
|
||||
}
|
||||
|
||||
if (tr_variantDictFindStr(t, TR_KEY_creator, &str, NULL) && str != NULL && *str != '\0')
|
||||
if (tr_variantDictFindStr(t, TR_KEY_creator, &str, NULL) && !tr_str_is_empty(str))
|
||||
{
|
||||
printf(" Creator: %s\n", str);
|
||||
}
|
||||
|
@ -1275,7 +1276,7 @@ static void printFileList(tr_variant* top)
|
|||
int64_t have;
|
||||
int64_t length;
|
||||
int64_t priority;
|
||||
int64_t wanted;
|
||||
bool wanted;
|
||||
char const* filename;
|
||||
tr_variant* file = tr_variantListChild(files, j);
|
||||
|
||||
|
@ -1283,7 +1284,7 @@ static void printFileList(tr_variant* top)
|
|||
tr_variantDictFindStr(file, TR_KEY_name, &filename, NULL) &&
|
||||
tr_variantDictFindInt(file, TR_KEY_bytesCompleted, &have) &&
|
||||
tr_variantGetInt(tr_variantListChild(priorities, j), &priority) &&
|
||||
tr_variantGetInt(tr_variantListChild(wanteds, j), &wanted))
|
||||
tr_variantGetBool(tr_variantListChild(wanteds, j), &wanted))
|
||||
{
|
||||
char sizestr[64];
|
||||
double percent = (double)have / length;
|
||||
|
@ -1376,7 +1377,7 @@ static void printPiecesImpl(uint8_t const* raw, size_t rawlen, size_t j)
|
|||
{
|
||||
for (int e = 0; i < j && e < 8; ++e, ++i)
|
||||
{
|
||||
printf("%c", str[k] & (1 << (7 - e)) ? '1' : '0');
|
||||
printf("%c", (str[k] & (1 << (7 - e))) != 0 ? '1' : '0');
|
||||
}
|
||||
|
||||
printf(" ");
|
||||
|
@ -2608,7 +2609,7 @@ static int processArgs(char const* rpcurl, int argc, char const* const* argv)
|
|||
tr_variant* targs = NULL;
|
||||
tr_variant* sargs = NULL;
|
||||
|
||||
if (*id != '\0')
|
||||
if (!tr_str_is_empty(id))
|
||||
{
|
||||
targs = ensure_tset(&tset);
|
||||
}
|
||||
|
|
12
utils/show.c
12
utils/show.c
|
@ -30,11 +30,11 @@
|
|||
|
||||
static tr_option options[] =
|
||||
{
|
||||
{ 'm', "magnet", "Give a magnet link for the specified torrent", "m", 0, NULL },
|
||||
{ 's', "scrape", "Ask the torrent's trackers how many peers are in the torrent's swarm", "s", 0, NULL },
|
||||
{ 'u', "unsorted", "Do not sort files by name", "u", 0, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
{ 0, NULL, NULL, NULL, 0, NULL }
|
||||
{ 'm', "magnet", "Give a magnet link for the specified torrent", "m", false, NULL },
|
||||
{ 's', "scrape", "Ask the torrent's trackers how many peers are in the torrent's swarm", "s", false, NULL },
|
||||
{ 'u', "unsorted", "Do not sort files by name", "u", false, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", false, NULL },
|
||||
{ 0, NULL, NULL, NULL, false, NULL }
|
||||
};
|
||||
|
||||
static char const* getUsage(void)
|
||||
|
@ -142,7 +142,7 @@ static void showInfo(tr_info const* inf)
|
|||
printf(" Created by: %s\n", inf->creator ? inf->creator : "Unknown");
|
||||
printf(" Created on: %s\n", unix_timestamp_to_str(inf->dateCreated));
|
||||
|
||||
if (inf->comment != NULL && *inf->comment != '\0')
|
||||
if (!tr_str_is_empty(inf->comment))
|
||||
{
|
||||
printf(" Comment: %s\n", inf->comment);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue