From 6c77fa92ce3cc90d551db81a7fffbb49d6daa013 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 24 Sep 2021 09:38:09 -0500 Subject: [PATCH] Port transmission-cli to C++ (#1831) * move transmission-cli to C++ --- Transmission.xcodeproj/project.pbxproj | 8 ++++---- cli/CMakeLists.txt | 4 +++- cli/{cli.c => cli.cc} | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) rename cli/{cli.c => cli.cc} (99%) diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index 41c0c450c..1d83ef545 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -226,7 +226,7 @@ A2AF1C390A3D0F6200F1575D /* FileOutlineView.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2AF1C370A3D0F6200F1575D /* FileOutlineView.mm */; }; A2AF23C816B44FA0003BC59E /* log.cc in Sources */ = {isa = PBXBuildFile; fileRef = A2AF23C616B44FA0003BC59E /* log.cc */; }; A2AF23C916B44FA0003BC59E /* log.h in Headers */ = {isa = PBXBuildFile; fileRef = A2AF23C716B44FA0003BC59E /* log.h */; }; - A2B3FB460E5901E700FF78FB /* cli.c in Sources */ = {isa = PBXBuildFile; fileRef = A2B3FB450E5901E700FF78FB /* cli.c */; }; + A2B3FB460E5901E700FF78FB /* cli.cc in Sources */ = {isa = PBXBuildFile; fileRef = A2B3FB450E5901E700FF78FB /* cli.cc */; }; A2B3FB4C0E59023000FF78FB /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; A2B3FB530E59027100FF78FB /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; A2B5B4E91880665E0071A66A /* ShareTorrentFileHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = A2B5B4E81880665E0071A66A /* ShareTorrentFileHelper.mm */; }; @@ -869,7 +869,7 @@ A2AF1C370A3D0F6200F1575D /* FileOutlineView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FileOutlineView.mm; sourceTree = ""; }; A2AF23C616B44FA0003BC59E /* log.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = log.cc; sourceTree = ""; }; A2AF23C716B44FA0003BC59E /* log.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = log.h; sourceTree = ""; }; - A2B3FB450E5901E700FF78FB /* cli.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cli.c; sourceTree = ""; }; + A2B3FB450E5901E700FF78FB /* cli.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = cli.cc; sourceTree = ""; }; A2B5B4E71880665E0071A66A /* ShareTorrentFileHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareTorrentFileHelper.h; sourceTree = ""; }; A2B5B4E81880665E0071A66A /* ShareTorrentFileHelper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ShareTorrentFileHelper.mm; sourceTree = ""; }; A2B5BB7A0D9C7C2300FCB650 /* es */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = es; path = es.lproj/AddWindow.xib; sourceTree = ""; }; @@ -1554,7 +1554,7 @@ 4DDBB71F09E16BFE00284745 /* CLI */ = { isa = PBXGroup; children = ( - A2B3FB450E5901E700FF78FB /* cli.c */, + A2B3FB450E5901E700FF78FB /* cli.cc */, ); name = CLI; path = cli; @@ -2520,7 +2520,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - A2B3FB460E5901E700FF78FB /* cli.c in Sources */, + A2B3FB460E5901E700FF78FB /* cli.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index a2c97f6b2..c4a82bc9f 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -1,5 +1,7 @@ project(trcli) +add_compile_options(${CXX_WARNING_FLAGS}) + include_directories(${CMAKE_SOURCE_DIR}) tr_win32_app_info(${PROJECT_NAME}_WIN32_RC_FILE @@ -7,7 +9,7 @@ tr_win32_app_info(${PROJECT_NAME}_WIN32_RC_FILE "${TR_NAME}-cli" "${TR_NAME}-cli.exe") -add_executable(${TR_NAME}-cli cli.c ${${PROJECT_NAME}_WIN32_RC_FILE}) +add_executable(${TR_NAME}-cli cli.cc ${${PROJECT_NAME}_WIN32_RC_FILE}) include_directories(${TR_NAME}-cli ${CURL_INCLUDE_DIRS}) target_link_libraries(${TR_NAME}-cli ${TR_NAME}) diff --git a/cli/cli.c b/cli/cli.cc similarity index 99% rename from cli/cli.c rename to cli/cli.cc index 0fbeb8a44..3ae7e7995 100644 --- a/cli/cli.c +++ b/cli/cli.cc @@ -144,13 +144,14 @@ static void onTorrentFileDownloaded( long response_code, void const* response, size_t response_byte_count, - void* ctor) + void* vctor) { TR_UNUSED(session); TR_UNUSED(did_connect); TR_UNUSED(did_timeout); TR_UNUSED(response_code); + auto* ctor = static_cast(vctor); tr_ctorSetMetainfo(ctor, response, response_byte_count); waitingOnWeb = false; }