CUBRID Engine  latest
base64.c File Reference
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
#include <stddef.h>
#include <assert.h>
#include "porting.h"
#include "error_code.h"
#include "memory_alloc.h"
#include "base64.h"
Include dependency graph for base64.c:

Go to the source code of this file.

Classes

struct  base64_chunk
 

Macros

#define MAX_BASE64_LINE_LENGTH   76
 
#define CH_INVALID   -1
 
#define CH_SPACE   -2
 

Typedefs

typedef struct base64_chunk BASE64_CHUNK
 

Functions

static bool char_is_invalid (unsigned char ch)
 
static bool char_is_padding (unsigned char ch)
 
static int get_base64_encode_len (int src_len)
 
static int base64_encode_local (const unsigned char *src, int src_len, unsigned char *dest)
 
static int base64_remove_space (const unsigned char *src, int src_len, unsigned char *dest, int *dst_len)
 
static int base64_partition_into_chunk (const unsigned char *src, int src_len, int *chunk_num, int *dst_len, BASE64_CHUNK ***pppchunk)
 
static int base64_decode_chunk (unsigned char *dest, int chunk_num, BASE64_CHUNK **ppchunk)
 
static void free_base64_chunk (BASE64_CHUNK **ppchunk, int chunk_num)
 
static int find_base64 (unsigned char ch)
 
int base64_decode (const unsigned char *src, int src_len, unsigned char **dest, int *dest_len)
 
int base64_encode (const unsigned char *src, int src_len, unsigned char **dest, int *dest_len)
 

Variables

const char * base64_map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"
 
const char from_base64_table []
 

Macro Definition Documentation

#define CH_INVALID   -1

Definition at line 42 of file base64.c.

Referenced by char_is_invalid().

#define CH_SPACE   -2

Definition at line 43 of file base64.c.

Referenced by base64_remove_space().

#define MAX_BASE64_LINE_LENGTH   76

Definition at line 41 of file base64.c.

Referenced by base64_encode_local(), and get_base64_encode_len().

Typedef Documentation

typedef struct base64_chunk BASE64_CHUNK

Definition at line 46 of file base64.c.

Function Documentation

int base64_decode ( const unsigned char *  src,
int  src_len,
unsigned char **  dest,
int *  dest_len 
)
static int base64_decode_chunk ( unsigned char *  dest,
int  chunk_num,
BASE64_CHUNK **  ppchunk 
)
static

Definition at line 337 of file base64.c.

References assert, base64_chunk::base64_bytes, i, NO_ERROR, NULL, and base64_chunk::padding_len.

Referenced by base64_decode().

Here is the caller graph for this function:

int base64_encode ( const unsigned char *  src,
int  src_len,
unsigned char **  dest,
int *  dest_len 
)

Definition at line 502 of file base64.c.

References assert, base64_encode_local(), db_private_alloc, db_private_free_and_init, ER_OUT_OF_VIRTUAL_MEMORY, get_base64_encode_len(), NO_ERROR, and NULL.

Referenced by db_string_to_base64().

Here is the caller graph for this function:

static int base64_encode_local ( const unsigned char *  src,
int  src_len,
unsigned char *  dest 
)
static

Definition at line 556 of file base64.c.

References assert, base64_map, i, MAX_BASE64_LINE_LENGTH, NO_ERROR, NULL, and p.

Referenced by base64_encode().

Here is the caller graph for this function:

static int base64_partition_into_chunk ( const unsigned char *  src,
int  src_len,
int *  chunk_num,
int *  dst_len,
BASE64_CHUNK ***  pppchunk 
)
static
static int base64_remove_space ( const unsigned char *  src,
int  src_len,
unsigned char *  dest,
int *  dst_len 
)
static

Definition at line 293 of file base64.c.

References assert, CH_SPACE, from_base64_table, i, NO_ERROR, and NULL.

Referenced by base64_decode().

Here is the caller graph for this function:

static bool char_is_invalid ( unsigned char  ch)
static

Definition at line 104 of file base64.c.

References CH_INVALID, and from_base64_table.

Referenced by base64_partition_into_chunk().

Here is the caller graph for this function:

static bool char_is_padding ( unsigned char  ch)
static

Definition at line 115 of file base64.c.

Referenced by base64_partition_into_chunk().

Here is the caller graph for this function:

static int find_base64 ( unsigned char  ch)
static

Definition at line 126 of file base64.c.

References assert, base64_map, CAST_STRLEN, and NULL.

Referenced by base64_partition_into_chunk().

Here is the caller graph for this function:

static void free_base64_chunk ( BASE64_CHUNK **  ppchunk,
int  chunk_num 
)
static

Definition at line 613 of file base64.c.

References db_private_free, i, and NULL.

Referenced by base64_decode(), and base64_partition_into_chunk().

Here is the caller graph for this function:

static int get_base64_encode_len ( int  src_len)
static

Definition at line 472 of file base64.c.

References assert, and MAX_BASE64_LINE_LENGTH.

Referenced by base64_encode().

Here is the caller graph for this function:

Variable Documentation

const char* base64_map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"

Definition at line 56 of file base64.c.

Referenced by base64_encode_local(), and find_base64().

const char from_base64_table[]
Initial value:
= { -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -2, -2, -1, -1, -1, -1,
-1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
}

Definition at line 64 of file base64.c.

Referenced by base64_remove_space(), and char_is_invalid().