aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/camel-mime-filter-basic.c4
-rw-r--r--camel/camel-mime-utils.c11
-rw-r--r--camel/camel-mime-utils.h4
-rw-r--r--camel/camel-multipart.c2
4 files changed, 11 insertions, 10 deletions
diff --git a/camel/camel-mime-filter-basic.c b/camel/camel-mime-filter-basic.c
index 48e2106e35..8dd94e1580 100644
--- a/camel/camel-mime-filter-basic.c
+++ b/camel/camel-mime-filter-basic.c
@@ -99,7 +99,7 @@ complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out,
case CAMEL_MIME_FILTER_BASIC_BASE64_ENC:
/* wont go to more than 2x size (overly conservative) */
camel_mime_filter_set_size(mf, len*2, FALSE);
- newlen = base64_encode_close(in, len, mf->outbuf, &f->state, &f->save);
+ newlen = base64_encode_close(in, len, TRUE, mf->outbuf, &f->state, &f->save);
break;
case CAMEL_MIME_FILTER_BASIC_QP_ENC:
/* *4 is definetly more than needed ... */
@@ -143,7 +143,7 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s
case CAMEL_MIME_FILTER_BASIC_BASE64_ENC:
/* wont go to more than 2x size (overly conservative) */
camel_mime_filter_set_size(mf, len*2, FALSE);
- newlen = base64_encode_step(in, len, mf->outbuf, &f->state, &f->save);
+ newlen = base64_encode_step(in, len, TRUE, mf->outbuf, &f->state, &f->save);
break;
case CAMEL_MIME_FILTER_BASIC_QP_ENC:
/* *4 is overly conservative, but will do */
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 8b6194763d..cc5fa813dd 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -273,13 +273,13 @@ int main(int argc, char **argv)
/* call this when finished encoding everything, to
flush off the last little bit */
int
-base64_encode_close(unsigned char *in, int inlen, unsigned char *out, int *state, int *save)
+base64_encode_close(unsigned char *in, int inlen, gboolean break_lines, unsigned char *out, int *state, int *save)
{
int c1, c2;
unsigned char *outptr = out;
if (inlen>0)
- outptr += base64_encode_step(in, inlen, outptr, state, save);
+ outptr += base64_encode_step(in, inlen, break_lines, outptr, state, save);
c1 = ((char *)save)[1];
c2 = ((char *)save)[2];
@@ -297,7 +297,8 @@ base64_encode_close(unsigned char *in, int inlen, unsigned char *out, int *state
outptr += 4;
break;
}
- *outptr++ = '\n';
+ if (break_lines)
+ *outptr++ = '\n';
*save = 0;
*state = 0;
@@ -311,7 +312,7 @@ base64_encode_close(unsigned char *in, int inlen, unsigned char *out, int *state
0 on first invocation).
*/
int
-base64_encode_step(unsigned char *in, int len, unsigned char *out, int *state, int *save)
+base64_encode_step(unsigned char *in, int len, gboolean break_lines, unsigned char *out, int *state, int *save)
{
register unsigned char *inptr, *outptr;
@@ -348,7 +349,7 @@ base64_encode_step(unsigned char *in, int len, unsigned char *out, int *state, i
*outptr++ = base64_alphabet [ ( (c2 &0x0f) << 2 ) | (c3 >> 6) ];
*outptr++ = base64_alphabet [ c3 & 0x3f ];
/* this is a bit ugly ... */
- if ((++already)>=19) {
+ if (break_lines && (++already)>=19) {
*outptr++='\n';
already = 0;
}
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index 1a503d6710..dc865004ee 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -167,8 +167,8 @@ void header_mime_decode(const char *in, int *maj, int *min);
/* do incremental base64/quoted-printable (de/en)coding */
int base64_decode_step(unsigned char *in, int len, unsigned char *out, int *state, unsigned int *save);
-int base64_encode_step(unsigned char *in, int len, unsigned char *out, int *state, int *save);
-int base64_encode_close(unsigned char *in, int inlen, unsigned char *out, int *state, int *save);
+int base64_encode_step(unsigned char *in, int len, gboolean break_lines, unsigned char *out, int *state, int *save);
+int base64_encode_close(unsigned char *in, int inlen, gboolean break_lines, unsigned char *out, int *state, int *save);
int uudecode_step (unsigned char *in, int len, unsigned char *out, int *state, guint32 *save, char *uulen);
diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c
index 1d0446842c..018d90b509 100644
--- a/camel/camel-multipart.c
+++ b/camel/camel-multipart.c
@@ -362,7 +362,7 @@ set_boundary (CamelMultipart *multipart, gchar *boundary)
strcpy (bbuf, "=-");
p = bbuf + 2;
state = save = 0;
- p += base64_encode_step (digest, 16, p, &state, &save);
+ p += base64_encode_step (digest, 16, FALSE, p, &state, &save);
*p = '\0';
boundary = bbuf;