From abc60025786284987b4d95b07623e12c0e2ef01a Mon Sep 17 00:00:00 2001 From: atraczyk <andreastraczyk@gmail.com> Date: Tue, 4 Oct 2016 13:33:19 -0400 Subject: [PATCH] eth: simplify Change-Id: I44a0e1d4a5dc0acbe249ea7da8d3c81d73d1827f --- MSVC/ring-daemon.vcxproj | 12 +- MSVC/ring-daemon.vcxproj.filters | 28 +--- src/{sip/base64.c => base64.cpp} | 37 +++++ src/{sip => }/base64.h | 48 +----- src/ringdht/eth/libdevcore/Assertions.h | 111 ------------- src/ringdht/eth/libdevcore/Base64.cpp | 146 ----------------- src/ringdht/eth/libdevcore/Base64.h | 62 -------- src/ringdht/eth/libdevcore/Diff.h | 52 ------ src/ringdht/eth/libdevcore/Makefile.am | 2 - src/ringdht/eth/libdevcore/Terminal.h | 148 ------------------ src/ringdht/eth/libdevcore/UndefMacros.h | 46 ------ src/ringdht/eth/libdevcore/concurrent_queue.h | 60 ------- src/ringdht/eth/libdevcore/debugbreak.h | 125 --------------- src/ringdht/eth/libdevcrypto/CryptoPP.cpp | 23 +-- src/ringdht/ringaccount.cpp | 2 +- src/sip/sdp.cpp | 2 +- 16 files changed, 50 insertions(+), 854 deletions(-) rename src/{sip/base64.c => base64.cpp} (81%) rename src/{sip => }/base64.h (63%) delete mode 100644 src/ringdht/eth/libdevcore/Assertions.h delete mode 100644 src/ringdht/eth/libdevcore/Base64.cpp delete mode 100644 src/ringdht/eth/libdevcore/Base64.h delete mode 100644 src/ringdht/eth/libdevcore/Diff.h delete mode 100644 src/ringdht/eth/libdevcore/Terminal.h delete mode 100644 src/ringdht/eth/libdevcore/UndefMacros.h delete mode 100644 src/ringdht/eth/libdevcore/concurrent_queue.h delete mode 100644 src/ringdht/eth/libdevcore/debugbreak.h diff --git a/MSVC/ring-daemon.vcxproj b/MSVC/ring-daemon.vcxproj index 360135cb33..b9aea63141 100644 --- a/MSVC/ring-daemon.vcxproj +++ b/MSVC/ring-daemon.vcxproj @@ -454,7 +454,7 @@ <ClInclude Include="..\src\account_schema.h" /> <ClInclude Include="..\src\archiver.h" /> <ClInclude Include="..\src\array_size.h" /> - <ClInclude Include="..\src\ring_base64.h" /> + <ClInclude Include="..\src\base64.h" /> <ClInclude Include="..\src\call.h" /> <ClInclude Include="..\src\call_factory.h" /> <ClInclude Include="..\src\client\ring_signal.h" /> @@ -532,14 +532,9 @@ <ClInclude Include="..\src\preferences.h" /> <ClInclude Include="..\src\rational.h" /> <ClInclude Include="..\src\registration_states.h" /> - <ClInclude Include="..\src\ringdht\eth\libdevcore\Assertions.h" /> - <ClInclude Include="..\src\ringdht\eth\libdevcore\Base64.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\boost_multiprecision_number_compare_bug_workaround.hpp" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\Common.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\CommonData.h" /> - <ClInclude Include="..\src\ringdht\eth\libdevcore\concurrent_queue.h" /> - <ClInclude Include="..\src\ringdht\eth\libdevcore\debugbreak.h" /> - <ClInclude Include="..\src\ringdht\eth\libdevcore\Diff.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\Exceptions.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\FixedHash.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\Guards.h" /> @@ -547,8 +542,6 @@ <ClInclude Include="..\src\ringdht\eth\libdevcore\picosha2.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\RLP.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\SHA3.h" /> - <ClInclude Include="..\src\ringdht\eth\libdevcore\Terminal.h" /> - <ClInclude Include="..\src\ringdht\eth\libdevcore\UndefMacros.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcore\vector_ref.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcrypto\AES.h" /> <ClInclude Include="..\src\ringdht\eth\libdevcrypto\Common.h" /> @@ -593,7 +586,7 @@ <ClCompile Include="..\src\account.cpp" /> <ClCompile Include="..\src\account_factory.cpp" /> <ClCompile Include="..\src\archiver.cpp" /> - <ClCompile Include="..\src\ring_base64.cpp" /> + <ClCompile Include="..\src\base64.cpp" /> <ClCompile Include="..\src\buildinfo.cpp" /> <ClCompile Include="..\src\call.cpp" /> <ClCompile Include="..\src\call_factory.cpp" /> @@ -655,7 +648,6 @@ <ClCompile Include="..\src\plugin_loader_dl.cpp" /> <ClCompile Include="..\src\plugin_manager.cpp" /> <ClCompile Include="..\src\preferences.cpp" /> - <ClCompile Include="..\src\ringdht\eth\libdevcore\Base64.cpp" /> <ClCompile Include="..\src\ringdht\eth\libdevcore\Common.cpp" /> <ClCompile Include="..\src\ringdht\eth\libdevcore\CommonData.cpp" /> <ClCompile Include="..\src\ringdht\eth\libdevcore\FixedHash.cpp" /> diff --git a/MSVC/ring-daemon.vcxproj.filters b/MSVC/ring-daemon.vcxproj.filters index 548351f9f6..b436e25a3f 100644 --- a/MSVC/ring-daemon.vcxproj.filters +++ b/MSVC/ring-daemon.vcxproj.filters @@ -469,27 +469,12 @@ <ClInclude Include="..\src\ringdht\eth\libdevcrypto\Exceptions.h"> <Filter>Header Files\ringdht\eth\libdevcrypto</Filter> </ClInclude> - <ClInclude Include="..\src\ringdht\eth\libdevcore\Assertions.h"> - <Filter>Header Files\ringdht\eth\libdevcore</Filter> - </ClInclude> - <ClInclude Include="..\src\ringdht\eth\libdevcore\Base64.h"> - <Filter>Header Files\ringdht\eth\libdevcore</Filter> - </ClInclude> <ClInclude Include="..\src\ringdht\eth\libdevcore\Common.h"> <Filter>Header Files\ringdht\eth\libdevcore</Filter> </ClInclude> <ClInclude Include="..\src\ringdht\eth\libdevcore\CommonData.h"> <Filter>Header Files\ringdht\eth\libdevcore</Filter> </ClInclude> - <ClInclude Include="..\src\ringdht\eth\libdevcore\concurrent_queue.h"> - <Filter>Header Files\ringdht\eth\libdevcore</Filter> - </ClInclude> - <ClInclude Include="..\src\ringdht\eth\libdevcore\debugbreak.h"> - <Filter>Header Files\ringdht\eth\libdevcore</Filter> - </ClInclude> - <ClInclude Include="..\src\ringdht\eth\libdevcore\Diff.h"> - <Filter>Header Files\ringdht\eth\libdevcore</Filter> - </ClInclude> <ClInclude Include="..\src\ringdht\eth\libdevcore\Exceptions.h"> <Filter>Header Files\ringdht\eth\libdevcore</Filter> </ClInclude> @@ -511,12 +496,6 @@ <ClInclude Include="..\src\ringdht\eth\libdevcore\SHA3.h"> <Filter>Header Files\ringdht\eth\libdevcore</Filter> </ClInclude> - <ClInclude Include="..\src\ringdht\eth\libdevcore\Terminal.h"> - <Filter>Header Files\ringdht\eth\libdevcore</Filter> - </ClInclude> - <ClInclude Include="..\src\ringdht\eth\libdevcore\UndefMacros.h"> - <Filter>Header Files\ringdht\eth\libdevcore</Filter> - </ClInclude> <ClInclude Include="..\src\ringdht\eth\libdevcore\vector_ref.h"> <Filter>Header Files\ringdht\eth\libdevcore</Filter> </ClInclude> @@ -529,7 +508,7 @@ <ClInclude Include="..\src\thread_pool.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\src\ring_base64.h"> + <ClInclude Include="..\src\base64.h"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> @@ -804,9 +783,6 @@ <ClCompile Include="..\src\media\video\uwpvideo\video_device_monitor_impl.cpp"> <Filter>Source Files\media\video\uwpvideo</Filter> </ClCompile> - <ClCompile Include="..\src\ringdht\eth\libdevcore\Base64.cpp"> - <Filter>Source Files\ringdht\eth\libdevcore</Filter> - </ClCompile> <ClCompile Include="..\src\ringdht\eth\libdevcore\Common.cpp"> <Filter>Source Files\ringdht\eth\libdevcore</Filter> </ClCompile> @@ -846,7 +822,7 @@ <ClCompile Include="..\src\thread_pool.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="..\src\ring_base64.cpp"> + <ClCompile Include="..\src\base64.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> diff --git a/src/sip/base64.c b/src/base64.cpp similarity index 81% rename from src/sip/base64.c rename to src/base64.cpp index 707352ad1d..d14812afd3 100644 --- a/src/sip/base64.c +++ b/src/base64.cpp @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "base64.h" + #include <stdint.h> #include <stdlib.h> @@ -109,3 +111,38 @@ uint8_t *ring_base64_decode(const char *input, size_t input_length, return output; } + +namespace ring { +namespace base64 { + +std::string +encode(const std::vector<uint8_t>::const_iterator begin, + const std::vector<uint8_t>::const_iterator end) +{ + size_t output_length = 4 * ((std::distance(begin, end) + 2) / 3); + std::string out; + out.resize(output_length); + ring_base64_encode(&(*begin), std::distance(begin, end), + &(*out.begin()), &output_length); + out.resize(output_length); + return out; +} + +std::string +encode(const std::vector<uint8_t>& dat) +{ + return encode(dat.cbegin(), dat.cend()); +} + +std::vector<uint8_t> +decode(const std::string& str) +{ + size_t output_length = str.length() / 4 * 3 + 2; + std::vector<uint8_t> output; + output.resize(output_length); + ring_base64_decode(str.data(), str.size(), output.data(), &output_length); + output.resize(output_length); + return output; +} + +}} // namespace ring::base64 diff --git a/src/sip/base64.h b/src/base64.h similarity index 63% rename from src/sip/base64.h rename to src/base64.h index 2e2069114e..80b53c3521 100644 --- a/src/sip/base64.h +++ b/src/base64.h @@ -16,14 +16,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef H_BASE64 -#define H_BASE64 +#pragma once -#ifdef __cplusplus -extern "C" { -#endif - -#include "stdint.h" +#include <stdint.h> +#include <stddef.h> /** * Encode a buffer in base64. @@ -51,46 +47,14 @@ char *ring_base64_encode(const uint8_t *input, size_t input_length, uint8_t *ring_base64_decode(const char *input, size_t input_length, uint8_t *output, size_t *output_length); -#ifdef __cplusplus -} -#endif - #include <string> #include <vector> namespace ring { namespace base64 { -std::string -encode(const std::vector<uint8_t>::const_iterator begin, - const std::vector<uint8_t>::const_iterator end) -{ - size_t output_length = 4 * ((std::distance(begin, end) + 2) / 3); - std::string out; - out.resize(output_length); - ring_base64_encode(&(*begin), std::distance(begin, end), - &(*out.begin()), &output_length); - out.resize(output_length); - return out; -} - -std::string -encode(const std::vector<uint8_t>& dat) -{ - return encode(dat.cbegin(), dat.cend()); -} - -std::vector<uint8_t> -decode(const std::string& str) -{ - size_t output_length = str.length() / 4 * 3 + 2; - std::vector<uint8_t> output; - output.resize(output_length); - ring_base64_decode(str.data(), str.size(), output.data(), &output_length); - output.resize(output_length); - return output; -} +std::string encode(const std::vector<uint8_t>::const_iterator begin, const std::vector<uint8_t>::const_iterator end); +std::string encode(const std::vector<uint8_t>& dat); +std::vector<uint8_t> decode(const std::string& str); }} // namespace ring::base64 - -#endif // H_BASE64 diff --git a/src/ringdht/eth/libdevcore/Assertions.h b/src/ringdht/eth/libdevcore/Assertions.h deleted file mode 100644 index 7b4a4a7658..0000000000 --- a/src/ringdht/eth/libdevcore/Assertions.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - This file is part of cpp-ethereum. - - cpp-ethereum 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. - - cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. -*/ -/** - * @file Assertions.h - * @author Christian <c@ethdev.com> - * @date 2015 - * - * Assertion handling. - */ - -#pragma once - -#include "Exceptions.h" -#include "debugbreak.h" - -namespace dev -{ - -#if defined(_MSC_VER) -#define ETH_FUNC __FUNCSIG__ -#elif defined(__GNUC__) -#define ETH_FUNC __PRETTY_FUNCTION__ -#else -#define ETH_FUNC __func__ -#endif - -#define asserts(A) ::dev::assertAux(A, #A, __LINE__, __FILE__, ETH_FUNC) -#define assertsEqual(A, B) ::dev::assertEqualAux(A, B, #A, #B, __LINE__, __FILE__, ETH_FUNC) - -inline bool assertAux(bool _a, char const* _aStr, unsigned _line, char const* _file, char const* _func) -{ - bool ret = _a; - if (!ret) - { - std::cerr << "Assertion failed:" << _aStr << " [func=" << _func << ", line=" << _line << ", file=" << _file << "]" << std::endl; -#if ETH_DEBUG - debug_break(); -#endif - } - return !ret; -} - -template<class A, class B> -inline bool assertEqualAux(A const& _a, B const& _b, char const* _aStr, char const* _bStr, unsigned _line, char const* _file, char const* _func) -{ - bool ret = _a == _b; - if (!ret) - { - std::cerr << "Assertion failed: " << _aStr << " == " << _bStr << " [func=" << _func << ", line=" << _line << ", file=" << _file << "]" << std::endl; - std::cerr << " Fail equality: " << _a << "==" << _b << std::endl; -#if ETH_DEBUG - debug_break(); -#endif - } - return !ret; -} - -/// Assertion that throws an exception containing the given description if it is not met. -/// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong."); -/// Do NOT supply an exception object as the second parameter. -#define assertThrow(_condition, _ExceptionType, _description) \ - ::dev::assertThrowAux<_ExceptionType>(_condition, _description, __LINE__, __FILE__, ETH_FUNC) - -using errinfo_comment = boost::error_info<struct tag_comment, std::string>; - -template <class _ExceptionType> -inline void assertThrowAux( - bool _condition, - ::std::string const& _errorDescription, - unsigned _line, - char const* _file, - char const* _function -) -{ - if (!_condition) - ::boost::throw_exception( - _ExceptionType() << - ::dev::errinfo_comment(_errorDescription) << - ::boost::throw_function(_function) << - ::boost::throw_file(_file) << - ::boost::throw_line(_line) - ); -} - -template <class _ExceptionType> -inline void assertThrowAux( - void const* _pointer, - ::std::string const& _errorDescription, - unsigned _line, - char const* _file, - char const* _function -) -{ - assertThrowAux<_ExceptionType>(_pointer != nullptr, _errorDescription, _line, _file, _function); -} - -} diff --git a/src/ringdht/eth/libdevcore/Base64.cpp b/src/ringdht/eth/libdevcore/Base64.cpp deleted file mode 100644 index 8ee2b29f72..0000000000 --- a/src/ringdht/eth/libdevcore/Base64.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - base64.cpp and base64.h - - Copyright (C) 2004-2008 René Nyffenegger - - This source code is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this source code must not be misrepresented; you must not - claim that you wrote the original source code. If you use this source code - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original source code. - - 3. This notice may not be removed or altered from any source distribution. - - René Nyffenegger rene.nyffenegger@adp-gmbh.ch -*/ -/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// Originally by René Nyffenegger, modified by some other guy and then devified by Gav Wood. - -#include "Base64.h" - -using namespace std; -using namespace dev; - -static inline bool is_base64(byte c) -{ - return (isalnum(c) || (c == '+') || (c == '/')); -} - -static inline byte find_base64_char_index(byte c) -{ - if ('A' <= c && c <= 'Z') return c - 'A'; - else if ('a' <= c && c <= 'z') return c - 'a' + 1 + find_base64_char_index('Z'); - else if ('0' <= c && c <= '9') return c - '0' + 1 + find_base64_char_index('z'); - else if (c == '+') return 1 + find_base64_char_index('9'); - else if (c == '/') return 1 + find_base64_char_index('+'); - else return 1 + find_base64_char_index('/'); -} - -string dev::toBase64(bytesConstRef _in) -{ - static const char base64_chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - - string ret; - int i = 0; - int j = 0; - byte char_array_3[3]; - byte char_array_4[4]; - - auto buf = _in.data(); - auto bufLen = _in.size(); - - while (bufLen--) - { - char_array_3[i++] = *(buf++); - if (i == 3) - { - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for (i = 0; i < 4; i++) - ret += base64_chars[char_array_4[i]]; - i = 0; - } - } - - if (i) - { - for (j = i; j < 3; j++) - char_array_3[j] = '\0'; - - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for (j = 0; j < i + 1; j++) - ret += base64_chars[char_array_4[j]]; - - while (i++ < 3) - ret += '='; - } - - return ret; -} - -bytes dev::fromBase64(string const& encoded_string) -{ - auto in_len = encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - byte char_array_3[3]; - byte char_array_4[4]; - bytes ret; - - while (in_len-- && encoded_string[in_] != '=' && is_base64(encoded_string[in_])) - { - char_array_4[i++] = encoded_string[in_]; in_++; - if (i == 4) - { - for (i = 0; i < 4; i++) - char_array_4[i] = find_base64_char_index(char_array_4[i]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (i = 0; (i < 3); i++) - ret.push_back(char_array_3[i]); - i = 0; - } - } - - if (i) - { - for (j = i; j < 4; j++) - char_array_4[j] = 0; - - for (j = 0; j < 4; j++) - char_array_4[j] = find_base64_char_index(char_array_4[j]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (j = 0; j < i - 1; j++) - ret.push_back(char_array_3[j]); - } - - return ret; -} diff --git a/src/ringdht/eth/libdevcore/Base64.h b/src/ringdht/eth/libdevcore/Base64.h deleted file mode 100644 index 42f454a22a..0000000000 --- a/src/ringdht/eth/libdevcore/Base64.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - base64.cpp and base64.h - - Copyright (C) 2004-2008 René Nyffenegger - - This source code is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this source code must not be misrepresented; you must not - claim that you wrote the original source code. If you use this source code - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original source code. - - 3. This notice may not be removed or altered from any source distribution. - - René Nyffenegger rene.nyffenegger@adp-gmbh.ch -*/ -/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// Originally by René Nyffenegger. -/// DEVified by Gav Wood. -#pragma once - -#include <string> -#include "Common.h" -#include "FixedHash.h" - -namespace dev -{ - -std::string toBase64(bytesConstRef _in); -bytes fromBase64(std::string const& _in); - -template <size_t N> inline std::string toBase36(FixedHash<N> const& _h) -{ - static char const* c_alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - typename FixedHash<N>::Arith a = _h; - std::string ret; - for (; a > 0; a /= 36) - { - unsigned r = (unsigned)(a - a / 36 * 36); // boost's % is broken - ret = c_alphabet[r] + ret; - } - return ret; -} - -template <size_t N> inline FixedHash<N> fromBase36(std::string const& _h) -{ - typename FixedHash<N>::Arith ret = 0; - for (char c: _h) - ret = ret * 36 + (c < 'A' ? c - '0' : (c - 'A' + 10)); - return ret; -} - -} diff --git a/src/ringdht/eth/libdevcore/Diff.h b/src/ringdht/eth/libdevcore/Diff.h deleted file mode 100644 index fa5f6be2d2..0000000000 --- a/src/ringdht/eth/libdevcore/Diff.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - This file is part of cpp-ethereum. - - cpp-ethereum 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. - - cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. -*/ -/** @file Diff.h - * @author Gav Wood <i@gavwood.com> - * @date 2014 - */ - -#pragma once - -namespace dev -{ - -enum class ExistDiff -{ - Same, - New, - Dead -}; - -template <class T> -class Diff -{ -public: - Diff() {} - Diff(T _from, T _to): m_from(_from), m_to(_to) {} - - T const& from() const { return m_from; } - T const& to() const { return m_to; } - - explicit operator bool() const { return m_from != m_to; } - -private: - T m_from; - T m_to; -}; - -} - diff --git a/src/ringdht/eth/libdevcore/Makefile.am b/src/ringdht/eth/libdevcore/Makefile.am index 17c7a030af..24aebec25b 100644 --- a/src/ringdht/eth/libdevcore/Makefile.am +++ b/src/ringdht/eth/libdevcore/Makefile.am @@ -7,7 +7,6 @@ libdevcore_la_CXXFLAGS = @CXXFLAGS@ libdevcore_la_SOURCES = FixedHash.cpp \ Hash.cpp \ Guards.cpp \ - Base64.cpp \ Common.cpp \ RLP.cpp \ SHA3.cpp \ @@ -16,7 +15,6 @@ libdevcore_la_SOURCES = FixedHash.cpp \ noinst_HEADERS = FixedHash.h \ Hash.h \ Guards.h \ - Base64.h \ Common.h \ RLP.h \ SHA3.h \ diff --git a/src/ringdht/eth/libdevcore/Terminal.h b/src/ringdht/eth/libdevcore/Terminal.h deleted file mode 100644 index d46c302735..0000000000 --- a/src/ringdht/eth/libdevcore/Terminal.h +++ /dev/null @@ -1,148 +0,0 @@ -#pragma once - -namespace dev -{ -namespace con -{ - -#if defined(_WIN32) - -#define EthReset "" // Text Reset - -#define EthReset "" // Text Reset - - // Regular Colors -#define EthBlack "" // Black -#define EthCoal "" // Black -#define EthGray "" // White -#define EthWhite "" // White -#define EthMaroon "" // Red -#define EthRed "" // Red -#define EthGreen "" // Green -#define EthLime "" // Green -#define EthOrange "" // Yellow -#define EthYellow "" // Yellow -#define EthNavy "" // Blue -#define EthBlue "" // Blue -#define EthViolet "" // Purple -#define EthPurple "" // Purple -#define EthTeal "" // Cyan -#define EthCyan "" // Cyan - -#define EthBlackBold "" // Black -#define EthCoalBold "" // Black -#define EthGrayBold "" // White -#define EthWhiteBold "" // White -#define EthMaroonBold "" // Red -#define EthRedBold "" // Red -#define EthGreenBold "" // Green -#define EthLimeBold "" // Green -#define EthOrangeBold "" // Yellow -#define EthYellowBold "" // Yellow -#define EthNavyBold "" // Blue -#define EthBlueBold "" // Blue -#define EthVioletBold "" // Purple -#define EthPurpleBold "" // Purple -#define EthTealBold "" // Cyan -#define EthCyanBold "" // Cyan - - // Background -#define EthOnBlack "" // Black -#define EthOnCoal "" // Black -#define EthOnGray "" // White -#define EthOnWhite "" // White -#define EthOnMaroon "" // Red -#define EthOnRed "" // Red -#define EthOnGreen "" // Green -#define EthOnLime "" // Green -#define EthOnOrange "" // Yellow -#define EthOnYellow "" // Yellow -#define EthOnNavy "" // Blue -#define EthOnBlue "" // Blue -#define EthOnViolet "" // Purple -#define EthOnPurple "" // Purple -#define EthOnTeal "" // Cyan -#define EthOnCyan "" // Cyan - - // Underline -#define EthBlackUnder "" // Black -#define EthGrayUnder "" // White -#define EthMaroonUnder "" // Red -#define EthGreenUnder "" // Green -#define EthOrangeUnder "" // Yellow -#define EthNavyUnder "" // Blue -#define EthVioletUnder "" // Purple -#define EthTealUnder "" // Cyan - -#else - -#define EthReset "\x1b[0m" // Text Reset - -// Regular Colors -#define EthBlack "\x1b[30m" // Black -#define EthCoal "\x1b[90m" // Black -#define EthGray "\x1b[37m" // White -#define EthWhite "\x1b[97m" // White -#define EthMaroon "\x1b[31m" // Red -#define EthRed "\x1b[91m" // Red -#define EthGreen "\x1b[32m" // Green -#define EthLime "\x1b[92m" // Green -#define EthOrange "\x1b[33m" // Yellow -#define EthYellow "\x1b[93m" // Yellow -#define EthNavy "\x1b[34m" // Blue -#define EthBlue "\x1b[94m" // Blue -#define EthViolet "\x1b[35m" // Purple -#define EthPurple "\x1b[95m" // Purple -#define EthTeal "\x1b[36m" // Cyan -#define EthCyan "\x1b[96m" // Cyan - -#define EthBlackBold "\x1b[1;30m" // Black -#define EthCoalBold "\x1b[1;90m" // Black -#define EthGrayBold "\x1b[1;37m" // White -#define EthWhiteBold "\x1b[1;97m" // White -#define EthMaroonBold "\x1b[1;31m" // Red -#define EthRedBold "\x1b[1;91m" // Red -#define EthGreenBold "\x1b[1;32m" // Green -#define EthLimeBold "\x1b[1;92m" // Green -#define EthOrangeBold "\x1b[1;33m" // Yellow -#define EthYellowBold "\x1b[1;93m" // Yellow -#define EthNavyBold "\x1b[1;34m" // Blue -#define EthBlueBold "\x1b[1;94m" // Blue -#define EthVioletBold "\x1b[1;35m" // Purple -#define EthPurpleBold "\x1b[1;95m" // Purple -#define EthTealBold "\x1b[1;36m" // Cyan -#define EthCyanBold "\x1b[1;96m" // Cyan - -// Background -#define EthOnBlack "\x1b[40m" // Black -#define EthOnCoal "\x1b[100m" // Black -#define EthOnGray "\x1b[47m" // White -#define EthOnWhite "\x1b[107m" // White -#define EthOnMaroon "\x1b[41m" // Red -#define EthOnRed "\x1b[101m" // Red -#define EthOnGreen "\x1b[42m" // Green -#define EthOnLime "\x1b[102m" // Green -#define EthOnOrange "\x1b[43m" // Yellow -#define EthOnYellow "\x1b[103m" // Yellow -#define EthOnNavy "\x1b[44m" // Blue -#define EthOnBlue "\x1b[104m" // Blue -#define EthOnViolet "\x1b[45m" // Purple -#define EthOnPurple "\x1b[105m" // Purple -#define EthOnTeal "\x1b[46m" // Cyan -#define EthOnCyan "\x1b[106m" // Cyan - -// Underline -#define EthBlackUnder "\x1b[4;30m" // Black -#define EthGrayUnder "\x1b[4;37m" // White -#define EthMaroonUnder "\x1b[4;31m" // Red -#define EthGreenUnder "\x1b[4;32m" // Green -#define EthOrangeUnder "\x1b[4;33m" // Yellow -#define EthNavyUnder "\x1b[4;34m" // Blue -#define EthVioletUnder "\x1b[4;35m" // Purple -#define EthTealUnder "\x1b[4;36m" // Cyan - -#endif - -} - -} diff --git a/src/ringdht/eth/libdevcore/UndefMacros.h b/src/ringdht/eth/libdevcore/UndefMacros.h deleted file mode 100644 index 91249523b7..0000000000 --- a/src/ringdht/eth/libdevcore/UndefMacros.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - This file is part of cpp-ethereum. - - cpp-ethereum 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. - - cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. -*/ -/** @file UndefMacros.h - * @author Lefteris <lefteris@ethdev.com> - * @date 2015 - * - * This header should be used to #undef some really evil macros defined by - * windows.h which result in conflict with our libsolidity/Token.h - */ -#pragma once - -#if defined(_MSC_VER) || defined(__MINGW32__) - -#undef DELETE -#undef IN -#undef VOID -#undef THIS -#undef CONST - -// Conflicting define on MinGW in windows.h -// windows.h(19): #define interface struct -#ifdef interface -#undef interface -#endif - -#elif defined(DELETE) || defined(IN) || defined(VOID) || defined(THIS) || defined(CONST) || defined(interface) - -#error "The preceding macros in this header file are reserved for V8's "\ -"TOKEN_LIST. Please add a platform specific define above to undefine "\ -"overlapping macros." - -#endif diff --git a/src/ringdht/eth/libdevcore/concurrent_queue.h b/src/ringdht/eth/libdevcore/concurrent_queue.h deleted file mode 100644 index 2e88fc5762..0000000000 --- a/src/ringdht/eth/libdevcore/concurrent_queue.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - This file is part of cpp-ethereum. - - cpp-ethereum 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. - - cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. -*/ -#pragma once -#include <utility> -#include <queue> -#include <condition_variable> -#include <mutex> - - -namespace dev -{ - -/// Concurrent queue. -/// You can push and pop elements to/from the queue. Pop will block until the queue is not empty. -/// The default backend (_QueueT) is std::queue. It can be changed to any type that has -/// proper push(), pop(), empty() and front() methods. -template<typename _T, typename _QueueT = std::queue<_T>> -class concurrent_queue -{ -public: - template<typename _U> - void push(_U&& _elem) - { - { - std::lock_guard<decltype(x_mutex)> guard{x_mutex}; - m_queue.push(std::forward<_U>(_elem)); - } - m_cv.notify_one(); - } - - _T pop() - { - std::unique_lock<std::mutex> lock{x_mutex}; - m_cv.wait(lock, [this]{ return !m_queue.empty(); }); - auto item = std::move(m_queue.front()); - m_queue.pop(); - return item; - } - -private: - _QueueT m_queue; - std::mutex x_mutex; - std::condition_variable m_cv; -}; - -} diff --git a/src/ringdht/eth/libdevcore/debugbreak.h b/src/ringdht/eth/libdevcore/debugbreak.h deleted file mode 100644 index 65612a3404..0000000000 --- a/src/ringdht/eth/libdevcore/debugbreak.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (c) 2013, Scott Tsai - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef DEBUG_BREAK_H -#define DEBUG_BREAK_H - -#if defined(_MSC_VER) || defined(__MINGW32__) - -#define debug_break __debugbreak - -#else - -#include <signal.h> -#include <unistd.h> -#include <sys/syscall.h> - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - /* gcc optimizers consider code after __builtin_trap() dead. - * Making __builtin_trap() unsuitable for breaking into the debugger */ - DEBUG_BREAK_PREFER_BUILTIN_TRAP_TO_SIGTRAP = 0, -}; - -#if defined(__i386__) || defined(__x86_64__) -enum { HAVE_TRAP_INSTRUCTION = 1, }; -__attribute__((gnu_inline, always_inline)) -static void __inline__ trap_instruction(void) -{ - __asm__ volatile("int $0x03"); -} -#elif defined(__thumb__) -enum { HAVE_TRAP_INSTRUCTION = 1, }; -/* FIXME: handle __THUMB_INTERWORK__ */ -__attribute__((gnu_inline, always_inline)) -static void __inline__ trap_instruction(void) -{ - /* See 'arm-linux-tdep.c' in GDB source. - * Both instruction sequences below works. */ -#if 1 - /* 'eabi_linux_thumb_le_breakpoint' */ - __asm__ volatile(".inst 0xde01"); -#else - /* 'eabi_linux_thumb2_le_breakpoint' */ - __asm__ volatile(".inst.w 0xf7f0a000"); -#endif - - /* Known problem: - * After a breakpoint hit, can't stepi, step, or continue in GDB. - * 'step' stuck on the same instruction. - * - * Workaround: a new GDB command, - * 'debugbreak-step' is defined in debugbreak-gdb.py - * that does: - * (gdb) set $instruction_len = 2 - * (gdb) tbreak *($pc + $instruction_len) - * (gdb) jump *($pc + $instruction_len) - */ -} -#elif defined(__arm__) && !defined(__thumb__) -enum { HAVE_TRAP_INSTRUCTION = 1, }; -__attribute__((gnu_inline, always_inline)) -static void __inline__ trap_instruction(void) -{ - /* See 'arm-linux-tdep.c' in GDB source, - * 'eabi_linux_arm_le_breakpoint' */ - __asm__ volatile(".inst 0xe7f001f0"); - /* Has same known problem and workaround - * as Thumb mode */ -} -#else -enum { HAVE_TRAP_INSTRUCTION = 0, }; -#endif - -__attribute__((gnu_inline, always_inline)) -static void __inline__ debug_break(void) -{ - if (HAVE_TRAP_INSTRUCTION) { -#if defined(ETH_EMSCRIPTEN) - asm("debugger"); -#else - trap_instruction(); -#endif - } else if (DEBUG_BREAK_PREFER_BUILTIN_TRAP_TO_SIGTRAP) { - /* raises SIGILL on Linux x86{,-64}, to continue in gdb: - * (gdb) handle SIGILL stop nopass - * */ - __builtin_trap(); - } else { - raise(SIGTRAP); - } -} - -#ifdef __cplusplus -} -#endif - -#endif - -#endif diff --git a/src/ringdht/eth/libdevcrypto/CryptoPP.cpp b/src/ringdht/eth/libdevcrypto/CryptoPP.cpp index c778f404f7..6c9de74741 100644 --- a/src/ringdht/eth/libdevcrypto/CryptoPP.cpp +++ b/src/ringdht/eth/libdevcrypto/CryptoPP.cpp @@ -1,26 +1,5 @@ -/* - This file is part of cpp-ethereum. - - cpp-ethereum 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. - - cpp-ethereum 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 cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. - */ -/** @file CryptoPP.cpp - * @author Alex Leverington <nessence@gmail.com> - * @date 2014 - */ #include <libdevcore/Guards.h> -#include <libdevcore/Assertions.h> #include "ECDHE.h" /* * At 5.6.3 the ECIES implementation has been deprecated and a warning has @@ -226,7 +205,7 @@ Signature Secp256k1PP::sign(Secret const& _k, bytesConstRef _message) Signature Secp256k1PP::sign(Secret const& _key, h256 const& _hash) { // assumption made by signing alogrithm - asserts(m_q == m_qs); + assert(m_q == m_qs); Signature sig; diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index 5fc2121eb7..41bc5f602f 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -59,7 +59,7 @@ #include "config/yamlparser.h" #include "security/certstore.h" #include "libdevcrypto/Common.h" -#include "ring_base64.h" +#include "base64.h" #include <yaml-cpp/yaml.h> #include <json/json.h> diff --git a/src/sip/sdp.cpp b/src/sip/sdp.cpp index 0d29ba3a54..0ebf3df937 100644 --- a/src/sip/sdp.cpp +++ b/src/sip/sdp.cpp @@ -30,7 +30,7 @@ #include "sipaccount.h" #include "sipvoiplink.h" #include "string_utils.h" -#include "ring_base64.h" +#include "base64.h" #include "manager.h" #include "logger.h" -- GitLab