6 /* Characters and translation as per rfc2047. */
7 static char char64table
[128] = {
8 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
9 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
10 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
11 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
12 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
13 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
14 -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
15 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
18 #define char64enc(c) (((c) & 0x80) ? -1 : char64table[(c)])
20 static void die_nomem(fatal
)
23 strerr_die2x(111,fatal
,ERR_NOMEM
);
26 void decodeB(cpfrom
,n
,outdata
,fatal
)
31 /* does B decoding of the string pointed to by cpfrom up to the character */
32 /* before the one pointed to by cpnext, and appends the results to mimeline*/
35 char holdch
[4] = "???";
37 char c
; /* needs to be signed */
44 if (!stralloc_readyplus(outdata
,n
)) die_nomem(fatal
);
47 for (j
= 2; j
>= 0; --j
) {
48 holdch
[j
] = hold32
& 0xff;
51 if (!stralloc_cats(outdata
,holdch
)) die_nomem(fatal
);
57 if (cp
>= cpnext
) { /* pad */
63 if (c
< 0) /* ignore illegal characters */
66 hold32
= (hold32
<< 6) | (c
& 0x7f);