mirror of
https://github.com/transmission/transmission
synced 2025-03-10 06:02:57 +00:00
refactor: port daemon and utils to C++ (#1825)
* refactor: compile daemon/ and utils/ as C++ Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
This commit is contained in:
parent
21407d67e9
commit
1ee88c019f
10 changed files with 77 additions and 55 deletions
|
@ -302,7 +302,7 @@
|
|||
BE75C38A0C72A1ED00DBEFE0 /* libevent.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE75C3490C729E9500DBEFE0 /* libevent.a */; };
|
||||
BEFC1C050C07753500B0BB3C /* libtransmission.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D18389709DEC0030047D688 /* libtransmission.a */; };
|
||||
BEFC1C1A0C07756200B0BB3C /* daemon.c in Sources */ = {isa = PBXBuildFile; fileRef = BEFC1C0E0C07756200B0BB3C /* daemon.c */; };
|
||||
BEFC1D050C07825A00B0BB3C /* remote.c in Sources */ = {isa = PBXBuildFile; fileRef = BEFC1C140C07756200B0BB3C /* remote.c */; };
|
||||
BEFC1D050C07825A00B0BB3C /* remote.cc in Sources */ = {isa = PBXBuildFile; fileRef = BEFC1C140C07756200B0BB3C /* remote.cc */; };
|
||||
BEFC1D2D0C0783D900B0BB3C /* libtransmission.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D18389709DEC0030047D688 /* libtransmission.a */; };
|
||||
BEFC1E290C07861A00B0BB3C /* version.h in Headers */ = {isa = PBXBuildFile; fileRef = BEFC1DF00C07861A00B0BB3C /* version.h */; };
|
||||
BEFC1E2A0C07861A00B0BB3C /* utils.h in Headers */ = {isa = PBXBuildFile; fileRef = BEFC1DF10C07861A00B0BB3C /* utils.h */; };
|
||||
|
@ -363,7 +363,7 @@
|
|||
C1A751E626ED09A30038B90A /* arc4.h in Headers */ = {isa = PBXBuildFile; fileRef = C1A751E426ED09A30038B90A /* arc4.h */; };
|
||||
C1BF7BA81F2A3CB7008E88A7 /* upnpdev.c in Sources */ = {isa = PBXBuildFile; fileRef = C1BF7BA71F2A3CB7008E88A7 /* upnpdev.c */; };
|
||||
C1BF7BAA1F2A3CCE008E88A7 /* upnpdev.h in Headers */ = {isa = PBXBuildFile; fileRef = C1BF7BA91F2A3CCE008E88A7 /* upnpdev.h */; };
|
||||
C1F690FD1AD0627500D95CF0 /* daemon-posix.c in Sources */ = {isa = PBXBuildFile; fileRef = C1F690FC1AD0627500D95CF0 /* daemon-posix.c */; };
|
||||
C1F690FD1AD0627500D95CF0 /* daemon-posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = C1F690FC1AD0627500D95CF0 /* daemon-posix.cc */; };
|
||||
C1FEE5771C3223CC00D62832 /* watchdir-common.h in Headers */ = {isa = PBXBuildFile; fileRef = C1FEE5721C3223CC00D62832 /* watchdir-common.h */; };
|
||||
C1FEE5781C3223CC00D62832 /* watchdir-generic.cc in Sources */ = {isa = PBXBuildFile; fileRef = C1FEE5731C3223CC00D62832 /* watchdir-generic.cc */; };
|
||||
C1FEE5791C3223CC00D62832 /* watchdir-kqueue.cc in Sources */ = {isa = PBXBuildFile; fileRef = C1FEE5741C3223CC00D62832 /* watchdir-kqueue.cc */; };
|
||||
|
@ -966,8 +966,8 @@
|
|||
BE1183680CE160D50002D0F3 /* miniupnpc.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = miniupnpc.c; sourceTree = "<group>"; };
|
||||
BE75C3490C729E9500DBEFE0 /* libevent.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libevent.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BEFC1C000C07750000B0BB3C /* transmission-daemon */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "transmission-daemon"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BEFC1C0E0C07756200B0BB3C /* daemon.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = daemon.c; sourceTree = "<group>"; };
|
||||
BEFC1C140C07756200B0BB3C /* remote.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = remote.c; sourceTree = "<group>"; };
|
||||
BEFC1C0E0C07756200B0BB3C /* daemon.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = daemon.cc; sourceTree = "<group>"; };
|
||||
BEFC1C140C07756200B0BB3C /* remote.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = remote.cc; sourceTree = "<group>"; };
|
||||
BEFC1CF90C07822400B0BB3C /* transmission-remote */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "transmission-remote"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BEFC1DF00C07861A00B0BB3C /* version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
|
||||
BEFC1DF10C07861A00B0BB3C /* utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = "<group>"; };
|
||||
|
@ -1025,7 +1025,7 @@
|
|||
C1A751E426ED09A30038B90A /* arc4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = arc4.h; path = "third-party/arc4/src/arc4.h"; sourceTree = SOURCE_ROOT; };
|
||||
C1BF7BA71F2A3CB7008E88A7 /* upnpdev.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = upnpdev.c; sourceTree = "<group>"; };
|
||||
C1BF7BA91F2A3CCE008E88A7 /* upnpdev.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = upnpdev.h; sourceTree = "<group>"; };
|
||||
C1F690FC1AD0627500D95CF0 /* daemon-posix.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "daemon-posix.c"; sourceTree = "<group>"; };
|
||||
C1F690FC1AD0627500D95CF0 /* daemon-posix.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "daemon-posix.cc"; sourceTree = "<group>"; };
|
||||
C1F690FE1AD0628400D95CF0 /* daemon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = daemon.h; sourceTree = "<group>"; };
|
||||
C1FEE5721C3223CC00D62832 /* watchdir-common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "watchdir-common.h"; sourceTree = "<group>"; };
|
||||
C1FEE5731C3223CC00D62832 /* watchdir-generic.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "watchdir-generic.cc"; sourceTree = "<group>"; };
|
||||
|
@ -1734,9 +1734,9 @@
|
|||
BEFC1C0B0C07754700B0BB3C /* daemon */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BEFC1C0E0C07756200B0BB3C /* daemon.c */,
|
||||
BEFC1C0E0C07756200B0BB3C /* daemon.cc */,
|
||||
C1F690FE1AD0628400D95CF0 /* daemon.h */,
|
||||
C1F690FC1AD0627500D95CF0 /* daemon-posix.c */,
|
||||
C1F690FC1AD0627500D95CF0 /* daemon-posix.cc */,
|
||||
);
|
||||
path = daemon;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1744,7 +1744,7 @@
|
|||
C15E58AC219A37C600AB292F /* utils */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BEFC1C140C07756200B0BB3C /* remote.c */,
|
||||
BEFC1C140C07756200B0BB3C /* remote.cc */,
|
||||
);
|
||||
path = utils;
|
||||
sourceTree = "<group>";
|
||||
|
@ -2683,8 +2683,8 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BEFC1C1A0C07756200B0BB3C /* daemon.c in Sources */,
|
||||
C1F690FD1AD0627500D95CF0 /* daemon-posix.c in Sources */,
|
||||
BEFC1C1A0C07756200B0BB3C /* daemon.cc in Sources */,
|
||||
C1F690FD1AD0627500D95CF0 /* daemon-posix.cc in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -2692,7 +2692,7 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BEFC1D050C07825A00B0BB3C /* remote.c in Sources */,
|
||||
BEFC1D050C07825A00B0BB3C /* remote.cc in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -3085,6 +3085,8 @@
|
|||
0053D3D60C86774200545606 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3099,6 +3101,8 @@
|
|||
0053D3D70C86774200545606 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3117,6 +3121,8 @@
|
|||
0053D3D80C86774200545606 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3261,6 +3267,8 @@
|
|||
4DDBB71E09E16BF100284745 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3473,6 +3481,8 @@
|
|||
A250CFED0CDA19680068B4B6 /* Release - Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3521,6 +3531,8 @@
|
|||
A250CFEF0CDA19680068B4B6 /* Release - Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3539,6 +3551,8 @@
|
|||
A250CFF00CDA19680068B4B6 /* Release - Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3684,6 +3698,8 @@
|
|||
BEFC1C0A0C07753800B0BB3C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -3702,6 +3718,8 @@
|
|||
BEFC1CF80C07822400B0BB3C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_OBJC_ARC = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
|
|
@ -4,6 +4,8 @@ if(WITH_SYSTEMD)
|
|||
add_definitions(-DUSE_SYSTEMD)
|
||||
endif()
|
||||
|
||||
add_compile_options(${CXX_WARNING_FLAGS})
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
|
@ -14,15 +16,15 @@ include_directories(
|
|||
)
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
daemon.c
|
||||
daemon-posix.c
|
||||
daemon-win32.c
|
||||
daemon.cc
|
||||
daemon-posix.cc
|
||||
daemon-win32.cc
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set_source_files_properties(daemon-posix.c PROPERTIES HEADER_FILE_ONLY ON)
|
||||
set_source_files_properties(daemon-posix.cc PROPERTIES HEADER_FILE_ONLY ON)
|
||||
else()
|
||||
set_source_files_properties(daemon-win32.c PROPERTIES HEADER_FILE_ONLY ON)
|
||||
set_source_files_properties(daemon-win32.cc PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
|
||||
set(${PROJECT_NAME}_HEADERS
|
||||
|
|
|
@ -56,7 +56,7 @@ static void handle_signal(int sig)
|
|||
break;
|
||||
|
||||
default:
|
||||
assert(!"Unexpected signal");
|
||||
assert("Unexpected signal");
|
||||
}
|
||||
}
|
||||
|
|
@ -201,14 +201,14 @@ static char const* getConfigDir(int argc, char const* const* argv)
|
|||
{
|
||||
int c;
|
||||
char const* configDir = NULL;
|
||||
char const* optarg;
|
||||
char const* optstr;
|
||||
int const ind = tr_optind;
|
||||
|
||||
while ((c = tr_getopt(getUsage(), argc, argv, options, &optarg)) != TR_OPT_DONE)
|
||||
while ((c = tr_getopt(getUsage(), argc, argv, options, &optstr)) != TR_OPT_DONE)
|
||||
{
|
||||
if (c == 'g')
|
||||
{
|
||||
configDir = optarg;
|
||||
configDir = optstr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -223,9 +223,9 @@ static char const* getConfigDir(int argc, char const* const* argv)
|
|||
return configDir;
|
||||
}
|
||||
|
||||
static tr_watchdir_status onFileAdded(tr_watchdir_t dir, char const* name, void* context)
|
||||
static tr_watchdir_status onFileAdded(tr_watchdir_t dir, char const* name, void* vsession)
|
||||
{
|
||||
tr_session const* session = context;
|
||||
auto const* session = static_cast<tr_session const*>(vsession);
|
||||
|
||||
if (!tr_str_has_suffix(name, ".torrent"))
|
||||
{
|
||||
|
@ -408,7 +408,7 @@ static bool parse_args(
|
|||
int* exit_code)
|
||||
{
|
||||
int c;
|
||||
char const* optarg;
|
||||
char const* optstr;
|
||||
|
||||
*paused = false;
|
||||
*dump_settings = false;
|
||||
|
@ -416,12 +416,12 @@ static bool parse_args(
|
|||
|
||||
tr_optind = 1;
|
||||
|
||||
while ((c = tr_getopt(getUsage(), argc, argv, options, &optarg)) != TR_OPT_DONE)
|
||||
while ((c = tr_getopt(getUsage(), argc, argv, options, &optstr)) != TR_OPT_DONE)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'a':
|
||||
tr_variantDictAddStr(settings, TR_KEY_rpc_whitelist, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_rpc_whitelist, optstr);
|
||||
tr_variantDictAddBool(settings, TR_KEY_rpc_whitelist_enabled, true);
|
||||
break;
|
||||
|
||||
|
@ -434,7 +434,7 @@ static bool parse_args(
|
|||
break;
|
||||
|
||||
case 'c':
|
||||
tr_variantDictAddStr(settings, TR_KEY_watch_dir, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_watch_dir, optstr);
|
||||
tr_variantDictAddBool(settings, TR_KEY_watch_dir_enabled, true);
|
||||
break;
|
||||
|
||||
|
@ -443,7 +443,7 @@ static bool parse_args(
|
|||
break;
|
||||
|
||||
case 941:
|
||||
tr_variantDictAddStr(settings, TR_KEY_incomplete_dir, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_incomplete_dir, optstr);
|
||||
tr_variantDictAddBool(settings, TR_KEY_incomplete_dir_enabled, true);
|
||||
break;
|
||||
|
||||
|
@ -456,9 +456,9 @@ static bool parse_args(
|
|||
break;
|
||||
|
||||
case 'e':
|
||||
if (reopen_log_file(optarg))
|
||||
if (reopen_log_file(optstr))
|
||||
{
|
||||
logfileName = optarg;
|
||||
logfileName = optstr;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -484,7 +484,7 @@ static bool parse_args(
|
|||
break;
|
||||
|
||||
case 'p':
|
||||
tr_variantDictAddInt(settings, TR_KEY_rpc_port, atoi(optarg));
|
||||
tr_variantDictAddInt(settings, TR_KEY_rpc_port, atoi(optstr));
|
||||
break;
|
||||
|
||||
case 't':
|
||||
|
@ -496,19 +496,19 @@ static bool parse_args(
|
|||
break;
|
||||
|
||||
case 'u':
|
||||
tr_variantDictAddStr(settings, TR_KEY_rpc_username, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_rpc_username, optstr);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
tr_variantDictAddStr(settings, TR_KEY_rpc_password, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_rpc_password, optstr);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
tr_variantDictAddStr(settings, TR_KEY_download_dir, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_download_dir, optstr);
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
tr_variantDictAddInt(settings, TR_KEY_peer_port, atoi(optarg));
|
||||
tr_variantDictAddInt(settings, TR_KEY_peer_port, atoi(optstr));
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
|
@ -520,11 +520,11 @@ static bool parse_args(
|
|||
break;
|
||||
|
||||
case 'L':
|
||||
tr_variantDictAddInt(settings, TR_KEY_peer_limit_global, atoi(optarg));
|
||||
tr_variantDictAddInt(settings, TR_KEY_peer_limit_global, atoi(optstr));
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
tr_variantDictAddInt(settings, TR_KEY_peer_limit_per_torrent, atoi(optarg));
|
||||
tr_variantDictAddInt(settings, TR_KEY_peer_limit_per_torrent, atoi(optstr));
|
||||
break;
|
||||
|
||||
case 800:
|
||||
|
@ -544,19 +544,19 @@ static bool parse_args(
|
|||
break;
|
||||
|
||||
case 'i':
|
||||
tr_variantDictAddStr(settings, TR_KEY_bind_address_ipv4, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_bind_address_ipv4, optstr);
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
tr_variantDictAddStr(settings, TR_KEY_bind_address_ipv6, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_bind_address_ipv6, optstr);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
tr_variantDictAddStr(settings, TR_KEY_rpc_bind_address, optarg);
|
||||
tr_variantDictAddStr(settings, TR_KEY_rpc_bind_address, optstr);
|
||||
break;
|
||||
|
||||
case 953:
|
||||
tr_variantDictAddReal(settings, TR_KEY_ratio_limit, atof(optarg));
|
||||
tr_variantDictAddReal(settings, TR_KEY_ratio_limit, atof(optstr));
|
||||
tr_variantDictAddBool(settings, TR_KEY_ratio_limit_enabled, true);
|
||||
break;
|
||||
|
||||
|
@ -565,7 +565,7 @@ static bool parse_args(
|
|||
break;
|
||||
|
||||
case 'x':
|
||||
tr_variantDictAddStr(settings, key_pidfile, optarg);
|
||||
tr_variantDictAddStr(settings, key_pidfile, optstr);
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
|
@ -651,7 +651,7 @@ static void daemon_stop(void* arg)
|
|||
event_base_loopexit(ev_base, NULL);
|
||||
}
|
||||
|
||||
static int daemon_start(void* raw_arg, bool foreground)
|
||||
static int daemon_start(void* varg, bool foreground)
|
||||
{
|
||||
#ifndef HAVE_SYSLOG
|
||||
TR_UNUSED(foreground);
|
||||
|
@ -664,7 +664,7 @@ static int daemon_start(void* raw_arg, bool foreground)
|
|||
struct event* status_ev = NULL;
|
||||
tr_watchdir_t watchdir = NULL;
|
||||
|
||||
struct daemon_data* const arg = raw_arg;
|
||||
auto* arg = static_cast<daemon_data*>(varg);
|
||||
tr_variant* const settings = &arg->settings;
|
||||
char const* const configDir = arg->configDir;
|
||||
|
||||
|
@ -779,7 +779,7 @@ static int daemon_start(void* raw_arg, bool foreground)
|
|||
|
||||
/* Create new timer event to report daemon status */
|
||||
{
|
||||
struct timeval one_sec = { .tv_sec = 1, .tv_usec = 0 };
|
||||
constexpr auto one_sec = timeval{ 1, 0 }; // 1 second
|
||||
status_ev = event_new(ev_base, -1, EV_PERSIST, &periodicUpdate, NULL);
|
||||
|
||||
if (status_ev == NULL)
|
||||
|
@ -905,10 +905,10 @@ int tr_main(int argc, char* argv[])
|
|||
return ret;
|
||||
}
|
||||
|
||||
dtr_callbacks const cb = {
|
||||
.on_start = &daemon_start,
|
||||
.on_stop = &daemon_stop,
|
||||
.on_reconfigure = &daemon_reconfigure,
|
||||
auto constexpr cb = dtr_callbacks{
|
||||
&daemon_start,
|
||||
&daemon_stop,
|
||||
&daemon_reconfigure,
|
||||
};
|
||||
|
||||
tr_error* error = NULL;
|
|
@ -1,6 +1,6 @@
|
|||
project(trutils)
|
||||
|
||||
add_compile_options(${C_WARNING_FLAGS})
|
||||
add_compile_options(${CXX_WARNING_FLAGS})
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
|
@ -17,7 +17,7 @@ foreach(P create edit remote show)
|
|||
"${TR_NAME}-${P}"
|
||||
"${TR_NAME}-${P}.exe")
|
||||
|
||||
add_executable(${TR_NAME}-${P} ${P}.c ${${PROJECT_NAME}_${P}_WIN32_RC_FILE})
|
||||
add_executable(${TR_NAME}-${P} ${P}.cc ${${PROJECT_NAME}_${P}_WIN32_RC_FILE})
|
||||
target_link_libraries(${TR_NAME}-${P} ${TR_NAME})
|
||||
|
||||
install(TARGETS ${TR_NAME}-${P} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
|
|
@ -560,7 +560,7 @@ static char* getEncodedMetainfo(char const* filename)
|
|||
|
||||
if (buf != NULL)
|
||||
{
|
||||
b64 = tr_base64_encode(buf, len, NULL);
|
||||
b64 = static_cast<char*>(tr_base64_encode(buf, len, NULL));
|
||||
tr_free(buf);
|
||||
}
|
||||
|
||||
|
@ -796,8 +796,9 @@ static tr_quark const list_keys[] = {
|
|||
TR_KEY_uploadRatio, //
|
||||
};
|
||||
|
||||
static size_t writeFunc(void* ptr, size_t size, size_t nmemb, void* buf)
|
||||
static size_t writeFunc(void* ptr, size_t size, size_t nmemb, void* vbuf)
|
||||
{
|
||||
auto* const buf = static_cast<evbuffer*>(vbuf);
|
||||
size_t const byteCount = size * nmemb;
|
||||
evbuffer_add(buf, ptr, byteCount);
|
||||
return byteCount;
|
||||
|
@ -808,7 +809,7 @@ static size_t parseResponseHeader(void* ptr, size_t size, size_t nmemb, void* st
|
|||
{
|
||||
TR_UNUSED(stream);
|
||||
|
||||
char const* line = ptr;
|
||||
auto const* const line = static_cast<char const*>(ptr);
|
||||
size_t const line_len = size * nmemb;
|
||||
char const* key = TR_RPC_SESSION_ID_HEADER ": ";
|
||||
size_t const key_len = strlen(key);
|
||||
|
@ -1401,7 +1402,7 @@ static void printPeers(tr_variant* top)
|
|||
static void printPiecesImpl(uint8_t const* raw, size_t raw_len, size_t piece_count)
|
||||
{
|
||||
size_t len = 0;
|
||||
char* const str = tr_base64_decode(raw, raw_len, &len);
|
||||
auto* const str = static_cast<char*>(tr_base64_decode(raw, raw_len, &len));
|
||||
printf(" ");
|
||||
|
||||
size_t piece = 0;
|
|
@ -193,8 +193,9 @@ static void showInfo(tr_info const* inf)
|
|||
tr_free(files);
|
||||
}
|
||||
|
||||
static size_t writeFunc(void* ptr, size_t size, size_t nmemb, void* buf)
|
||||
static size_t writeFunc(void* ptr, size_t size, size_t nmemb, void* vbuf)
|
||||
{
|
||||
auto* buf = static_cast<evbuffer*>(vbuf);
|
||||
size_t const byteCount = size * nmemb;
|
||||
evbuffer_add(buf, ptr, byteCount);
|
||||
return byteCount;
|
Loading…
Add table
Reference in a new issue