/* XMRig * Copyright 2010 Jeff Garzik * Copyright 2012-2014 pooler * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett * Copyright 2018-2019 SChernykh * Copyright 2016-2019 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "crypto/common/Algorithm.h" #ifdef _MSC_VER # define strncasecmp _strnicmp # define strcasecmp _stricmp #endif #ifndef ARRAY_SIZE # define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #endif namespace xmrig { struct AlgoName { const char *name; const char *shortName; const Algorithm::Id id; }; static AlgoName const algorithm_names[] = { { "cryptonight/0", "cn/0", Algorithm::CN_0 }, { "cryptonight", "cn", Algorithm::CN_0 }, { "cryptonight/1", "cn/1", Algorithm::CN_1 }, { "cryptonight-monerov7", nullptr, Algorithm::CN_1 }, { "cryptonight_v7", nullptr, Algorithm::CN_1 }, { "cryptonight/2", "cn/2", Algorithm::CN_2 }, { "cryptonight-monerov8", nullptr, Algorithm::CN_2 }, { "cryptonight_v8", nullptr, Algorithm::CN_2 }, { "cryptonight/r", "cn/r", Algorithm::CN_R }, { "cryptonight_r", nullptr, Algorithm::CN_R }, { "cryptonight/wow", "cn/wow", Algorithm::CN_WOW }, { "cryptonight/fast", "cn/fast", Algorithm::CN_FAST }, { "cryptonight/msr", "cn/msr", Algorithm::CN_FAST }, { "cryptonight/half", "cn/half", Algorithm::CN_HALF }, { "cryptonight/xao", "cn/xao", Algorithm::CN_XAO }, { "cryptonight_alloy", nullptr, Algorithm::CN_XAO }, { "cryptonight/rto", "cn/rto", Algorithm::CN_RTO }, { "cryptonight/rwz", "cn/rwz", Algorithm::CN_RWZ }, { "cryptonight/zls", "cn/zls", Algorithm::CN_ZLS }, { "cryptonight/double", "cn/double", Algorithm::CN_ZLS }, # ifdef XMRIG_ALGO_CN_GPU { "cryptonight/gpu", "cn/gpu", Algorithm::CN_GPU }, { "cryptonight_gpu", nullptr, Algorithm::CN_GPU }, # endif # ifdef XMRIG_ALGO_CN_LITE { "cryptonight-lite/0", "cn-lite/0", Algorithm::CN_LITE_0 }, { "cryptonight-lite/1", "cn-lite/1", Algorithm::CN_LITE_1 }, { "cryptonight-lite", "cn-lite", Algorithm::CN_LITE_1 }, { "cryptonight-light", "cn-light", Algorithm::CN_LITE_1 }, { "cryptonight_lite", nullptr, Algorithm::CN_LITE_1 }, { "cryptonight-aeonv7", nullptr, Algorithm::CN_LITE_1 }, { "cryptonight_lite_v7", nullptr, Algorithm::CN_LITE_1 }, # endif # ifdef XMRIG_ALGO_CN_HEAVY { "cryptonight-heavy/0", "cn-heavy/0", Algorithm::CN_HEAVY_0 }, { "cryptonight-heavy", "cn-heavy", Algorithm::CN_HEAVY_0 }, { "cryptonight_heavy", nullptr, Algorithm::CN_HEAVY_0 }, { "cryptonight-heavy/xhv", "cn-heavy/xhv", Algorithm::CN_HEAVY_XHV }, { "cryptonight_haven", nullptr, Algorithm::CN_HEAVY_XHV }, { "cryptonight-heavy/tube", "cn-heavy/tube", Algorithm::CN_HEAVY_TUBE }, { "cryptonight-bittube2", nullptr, Algorithm::CN_HEAVY_TUBE }, # endif # ifdef XMRIG_ALGO_CN_PICO { "cryptonight-pico", "cn-pico", Algorithm::CN_PICO }, { "cryptonight-pico/trtl", "cn-pico/trtl", Algorithm::CN_PICO }, { "cryptonight-turtle", "cn-trtl", Algorithm::CN_PICO }, { "cryptonight-ultralite", "cn-ultralite", Algorithm::CN_PICO }, { "cryptonight_turtle", "cn_turtle", Algorithm::CN_PICO }, # endif }; } /* namespace xmrig */ const char *xmrig::Algorithm::name(bool shortName) const { for (size_t i = 0; i < ARRAY_SIZE(algorithm_names); i++) { if (algorithm_names[i].id == m_id) { return shortName ? algorithm_names[i].shortName : algorithm_names[i].name; } } return "invalid"; } xmrig::Algorithm::Id xmrig::Algorithm::parse(const char *name) { if (name == nullptr || strlen(name) < 1) { return INVALID; } for (size_t i = 0; i < ARRAY_SIZE(algorithm_names); i++) { if ((strcasecmp(name, algorithm_names[i].name) == 0) || (algorithm_names[i].shortName != nullptr && strcasecmp(name, algorithm_names[i].shortName) == 0)) { return algorithm_names[i].id; } } return INVALID; }