[dovecot-cvs] dovecot/src/imap imap-fetch-body-section.c,1.10,1.11 imap-fetch.c,1.4,1.5

cras at procontrol.fi cras at procontrol.fi
Sun Apr 27 01:52:41 EEST 2003


Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv231/imap

Modified Files:
	imap-fetch-body-section.c imap-fetch.c 
Log Message:
Partial fetches were broken when they stopped between virtual CR and LF.



Index: imap-fetch-body-section.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch-body-section.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- imap-fetch-body-section.c	15 Apr 2003 13:03:55 -0000	1.10
+++ imap-fetch-body-section.c	26 Apr 2003 21:52:39 -0000	1.11
@@ -34,10 +34,11 @@
 	unsigned int uid;
 
 	uoff_t physical_start;
+	int cr_skipped;
 	struct message_size pos;
 };
 
-static struct partial_cache partial = { 0, 0, 0, { 0, 0, 0 } };
+static struct partial_cache partial = { 0, 0, 0, 0, { 0, 0, 0 } };
 
 static int seek_partial(unsigned int select_counter, unsigned int uid,
 			struct partial_cache *partial, struct istream *stream,
@@ -59,11 +60,10 @@
 
 	i_stream_seek(stream, partial->physical_start +
 		      partial->pos.physical_size);
-	message_skip_virtual(stream, virtual_skip, &partial->pos, &cr_skipped);
-
-	if (cr_skipped)
-		partial->pos.virtual_size--;
+	message_skip_virtual(stream, virtual_skip, &partial->pos,
+			     partial->cr_skipped, &cr_skipped);
 
+	partial->cr_skipped = FALSE;
 	return cr_skipped;
 }
 
@@ -75,7 +75,7 @@
 	struct message_size hdr_size, body_size;
 	struct istream *stream;
 	const char *str;
-	int skip_cr;
+	int skip_cr, last_cr;
 	uoff_t size;
 	off_t ret;
 
@@ -102,8 +102,9 @@
 			       body->skip);
 
 	ret = message_send(ctx->output, stream, &body_size,
-			   skip_cr, body->max_size);
+			   skip_cr, body->max_size, &last_cr);
 	if (ret > 0) {
+		partial.cr_skipped = last_cr != 0;
 		partial.pos.physical_size =
 			stream->v_offset - partial.physical_start;
 		partial.pos.virtual_size += ret;
@@ -287,7 +288,7 @@
 		if (o_stream_send_str(ctx->output, str) < 0)
 			return FALSE;
 		return message_send(ctx->output, input, size,
-				    body->skip, body->max_size) >= 0;
+				    body->skip, body->max_size, NULL) >= 0;
 	}
 
 	/* partial headers - copy the wanted fields into memory, inserting
@@ -418,7 +419,7 @@
 			   struct mail *mail, const struct message_part *part)
 {
 	const char *str;
-	int skip_cr;
+	int skip_cr, last_cr;
 	uoff_t size;
 	off_t ret;
 
@@ -436,8 +437,9 @@
 			       &partial, stream, part->physical_pos +
 			       part->header_size.physical_size, body->skip);
 	ret = message_send(ctx->output, stream, &part->body_size,
-			   skip_cr, body->max_size);
+			   skip_cr, body->max_size, &last_cr);
 	if (ret > 0) {
+		partial.cr_skipped = last_cr != 0;
 		partial.pos.physical_size =
 			stream->v_offset - partial.physical_start;
 		partial.pos.virtual_size += ret;

Index: imap-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/imap-fetch.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- imap-fetch.c	21 Jan 2003 06:46:08 -0000	1.4
+++ imap-fetch.c	26 Apr 2003 21:52:39 -0000	1.5
@@ -113,7 +113,7 @@
 		return FALSE;
 
 	return message_send(ctx->output, stream, &body_size,
-			    0, (uoff_t)-1) >= 0;
+			    0, (uoff_t)-1, NULL) >= 0;
 }
 
 static int fetch_send_rfc822_header(struct imap_fetch_context *ctx,
@@ -135,7 +135,8 @@
 	if (o_stream_send_str(ctx->output, str) < 0)
 		return FALSE;
 
-	return message_send(ctx->output, stream, &hdr_size, 0, (uoff_t)-1) >= 0;
+	return message_send(ctx->output, stream, &hdr_size,
+			    0, (uoff_t)-1, NULL) >= 0;
 }
 
 static int fetch_send_rfc822_text(struct imap_fetch_context *ctx,
@@ -159,7 +160,7 @@
 
 	i_stream_seek(stream, hdr_size.physical_size);
 	return message_send(ctx->output, stream, &body_size,
-			    0, (uoff_t)-1) >= 0;
+			    0, (uoff_t)-1, NULL) >= 0;
 }
 
 static int fetch_mail(struct imap_fetch_context *ctx, struct mail *mail)




More information about the dovecot-cvs mailing list