[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c,1.36,1.37

cras at procontrol.fi cras at procontrol.fi
Wed Mar 26 19:29:04 EET 2003


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory danu:/tmp/cvs-serv10853/lib-storage/index/mbox

Modified Files:
	mbox-save.c 
Log Message:
Better handling for multiline headers. Before we skipped headers larger than
input buffer size (8k with read (default), 256k with mmap). The skipping was
also a bit buggy.

Now we parse the lines one at a time. There's also a way to read the header
fully into memory before parsing it, if really needed.



Index: mbox-save.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- mbox-save.c	21 Mar 2003 06:47:06 -0000	1.36
+++ mbox-save.c	26 Mar 2003 17:29:02 -0000	1.37
@@ -169,8 +169,8 @@
 	return str_c(str);
 }
 
-static int save_header_callback(const unsigned char *name, size_t len,
-				write_func_t *write_func, void *context)
+static int save_header_callback(const char *name, write_func_t *write_func,
+				void *context)
 {
 	static const char *content_length = "Content-Length: ";
 	struct mail_save_context *ctx = context;
@@ -178,8 +178,7 @@
 	char *buf;
 	size_t space;
 
-	switch (len) {
-	case 0:
+	if (name == NULL) {
 		/* write system flags */
 		str = get_system_flags(ctx->flags->flags);
 		if (write_func(ctx->output, str, strlen(str)) < 0)
@@ -209,27 +208,29 @@
 			return -1;
 		}
 		ctx->eoh_offset = ctx->output->offset;
-		break;
-	case 5:
-		if (memcasecmp(name, "X-UID", 5) == 0)
+		return 1;
+	}
+
+	switch (*name) {
+	case 'C':
+	case 'c':
+		if (strcasecmp(name, "Content-Length") == 0)
 			return 0;
 		break;
-	case 6:
-		if (memcasecmp(name, "Status", 6) == 0)
+	case 'S':
+	case 's':
+		if (strcasecmp(name, "Status") == 0)
 			return 0;
 		break;
-	case 8:
-		if (memcasecmp(name, "X-Status", 8) == 0)
+	case 'X':
+	case 'x':
+		if (strcasecmp(name, "X-UID") == 0)
 			return 0;
-		break;
-	case 10:
-		if (memcasecmp(name, "X-Keywords", 10) == 0)
+		if (strcasecmp(name, "X-Status") == 0)
 			return 0;
-		if (memcasecmp(name, "X-IMAPbase", 10) == 0)
+		if (strcasecmp(name, "X-Keywords") == 0)
 			return 0;
-		break;
-	case 14:
-		if (memcasecmp(name, "Content-Length", 14) == 0)
+		if (strcasecmp(name, "X-IMAPbase") == 0)
 			return 0;
 		break;
 	}




More information about the dovecot-cvs mailing list