diff options
Diffstat (limited to 'camel/camel-stream-b64.c')
-rw-r--r-- | camel/camel-stream-b64.c | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/camel/camel-stream-b64.c b/camel/camel-stream-b64.c index f2155a2c95..3b97b11aad 100644 --- a/camel/camel-stream-b64.c +++ b/camel/camel-stream-b64.c @@ -32,38 +32,38 @@ static CamelStreamClass *parent_class = NULL; static guchar char_to_six_bits [256] = { - 66, 66, 66, 66, 66, 66, 66, 66, /* 0 .. 7 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 8 .. 15 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 16 .. 23 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 24 .. 31 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 32 .. 39 */ - 66, 66, 66, 62, 66, 66, 66, 63, /* 40 .. 47 */ - 52, 53, 54, 55, 56, 57, 58, 59, /* 48 .. 55 */ - 60, 61, 66, 66, 66, 65, 66, 66, /* 56 .. 63 */ - 66, 0, 1, 2, 3, 4, 5, 6, /* 64 .. 71 */ - 7, 8, 9, 10, 11, 12, 13, 14, /* 72 .. 79 */ - 15, 16, 17, 18, 19, 20, 21, 22, /* 80 .. 87 */ - 23, 24, 25, 66, 66, 66, 66, 66, /* 88 .. 95 */ - 66, 26, 27, 28, 29, 30, 31, 32, /* 96 .. 103 */ - 33, 34, 35, 36, 37, 38, 39, 40, /* 104 .. 111 */ - 41, 42, 43, 44, 45, 46, 47, 48, /* 112 .. 119 */ - 49, 50, 51, 66, 66, 66, 66, 66, /* 120 .. 127 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 128 .. 135 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 136 .. 143 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 144 .. 151 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 152 .. 159 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 160 .. 167 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 168 .. 175 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 176 .. 183 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 184 .. 191 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 192 .. 199 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 200 .. 207 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 208 .. 215 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 216 .. 223 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 224 .. 231 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 232 .. 239 */ - 66, 66, 66, 66, 66, 66, 66, 66, /* 240 .. 247 */ - 66, 66, 66, 66, 66, 66, 66, 66 /* 248 .. 255 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 0 .. 7 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 8 .. 15 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 16 .. 23 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 24 .. 31 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 32 .. 39 */ + 128, 128, 128, 62, 128, 128, 128, 63, /* 40 .. 47 */ + 52, 53, 54, 55, 56, 57, 58, 59, /* 48 .. 55 */ + 60, 61, 128, 128, 128, 64, 128, 128, /* 56 .. 63 */ + 128, 0, 1, 2, 3, 4, 5, 6, /* 64 .. 71 */ + 7, 8, 9, 10, 11, 12, 13, 14, /* 72 .. 79 */ + 15, 16, 17, 18, 19, 20, 21, 22, /* 80 .. 87 */ + 23, 24, 25, 128, 128, 128, 128, 128, /* 88 .. 95 */ + 128, 26, 27, 28, 29, 30, 31, 32, /* 96 .. 103 */ + 33, 34, 35, 36, 37, 38, 39, 40, /* 104 .. 111 */ + 41, 42, 43, 44, 45, 46, 47, 48, /* 112 .. 119 */ + 49, 50, 51, 128, 128, 128, 128, 128, /* 120 .. 127 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 128 .. 135 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 136 .. 143 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 144 .. 151 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 152 .. 159 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 160 .. 167 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 168 .. 175 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 176 .. 183 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 184 .. 191 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 192 .. 199 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 200 .. 207 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 208 .. 215 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 216 .. 223 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 224 .. 231 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 232 .. 239 */ + 128, 128, 128, 128, 128, 128, 128, 128, /* 240 .. 247 */ + 128, 128, 128, 128, 128, 128, 128, 128 /* 248 .. 255 */ }; @@ -253,17 +253,21 @@ static gint read_decode__static (CamelStream *stream, /* if we encounter an '=' we can assume the end of the stream has been found */ - if (six_bits_value == 65) { + if (six_bits_value == 64) { stream_b64->eos = TRUE; + status->keep = 0; + break; } /* test if we must ignore the character */ - if (six_bits_value != 66) { - + if (six_bits_value != 128) { + six_bits_value = six_bits_value & 0x3f; + switch (status->state % 4){ case 0: status->keep = six_bits_value << 2; + break; case 1: buffer [j++] = status->keep | (six_bits_value >> 4); @@ -275,14 +279,15 @@ static gint read_decode__static (CamelStream *stream, break; case 3: buffer [j++] = status->keep | six_bits_value; + status->keep = 0; break; } status->state = (status->state + 1) % 4; + } - - nb_read_in_input = camel_stream_read (input_stream, &c, 1); + if (j<n) nb_read_in_input = camel_stream_read (input_stream, &c, 1); } |