18 static char alphabet[67] =
19 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n";
24 if (ch >=
'A' && ch <=
'Z')
26 if (ch >=
'a' && ch <=
'z')
28 if (ch >=
'0' && ch <=
'9')
36 if (ch ==
'\n' || ch ==
' ' || ch ==
'\r' || ch ==
'\t' ||
37 ch ==
'\f' || ch ==
'\v')
62 while (in.
used() != 0)
64 unsigned char next = in.
getch();
65 bits = (bits << 8) | next;
69 out.
putch(alphabet[bits >> 2]);
74 out.
putch(alphabet[bits >> 4]);
79 out.
putch(alphabet[bits >> 6]);
80 out.
putch(alphabet[bits & 0x3f]);
87 if (flush && state != ATBIT0)
99 out.
putch(alphabet[bits << 4]);
104 out.
putch(alphabet[bits << 2]);
134 while (in.
used() != 0)
136 unsigned char next = in.
getch();
137 int symbol =
lookup(next);
141 seterror(
"invalid character #%s in base64 input", next);
155 bits = (bits << 6) | symbol;
162 out.
putch(bits >> 4);
167 out.
putch(bits >> 2);
179 "after base64 padding", next);
186 if (flush && (state == ATBIT2 || state == ATBIT4 || state == ATBIT6))