[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c, 1.67, 1.68

cras at dovecot.org cras at dovecot.org
Wed Dec 15 20:48:09 EET 2004


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

Modified Files:
	mbox-save.c 
Log Message:
If we want MD5 sums in indexes, mail saving should also add them.



Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- mbox-save.c	24 Nov 2004 18:39:58 -0000	1.67
+++ mbox-save.c	15 Dec 2004 18:48:06 -0000	1.68
@@ -14,6 +14,7 @@
 #include "mbox-file.h"
 #include "mbox-from.h"
 #include "mbox-lock.h"
+#include "mbox-md5.h"
 #include "mbox-sync-private.h"
 
 #include <stddef.h>
@@ -41,6 +42,7 @@
 
 	struct index_mail mail;
 	const struct mail_full_flags *flags;
+	struct mbox_md5_context *mbox_md5_ctx;
 
 	unsigned int synced:1;
 	unsigned int failed:1;
@@ -276,10 +278,13 @@
 }
 
 static void save_header_callback(struct message_header_line *hdr,
-				 int *matched __attr_unused__, void *context)
+				 int *matched, void *context)
 {
 	struct mbox_save_context *ctx = context;
 
+	if (!*matched && ctx->ibox->mbox_save_md5 && hdr != NULL)
+		mbox_md5_continue(ctx->mbox_md5_ctx, hdr);
+
 	if ((hdr == NULL && ctx->eoh_input_offset == (uoff_t)-1) ||
 	    (hdr != NULL && hdr->eoh))
 		ctx->eoh_input_offset = ctx->input->v_offset;
@@ -371,6 +376,8 @@
 		ctx->body_output = getenv("MAIL_SAVE_CRLF") != NULL ?
 			o_stream_create_crlf(default_pool, ctx->output) :
 			o_stream_create_lf(default_pool, ctx->output);
+		if (ctx->ibox->mbox_save_md5)
+			ctx->mbox_md5_ctx = mbox_md5_init();
 	}
 
 	return &ctx->ctx;
@@ -429,6 +436,15 @@
 		}
 	}
 
+	if (ctx->ibox->mbox_save_md5) {
+		unsigned char hdr_md5_sum[16];
+
+		mbox_md5_finish(ctx->mbox_md5_ctx, hdr_md5_sum);
+		mail_index_update_ext(ctx->trans, ctx->seq,
+				      ctx->ibox->md5hdr_ext_idx,
+				      hdr_md5_sum, NULL);
+	}
+
 	/* append our own headers and ending empty line */
 	ctx->extra_hdr_offset = ctx->output->offset;
 	if (o_stream_send(ctx->output, str_data(ctx->headers),



More information about the dovecot-cvs mailing list