Export base64 encoder and decoder
parent
c4f48bc47d
commit
135127dcc1
|
@ -48,6 +48,9 @@
|
||||||
#define nvnc_trace(...)
|
#define nvnc_trace(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NVNC_BASE64_ENCODED_SIZE(x) ((((x) + 2) / 3) * 4 + 1)
|
||||||
|
#define NVNC_BASE64_DECODED_MAX_SIZE(x) ((((x) + 3) / 4) * 3)
|
||||||
|
|
||||||
struct nvnc;
|
struct nvnc;
|
||||||
struct nvnc_client;
|
struct nvnc_client;
|
||||||
struct nvnc_desktop_layout;
|
struct nvnc_desktop_layout;
|
||||||
|
@ -237,3 +240,6 @@ void nvnc_set_cursor(struct nvnc*, struct nvnc_fb*, uint16_t width,
|
||||||
void nvnc_set_log_fn(nvnc_log_fn);
|
void nvnc_set_log_fn(nvnc_log_fn);
|
||||||
void nvnc_set_log_level(enum nvnc_log_level);
|
void nvnc_set_log_level(enum nvnc_log_level);
|
||||||
void nvnc__log(const struct nvnc_log_data*, const char* fmt, ...);
|
void nvnc__log(const struct nvnc_log_data*, const char* fmt, ...);
|
||||||
|
|
||||||
|
void nvnc_base64_encode(char* dst, const uint8_t* src, size_t src_len);
|
||||||
|
ssize_t nvnc_base64_decode(uint8_t* dst, const char* src);
|
||||||
|
|
15
src/base64.c
15
src/base64.c
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
#include "neatvnc.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -21,6 +22,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define EXPORT __attribute__((visibility("default")))
|
||||||
|
|
||||||
static const char base64_enc_lut[] =
|
static const char base64_enc_lut[] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
|
@ -153,3 +156,15 @@ ssize_t base64_decode(uint8_t* dst, const char* src)
|
||||||
|
|
||||||
return i * 3 + di;
|
return i * 3 + di;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORT
|
||||||
|
void nvnc_base64_encode(char* dst, const uint8_t* src, size_t src_len)
|
||||||
|
{
|
||||||
|
base64_encode(dst, src, src_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT
|
||||||
|
ssize_t nvnc_base64_decode(uint8_t* dst, const char* src)
|
||||||
|
{
|
||||||
|
return base64_decode(dst, src);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue