dovecot-2.0: pop3: Small code cleanup.

dovecot at dovecot.org dovecot at dovecot.org
Wed May 4 12:44:27 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/869795a295b5
changeset: 12765:869795a295b5
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 04 10:17:27 2011 +0200
description:
pop3: Small code cleanup.

diffstat:

 src/pop3/pop3-client.h   |   3 ---
 src/pop3/pop3-commands.c |  24 ++++++++++++------------
 2 files changed, 12 insertions(+), 15 deletions(-)

diffs (82 lines):

diff -r c838d40bd38e -r 869795a295b5 src/pop3/pop3-client.h
--- a/src/pop3/pop3-client.h	Tue May 03 18:41:10 2011 +0200
+++ b/src/pop3/pop3-client.h	Wed May 04 10:17:27 2011 +0200
@@ -45,9 +45,6 @@
 	unsigned int top_count;
 	unsigned int retr_count;
 
-	uoff_t *byte_counter;
-	uoff_t byte_counter_offset;
-
 	unsigned char *deleted_bitmask;
 	unsigned char *seen_bitmask;
 
diff -r c838d40bd38e -r 869795a295b5 src/pop3/pop3-commands.c
--- a/src/pop3/pop3-commands.c	Tue May 03 18:41:10 2011 +0200
+++ b/src/pop3/pop3-commands.c	Wed May 04 10:17:27 2011 +0200
@@ -265,6 +265,9 @@
 	struct istream *stream;
 	uoff_t body_lines;
 
+	uoff_t *byte_counter;
+	uoff_t byte_counter_offset;
+
 	unsigned char last;
 	bool cr_skipped, in_body;
 };
@@ -365,9 +368,8 @@
 		(void)o_stream_send(client->output, "\r\n", 2);
 	}
 
-	*client->byte_counter +=
-		client->output->offset - client->byte_counter_offset;
-        client->byte_counter = NULL;
+	*ctx->byte_counter +=
+		client->output->offset - ctx->byte_counter_offset;
 
 	client_send_line(client, ".");
 	fetch_deinit(ctx);
@@ -387,7 +389,8 @@
 	return 1;
 }
 
-static int fetch(struct client *client, unsigned int msgnum, uoff_t body_lines)
+static int fetch(struct client *client, unsigned int msgnum, uoff_t body_lines,
+		 uoff_t *byte_counter)
 {
         struct fetch_context *ctx;
 	struct mail_search_args *search_args;
@@ -399,6 +402,9 @@
 	ctx->search_ctx = mailbox_search_init(client->trans, search_args, NULL);
 	mail_search_args_unref(&search_args);
 
+	ctx->byte_counter = byte_counter;
+	ctx->byte_counter_offset = client->output->offset;
+
 	ctx->mail = mail_alloc(client->trans, MAIL_FETCH_STREAM_HEADER |
 			       MAIL_FETCH_STREAM_BODY, NULL);
 
@@ -445,10 +451,7 @@
 		client->last_seen = msgnum+1;
 
 	client->retr_count++;
-	client->byte_counter = &client->retr_bytes;
-	client->byte_counter_offset = client->output->offset;
-
-	return fetch(client, msgnum, (uoff_t)-1);
+	return fetch(client, msgnum, (uoff_t)-1, &client->retr_bytes);
 }
 
 static int cmd_rset(struct client *client, const char *args ATTR_UNUSED)
@@ -511,10 +514,7 @@
 		return -1;
 
 	client->top_count++;
-	client->byte_counter = &client->top_bytes;
-	client->byte_counter_offset = client->output->offset;
-
-	return fetch(client, msgnum, max_lines);
+	return fetch(client, msgnum, max_lines, &client->top_bytes);
 }
 
 struct cmd_uidl_context {


More information about the dovecot-cvs mailing list