#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ellipsis-base64.h"
#include "utils/ellipsis-error.h"
#include <stdint.h>
Macros | |
#define | DEC_POS(X) dec_pos_ ## X |
#define | DEC_POS_INIT(C, X) [C] = DEC_POS(X) |
#define | ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) |
#define | ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR, ...) |
#define | ELLIPSIS_CONTRACT_ICE_OR_TRUE(...) |
#define | ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) |
#define | ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR, ...) |
#define | ELLIPSIS_TEST_ICE(...) (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr) |
#define | ELLIPSIS_TO_VOIDS(...) ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__)))) |
#define | STRINGIFY(...) STRINGIFY_(__VA_ARGS__) |
#define | STRINGIFY_(...) #__VA_ARGS__ |
Typedefs | |
typedef struct ellipsis‿contracts‿is_ice | ellipsis‿contracts‿is_ice |
Enumerations | |
enum | ellipsis_dec_pos { dec_pos_A , dec_pos_B , dec_pos_C , dec_pos_D , dec_pos_E , dec_pos_F , dec_pos_G , dec_pos_H , dec_pos_I , dec_pos_J , dec_pos_K , dec_pos_L , dec_pos_M , dec_pos_N , dec_pos_O , dec_pos_P , dec_pos_Q , dec_pos_R , dec_pos_S , dec_pos_T , dec_pos_U , dec_pos_V , dec_pos_W , dec_pos_X , dec_pos_Y , dec_pos_Z , dec_pos_a , dec_pos_b , dec_pos_c , dec_pos_d , dec_pos_e , dec_pos_f , dec_pos_g , dec_pos_h , dec_pos_i , dec_pos_j , dec_pos_k , dec_pos_l , dec_pos_m , dec_pos_n , dec_pos_o , dec_pos_p , dec_pos_q , dec_pos_r , dec_pos_s , dec_pos_t , dec_pos_u , dec_pos_v , dec_pos_w , dec_pos_x , dec_pos_y , dec_pos_z , dec_pos_0 , dec_pos_1 , dec_pos_2 , dec_pos_3 , dec_pos_4 , dec_pos_5 , dec_pos_6 , dec_pos_7 , dec_pos_8 , dec_pos_9 , dec_pos_plus , dec_pos_slash } |
Functions | |
ellipsis‿str8 * | ellipsis‿base64‿decode‿_Inner (size_t len, unsigned char const buf[static restrict len]) |
ellipsis‿str8 * | ellipsis‿base64‿decode‿_Insta (size_t len, unsigned char const buf[static restrict len]) |
Decode a string that contains base64 encoded information into a binary data array. | |
static uint32_t | ellipsis‿base64‿decode_4 (uint32_t c0, uint32_t c1, uint32_t c2, uint32_t c3) |
static uint32_t | ellipsis‿base64‿decode_down (uint32_t inp) |
char * | ellipsis‿base64‿encode‿_Inner (ellipsis‿str8 const buf[static restrict 1]) |
char * | ellipsis‿base64‿encode‿_Insta (ellipsis‿str8 const source[static restrict 1]) |
Encode binary data into a string that is base64 encoded. | |
static uint32_t | ellipsis‿base64‿encode_1 (uint32_t c0) |
static uint32_t | ellipsis‿base64‿encode_2 (uint32_t c0, uint32_t c1) |
static uint32_t | ellipsis‿base64‿encode_3 (uint32_t c0, uint32_t c1, uint32_t c2) |
static uint32_t | ellipsis‿base64‿encode_up (uint32_t inp) |
static void | ellipsis‿base64‿print_1 (char tar[4], uint32_t enc) |
static void | ellipsis‿base64‿print_2 (char tar[4], uint32_t enc) |
static void | ellipsis‿base64‿print_3 (char tar[4], uint32_t enc) |
static void | ellipsis‿base64‿print_4 (uint8_t tar[static 3], uint32_t enc) |
Variables | |
constexpr unsigned char | ellipsis‿base64‿dec [256] |
constexpr char32_t | ellipsis‿base64‿enc [] = U"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" |
constexpr uint32_t | ellipsis‿base64‿esign = '=' |
thread_local bool volatile | ellipsis‿contracts‿ignore‿dynamic |
thread_local bool volatile | ellipsis‿contracts‿proceed‿dynamic |
thread_local bool volatile | ellipsis‿contracts‿verbose‿dynamic |
#define DEC_POS | ( | X | ) | dec_pos_ ## X |
#define ELLIPSIS_CONTRACT | ( | COUNT, | |
COND, | |||
ACTION, | |||
VERB, | |||
CSTR, | |||
CTYPE, | |||
... | |||
) |
#define ELLIPSIS_CONTRACT_CHECK_STATIC | ( | CTYPE, | |
COND, | |||
CSTR, | |||
... | |||
) |
#define ELLIPSIS_CONTRACT_ICE_OR_TRUE | ( | ... | ) |
#define ELLIPSIS_CONTRACT_IMPL | ( | COUNT, | |
COND, | |||
ACTION, | |||
VERB, | |||
CSTR, | |||
CTYPE, | |||
... | |||
) |
#define ELLIPSIS_CONTRACT_VIOLATION | ( | COUNT, | |
VERB, | |||
CTYPE, | |||
CSTR, | |||
... | |||
) |
#define ELLIPSIS_TEST_ICE | ( | ... | ) | (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr) |
#define ELLIPSIS_TO_VOIDS | ( | ... | ) | ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__)))) |
#define STRINGIFY | ( | ... | ) | STRINGIFY_(__VA_ARGS__) |
#define STRINGIFY_ | ( | ... | ) | #__VA_ARGS__ |
typedef struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice |
enum ellipsis_dec_pos |
ellipsis‿str8 * ellipsis‿base64‿decode‿_Inner | ( | size_t | len, |
unsigned char const | buf[static restrict len] | ||
) |
References ellipsis‿base64‿decode_4(), ellipsis‿base64‿print_4(), and ELLIPSIS_WARNING.
Referenced by ellipsis‿base64‿decode‿_Ctra().
|
inline |
Decode a string that contains base64 encoded information into a binary data array.
len
must be a multiple of 4
. In general the length of the output data is then len/4
. One byte is added for a null termination.
The returned string is dynamically allocated with malloc
. If the target length is not a multiple of 3, (that is if the source string has one or two =
characters at the end) one or two bytes are padded with 0
at the end.
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
end inner defer anchor, level 1
References ellipsis‿base64‿decode‿_Ctra(), and ellipsis‿base64‿decode‿_Insta().
Referenced by ellipsis‿base64‿decode‿_Insta(), and ellipsis‿base64‿decode().
|
static |
References ellipsis‿base64‿decode_down().
Referenced by ellipsis‿base64‿decode‿_Inner().
|
static |
References ellipsis‿base64‿dec.
Referenced by ellipsis‿base64‿decode_4().
char * ellipsis‿base64‿encode‿_Inner | ( | ellipsis‿str8 const | buf[static restrict 1] | ) |
References ellipsis‿base64‿encode_1(), ellipsis‿base64‿encode_2(), ellipsis‿base64‿encode_3(), ellipsis‿base64‿print_1(), ellipsis‿base64‿print_2(), ellipsis‿base64‿print_3(), ellipsis‿malloc, and ellipsis‿str8::length.
Referenced by ellipsis‿base64‿encode‿_Ctra().
|
inline |
Encode binary data into a string that is base64 encoded.
The returned string is null-terminated and dynamically allocated with malloc
.
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
end inner defer anchor, level 1
References ellipsis‿base64‿encode‿_Ctra(), and ellipsis‿base64‿encode‿_Insta().
Referenced by ellipsis‿base64‿encode‿_Insta(), and ellipsis‿base64‿encode().
|
static |
References ellipsis‿base64‿encode_up().
Referenced by ellipsis‿base64‿encode‿_Inner().
|
static |
References ellipsis‿base64‿encode_up().
Referenced by ellipsis‿base64‿encode‿_Inner().
|
static |
References ellipsis‿base64‿encode_up().
Referenced by ellipsis‿base64‿encode‿_Inner().
|
static |
References ellipsis‿base64‿enc.
Referenced by ellipsis‿base64‿encode_1(), ellipsis‿base64‿encode_2(), and ellipsis‿base64‿encode_3().
|
static |
References ellipsis‿base64‿esign.
Referenced by ellipsis‿base64‿encode‿_Inner().
|
static |
References ellipsis‿base64‿esign.
Referenced by ellipsis‿base64‿encode‿_Inner().
|
static |
|
static |
|
constexpr |
Referenced by ellipsis‿base64‿decode_down().
|
constexpr |
Referenced by ellipsis‿base64‿encode_up().
|
constexpr |
Referenced by ellipsis‿base64‿print_1(), and ellipsis‿base64‿print_2().
|
extern |
|
extern |
|
extern |