#include <stddef.h>
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "my_config.h"
#include "my_inttypes.h"
Go to the source code of this file.
◆ MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS
#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1 |
◆ MY_BASE64_DECODER
◆ base64_decode()
static int64 base64_decode |
( |
const char * |
src_base, |
|
|
size_t |
len, |
|
|
void * |
dst, |
|
|
const char ** |
end_ptr, |
|
|
int |
flags |
|
) |
| |
|
inlinestatic |
Decode a base64 string The base64-encoded data in the range ['src','*end_ptr') will be decoded and stored starting at 'dst'.
The decoding will stop after 'len' characters have been read from 'src', or when padding occurs in the base64-encoded data. In either case: if 'end_ptr' is non-null, '*end_ptr' will be set to point to the character after the last read character, even in the presence of error.
Note: We require that 'dst' is pre-allocated to correct size.
- Parameters
-
src_base | Pointer to base64-encoded string |
len | Length of string at 'src' |
dst | Pointer to location where decoded data will be stored |
end_ptr | Pointer to variable that will refer to the character after the end of the encoded data that were decoded. Can be NULL. |
flags | flags e.g. allow multiple chunks |
- Returns
- Number of bytes written at 'dst', or -1 in case of failure
◆ base64_decode_max_arg_length()
static uint64 base64_decode_max_arg_length |
( |
| ) |
|
|
inlinestatic |
◆ base64_encode()
static int base64_encode |
( |
const void * |
src, |
|
|
size_t |
src_len, |
|
|
char * |
dst |
|
) |
| |
|
inlinestatic |
◆ base64_encode_max_arg_length()
static uint64 base64_encode_max_arg_length |
( |
| ) |
|
|
inlinestatic |
◆ base64_needed_decoded_length()
static uint64 base64_needed_decoded_length |
( |
uint64 |
length_of_encoded_data | ) |
|
|
inlinestatic |
◆ base64_needed_encoded_length()
static uint64 base64_needed_encoded_length |
( |
uint64 |
length_of_data | ) |
|
|
inlinestatic |
◆ my_base64_add()
Convert the next character in a base64 encoded stream to a number in the range [0..63] and mix it with the previously collected value in decoder->c.
- Parameters
-
decoder | base64 decoding stream |
- Returns
- false on success true on error (invalid base64 character found)
◆ my_base64_decoder_getch()
Get the next character from a base64 encoded stream.
Skip spaces, then scan the next base64 character or a pad character and collect bits into decoder->c.
- Parameters
-
decoder | Pointer to MY_BASE64_DECODER |
- Returns
- false on success (a valid base64 encoding character found) true on error (unexpected character or unexpected end-of-input found)
◆ my_base64_decoder_skip_spaces()
Skip leading spaces in a base64 encoded stream and stop on the first non-space character.
decoder->src will point to the first non-space character, or to the end of the input string. In case when end-of-input met on unexpected position, decoder->error is also set to 1.
- Parameters
-
decoder | Pointer to MY_BASE64_DECODER |
- Returns
- false on success (there are some more non-space input characters) true on error (end-of-input found)
◆ base64_table
Initial value:=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"
◆ from_base64_table