/* * DISTRHO Plugin Framework (DPF) * Copyright (C) 2012-2021 Filipe Coelho * Copyright (C) 2022 Jean Pierre Cimalando * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this * permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #pragma once #include #include #include #include #include #include // ----------------------------------------------------------------------- // base64 stuff, based on http://www.adp-gmbh.ch/cpp/common/base64.html /* 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 */ // ----------------------------------------------------------------------- // Helpers #ifndef DOXYGEN namespace DistrhoBase64Helpers { static std::array createCharIndexTable() { std::array table; table.fill(-1); int8_t index = 0; for (uint8_t c = 'A'; c <= 'Z'; ++c) table[c] = index++; for (uint8_t c = 'a'; c <= 'z'; ++c) table[c] = index++; for (uint8_t c = '0'; c <= '9'; ++c) table[c] = index++; table['+'] = index++; table['/'] = index++; return table; } static const std::array kCharIndexTable = createCharIndexTable(); } // namespace DistrhoBase64Helpers #endif // ----------------------------------------------------------------------- static inline std::vector d_getChunkFromBase64String(const char* const base64string, std::size_t base64stringLen = ~std::size_t(0)) { std::vector ret; if (! base64string) return ret; uint32_t i=0, j=0; uint32_t charArray3[3], charArray4[4]; if (base64stringLen == ~std::size_t(0)) base64stringLen = std::strlen(base64string); ret.reserve(base64stringLen*3/4 + 4); for (std::size_t l=0; l> 2; charArray4[1] = ((charArray3[0] & 0x03) << 4) + ((charArray3[1] & 0xf0) >> 4); charArray4[2] = ((charArray3[1] & 0x0f) << 2) + ((charArray3[2] & 0xc0) >> 6); charArray4[3] = charArray3[2] & 0x3f; for (j=0; j<4 && i<3 && j