summaryrefslogtreecommitdiff
path: root/mailbox
diff options
context:
space:
mode:
authorFrederic Gobry <frederic.gobry@smartdata.ch>2002-11-28 16:40:55 +0000
committerFrederic Gobry <frederic.gobry@smartdata.ch>2002-11-28 16:40:55 +0000
commit1d95c0ddbb712a575604e8a398402c6ca2073ea2 (patch)
treea9f52794962aaa35ad3953a0fb6dd2fe98f65a86 /mailbox
parente130b702f61f60addda58ef139d55401f9938143 (diff)
downloadmailutils-1d95c0ddbb712a575604e8a398402c6ca2073ea2.tar.gz
mailutils-1d95c0ddbb712a575604e8a398402c6ca2073ea2.tar.bz2
set the content-transfer-encoding of a mime message with one part
Diffstat (limited to 'mailbox')
-rw-r--r--mailbox/mime.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/mailbox/mime.c b/mailbox/mime.c
index 02c314528..bdc510eda 100644
--- a/mailbox/mime.c
+++ b/mailbox/mime.c
@@ -399,10 +399,11 @@ _mimepart_body_lines (body_t body, size_t *plines)
static int
_mime_set_content_type(mime_t mime)
{
- char content_type[256];
+ char content_type[256], * content_te;
char boundary[128];
header_t hdr = NULL;
size_t size;
+ int ret;
/* Delayed the creation of the header 'til they create the final message via
mime_get_message() */
@@ -424,6 +425,8 @@ _mime_set_content_type(mime_t mime)
strcat(content_type, mime->boundary);
strcat(content_type, "\"");
mime->flags |= MIME_ADDED_MULTIPART_CT;
+
+ ret = header_set_value(mime->hdrs, MU_HEADER_CONTENT_TYPE, content_type, 1);
} else {
if ( (mime->flags & (MIME_ADDED_CT|MIME_ADDED_MULTIPART_CT)) == MIME_ADDED_CT )
return 0;
@@ -434,9 +437,25 @@ _mime_set_content_type(mime_t mime)
strcpy(content_type, "text/plain; charset=us-ascii");
else
header_get_value(hdr, MU_HEADER_CONTENT_TYPE, content_type, sizeof(content_type), &size);
+
+ ret = header_set_value(mime->hdrs, MU_HEADER_CONTENT_TYPE, content_type, 1);
+ if (ret) return ret;
+
+ /* if the only part contains a transfer-encoding
+ field, set it on the message header too */
+ if (hdr &&
+ header_aget_value (hdr,
+ MU_HEADER_CONTENT_TRANSFER_ENCODING,
+ & content_te) == 0)
+ {
+ ret = header_set_value (mime->hdrs,
+ MU_HEADER_CONTENT_TRANSFER_ENCODING,
+ content_te, 1);
+ free (content_te);
+ }
}
mime->flags |= MIME_ADDED_CT;
- return header_set_value(mime->hdrs, MU_HEADER_CONTENT_TYPE, content_type, 1);
+ return ret;
}
#define ADD_CHAR(buf, c, offset, buflen, nbytes) {*(buf)++ = c; (offset)++; (nbytes)++;if (--(buflen) == 0) return 0;}

Return to:

Send suggestions and report system problems to the System administrator.