Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef BASE64_H
00022 # define BASE64_H
00023
00024
00025 # include <stddef.h>
00026
00027
00028 # include <stdbool.h>
00029
00030
00031
00032 # define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
00033
00034 struct base64_decode_context
00035 {
00036 unsigned int i;
00037 char buf[4];
00038 };
00039
00040 extern bool isbase64 (char ch);
00041
00042 extern void base64_encode (const char *in, size_t inlen,
00043 char *out, size_t outlen);
00044
00045 extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
00046
00047 extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
00048
00049 extern bool base64_decode_ctx (struct base64_decode_context *ctx,
00050 const char *in, size_t inlen,
00051 char *out, size_t *outlen);
00052
00053 extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
00054 const char *in, size_t inlen,
00055 char **out, size_t *outlen);
00056
00057 #define base64_decode(in, inlen, out, outlen) \
00058 base64_decode_ctx (NULL, in, inlen, out, outlen)
00059
00060 #define base64_decode_alloc(in, inlen, out, outlen) \
00061 base64_decode_alloc_ctx (NULL, in, inlen, out, outlen)
00062
00063 #endif