1int ret = 0;
2const uint8_t *s = (const uint8_t *) src;
3uint8_t *o = (uint8_t *) out;
4uint8_t q;
5
6// Use local temporaries to avoid cache thrashing:
7size_t olen = 0;
8size_t slen = srclen;
9struct base64_state st;
10st.eof = state->eof;
11st.bytes = state->bytes;
12st.carry = state->carry;
13
14// If we previously saw an EOF or an invalid character, bail out:
15if (st.eof) {
16 *outlen = 0;
17 ret = 0;
18 // If there was a trailing '=' to check, check it:
19 if (slen && (st.eof == BASE64_AEOF)) {
20 state->bytes = 0;
21 state->eof = BASE64_EOF;
22 ret = ((base64_table_dec[*s++] == 254) && (slen == 1)) ? 1 : 0;
23 }
24 return ret;
25}
26
27// Turn four 6-bit numbers into three bytes:
28// out[0] = 11111122
29// out[1] = 22223333
30// out[2] = 33444444
31
32// Duff's device again:
33switch (st.bytes)
34{
35 for (;;)
36 {
37 case 0:
38