7#ifndef ELLIPSIS_BASE64_H
8#define ELLIPSIS_BASE64_H
20#define STRINGIFY(...) STRINGIFY_(__VA_ARGS__)
21#define STRINGIFY_(...) #__VA_ARGS__
23#define ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR, ...) \
25 static char const contract_format_ ## COUNT[] = \
26 __FILE__ ":" STRINGIFY(__LINE__) ": violation of " CTYPE " `" CSTR "`" __VA_OPT__(", ") __VA_ARGS__ "\n";\
28 ? fputs(contract_format_ ## COUNT, stderr) \
32#define ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) \
35 : (ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR __VA_OPT__(,) __VA_ARGS__) \
40#define ELLIPSIS_TO_VOIDS(...) ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__))))
42#define ELLIPSIS_TEST_ICE(...) (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr)
44#define ELLIPSIS_CONTRACT_ICE_OR_TRUE(...) \
46 ELLIPSIS_TEST_ICE(__VA_ARGS__), \
47 ellipsis‿contracts‿is_ice*: (__VA_ARGS__), \
50#define ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR, ...) \
52 static_assert(ELLIPSIS_CONTRACT_ICE_OR_TRUE(COND), \
53 "compile time violation of " CTYPE " " CSTR \
54 __VA_OPT__(", ") __VA_ARGS__ );\
57#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) \
61 ELLIPSIS_TEST_ICE(COND), \
62 ellipsis‿contracts‿is_ice*: ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR __VA_OPT__(,) __VA_ARGS__), \
63 default: ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE __VA_OPT__(,) __VA_ARGS__));\
82 typeof(
char*) DEFER_LOC_ID_0_1;
83 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
84 DEFER_LOC_ID_0_1 = (typeof(
char*)) {};
86 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
87 [[__maybe_unused__]]
register bool defer_return_flag =
false;
90 goto DEFER_END_ID_1_2;
93 do {
ELLIPSIS_CONTRACT(1, source, abort,
true,
"source",
"assertion",
"missing source for encoding UTF-8 string");}
while (
false);
95 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
96 unsigned (*DEFER_LOC_ID_1_1)[DEFER_LOC_ID_0_2] = {};
99 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
100 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
101 {
ELLIPSIS_CONTRACT(2, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"allocation for encoding UTF-8 string failed");}
109 defer_return_flag =
true;
116[[__maybe_unused__]] DEFER_END_ID_1_2:;
117 return DEFER_LOC_ID_0_1;
138 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
141 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
142 [[__maybe_unused__]]
register bool defer_return_flag =
false;
145 goto DEFER_END_ID_1_4;
148 do {
ELLIPSIS_CONTRACT(3, buf, abort,
true,
"buf",
"assertion",
"missing input string when decoding UTF-8 string");}
while (
false);
150 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
151 unsigned (*DEFER_LOC_ID_1_2)[DEFER_LOC_ID_0_2] = {};
154 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
155 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
156 {
ELLIPSIS_CONTRACT(4, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"allocation for decoding UTF-8 string failed");}
164 defer_return_flag =
true;
171[[__maybe_unused__]] DEFER_END_ID_1_4:;
172 return DEFER_LOC_ID_0_1;
185 typeof(
char*) DEFER_LOC_ID_0_1;
186 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
187 DEFER_LOC_ID_0_1 = (typeof(
char*)) {};
189 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
190 [[__maybe_unused__]]
register bool defer_return_flag =
false;
193 goto DEFER_END_ID_1_6;
196 do {
ELLIPSIS_CONTRACT(5, source, unreachable,
false,
"source",
"assumption",
"missing source for encoding UTF-8 string");}
while (
false);
198 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
199 unsigned (*DEFER_LOC_ID_1_3)[DEFER_LOC_ID_0_2] = {};
202 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
203 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
204 {
ELLIPSIS_CONTRACT(6, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"allocation for encoding UTF-8 string failed");}
212 defer_return_flag =
true;
219[[__maybe_unused__]] DEFER_END_ID_1_6:;
220 return DEFER_LOC_ID_0_1;
241 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
244 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
245 [[__maybe_unused__]]
register bool defer_return_flag =
false;
248 goto DEFER_END_ID_1_8;
251 do {
ELLIPSIS_CONTRACT(7, buf, unreachable,
false,
"buf",
"assumption",
"missing input string when decoding UTF-8 string");}
while (
false);
253 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
254 unsigned (*DEFER_LOC_ID_1_4)[DEFER_LOC_ID_0_2] = {};
257 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
258 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
259 {
ELLIPSIS_CONTRACT(8, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"allocation for decoding UTF-8 string failed");}
267 defer_return_flag =
true;
274[[__maybe_unused__]] DEFER_END_ID_1_8:;
275 return DEFER_LOC_ID_0_1;
char * ellipsis‿base64‿encode‿_Insta(ellipsis‿str8 const source[static restrict 1])
Encode binary data into a string that is base64 encoded.
Definition ellipsis-base64.c:382
char * ellipsis‿base64‿encode‿_Inner(ellipsis‿str8 const buf[static restrict 1])
Definition ellipsis-base64.c:307
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.
Definition ellipsis-base64.c:426
ellipsis‿str8 * ellipsis‿base64‿decode‿_Inner(size_t len, unsigned char const buf[static restrict len])
Definition ellipsis-base64.c:336
thread_local bool volatile ellipsis‿contracts‿verbose‿dynamic
#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE,...)
Definition ellipsis-base64.h:57
ellipsis‿str8 * ellipsis‿base64‿decode‿_Ctra(size_t len, unsigned char const buf[static restrict len])
Decode a string that contains base64 encoded information into a binary data array.
Definition ellipsis-base64.h:239
thread_local bool volatile ellipsis‿contracts‿proceed‿dynamic
ellipsis‿str8 * ellipsis‿base64‿decode(size_t len, unsigned char const buf[static restrict len])
Decode a string that contains base64 encoded information into a binary data array.
Definition ellipsis-base64.h:136
char * ellipsis‿base64‿encode(ellipsis‿str8 const source[static restrict 1])
Encode binary data into a string that is base64 encoded.
Definition ellipsis-base64.h:81
thread_local bool volatile ellipsis‿contracts‿ignore‿dynamic
char * ellipsis‿base64‿encode‿_Ctra(ellipsis‿str8 const source[static restrict 1])
Encode binary data into a string that is base64 encoded.
Definition ellipsis-base64.h:184
#define GNU_ATTR_MALLOC(...)
Definition ellipsis-error.h:44
struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice
Definition ellipsis-expression.c:24
A structure with a flexible array member of base type ellipsis‿str8‿base.
Definition ellipsis-str8.h:150