base64.h
author Ryan C. Gordon <icculus@icculus.org>
Sun, 18 Jun 2017 19:50:43 -0400
changeset 57 4974e5368a29
parent 0 d7ee4e2ed49d
permissions -rw-r--r--
Minor type cleanup ("unsigned char" -> "uint8_t").
icculus@0
     1
/*
icculus@0
     2
cdecode.h - c header for a base64 decoding algorithm
icculus@0
     3
This is part of the libb64 project, and has been placed in the public domain.
icculus@0
     4
For details, see http://sourceforge.net/projects/libb64
icculus@0
     5
*/
icculus@0
     6
icculus@0
     7
#ifndef _INCL_BASE64_H_
icculus@0
     8
#define _INCL_BASE64_H_
icculus@0
     9
icculus@0
    10
#include <stdint.h>
icculus@0
    11
icculus@0
    12
typedef enum
icculus@0
    13
{
icculus@0
    14
	step_a, step_b, step_c, step_d
icculus@0
    15
} base64_decodestep;
icculus@0
    16
icculus@0
    17
typedef struct
icculus@0
    18
{
icculus@0
    19
	base64_decodestep step;
icculus@0
    20
	char plainchar;
icculus@0
    21
} base64_decodestate;
icculus@0
    22
icculus@0
    23
void base64_init_decodestate(base64_decodestate* state_in);
icculus@0
    24
int base64_decode_value(char value_in);
icculus@0
    25
int base64_decode_block(const char* code_in, const int length_in, uint8_t* plaintext_out, base64_decodestate* state_in);
icculus@0
    26
icculus@0
    27
icculus@0
    28
typedef enum
icculus@0
    29
{
icculus@0
    30
	step_A, step_B, step_C
icculus@0
    31
} base64_encodestep;
icculus@0
    32
icculus@0
    33
typedef struct
icculus@0
    34
{
icculus@0
    35
	base64_encodestep step;
icculus@0
    36
	char result;
icculus@0
    37
	int stepcount;
icculus@0
    38
} base64_encodestate;
icculus@0
    39
icculus@0
    40
void base64_init_encodestate(base64_encodestate* state_in);
icculus@0
    41
char base64_encode_value(char value_in);
icculus@0
    42
int base64_encode_block(const uint8_t* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in);
icculus@0
    43
int base64_encode_blockend(char* code_out, base64_encodestate* state_in);
icculus@0
    44
icculus@0
    45
#endif
icculus@0
    46