eĿlipsis
a language independent preprocessor
 
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Loading...
Searching...
No Matches
ellipsis-base64.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ellipsis-base64.h"
#include "utils/ellipsis-error.h"
#include <stdint.h>
Include dependency graph for ellipsis-base64.c:

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‿str8ellipsis‿base64‿decode‿_Inner (size_t len, unsigned char const buf[static restrict len])
 
ellipsis‿str8ellipsis‿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
 

Detailed Description

Warning
This is a file generated by eĿlipsis version 20250309, do not modify

Macro Definition Documentation

◆ DEC_POS

#define DEC_POS (   X)    dec_pos_ ## X

◆ DEC_POS_INIT

#define DEC_POS_INIT (   C,
 
)    [C] = DEC_POS(X)

◆ ELLIPSIS_CONTRACT

#define ELLIPSIS_CONTRACT (   COUNT,
  COND,
  ACTION,
  VERB,
  CSTR,
  CTYPE,
  ... 
)
Value:
\
do { \
_Generic( \
default: ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE __VA_OPT__(,) __VA_ARGS__));\
} while(false)
#define ELLIPSIS_TEST_ICE(...)
Definition ellipsis-base64.c:45
#define ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR,...)
Definition ellipsis-base64.c:53
#define ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE,...)
Definition ellipsis-base64.c:35
struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice
Definition ellipsis-expression.c:24
#define __VA_OPT__
A pseudo macro that cannot be redefined.
Definition ellipsis-predefined.dirs:89

◆ ELLIPSIS_CONTRACT_CHECK_STATIC

#define ELLIPSIS_CONTRACT_CHECK_STATIC (   CTYPE,
  COND,
  CSTR,
  ... 
)
Value:
({\
static_assert(ELLIPSIS_CONTRACT_ICE_OR_TRUE(COND), \
"compile time violation of " CTYPE " " CSTR \
__VA_OPT__(", ") __VA_ARGS__ );\
})
#define ELLIPSIS_CONTRACT_ICE_OR_TRUE(...)
Definition ellipsis-base64.c:47

◆ ELLIPSIS_CONTRACT_ICE_OR_TRUE

#define ELLIPSIS_CONTRACT_ICE_OR_TRUE (   ...)
Value:
_Generic( \
ELLIPSIS_TEST_ICE(__VA_ARGS__), \
ellipsis‿contracts‿is_ice*: (__VA_ARGS__), \
default: true)
#define true
The constant true made accessible to the preprocessor.
Definition ellipsis-builtins.dirs:32

◆ ELLIPSIS_CONTRACT_IMPL

#define ELLIPSIS_CONTRACT_IMPL (   COUNT,
  COND,
  ACTION,
  VERB,
  CSTR,
  CTYPE,
  ... 
)
Value:
(((false) || (COND)) \
? (void)0 \
: (ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR __VA_OPT__(,) __VA_ARGS__) \
, ((false) \
? (void)0 \
: ACTION())))
#define ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR,...)
Definition ellipsis-base64.c:26

◆ ELLIPSIS_CONTRACT_VIOLATION

