diff --git a/.gitmodules b/.gitmodules index 83990074..d33568ec 100644 --- a/.gitmodules +++ b/.gitmodules @@ -32,3 +32,6 @@ [submodule "deps/bitmrc"] path = deps/bitmrc url = git@github.com:iw4x-dev-urandom/BitMRC.git +[submodule "deps/base128"] + path = deps/base128 + url = https://github.com/seizu/base128.git diff --git a/deps/base128 b/deps/base128 new file mode 160000 index 00000000..64c8ab27 --- /dev/null +++ b/deps/base128 @@ -0,0 +1 @@ +Subproject commit 64c8ab2755e14d316b18aff9746f0180f5fe301b diff --git a/premake/base128.lua b/premake/base128.lua new file mode 100644 index 00000000..bd8a7db3 --- /dev/null +++ b/premake/base128.lua @@ -0,0 +1,54 @@ +base128 = { + settings = nil +} + +function base128.setup(settings) + if not settings.source then error("Missing source.") end + + base128.settings = settings +end + +function base128.import() + if not base128.settings then error("Run base128.setup first") end + + base128.links() + base128.includes() +end + +function base128.links() + if not base128.settings then error("Run base128.setup first") end + + links { "base128" } +end + +function base128.includes() + if not base128.settings then error("Run base128.setup first") end + + includedirs { path.join(base128.settings.source, "cpp") } +end + +function base128.project() + if not base128.settings then error("Run base128.setup first") end + + project "base128" + language "C++" + + base128.includes() + + files + { + path.join(base128.settings.source, "cpp/*.cpp"), + path.join(base128.settings.source, "cpp/*.h"), + } + removefiles + { + "**/demo.*", + } + + -- not our code, ignore POSIX usage warnings for now + warnings "Off" + + defines { "_LIB" } + removedefines { "_USRDLL", "_DLL" } + kind "StaticLib" +end diff --git a/premake5.lua b/premake5.lua index 06cf8f60..c05b6be6 100644 --- a/premake5.lua +++ b/premake5.lua @@ -140,6 +140,7 @@ newaction { depsBasePath = "./deps" +require "premake/base128" require "premake/bitmrc" require "premake/fmt" require "premake/json11" @@ -153,6 +154,10 @@ require "premake/sqlite3" require "premake/winksignals" require "premake/zlib" +base128.setup +{ + source = path.join(depsBasePath, "base128"), +} bitmrc.setup { source = path.join(depsBasePath, "bitmrc"), @@ -290,6 +295,7 @@ workspace "iw4x" if not _OPTIONS["disable-bitmessage"] then bitmrc.import() end + base128.import() fmt.import() json11.import() libtomcrypt.import() @@ -398,6 +404,7 @@ workspace "iw4x" libcryptopp.project() sqlite3.project() end + base128.project() fmt.project() json11.project() libtomcrypt.project() diff --git a/src/Components/Modules/MinidumpUpload.cpp b/src/Components/Modules/MinidumpUpload.cpp index 7947e4f9..1fbef281 100644 --- a/src/Components/Modules/MinidumpUpload.cpp +++ b/src/Components/Modules/MinidumpUpload.cpp @@ -279,6 +279,11 @@ namespace Components std::string compressedMinidump = Utils::Compression::ZLib::Compress(minidump->ToString()); +#ifndef DISABLE_BASE128 + extraHeaders["Encoding"] = "base128"; + compressedMinidump = Utils::String::EncodeBase128(compressedMinidump); +#endif + Logger::Print("Uploading minidump...\n"); #ifdef DISABLE_BITMESSAGE @@ -345,7 +350,8 @@ namespace Components std::string marker = "MINIDUMP"; std::stringstream output; - extraHeaders["Encoding"] = "raw"; + if (extraHeaders.find("Encoding") == extraHeaders.end()) + extraHeaders["Encoding"] = "raw"; extraHeaders["Version"] = VERSION_STR; output << "-----BEGIN " << marker << "-----\n"; diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index a1ec1bfc..cba41fa9 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -1,4 +1,5 @@ #include "STDInclude.hpp" +#include "base128.h" namespace Utils { @@ -131,6 +132,14 @@ namespace Utils return EncodeBase64(input.c_str(), input.size()); } + // Encodes a given string in Base128 + std::string EncodeBase128(const std::string& input) { + auto encoder = new base128(); + auto buffer = encoder->encode(const_cast(static_cast(input.data())), input.size()); + delete encoder; + return std::string(buffer); + } + // Generates a UUID and returns the string representation of it std::string GenerateUUIDString() { // Generate UUID data diff --git a/src/Utils/String.hpp b/src/Utils/String.hpp index 84af479d..6ca9cc57 100644 --- a/src/Utils/String.hpp +++ b/src/Utils/String.hpp @@ -43,6 +43,8 @@ namespace Utils std::string EncodeBase64(const char* input, const unsigned long inputSize); std::string EncodeBase64(const std::string& input); + std::string EncodeBase128(const std::string& input); + std::string GenerateUUIDString(); } }