MySQL 9.1.0
Source Code Documentation
base64.h File Reference
#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.

Classes

struct  my_base64_decoder_t
 

Macros

#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS   1
 

Typedefs

typedef struct my_base64_decoder_t MY_BASE64_DECODER
 

Functions

static bool my_base64_decoder_skip_spaces (MY_BASE64_DECODER *decoder)
 Skip leading spaces in a base64 encoded stream and stop on the first non-space character. More...
 
static bool my_base64_add (MY_BASE64_DECODER *decoder)
 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. More...
 
static bool my_base64_decoder_getch (MY_BASE64_DECODER *decoder)
 Get the next character from a base64 encoded stream. More...
 
static uint64 base64_needed_encoded_length (uint64 length_of_data)
 
constexpr uint64 base64_encode_max_arg_length ()
 
static uint64 base64_needed_decoded_length (uint64 length_of_encoded_data)
 
constexpr uint64 base64_decode_max_arg_length ()
 
static int base64_encode (const void *src, size_t src_len, char *dst)
 
static int64 base64_decode (const char *src_base, size_t len, void *dst, const char **end_ptr, int flags)
 Decode a base64 string The base64-encoded data in the range ['src','*end_ptr') will be decoded and stored starting at 'dst'. More...
 

Variables

static char base64_table []
 
static int8 from_base64_table []
 

Macro Definition Documentation

◆ MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS

#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS   1

Typedef Documentation

◆ MY_BASE64_DECODER

Function Documentation

◆ 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_basePointer to base64-encoded string
lenLength of string at 'src'
dstPointer to location where decoded data will be stored
end_ptrPointer to variable that will refer to the character after the end of the encoded data that were decoded. Can be NULL.
flagsflags e.g. allow multiple chunks
Returns
Number of bytes written at 'dst', or -1 in case of failure

◆ base64_decode_max_arg_length()

constexpr uint64 base64_decode_max_arg_length ( )
inlineconstexpr

◆ base64_encode()

static int base64_encode ( const void *  src,
size_t  src_len,
char *  dst 
)
inlinestatic

◆ base64_encode_max_arg_length()

constexpr uint64 base64_encode_max_arg_length ( )
inlineconstexpr

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

static bool my_base64_add ( MY_BASE64_DECODER decoder)
inlinestatic

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
decoderbase64 decoding stream
Returns
false on success true on error (invalid base64 character found)

◆ my_base64_decoder_getch()

static bool my_base64_decoder_getch ( MY_BASE64_DECODER decoder)
inlinestatic

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

static bool my_base64_decoder_skip_spaces ( MY_BASE64_DECODER decoder)
inlinestatic

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
decoderPointer to MY_BASE64_DECODER
Returns
false on success (there are some more non-space input characters) true on error (end-of-input found)

Variable Documentation

◆ base64_table

char base64_table[]
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"

◆ from_base64_table

int8 from_base64_table[]
static