From 3c79ed42bd3ed26f7974cceee1558a81195e10dd Mon Sep 17 00:00:00 2001 From: gangatp Date: Mon, 18 Dec 2023 20:47:02 +0530 Subject: [PATCH] updating cpp-base64 --- .gitmodules | 3 + Include/Libraries/cpp-base64/base64.h | 15 - Libraries/cpp-base64/Include/base64.h | 35 +++ Libraries/cpp-base64/Source/base64.cpp | 282 ++++++++++++++++++ Libraries/cpp-base64/cpp-base64_V2.rc.08.txt | 1 + Source/CMakeLists.txt | 2 +- Source/Libraries/cpp-base64/base64.cpp | 125 -------- .../NMR_ModelReaderNode_KeyStoreCEKParams.cpp | 40 ++- ...MR_ModelReaderNode_KeyStoreCipherValue.cpp | 10 +- .../NMR_ModelReaderNode_KeyStoreKEKParams.cpp | 2 +- .../NMR_ModelWriterNode_KeyStore.cpp | 2 +- submodules/cpp-base64 | 1 + submodules/update_libs.bat | 26 ++ submodules/update_libs.sh | 23 ++ 14 files changed, 406 insertions(+), 161 deletions(-) delete mode 100644 Include/Libraries/cpp-base64/base64.h create mode 100644 Libraries/cpp-base64/Include/base64.h create mode 100644 Libraries/cpp-base64/Source/base64.cpp create mode 100644 Libraries/cpp-base64/cpp-base64_V2.rc.08.txt delete mode 100644 Source/Libraries/cpp-base64/base64.cpp create mode 160000 submodules/cpp-base64 diff --git a/.gitmodules b/.gitmodules index 1d891d421..ed2779ca9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "submodules/zlib"] path = submodules/zlib url = https://github.com/madler/zlib.git +[submodule "submodules/cpp-base64"] + path = submodules/cpp-base64 + url = https://github.com/ReneNyffenegger/cpp-base64.git diff --git a/Include/Libraries/cpp-base64/base64.h b/Include/Libraries/cpp-base64/base64.h deleted file mode 100644 index e8442ea0c..000000000 --- a/Include/Libraries/cpp-base64/base64.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// base64 encoding and decoding with C++. -// Version: 1.01.00 -// - -#ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A -#define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A - -#include -#include - -std::string base64_encode(std::vector const & buffer); -std::vector base64_decode(std::string const& s); - -#endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */ diff --git a/Libraries/cpp-base64/Include/base64.h b/Libraries/cpp-base64/Include/base64.h new file mode 100644 index 000000000..866505e5d --- /dev/null +++ b/Libraries/cpp-base64/Include/base64.h @@ -0,0 +1,35 @@ +// +// base64 encoding and decoding with C++. +// Version: 2.rc.08 (release candidate) +// + +#ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A +#define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A + +#include + +#if __cplusplus >= 201703L +#include +#endif // __cplusplus >= 201703L + +std::string base64_encode (std::string const& s, bool url = false); +std::string base64_encode_pem (std::string const& s); +std::string base64_encode_mime(std::string const& s); + +std::string base64_decode(std::string const& s, bool remove_linebreaks = false); +std::string base64_encode(unsigned char const*, size_t len, bool url = false); + +#if __cplusplus >= 201703L +// +// Interface with std::string_view rather than const std::string& +// Requires C++17 +// Provided by Yannic Bonenberger (https://github.com/Yannic) +// +std::string base64_encode (std::string_view s, bool url = false); +std::string base64_encode_pem (std::string_view s); +std::string base64_encode_mime(std::string_view s); + +std::string base64_decode(std::string_view s, bool remove_linebreaks = false); +#endif // __cplusplus >= 201703L + +#endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */ diff --git a/Libraries/cpp-base64/Source/base64.cpp b/Libraries/cpp-base64/Source/base64.cpp new file mode 100644 index 000000000..7666ef888 --- /dev/null +++ b/Libraries/cpp-base64/Source/base64.cpp @@ -0,0 +1,282 @@ +/* + base64.cpp and base64.h + + base64 encoding and decoding with C++. + More information at + https://renenyffenegger.ch/notes/development/Base64/Encoding-and-decoding-base-64-with-cpp + + Version: 2.rc.08 (release candidate) + + Copyright (C) 2004-2017, 2020, 2021 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 + +*/ + +#include "base64.h" + +#include +#include + + // + // Depending on the url parameter in base64_chars, one of + // two sets of base64 characters needs to be chosen. + // They differ in their last two characters. + // +static const char* base64_chars[2] = { + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "+/", + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "-_"}; + +static unsigned int pos_of_char(const unsigned char chr) { + // + // Return the position of chr within base64_encode() + // + + if (chr >= 'A' && chr <= 'Z') return chr - 'A'; + else if (chr >= 'a' && chr <= 'z') return chr - 'a' + ('Z' - 'A') + 1; + else if (chr >= '0' && chr <= '9') return chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2; + else if (chr == '+' || chr == '-') return 62; // Be liberal with input and accept both url ('-') and non-url ('+') base 64 characters ( + else if (chr == '/' || chr == '_') return 63; // Ditto for '/' and '_' + else + // + // 2020-10-23: Throw std::exception rather than const char* + //(Pablo Martin-Gomez, https://github.com/Bouska) + // + throw std::runtime_error("Input is not valid base64-encoded data."); +} + +static std::string insert_linebreaks(std::string str, size_t distance) { + // + // Provided by https://github.com/JomaCorpFX, adapted by me. + // + if (!str.length()) { + return ""; + } + + size_t pos = distance; + + while (pos < str.size()) { + str.insert(pos, "\n"); + pos += distance + 1; + } + + return str; +} + +template +static std::string encode_with_line_breaks(String s) { + return insert_linebreaks(base64_encode(s, false), line_length); +} + +template +static std::string encode_pem(String s) { + return encode_with_line_breaks(s); +} + +template +static std::string encode_mime(String s) { + return encode_with_line_breaks(s); +} + +template +static std::string encode(String s, bool url) { + return base64_encode(reinterpret_cast(s.data()), s.length(), url); +} + +std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, bool url) { + + size_t len_encoded = (in_len +2) / 3 * 4; + + unsigned char trailing_char = url ? '.' : '='; + + // + // Choose set of base64 characters. They differ + // for the last two positions, depending on the url + // parameter. + // A bool (as is the parameter url) is guaranteed + // to evaluate to either 0 or 1 in C++ therefore, + // the correct character set is chosen by subscripting + // base64_chars with url. + // + const char* base64_chars_ = base64_chars[url]; + + std::string ret; + ret.reserve(len_encoded); + + unsigned int pos = 0; + + while (pos < in_len) { + ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0xfc) >> 2]); + + if (pos+1 < in_len) { + ret.push_back(base64_chars_[((bytes_to_encode[pos + 0] & 0x03) << 4) + ((bytes_to_encode[pos + 1] & 0xf0) >> 4)]); + + if (pos+2 < in_len) { + ret.push_back(base64_chars_[((bytes_to_encode[pos + 1] & 0x0f) << 2) + ((bytes_to_encode[pos + 2] & 0xc0) >> 6)]); + ret.push_back(base64_chars_[ bytes_to_encode[pos + 2] & 0x3f]); + } + else { + ret.push_back(base64_chars_[(bytes_to_encode[pos + 1] & 0x0f) << 2]); + ret.push_back(trailing_char); + } + } + else { + + ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0x03) << 4]); + ret.push_back(trailing_char); + ret.push_back(trailing_char); + } + + pos += 3; + } + + + return ret; +} + +template +static std::string decode(String encoded_string, bool remove_linebreaks) { + // + // decode(…) is templated so that it can be used with String = const std::string& + // or std::string_view (requires at least C++17) + // + + if (encoded_string.empty()) return std::string(); + + if (remove_linebreaks) { + + std::string copy(encoded_string); + + copy.erase(std::remove(copy.begin(), copy.end(), '\n'), copy.end()); + + return base64_decode(copy, false); + } + + size_t length_of_string = encoded_string.length(); + size_t pos = 0; + + // + // The approximate length (bytes) of the decoded string might be one or + // two bytes smaller, depending on the amount of trailing equal signs + // in the encoded string. This approximation is needed to reserve + // enough space in the string to be returned. + // + size_t approx_length_of_decoded_string = length_of_string / 4 * 3; + std::string ret; + ret.reserve(approx_length_of_decoded_string); + + while (pos < length_of_string) { + // + // Iterate over encoded input string in chunks. The size of all + // chunks except the last one is 4 bytes. + // + // The last chunk might be padded with equal signs or dots + // in order to make it 4 bytes in size as well, but this + // is not required as per RFC 2045. + // + // All chunks except the last one produce three output bytes. + // + // The last chunk produces at least one and up to three bytes. + // + + size_t pos_of_char_1 = pos_of_char(encoded_string[pos+1] ); + + // + // Emit the first output byte that is produced in each chunk: + // + ret.push_back(static_cast( ( (pos_of_char(encoded_string[pos+0]) ) << 2 ) + ( (pos_of_char_1 & 0x30 ) >> 4))); + + if ( ( pos + 2 < length_of_string ) && // Check for data that is not padded with equal signs (which is allowed by RFC 2045) + encoded_string[pos+2] != '=' && + encoded_string[pos+2] != '.' // accept URL-safe base 64 strings, too, so check for '.' also. + ) + { + // + // Emit a chunk's second byte (which might not be produced in the last chunk). + // + unsigned int pos_of_char_2 = pos_of_char(encoded_string[pos+2] ); + ret.push_back(static_cast( (( pos_of_char_1 & 0x0f) << 4) + (( pos_of_char_2 & 0x3c) >> 2))); + + if ( ( pos + 3 < length_of_string ) && + encoded_string[pos+3] != '=' && + encoded_string[pos+3] != '.' + ) + { + // + // Emit a chunk's third byte (which might not be produced in the last chunk). + // + ret.push_back(static_cast( ( (pos_of_char_2 & 0x03 ) << 6 ) + pos_of_char(encoded_string[pos+3]) )); + } + } + + pos += 4; + } + + return ret; +} + +std::string base64_decode(std::string const& s, bool remove_linebreaks) { + return decode(s, remove_linebreaks); +} + +std::string base64_encode(std::string const& s, bool url) { + return encode(s, url); +} + +std::string base64_encode_pem (std::string const& s) { + return encode_pem(s); +} + +std::string base64_encode_mime(std::string const& s) { + return encode_mime(s); +} + +#if __cplusplus >= 201703L +// +// Interface with std::string_view rather than const std::string& +// Requires C++17 +// Provided by Yannic Bonenberger (https://github.com/Yannic) +// + +std::string base64_encode(std::string_view s, bool url) { + return encode(s, url); +} + +std::string base64_encode_pem(std::string_view s) { + return encode_pem(s); +} + +std::string base64_encode_mime(std::string_view s) { + return encode_mime(s); +} + +std::string base64_decode(std::string_view s, bool remove_linebreaks) { + return decode(s, remove_linebreaks); +} + +#endif // __cplusplus >= 201703L diff --git a/Libraries/cpp-base64/cpp-base64_V2.rc.08.txt b/Libraries/cpp-base64/cpp-base64_V2.rc.08.txt new file mode 100644 index 000000000..c31c6d51a --- /dev/null +++ b/Libraries/cpp-base64/cpp-base64_V2.rc.08.txt @@ -0,0 +1 @@ +"V2.rc.08" diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 0688f464c..523ec9eb3 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -12,7 +12,7 @@ if (USE_INCLUDED_ZLIB) file(GLOB ZLIB_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "Libraries/zlib/Source/*.c") endif() -file (GLOB CPPBASE64_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "Source/Libraries/cpp-base64/*.cpp") +file (GLOB CPPBASE64_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "Libraries/cpp-base64/Source/*.cpp") # sources set(SRCS_PLATFORM diff --git a/Source/Libraries/cpp-base64/base64.cpp b/Source/Libraries/cpp-base64/base64.cpp deleted file mode 100644 index 82a175a4a..000000000 --- a/Source/Libraries/cpp-base64/base64.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - base64.cpp and base64.h - - base64 encoding and decoding with C++. - - Version: 1.01.00 - - Copyright (C) 2004-2017 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 - - DISCLAIMER - This is a modified version. -*/ - -#include "Libraries/cpp-base64/base64.h" - -static const std::string base64_chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - - -static inline bool is_base64(unsigned char c) { - return (isalnum(c) || (c == '+') || (c == '/')); -} - -std::string base64_encode(std::vector const & buffer) { - size_t in_len = buffer.size(); - unsigned char const * bytes_to_encode = buffer.data(); - std::string ret; - int i = 0; - int j = 0; - unsigned char char_array_3[3]; - unsigned char char_array_4[4]; - - while (in_len--) { - char_array_3[i++] = *(bytes_to_encode++); - 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); - - for (j = 0; (j < i + 1); j++) - ret += base64_chars[char_array_4[j]]; - - while((i++ < 3)) - ret += '='; - - } - - return ret; - -} - -std::vector base64_decode(std::string const& encoded_string) { - size_t in_len = encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - unsigned char char_array_4[4], char_array_3[3]; - std::vector 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] = base64_chars.find(char_array_4[i]) & 0xff; - - 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 = 0; j < i; j++) - char_array_4[j] = base64_chars.find(char_array_4[j]) & 0xff; - - 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); - - for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]); - } - - return ret; -} diff --git a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp index c8d533f0d..378f4aed7 100644 --- a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp +++ b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCEKParams.cpp @@ -43,7 +43,7 @@ NMR_ModelReaderNode_KeyStoreCipherValue.h defines the Model Reader Node class th #include "Common/NMR_Exception_Windows.h" #include "Common/NMR_StringUtils.h" -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" namespace NMR { namespace ParserUtils { @@ -107,22 +107,30 @@ namespace NMR { __NMRASSERT(pChildName); __NMRASSERT(pXMLReader); __NMRASSERT(pNameSpace); - if (strcmp(pNameSpace, XML_3MF_NAMESPACE_SECURECONTENTSPEC) == 0) { - if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_IV) == 0) { - PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); - pXMLNode->parseXML(pXMLReader); - m_iv = base64_decode(pXMLNode->getValue()); - } else if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_TAG) == 0) { - PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); - pXMLNode->parseXML(pXMLReader); - m_tag = base64_decode(pXMLNode->getValue()); - } else if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_AAD) == 0) { - PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); - pXMLNode->parseXML(pXMLReader); - m_aad = base64_decode(pXMLNode->getValue()); - } else { - m_pWarnings->addWarning(NMR_ERROR_NAMESPACE_INVALID_ELEMENT, mrwInvalidOptionalValue); + try{ + if (strcmp(pNameSpace, XML_3MF_NAMESPACE_SECURECONTENTSPEC) == 0) { + if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_IV) == 0) { + PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + std::string result = base64_decode(pXMLNode->getValue()); + m_iv = std::vector(result.begin(), result.end()); + } else if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_TAG) == 0) { + PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + std::string result = base64_decode(pXMLNode->getValue()); + m_tag = std::vector(result.begin(), result.end()); + } else if (strcmp(pChildName, XML_3MF_SECURE_CONTENT_AAD) == 0) { + PModelReaderNode_StringValue pXMLNode = std::make_shared(m_pWarnings); + pXMLNode->parseXML(pXMLReader); + std::string result = base64_decode(pXMLNode->getValue()); + m_aad = std::vector(result.begin(), result.end()); + } else { + m_pWarnings->addWarning(NMR_ERROR_NAMESPACE_INVALID_ELEMENT, mrwInvalidOptionalValue); + } } } + catch (...) { + // base64_decode throws an exception if the input is not valid base64 + } } } diff --git a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp index d0a0420dc..e7a61218d 100644 --- a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp +++ b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreCipherValue.cpp @@ -41,7 +41,7 @@ NMR_ModelReaderNode_KeyStoreCipherValue.h defines the Model Reader Node class th #include "Common/NMR_StringUtils.h" #include "Model/Reader/NMR_ModelReaderNode_StringValue.h" -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" namespace NMR { @@ -71,7 +71,13 @@ namespace NMR { && strcmp(pChildName, XML_3MF_ELEMENT_CIPHERVALUE) == 0) { PModelReaderNode_StringValue pNode = std::make_shared(m_pWarnings); pNode->parseXML(pXMLReader); - m_sCipherValue = base64_decode(pNode->getValue()); + try { + std::string result = base64_decode(pNode->getValue()); + m_sCipherValue = std::vector(result.begin(), result.end()); + } + catch (...) { + // base64_decode throws an exception if the input is not valid base64 + } } } diff --git a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreKEKParams.cpp b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreKEKParams.cpp index b1ac663fe..8c436151f 100644 --- a/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreKEKParams.cpp +++ b/Source/Model/Reader/SecureContent101/NMR_ModelReaderNode_KeyStoreKEKParams.cpp @@ -40,7 +40,7 @@ NMR_ModelReaderNode_KeyStoreCipherValue.h defines the Model Reader Node class th #include "Common/NMR_Exception_Windows.h" #include "Common/NMR_StringUtils.h" -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" namespace NMR { diff --git a/Source/Model/Writer/SecureContent101/NMR_ModelWriterNode_KeyStore.cpp b/Source/Model/Writer/SecureContent101/NMR_ModelWriterNode_KeyStore.cpp index 7bf7565bb..63440ef2a 100644 --- a/Source/Model/Writer/SecureContent101/NMR_ModelWriterNode_KeyStore.cpp +++ b/Source/Model/Writer/SecureContent101/NMR_ModelWriterNode_KeyStore.cpp @@ -39,7 +39,7 @@ This is the class for exporting the 3mf keystore stream root node. #include "Common/NMR_Exception.h" #include "Common/NMR_StringUtils.h" #include "Common/NMR_UUID.h" -#include "Libraries/cpp-base64/base64.h" +#include "base64.h" #include #include diff --git a/submodules/cpp-base64 b/submodules/cpp-base64 new file mode 160000 index 000000000..07ae5045d --- /dev/null +++ b/submodules/cpp-base64 @@ -0,0 +1 @@ +Subproject commit 07ae5045d67b5bf6ffb46646b8ac2370eff1ae3e diff --git a/submodules/update_libs.bat b/submodules/update_libs.bat index 160fd9c73..e40236b46 100644 --- a/submodules/update_libs.bat +++ b/submodules/update_libs.bat @@ -55,3 +55,29 @@ for %%A in ("zlib" "") do ( echo "!tag!" >"!lib_path_dest!!lib_name!_!tag!.txt" ) ) + + +REM updating the cpp-base64 library +for %%A in ("cpp-base64" "") do ( + if "%update_lib%"==%%A ( + set lib_name="cpp-base64" + set lib_path_src="!base_path!!lib_name!\" + + cd !lib_name! + set "tag=" + for /f %%i in ('git describe --contains HEAD') do set "tag=%%i" + + cd !base_path! + REM delete the destination library folder when updating + RD /S /Q "..\Libraries\!lib_name!" + set lib_path_dest="..\Libraries\!lib_name!\" + mkdir !lib_path_dest! + + mkdir "!lib_path_dest!Include" + mkdir "!lib_path_dest!Source" + copy !lib_path_src!base*.h "!lib_path_dest!Include" /Y + copy !lib_path_src!base*.cpp "!lib_path_dest!Source" /Y + + echo "!tag!" >"!lib_path_dest!!lib_name!_!tag!.txt" + ) +) diff --git a/submodules/update_libs.sh b/submodules/update_libs.sh index 5d7f14a05..5b5d90749 100644 --- a/submodules/update_libs.sh +++ b/submodules/update_libs.sh @@ -53,5 +53,28 @@ if [[ "$1" == "zlib" || "$update_all_libs" == true ]]; then cp ${lib_path_src}*.h "${lib_path_dest}Include" cp ${lib_path_src}*.c "${lib_path_dest}Source" + echo "\"$tag\"" > "$lib_path_dest${lib_name}_$tag.txt" +fi + + +# Updating the cpp-base64 library +if [[ "$1" == "cpp-base64" || "$update_all_libs" == true ]]; then + lib_name="cpp-base64" + lib_path_src="$base_path$lib_name/" + + cd "$lib_name" + tag=$(git describe --contains HEAD) + cd "$base_path" + + # Delete the destination library folder when updating + lib_path_dest="../Libraries/$lib_name/" + rm -rf "$lib_path_dest" + mkdir -p "$lib_path_dest" + + mkdir "$lib_path_dest/Include" + mkdir "$lib_path_dest/Source" + cp ${lib_path_src}base*.h "${lib_path_dest}Include" + cp ${lib_path_src}base*.cpp "${lib_path_dest}Source" + echo "\"$tag\"" > "$lib_path_dest${lib_name}_$tag.txt" fi \ No newline at end of file