[dovecot-cvs] dovecot/src/lib-storage/index index-fetch.c,1.51,1.52 index-search.c,1.81,1.82 index-storage.h,1.52,1.53

cras at procontrol.fi cras at procontrol.fi
Sun Oct 26 22:13:17 EET 2003


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

Modified Files:
	index-fetch.c index-search.c index-storage.h 
Log Message:
Removed fetch_init/fetch_next from mail-storage. search_* makes it
unnecessary



Index: index-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-fetch.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- index-fetch.c	6 Aug 2003 20:15:33 -0000	1.51
+++ index-fetch.c	26 Oct 2003 20:13:15 -0000	1.52
@@ -10,92 +10,6 @@
 #include "index-messageset.h"
 #include "index-mail.h"
 
-struct mail_fetch_context {
-	struct index_mailbox *ibox;
-	struct mail_index *index;
-
-	struct messageset_context *msgset_ctx;
-	struct index_mail mail;
-
-	enum mail_lock_type old_lock;
-};
-
-struct mail_fetch_context *
-index_storage_fetch_init(struct mailbox *box,
-			 enum mail_fetch_field wanted_fields,
-			 const char *const *wanted_headers,
-			 const char *messageset, int uidset)
-{
-	struct index_mailbox *ibox = (struct index_mailbox *) box;
-	struct mail_fetch_context *ctx;
-	int check_mail;
-
-	ctx = i_new(struct mail_fetch_context, 1);
-	ctx->old_lock = ibox->index->lock_type;
-
-	check_mail = (client_workarounds &
-		      WORKAROUND_OE6_FETCH_NO_NEWMAIL) == 0;
-	if (!index_storage_sync_and_lock(ibox, check_mail, TRUE,
-					 MAIL_LOCK_SHARED))
-		return NULL;
-
-	ctx->ibox = ibox;
-	ctx->index = ibox->index;
-
-	index_mail_init(ibox, &ctx->mail, wanted_fields, wanted_headers);
-	ctx->msgset_ctx = index_messageset_init(ibox, messageset, uidset, TRUE);
-	return ctx;
-}
-
-int index_storage_fetch_deinit(struct mail_fetch_context *ctx, int *all_found)
-{
-	int ret;
-
-	ret = index_messageset_deinit(ctx->msgset_ctx);
-
-	if (all_found != NULL)
-		*all_found = ret > 0;
-
-	if (ctx->ibox->fetch_mail.pool != NULL)
-		index_mail_deinit(&ctx->ibox->fetch_mail);
-	if (ctx->mail.pool != NULL)
-		index_mail_deinit(&ctx->mail);
-
-	if (!index_storage_lock(ctx->ibox, ctx->old_lock))
-		ret = -1;
-
-	i_free(ctx);
-	return ret >= 0;
-}
-
-struct mail *index_storage_fetch_next(struct mail_fetch_context *ctx)
-{
-	const struct messageset_mail *msgset_mail;
-	int ret;
-
-	do {
-		msgset_mail = index_messageset_next(ctx->msgset_ctx);
-		if (msgset_mail == NULL) {
-			ret = -1;
-			break;
-		}
-
-		ctx->mail.mail.seq = msgset_mail->client_seq;
-		ctx->mail.mail.uid = msgset_mail->rec->uid;
-
-		ret = index_mail_next(&ctx->mail, msgset_mail->rec,
-				      msgset_mail->idx_seq, FALSE);
-	} while (ret == 0);
-
-	if (ret < 0) {
-		/* error or last record */
-		index_mail_deinit(&ctx->mail);
-		return NULL;
-	}
-
-	return &ctx->mail.mail;
-}
-
 static struct mail *
 fetch_record(struct index_mailbox *ibox, struct mail_index_record *rec,
 	     unsigned int idx_seq, enum mail_fetch_field wanted_fields)

Index: index-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- index-search.c	26 Oct 2003 19:41:10 -0000	1.81
+++ index-search.c	26 Oct 2003 20:13:15 -0000	1.82
@@ -870,15 +870,21 @@
 	return ctx;
 }
 
-int index_storage_search_deinit(struct mail_search_context *ctx)
+int index_storage_search_deinit(struct mail_search_context *ctx, int *all_found)
 {
-	int ret;
+	int ret, msgset_ret;
 
 	ret = !ctx->failed && ctx->error == NULL;
 
 	if (ctx->msgset_ctx != NULL) {
-		if (index_messageset_deinit(ctx->msgset_ctx) < 0)
+		msgset_ret = index_messageset_deinit(ctx->msgset_ctx);
+		if (msgset_ret < 0)
 			ret = FALSE;
+		if (all_found != NULL)
+			*all_found = msgset_ret > 0;
+	} else {
+		if (all_found != NULL)
+			*all_found = !ctx->failed;
 	}
 
 	if (ctx->ibox->fetch_mail.pool != NULL)

Index: index-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- index-storage.h	20 Oct 2003 06:18:59 -0000	1.52
+++ index-storage.h	26 Oct 2003 20:13:15 -0000	1.53
@@ -98,14 +98,6 @@
 			     struct mailbox_status *status);
 int index_storage_sync(struct mailbox *box, enum mailbox_sync_flags flags);
 
-struct mail_fetch_context *
-index_storage_fetch_init(struct mailbox *box,
-			 enum mail_fetch_field wanted_fields,
-			 const char *const *wanted_headers,
-			 const char *messageset, int uidset);
-int index_storage_fetch_deinit(struct mail_fetch_context *ctx, int *all_found);
-struct mail *index_storage_fetch_next(struct mail_fetch_context *ctx);
-
 struct mail *index_storage_fetch_uid(struct mailbox *box, unsigned int uid,
 				     enum mail_fetch_field wanted_fields);
 struct mail *index_storage_fetch_seq(struct mailbox *box, unsigned int seq,
@@ -119,7 +111,8 @@
 			  const enum mail_sort_type *sort_program,
 			  enum mail_fetch_field wanted_fields,
 			  const char *const wanted_headers[]);
-int index_storage_search_deinit(struct mail_search_context *ctx);
+int index_storage_search_deinit(struct mail_search_context *ctx,
+				int *all_found);
 struct mail *index_storage_search_next(struct mail_search_context *ctx);
 
 struct mail_copy_context *index_storage_copy_init(struct mailbox *box);



More information about the dovecot-cvs mailing list