]>
git.ipfire.org Git - thirdparty/squid.git/blob - lib/base64.c
10 #include "ansiproto.h"
12 static void base64_init
_PARAMS((void));
14 static int base64_initialized
= 0;
15 int base64_value
[256];
16 char base64_code
[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
23 for (i
= 0; i
< 256; i
++)
26 for (i
= 0; i
< 64; i
++)
27 base64_value
[(int) base64_code
[i
]] = i
;
28 base64_value
['='] = 0;
30 base64_initialized
= 1;
34 base64_decode(char *p
)
36 static char result
[8192];
45 if (!base64_initialized
)
51 i
= base64_value
[(int) *p
++];
56 if (c
== 4) { /* One quantum of four encoding characters/24 bit */
57 *d
++ = val
>> 16; /* High 8 bits */
58 *d
++ = (val
>> 8) & 0xff; /* Mid 8 bits */
59 *d
++ = val
& 0xff; /* Low 8 bits */
64 return *result
? result
: NULL
;