12int main(
int argc,
char* argv[]) {
15 N_STR* example_text =
char_to_nstr(
"This is an example of base64 encode/decode, with a newline:\nThis is the end of the testing test.");
17 while (example_text->
data[example_text->
written] !=
'\0') {
32 if (argc > 0 && argv[1]) {
33 N_STR* input_data = NULL;
34 N_STR* output_name = NULL;
35 N_STR* output_data = NULL;
36 N_STR* decoded_data = NULL;
38 nstrprintf(output_name,
"%s.encoded", argv[1]);
47 nstrprintf(output_name,
"%s.decoded", argv[1]);
#define _nstr(__PTR)
N_STR or "NULL" string for logging purposes.
N_STR * n_base64_decode(N_STR *bufcoded)
decode a N_STR *string
N_STR * n_base64_encode(N_STR *input)
encode a N_STR *string
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
size_t written
size of the written data inside the string
size_t length
length of string (in case we wanna keep information after the 0 end of string value)
#define free_nstr(__ptr)
free a N_STR structure and set the pointer to NULL
int nstr_to_file(N_STR *str, char *filename)
Write a N_STR content into a file.
N_STR * char_to_nstr(const char *src)
Convert a char into a N_STR, short version.
#define nstrprintf(__nstr_var, __format,...)
Macro to quickly allocate and sprintf to N_STR.
N_STR * file_to_nstr(char *filename)
Load a whole file into a N_STR.
A box including a string and his lenght.
base64 encoding and decoding functions using N_STR
List structures and definitions.
N_STR and string function declaration.