diff src/lib-index/mbox/mbox-rewrite.c @ 180:38341ad6a9db HEAD

partial changes to add X-IMAPbase parser update custom flags
author Timo Sirainen <tss@iki.fi>
date Sun, 08 Sep 2002 15:12:41 +0300
parents ff05b320482c
children 4223b9ed0c80
line wrap: on
line diff
--- a/src/lib-index/mbox/mbox-rewrite.c	Sun Sep 08 14:36:03 2002 +0300
+++ b/src/lib-index/mbox/mbox-rewrite.c	Sun Sep 08 15:12:41 2002 +0300
@@ -6,6 +6,7 @@
 #include "write-full.h"
 #include "mbox-index.h"
 #include "mail-index-util.h"
+#include "mail-custom-flags.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -145,8 +146,7 @@
 static int mbox_write_header(MailIndex *index,
 			     MailIndexRecord *rec, unsigned int seq,
 			     IOBuffer *inbuf, IOBuffer *outbuf,
-			     uoff_t end_offset,
-			     const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT])
+			     uoff_t end_offset)
 {
 	/* We need to update fields that define message flags. Standard fields
 	   are stored in Status and X-Status. For custom flags we use
@@ -161,7 +161,7 @@
 	*/
 	MboxRewriteContext ctx;
 	MessageSize hdr_size;
-	const char *str, *flags;
+	const char *str, *flags, **custom_flags;
 	unsigned int field;
 	int i;
 
@@ -173,6 +173,10 @@
 		return FALSE;
 	}
 
+	t_push();
+
+	custom_flags = mail_custom_flags_list_get(index->custom_flags);
+
 	/* parse the header, write the fields we don't want to change */
 	memset(&ctx, 0, sizeof(ctx));
 	ctx.outbuf = outbuf;
@@ -180,8 +184,6 @@
 	ctx.msg_flags = rec->msg_flags;
 	ctx.custom_flags = custom_flags;
 
-	t_push();
-
 	message_parse_header(NULL, inbuf, &hdr_size, header_func, &ctx);
 
 	i_assert(hdr_size.physical_size == rec->header_size);
@@ -250,14 +252,15 @@
 	}
 	t_pop();
 
+	mail_custom_flags_list_unref(index->custom_flags);
+
 	/* empty line ends headers */
 	(void)io_buffer_send(outbuf, "\n", 1);
 
 	return TRUE;
 }
 
-int mbox_index_rewrite(MailIndex *index,
-		       const char *custom_flags[MAIL_CUSTOM_FLAGS_COUNT])
+int mbox_index_rewrite(MailIndex *index)
 {
 	/* Write it to temp file and then rename() to real file.
 	   easier and much safer than moving data inside the file.
@@ -330,7 +333,7 @@
 		/* write header, updating flag fields */
 		offset += rec->header_size;
 		if (!mbox_write_header(index, rec, seq, inbuf, outbuf,
-				       offset, custom_flags)) {
+				       offset)) {
 			failed = TRUE;
 			break;
 		}