[dovecot-cvs] dovecot/src/lib-imap imap-bodystructure.c, 1.49, 1.50 imap-bodystructure.h, 1.10, 1.11

cras at dovecot.org cras at dovecot.org
Sun Jul 3 17:18:55 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib-imap
In directory talvi:/tmp/cvs-serv1657/lib-imap

Modified Files:
	imap-bodystructure.c imap-bodystructure.h 
Log Message:
Added imap_bodystructure_is_plain_7bit()



Index: imap-bodystructure.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-bodystructure.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- imap-bodystructure.c	5 Jun 2005 20:36:55 -0000	1.49
+++ imap-bodystructure.c	3 Jul 2005 14:18:53 -0000	1.50
@@ -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)
 {

Index: imap-bodystructure.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-bodystructure.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- imap-bodystructure.h	8 Jul 2004 20:26:15 -0000	1.10
+++ imap-bodystructure.h	3 Jul 2005 14:18:53 -0000	1.11
@@ -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);
 



More information about the dovecot-cvs mailing list