Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3460:e8cbf3ae00db HEAD
Added imap_bodystructure_is_plain_7bit()
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 03 Jul 2005 17:18:53 +0300 |
parents | 8dbce791a1cc |
children | b7ce2532250a |
files | src/lib-imap/imap-bodystructure.c src/lib-imap/imap-bodystructure.h |
diffstat | 2 files changed, 49 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap/imap-bodystructure.c Sun Jul 03 17:18:28 2005 +0300 +++ b/src/lib-imap/imap-bodystructure.c Sun Jul 03 17:18:53 2005 +0300 @@ -439,6 +439,51 @@ } } +int imap_bodystructure_is_plain_7bit(struct message_part *part) +{ + struct message_part_body_data *data = part->context; + + i_assert(part->parent == NULL); + + if (data == NULL) { + /* no bodystructure headers found */ + return TRUE; + } + + /* if content-type is text/xxx we don't have to check any + multipart stuff */ + if ((part->flags & MESSAGE_PART_FLAG_TEXT) == 0) + return FALSE; + if (part->next != NULL || part->children != NULL) + return FALSE; /* shouldn't happen normally.. */ + + /* must be text/plain */ + if (data->content_subtype != NULL && + strcasecmp(data->content_subtype, "\"plain\"") != 0) + return FALSE; + + /* only allowed parameter is charset=us-ascii, which is also default */ + if (data->content_type_params != NULL && + strcasecmp(data->content_type_params, DEFAULT_CHARSET) != 0) + return FALSE; + + if (data->content_id != NULL || + data->content_description != NULL) + return FALSE; + + if (data->content_transfer_encoding != NULL && + strcasecmp(data->content_transfer_encoding, "\"7bit\"") != 0) + return FALSE; + + /* BODYSTRUCTURE checks: */ + if (data->content_md5 != NULL || + data->content_disposition != NULL || + data->content_language != NULL) + return FALSE; + + return TRUE; +} + void imap_bodystructure_write(struct message_part *part, string_t *dest, int extended) {
--- a/src/lib-imap/imap-bodystructure.h Sun Jul 03 17:18:28 2005 +0300 +++ b/src/lib-imap/imap-bodystructure.h Sun Jul 03 17:18:53 2005 +0300 @@ -8,6 +8,10 @@ void imap_bodystructure_parse_header(pool_t pool, struct message_part *part, struct message_header_line *hdr); +/* Returns TRUE if BODYSTRUCTURE is + ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" n n NIL NIL NIL) */ +int imap_bodystructure_is_plain_7bit(struct message_part *part); + void imap_bodystructure_write(struct message_part *part, string_t *dest, int extended);