dovecot-1.0: Replaced kludgy input_first variable with just chec...

dovecot at dovecot.org dovecot at dovecot.org
Thu Nov 8 18:44:19 EET 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/a4a076529140
changeset: 5450:a4a076529140
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Nov 08 18:44:12 2007 +0200
description:
Replaced kludgy input_first variable with just checking if input stream's
offset is 0.

diffstat:

1 file changed, 6 insertions(+), 11 deletions(-)
src/deliver/deliver.c |   17 ++++++-----------

diffs (68 lines):

diff -r 6df077099f0b -r a4a076529140 src/deliver/deliver.c
--- a/src/deliver/deliver.c	Mon Nov 05 20:23:32 2007 +0200
+++ b/src/deliver/deliver.c	Thu Nov 08 18:44:12 2007 +0200
@@ -433,17 +433,16 @@ static void save_header_callback(struct 
 static void save_header_callback(struct message_header_line *hdr,
 				 bool *matched, void *context)
 {
-	bool *first = context;
-
-	if (*first) {
-		*first = FALSE;
+	struct istream *input = context;
+
+	if (input->v_offset == 0) {
 		if (hdr != NULL && strncmp(hdr->name, "From ", 5) == 0)
 			*matched = TRUE;
 	}
 }
 
 static struct istream *
-create_mbox_stream(int fd, const char *envelope_sender, bool **first_r)
+create_mbox_stream(int fd, const char *envelope_sender)
 {
 	const char *mbox_hdr;
 	struct istream *input_list[4], *input, *input_filter;
@@ -456,8 +455,6 @@ create_mbox_stream(int fd, const char *e
 	/* kind of kludgy to allocate memory just for this, but since this
 	   has to live as long as the input stream itself, this is the safest
 	   way to do it without it breaking accidentally. */
-	*first_r = i_new(bool, 1);
-	**first_r = TRUE;
 	input = i_stream_create_file(fd, default_pool, 4096, FALSE);
 	input_filter = i_stream_create_header_filter(input,
 						     HEADER_FILTER_EXCLUDE |
@@ -465,7 +462,7 @@ create_mbox_stream(int fd, const char *e
 						     mbox_hide_headers,
 						     mbox_hide_headers_count,
 						     save_header_callback,
-						     *first_r);
+						     input);
 	i_stream_unref(&input);
 
 	input_list[0] = i_stream_create_from_data(default_pool, mbox_hdr,
@@ -604,7 +601,6 @@ int main(int argc, char *argv[])
 	struct mail *mail;
 	uid_t process_euid;
 	bool stderr_rejection = FALSE;
-	bool *input_first;
 	int i, ret;
 
 	i_set_failure_exit_callback(failure_exit_callback);
@@ -791,7 +787,7 @@ int main(int argc, char *argv[])
 
 	mbox_storage = mail_storage_create("mbox", "/tmp", destination, 0,
 					   MAIL_STORAGE_LOCK_FCNTL);
-	input = create_mbox_stream(0, envelope_sender, &input_first);
+	input = create_mbox_stream(0, envelope_sender);
 	box = mailbox_open(mbox_storage, "Dovecot Delivery Mail", input,
 			   MAILBOX_OPEN_NO_INDEX_FILES |
 			   MAILBOX_OPEN_MBOX_ONE_MSG_ONLY);
@@ -863,7 +859,6 @@ int main(int argc, char *argv[])
 		/* ok, rejection sent */
 	}
 	i_stream_unref(&input);
-	i_free(input_first);
 
 	mail_free(&mail);
 	mailbox_transaction_rollback(&t);


More information about the dovecot-cvs mailing list