diff options
-rw-r--r-- | libdevcore/Base64.cpp | 146 | ||||
-rw-r--r-- | libdevcore/Base64.h | 42 | ||||
-rw-r--r-- | libdevcore/CMakeLists.txt | 4 | ||||
-rw-r--r-- | libdevcore/Common.cpp | 27 | ||||
-rw-r--r-- | libdevcore/Common.h | 1 | ||||
-rw-r--r-- | libdevcore/FixedHash.cpp | 50 | ||||
-rw-r--r-- | libdevcore/FixedHash.h | 19 | ||||
-rw-r--r-- | libevmasm/Assembly.h | 4 | ||||
-rw-r--r-- | libevmasm/CMakeLists.txt | 2 |
9 files changed, 3 insertions, 292 deletions
diff --git a/libdevcore/Base64.cpp b/libdevcore/Base64.cpp deleted file mode 100644 index 8ee2b29f..00000000 --- a/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/libdevcore/Base64.h b/libdevcore/Base64.h deleted file mode 100644 index d5481570..00000000 --- a/libdevcore/Base64.h +++ /dev/null @@ -1,42 +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); - - -} diff --git a/libdevcore/CMakeLists.txt b/libdevcore/CMakeLists.txt index 43dd71c3..620b1190 100644 --- a/libdevcore/CMakeLists.txt +++ b/libdevcore/CMakeLists.txt @@ -2,14 +2,14 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) -set(EXECUTABLE devcore) +set(EXECUTABLE soldevcore) file(GLOB HEADERS "*.h") include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -eth_use(${EXECUTABLE} REQUIRED Jsoncpp Dev::base) +eth_use(${EXECUTABLE} REQUIRED Dev::base) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) diff --git a/libdevcore/Common.cpp b/libdevcore/Common.cpp deleted file mode 100644 index 579e0f62..00000000 --- a/libdevcore/Common.cpp +++ /dev/null @@ -1,27 +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 Common.cpp - * @author Gav Wood <i@gavwood.com> - * @date 2014 - */ - -#include "Common.h" - -namespace dev -{ -const u256 Invalid256 = ~(u256)0; -} diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 7d301833..8bc5f58f 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -156,7 +156,6 @@ using string32 = std::array<char, 32>; // Null/Invalid values for convenience. static const bytes NullBytes; -extern const u256 Invalid256; /// Interprets @a _u as a two's complement signed number and returns the resulting s256. inline s256 u2s(u256 _u) diff --git a/libdevcore/FixedHash.cpp b/libdevcore/FixedHash.cpp deleted file mode 100644 index 420e2bb1..00000000 --- a/libdevcore/FixedHash.cpp +++ /dev/null @@ -1,50 +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 FixedHash.cpp - * @author Gav Wood <i@gavwood.com> - * @date 2014 - */ - -#include "FixedHash.h" -#include <ctime> -#include <boost/algorithm/string.hpp> - -using namespace std; -using namespace dev; - -boost::random_device dev::s_fixedHashEngine; - -h128 dev::fromUUID(std::string const& _uuid) -{ - try - { - return h128(boost::replace_all_copy(_uuid, "-", "")); - } - catch (...) - { - return h128(); - } -} - -std::string dev::toUUID(h128 const& _uuid) -{ - std::string ret = toHex(_uuid.ref()); - for (unsigned i: {20, 16, 12, 8}) - ret.insert(ret.begin() + i, '-'); - return ret; -} - diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index cf79bab0..a23aecc6 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -26,8 +26,6 @@ #include <array> #include <cstdint> #include <algorithm> -#include <boost/random/random_device.hpp> -#include <boost/random/uniform_int_distribution.hpp> #include <boost/functional/hash.hpp> #include "CommonData.h" @@ -38,8 +36,6 @@ namespace dev template <unsigned N> struct StaticLog2 { enum { result = 1 + StaticLog2<N/2>::result }; }; template <> struct StaticLog2<1> { enum { result = 0 }; }; -extern boost::random_device s_fixedHashEngine; - /// Fixed-size raw-byte array container type, with an API optimised for storing hashes. /// Transparently converts to/from the corresponding arithmetic type; this will /// assume the data contained in the hash is big-endian. @@ -150,17 +146,6 @@ public: /// @returns a constant reference to the object's data as an STL array. std::array<byte, N> const& asArray() const { return m_data; } - /// Populate with random data. - template <class Engine> - void randomize(Engine& _eng) - { - for (auto& i: m_data) - i = (uint8_t)boost::random::uniform_int_distribution<uint16_t>(0, 255)(_eng); - } - - /// @returns a random valued object. - static FixedHash random() { FixedHash ret; ret.randomize(s_fixedHashEngine); return ret; } - struct hash { /// Make a hash of the object's data. @@ -279,10 +264,6 @@ inline h160 left160(h256 const& _t) return ret; } -h128 fromUUID(std::string const& _uuid); - -std::string toUUID(h128 const& _uuid); - inline std::string toString(h256s const& _bs) { std::ostringstream out; diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index d48fa99c..af28e220 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -33,10 +33,6 @@ #include "Exceptions.h" #include <json/json.h> -namespace Json -{ -class Value; -} namespace dev { namespace eth diff --git a/libevmasm/CMakeLists.txt b/libevmasm/CMakeLists.txt index 8a283976..56b2faca 100644 --- a/libevmasm/CMakeLists.txt +++ b/libevmasm/CMakeLists.txt @@ -8,7 +8,7 @@ file(GLOB HEADERS "*.h") include_directories(BEFORE ..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -eth_use(${EXECUTABLE} REQUIRED Dev::devcore) +eth_use(${EXECUTABLE} REQUIRED Jsoncpp Dev::devcore) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) |