diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 1999-11-17 22:39:25 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 1999-11-17 22:39:25 +0800 |
commit | ca7044930f42a698fd88f914c2512a20e2eeaae9 (patch) | |
tree | 522962a77005d741097713e87de1d50353b17768 /camel/gmime-base64.c | |
parent | 16de3313b700cb56ab9e829d1e9b7e7d2c81241b (diff) | |
download | gsoc2013-evolution-ca7044930f42a698fd88f914c2512a20e2eeaae9.tar gsoc2013-evolution-ca7044930f42a698fd88f914c2512a20e2eeaae9.tar.gz gsoc2013-evolution-ca7044930f42a698fd88f914c2512a20e2eeaae9.tar.bz2 gsoc2013-evolution-ca7044930f42a698fd88f914c2512a20e2eeaae9.tar.lz gsoc2013-evolution-ca7044930f42a698fd88f914c2512a20e2eeaae9.tar.xz gsoc2013-evolution-ca7044930f42a698fd88f914c2512a20e2eeaae9.tar.zst gsoc2013-evolution-ca7044930f42a698fd88f914c2512a20e2eeaae9.zip |
Added streaming capability to CamelDataWrapper. This makes it possible, for
example, to build multipart messages out of files that are on disk without
loading them in memory.
svn path=/trunk/; revision=1394
Diffstat (limited to 'camel/gmime-base64.c')
-rw-r--r-- | camel/gmime-base64.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/camel/gmime-base64.c b/camel/gmime-base64.c index a9e596d2dc..db784f7143 100644 --- a/camel/gmime-base64.c +++ b/camel/gmime-base64.c @@ -30,15 +30,12 @@ gmime_encode_base64 (CamelStream *input, CamelStream *output) char buffer [BSIZE]; char obuf [80]; /* Output is limited to 76 characters, rfc2045 */ int n, i, j, state; - long bytes; - - j = 0; + int keep = 0; + state = 0; - bytes = 0; - while ((n = camel_stream_read (input, &buffer, sizeof (buffer))) > 0){ - int keep = 0; - - for (i = 0; i < n; i++, state++, bytes++){ + j = 0; + while ((n = camel_stream_read (input, buffer, sizeof (buffer))) > 0){ + for (i = 0; i < n; i++, state++){ char c = buffer [i]; switch (state % 3){ @@ -48,21 +45,23 @@ gmime_encode_base64 (CamelStream *input, CamelStream *output) break; case 1: obuf [j++] = base64_alphabet [keep | (c >> 4)]; - keep = (c & 0xf) << 4; + keep = (c & 0xf) << 2; break; case 2: obuf [j++] = base64_alphabet [keep | (c >> 6)]; obuf [j++] = base64_alphabet [c & 0x3f]; break; } - - if ((bytes % 72) == 0){ + + if (j == 72){ obuf [j++] = '\r'; obuf [j++] = '\n'; camel_stream_write (output, obuf, j); + j = 0; } } } + switch (state % 3){ case 0: /* full ouput, nothing left to do */ |