From 3055e03b7eabed13d9e0fa04dab241b46a2e70b8 Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 3 Dec 2020 19:45:16 +0700 Subject: [PATCH] Cleanup --- src/Summary.cpp | 8 ++++---- src/backend/cpu/interfaces/ICpuInfo.h | 10 ++-------- src/base/io/Console.h | 6 ++++++ src/base/tools/Cvt.cpp | 18 ++++++++++++++++++ src/base/tools/Cvt.h | 3 +++ 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/Summary.cpp b/src/Summary.cpp index a026c938c..e96a222da 100644 --- a/src/Summary.cpp +++ b/src/Summary.cpp @@ -160,11 +160,11 @@ static void print_threads(Config *config) static void print_commands(Config *) { if (Log::isColors()) { - Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BG(WHITE_BOLD_S "h") WHITE_BOLD("ashrate, ") - MAGENTA_BG(WHITE_BOLD_S "p") WHITE_BOLD("ause, ") - MAGENTA_BG(WHITE_BOLD_S "r") WHITE_BOLD("esume, ") + Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BG_BOLD("h") WHITE_BOLD("ashrate, ") + MAGENTA_BG_BOLD("p") WHITE_BOLD("ause, ") + MAGENTA_BG_BOLD("r") WHITE_BOLD("esume, ") WHITE_BOLD("re") MAGENTA_BG(WHITE_BOLD_S "s") WHITE_BOLD("ults, ") - MAGENTA_BG(WHITE_BOLD_S "c") WHITE_BOLD("onnection") + MAGENTA_BG_BOLD("c") WHITE_BOLD("onnection") ); } else { diff --git a/src/backend/cpu/interfaces/ICpuInfo.h b/src/backend/cpu/interfaces/ICpuInfo.h index 9270ca090..7464781a1 100644 --- a/src/backend/cpu/interfaces/ICpuInfo.h +++ b/src/backend/cpu/interfaces/ICpuInfo.h @@ -1,12 +1,6 @@ /* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig + * Copyright (c) 2018-2020 SChernykh + * Copyright (c) 2016-2020 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 diff --git a/src/base/io/Console.h b/src/base/io/Console.h index ecd07bdb7..65523b94c 100644 --- a/src/base/io/Console.h +++ b/src/base/io/Console.h @@ -28,6 +28,12 @@ using uv_handle_t = struct uv_handle_s; using uv_stream_t = struct uv_stream_s; using uv_tty_t = struct uv_tty_s; +#ifdef XMRIG_OS_WIN +using ssize_t = intptr_t; +#else +# include +#endif + namespace xmrig { diff --git a/src/base/tools/Cvt.cpp b/src/base/tools/Cvt.cpp index f0fc7209a..c80c022c0 100644 --- a/src/base/tools/Cvt.cpp +++ b/src/base/tools/Cvt.cpp @@ -237,6 +237,24 @@ xmrig::Buffer xmrig::Cvt::randomBytes(const size_t size) } +rapidjson::Value xmrig::Cvt::toHex(const Buffer &data, rapidjson::Document &doc) +{ + return toHex(data.data(), data.size(), doc); +} + + +rapidjson::Value xmrig::Cvt::toHex(const std::string &data, rapidjson::Document &doc) +{ + return toHex(reinterpret_cast(data.data()), data.size(), doc); +} + + +rapidjson::Value xmrig::Cvt::toHex(const uint8_t *in, size_t size, rapidjson::Document &doc) +{ + return toHex(in, size).toJSON(doc); +} + + xmrig::String xmrig::Cvt::toHex(const uint8_t *in, size_t size) { assert(in != nullptr && size > 0); diff --git a/src/base/tools/Cvt.h b/src/base/tools/Cvt.h index 3fbe12e0f..8b67b1466 100644 --- a/src/base/tools/Cvt.h +++ b/src/base/tools/Cvt.h @@ -48,6 +48,9 @@ public: static bool toHex(char *hex, size_t hex_maxlen, const uint8_t *bin, size_t bin_len); static Buffer fromHex(const char *in, size_t size); static Buffer randomBytes(size_t size); + static rapidjson::Value toHex(const Buffer &data, rapidjson::Document &doc); + static rapidjson::Value toHex(const std::string &data, rapidjson::Document &doc); + static rapidjson::Value toHex(const uint8_t *in, size_t size, rapidjson::Document &doc); static String toHex(const uint8_t *in, size_t size); };