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 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 52 53 54 55 56 57
|
#include "libbase64.h"
// Function parameters for encoding functions:
#define BASE64_ENC_PARAMS \
( struct base64_state *state \
, const char *src \
, size_t srclen \
, char *out \
, size_t *outlen \
)
// Function parameters for decoding functions:
#define BASE64_DEC_PARAMS \
( struct base64_state *state \
, const char *src \
, size_t srclen \
, char *out \
, size_t *outlen \
)
// This function is used as a stub when a certain encoder is not compiled in.
// It discards the inputs and returns zero output bytes.
static inline void
base64_enc_stub BASE64_ENC_PARAMS
{
(void) state;
(void) src;
(void) srclen;
(void) out;
*outlen = 0;
}
// This function is used as a stub when a certain decoder is not compiled in.
// It discards the inputs and returns an invalid decoding result.
static inline int
base64_dec_stub BASE64_DEC_PARAMS
{
(void) state;
(void) src;
(void) srclen;
(void) out;
(void) outlen;
return -1;
}
typedef void (* base64_enc_fn) BASE64_ENC_PARAMS;
typedef int (* base64_dec_fn) BASE64_DEC_PARAMS;
struct codec
{
base64_enc_fn enc;
base64_dec_fn dec;
};
extern void codec_choose (struct codec *, int flags);
|