// This file Copyright © Transmission authors and contributors. // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. #include #include /* fprintf () */ #include /* atoi () */ #include #include #include #include #include #include #include #include #include /* tr_wait_msec */ #include #include #include #include // tr_sessionFetch() /*** **** ***/ static auto constexpr MemK = size_t{ 1024 }; static char constexpr MemKStr[] = "KiB"; static char constexpr MemMStr[] = "MiB"; static char constexpr MemGStr[] = "GiB"; static char constexpr MemTStr[] = "TiB"; static auto constexpr DiskK = size_t{ 1000 }; static char constexpr DiskKStr[] = "kB"; static char constexpr DiskMStr[] = "MB"; static char constexpr DiskGStr[] = "GB"; static char constexpr DiskTStr[] = "TB"; static auto constexpr SpeedK = size_t{ 1000 }; #define SPEED_K_STR "kB/s" static char constexpr SpeedKStr[] = SPEED_K_STR; static char constexpr SpeedMStr[] = "MB/s"; static char constexpr SpeedGStr[] = "GB/s"; static char constexpr SpeedTStr[] = "TB/s"; /*** **** ***/ static auto constexpr LineWidth = int{ 80 }; static char constexpr MyConfigName[] = "transmission"; static char constexpr MyReadableName[] = "transmission-cli"; static char constexpr Usage [] = "A fast and easy BitTorrent client\n" "\n" "Usage: transmission-cli [options] "; static bool showVersion = false; static bool verify = false; static sig_atomic_t gotsig = false; static sig_atomic_t manualUpdate = false; static char const* torrentPath = nullptr; static auto constexpr Options = std::array{ { { 'b', "blocklist", "Enable peer blocklists", "b", false, nullptr }, { 'B', "no-blocklist", "Disable peer blocklists", "B", false, nullptr }, { 'd', "downlimit", "Set max download speed in " SPEED_K_STR, "d", true, "" }, { 'D', "no-downlimit", "Don't limit the download speed", "D", false, nullptr }, { 910, "encryption-required", "Encrypt all peer connections", "er", false, nullptr }, { 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", false, nullptr }, { 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", false, nullptr }, { 'f', "finish", "Run a script when the torrent finishes", "f", true, "