28 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
31 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
32 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
33 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
34 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
35 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
36 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
37 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
38 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
62 buf |= (
unsigned char) *s << (pos << 3);
73 if ((p - dst + 4) > dstlen)
91 if ((p - dst + 4) > dstlen)
96 *p++ = (pos == 0) ?
_base64[(
buf >> 6) & 0x3f] :
'=';
100 Assert((p - dst) <= dstlen);
104 memset(dst, 0, dstlen);
118 const char *srcend = src +
len,
132 if (
c ==
' ' ||
c ==
'\t' ||
c ==
'\n' ||
c ==
'\r')
158 if (
c > 0 &&
c < 127)
175 if ((p - dst + 1) > dstlen)
177 *p++ = (
buf >> 16) & 255;
179 if (end == 0 || end > 1)
182 if ((p - dst + 1) > dstlen)
184 *p++ = (
buf >> 8) & 255;
186 if (end == 0 || end > 2)
189 if ((p - dst + 1) > dstlen)
207 Assert((p - dst) <= dstlen);
211 memset(dst, 0, dstlen);
227 return (srclen + 2) / 3 * 4;
241 return (srclen * 3) >> 2;
int pg_b64_decode(const char *src, int len, char *dst, int dstlen)
int pg_b64_enc_len(int srclen)
int pg_b64_encode(const char *src, int len, char *dst, int dstlen)
int pg_b64_dec_len(int srclen)
static const char _base64[]
static const int8 b64lookup[128]
#define Assert(condition)