[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.72, 1.73 index-mail.c, 1.116, 1.117 index-search.c, 1.129, 1.130

tss at dovecot.org tss at dovecot.org
Wed Apr 4 12:27:41 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv25146/lib-storage/index

Modified Files:
	index-mail-headers.c index-mail.c index-search.c 
Log Message:
Header parser has now flags parameter to tell it how to handle linefeeds.
Changed message parser's boolean parameter to enum as well.



Index: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- index-mail-headers.c	4 Apr 2007 04:47:14 -0000	1.72
+++ index-mail-headers.c	4 Apr 2007 09:27:36 -0000	1.73
@@ -24,6 +24,12 @@
 	const char **name;
 };
 
+static const enum message_header_parser_flags hdr_parser_flags =
+	MESSAGE_HEADER_PARSER_FLAG_SKIP_INITIAL_LWSP |
+	MESSAGE_HEADER_PARSER_FLAG_DROP_CR;
+static const enum message_parser_flags msg_parser_flags =
+	MESSAGE_PARSER_FLAG_SKIP_BODY_BLOCK;
+
 static int header_line_cmp(const void *p1, const void *p2)
 {
 	const struct index_mail_line *l1 = p1, *l2 = p2;
@@ -346,6 +352,18 @@
 	index_mail_parse_header(mail->data.parts, hdr, mail);
 }
 
+void index_mail_cache_parse_init(struct mail *_mail, struct istream *input)
+{
+	struct index_mail *mail = (struct index_mail *)_mail;
+
+	i_assert(mail->data.parser_ctx == NULL);
+
+	index_mail_parse_header_init(mail, NULL);
+	mail->data.parser_ctx =
+		message_parser_init(mail->data_pool, input,
+				    hdr_parser_flags, msg_parser_flags);
+}
+
 static void index_mail_init_parser(struct index_mail *mail)
 {
 	struct index_mail_data *data = &mail->data;
@@ -354,12 +372,16 @@
 		(void)message_parser_deinit(&data->parser_ctx);
 
 	if (data->parts == NULL) {
-		data->parser_ctx =
-			message_parser_init(mail->data_pool, data->stream);
+		data->parser_ctx = message_parser_init(mail->data_pool,
+						       data->stream,
+						       hdr_parser_flags,
+						       msg_parser_flags);
 	} else {
 		data->parser_ctx =
 			message_parser_init_from_parts(data->parts,
-						       data->stream, FALSE);
+						       data->stream,
+						       hdr_parser_flags,
+						       msg_parser_flags);
 	}
 }
 
@@ -387,6 +409,7 @@
 	} else {
 		/* just read the header */
 		message_parse_header(data->stream, &data->hdr_size,
+				     hdr_parser_flags,
 				     index_mail_parse_header_cb, mail);
 	}
 	data->hdr_size_set = TRUE;
@@ -423,7 +446,7 @@
 	if (mail->data.envelope == NULL && stream != NULL) {
 		/* we got the headers from cache - parse them to get the
 		   envelope */
-		message_parse_header(stream, NULL,
+		message_parse_header(stream, NULL, hdr_parser_flags,
 				     imap_envelope_parse_callback, mail);
 		mail->data.save_envelope = FALSE;
 	}

Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- index-mail.c	3 Apr 2007 16:22:41 -0000	1.116
+++ index-mail.c	4 Apr 2007 09:27:38 -0000	1.117
@@ -1050,16 +1050,6 @@
 	pool_unref(mail->mail.pool);
 }
 
-void index_mail_cache_parse_init(struct mail *_mail, struct istream *input)
-{
-	struct index_mail *mail = (struct index_mail *)_mail;
-
-	i_assert(mail->data.parser_ctx == NULL);
-
-	index_mail_parse_header_init(mail, NULL);
-	mail->data.parser_ctx = message_parser_init(mail->data_pool, input);
-}
-
 void index_mail_cache_parse_continue(struct mail *_mail)
 {
 	struct index_mail *mail = (struct index_mail *)_mail;

Index: index-search.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- index-search.c	4 Apr 2007 04:47:14 -0000	1.129
+++ index-search.c	4 Apr 2007 09:27:38 -0000	1.130
@@ -66,6 +66,9 @@
 	struct message_body_search_context *body_search_ctx;
 };
 
+static const enum message_header_parser_flags hdr_parser_flags =
+	MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE;
+
 static int search_parse_msgset_args(struct index_mailbox *ibox,
 				    const struct mail_index_header *hdr,
 				    struct mail_search_arg *args,
@@ -602,7 +605,8 @@
 
 		if (hdr_ctx.parse_headers)
 			index_mail_parse_header_init(ctx->imail, headers_ctx);
-		message_parse_header(input, NULL, search_header, &hdr_ctx);
+		message_parse_header(input, NULL, hdr_parser_flags,
+				     search_header, &hdr_ctx);
 		if (headers_ctx != NULL)
 			mailbox_header_lookup_deinit(&headers_ctx);
 	} else {



More information about the dovecot-cvs mailing list