399 |
static int |
static int |
400 |
_mime_set_content_type(mime_t mime) |
_mime_set_content_type(mime_t mime) |
401 |
{ |
{ |
402 |
char content_type[256]; |
char content_type[256], * content_te; |
403 |
char boundary[128]; |
char boundary[128]; |
404 |
header_t hdr = NULL; |
header_t hdr = NULL; |
405 |
size_t size; |
size_t size; |
406 |
|
int ret; |
407 |
|
|
408 |
/* Delayed the creation of the header 'til they create the final message via |
/* Delayed the creation of the header 'til they create the final message via |
409 |
mime_get_message() */ |
mime_get_message() */ |
425 |
strcat(content_type, mime->boundary); |
strcat(content_type, mime->boundary); |
426 |
strcat(content_type, "\""); |
strcat(content_type, "\""); |
427 |
mime->flags |= MIME_ADDED_MULTIPART_CT; |
mime->flags |= MIME_ADDED_MULTIPART_CT; |
428 |
|
|
429 |
|
ret = header_set_value(mime->hdrs, MU_HEADER_CONTENT_TYPE, content_type, 1); |
430 |
} else { |
} else { |
431 |
if ( (mime->flags & (MIME_ADDED_CT|MIME_ADDED_MULTIPART_CT)) == MIME_ADDED_CT ) |
if ( (mime->flags & (MIME_ADDED_CT|MIME_ADDED_MULTIPART_CT)) == MIME_ADDED_CT ) |
432 |
return 0; |
return 0; |
437 |
strcpy(content_type, "text/plain; charset=us-ascii"); |
strcpy(content_type, "text/plain; charset=us-ascii"); |
438 |
else |
else |
439 |
header_get_value(hdr, MU_HEADER_CONTENT_TYPE, content_type, sizeof(content_type), &size); |
header_get_value(hdr, MU_HEADER_CONTENT_TYPE, content_type, sizeof(content_type), &size); |
440 |
|
|
441 |
|
ret = header_set_value(mime->hdrs, MU_HEADER_CONTENT_TYPE, content_type, 1); |
442 |
|
if (ret) return ret; |
443 |
|
|
444 |
|
/* if the only part contains a transfer-encoding |
445 |
|
field, set it on the message header too */ |
446 |
|
if (hdr && |
447 |
|
header_aget_value (hdr, |
448 |
|
MU_HEADER_CONTENT_TRANSFER_ENCODING, |
449 |
|
& content_te) == 0) |
450 |
|
{ |
451 |
|
ret = header_set_value (mime->hdrs, |
452 |
|
MU_HEADER_CONTENT_TRANSFER_ENCODING, |
453 |
|
content_te, 1); |
454 |
|
free (content_te); |
455 |
|
} |
456 |
} |
} |
457 |
mime->flags |= MIME_ADDED_CT; |
mime->flags |= MIME_ADDED_CT; |
458 |
return header_set_value(mime->hdrs, MU_HEADER_CONTENT_TYPE, content_type, 1); |
return ret; |
459 |
} |
} |
460 |
|
|
461 |
#define ADD_CHAR(buf, c, offset, buflen, nbytes) {*(buf)++ = c; (offset)++; (nbytes)++;if (--(buflen) == 0) return 0;} |
#define ADD_CHAR(buf, c, offset, buflen, nbytes) {*(buf)++ = c; (offset)++; (nbytes)++;if (--(buflen) == 0) return 0;} |