#define ELLIPSIS_CONTRACT_VIOLATION (   COUNT,
  VERB,
  CTYPE,
  CSTR,
  ... 
)
Value:
({\
static char const contract_format_ ## COUNT[] = \
__FILE__ ":" STRINGIFY(__LINE__) ": violation of " CTYPE " `" CSTR "`" __VA_OPT__(", ") __VA_ARGS__ "\n";\
(VERB \
? fputs(contract_format_ ## COUNT, stderr) \
: 0);\
})
#define STRINGIFY(...)
Definition ellipsis-base64.c:23
#define __FILE__
The current source file as required by the C standard.
Definition ellipsis-builtins.dirs:21
#define __LINE__
The current physical source line as required by the C standard.
Definition ellipsis-builtins.dirs:24

◆ ELLIPSIS_TEST_ICE

#define ELLIPSIS_TEST_ICE (   ...)    (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr)

◆ ELLIPSIS_TO_VOIDS

#define ELLIPSIS_TO_VOIDS (   ...)    ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__))))

◆ STRINGIFY

#define STRINGIFY (   ...)    STRINGIFY_(__VA_ARGS__)

◆ STRINGIFY_

#define STRINGIFY_ (   ...)    #__VA_ARGS__

Typedef Documentation

◆ ellipsis‿contracts‿is_ice

Enumeration Type Documentation

◆ ellipsis_dec_pos

Enumerator
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 

Function Documentation

◆ ellipsis‿base64‿decode‿_Inner()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsis‿base64‿decode‿_Insta()

ellipsis‿str8 * ellipsis‿base64‿decode‿_Insta ( size_t  len,
unsigned char const  buf[static restrict len] 
)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsis‿base64‿decode_4()

static uint32_t ellipsis‿base64‿decode_4 ( uint32_t  c0,
uint32_t  c1,
uint32_t  c2,
uint32_t  c3 
)
static

References ellipsis‿base64‿decode_down().

Referenced by ellipsis‿base64‿decode‿_Inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsis‿base64‿decode_down()

static uint32_t ellipsis‿base64‿decode_down ( uint32_t  inp)
static

References ellipsis‿base64‿dec.

Referenced by ellipsis‿base64‿decode_4().

Here is the caller graph for this function:

◆ ellipsis‿base64‿encode‿_Inner()

char * ellipsis‿base64‿encode‿_Inner ( ellipsis‿str8 const  buf[static restrict 1])
Remarks
This translation unit implements ellipsis‿base64::ellipsis‿base64‿encode, ellipsis‿base64::ellipsis‿base64‿decode

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsis‿base64‿encode‿_Insta()

char * ellipsis‿base64‿encode‿_Insta ( ellipsis‿str8 const  source[static restrict 1])
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsis‿base64‿encode_1()

static uint32_t ellipsis‿base64‿encode_1 ( uint32_t  c0)
static

References ellipsis‿base64‿encode_up().

Referenced by ellipsis‿base64‿encode‿_Inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsis‿base64‿encode_2()

static uint32_t ellipsis‿base64‿encode_2 ( uint32_t  c0,
uint32_t  c1 
)
static

References ellipsis‿base64‿encode_up().

Referenced by ellipsis‿base64‿encode‿_Inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsis‿base64‿encode_3()

static uint32_t ellipsis‿base64‿encode_3 ( uint32_t  c0,
uint32_t  c1,
uint32_t  c2 
)
static

References ellipsis‿base64‿encode_up().

Referenced by ellipsis‿base64‿encode‿_Inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsis‿base64‿encode_up()

static uint32_t ellipsis‿base64‿encode_up ( uint32_t  inp)
static

References ellipsis‿base64‿enc.

Referenced by ellipsis‿base64‿encode_1(), ellipsis‿base64‿encode_2(), and ellipsis‿base64‿encode_3().

Here is the caller graph for this function:

◆ ellipsis‿base64‿print_1()

static void ellipsis‿base64‿print_1 ( char  tar[4],
uint32_t  enc 
)
static

References ellipsis‿base64‿esign.

Referenced by ellipsis‿base64‿encode‿_Inner().

Here is the caller graph for this function:

◆ ellipsis‿base64‿print_2()

static void ellipsis‿base64‿print_2 ( char  tar[4],
uint32_t  enc 
)
static

References ellipsis‿base64‿esign.

Referenced by ellipsis‿base64‿encode‿_Inner().

Here is the caller graph for this function:

◆ ellipsis‿base64‿print_3()

static void ellipsis‿base64‿print_3 ( char  tar[4],
uint32_t  enc 
)
static

Referenced by ellipsis‿base64‿encode‿_Inner().

Here is the caller graph for this function:

◆ ellipsis‿base64‿print_4()

static void ellipsis‿base64‿print_4 ( uint8_t  tar[static 3],
uint32_t  enc 
)
static

Referenced by ellipsis‿base64‿decode‿_Inner().

Here is the caller graph for this function:

Variable Documentation

◆ ellipsis‿base64‿dec

constexpr unsigned char ellipsis‿base64‿dec[256]
constexpr

◆ ellipsis‿base64‿enc

constexpr char32_t ellipsis‿base64‿enc[] = U"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
constexpr

◆ ellipsis‿base64‿esign

constexpr uint32_t ellipsis‿base64‿esign = '='
constexpr

◆ ellipsis‿contracts‿ignore‿dynamic

thread_local bool volatile ellipsis‿contracts‿ignore‿dynamic
extern

◆ ellipsis‿contracts‿proceed‿dynamic

thread_local bool volatile ellipsis‿contracts‿proceed‿dynamic
extern

◆ ellipsis‿contracts‿verbose‿dynamic

thread_local bool volatile ellipsis‿contracts‿verbose‿dynamic
extern