Zachary Hall
9899794b81
Some checks failed
Build / build-gentoo (push) Failing after 1m11s
Build / download-system-deps (push) Successful in 3m44s
Build / get-source-code (push) Successful in 13m23s
Build / build-deb (push) Successful in 11m40s
Build / build-appimage (push) Successful in 4m53s
Build / build-android (push) Failing after 3m19s
Build / build-windows (push) Failing after 8m9s
23 lines
No EOL
967 B
C++
23 lines
No EOL
967 B
C++
#include "base85.h"
|
|
using std::vector;
|
|
// Functions modified from Dear ImGui and renamed to avoid collisions.
|
|
static unsigned int DecodeBase85Byte(char c) {
|
|
return c >= '\\' ? c-36 : c-35;
|
|
}
|
|
vector<unsigned char> *DecodeBase85(const char *src) {
|
|
vector<unsigned char> *dst_vec = new vector<unsigned char>();
|
|
dst_vec->resize(((strlen(src) + 4) / 5) * 4);
|
|
unsigned char *dst = dst_vec->data();
|
|
memset(dst, 0, dst_vec->size());
|
|
size_t dst_size = 0;
|
|
while (*src)
|
|
{
|
|
unsigned int tmp = DecodeBase85Byte(src[0]) + 85 * (DecodeBase85Byte(src[1]) + 85 * (DecodeBase85Byte(src[2]) + 85 * (DecodeBase85Byte(src[3]) + 85 * DecodeBase85Byte(src[4]))));
|
|
dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness.
|
|
src += 5;
|
|
dst += 4;
|
|
dst_size += 4;
|
|
}
|
|
dst_vec->resize(dst_size);
|
|
return dst_vec;
|
|
} |