[dovecot-cvs] dovecot/src/lib-index mail-index-view.c, 1.12, 1.13 mail-index.h, 1.116, 1.117

cras at procontrol.fi cras at procontrol.fi
Sun Jun 20 07:17:45 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv2054/lib-index

Modified Files:
	mail-index-view.c mail-index.h 
Log Message:
mail_index_lookup() and mail_index_lookup_extra() now returns 0 if message
has been expunged, 1 if not.



Index: mail-index-view.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-view.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mail-index-view.c	14 Jun 2004 04:27:44 -0000	1.12
+++ mail-index-view.c	20 Jun 2004 04:17:42 -0000	1.13
@@ -178,7 +178,7 @@
 	if (view->map == view->index->map) {
 		*map_r = view->map;
 		*rec_r = rec;
-		return 0;
+		return 1;
 	}
 
 	if (mail_index_view_lock_head(view, FALSE) < 0)
@@ -193,7 +193,7 @@
 
 	if (seq == 0) {
 		*rec_r = NULL;
-		return 0;
+		return 1;
 	}
 
 	do {
@@ -204,8 +204,13 @@
 			break;
 	} while (seq > 0);
 
-	*rec_r = n_rec->uid == uid ? n_rec : rec;
-	return 0;
+	if (n_rec->uid == uid) {
+		*rec_r = n_rec;
+		return 1;
+	} else {
+		*rec_r = rec;
+		return 0;
+	}
 }
 
 int mail_index_lookup(struct mail_index_view *view, uint32_t seq,
@@ -213,7 +218,7 @@
 {
 	struct mail_index_map *map;
 
-        return mail_index_lookup_int(view, seq, &map, rec_r);
+	return mail_index_lookup_int(view, seq, &map, rec_r);
 }
 
 int mail_index_lookup_uid(struct mail_index_view *view, uint32_t seq,
@@ -235,20 +240,21 @@
 	const struct mail_index_record *rec;
 	struct mail_index_map *map;
 	uint32_t offset;
+	int ret;
 
-	if (mail_index_lookup_int(view, seq, &map, &rec) < 0)
+	if ((ret = mail_index_lookup_int(view, seq, &map, &rec)) < 0)
 		return -1;
 
 	if (rec == NULL) {
 		*data_r = NULL;
-		return 0;
+		return ret;
 	}
 
 	/* FIXME: do data_id mapping conversion */
 
 	offset = view->index->extra_records[data_id].offset;
 	*data_r = CONST_PTR_OFFSET(rec, offset);
-	return 0;
+	return ret;
 }
 
 static uint32_t mail_index_bsearch_uid(struct mail_index_view *view,

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- mail-index.h	20 Jun 2004 03:25:33 -0000	1.116
+++ mail-index.h	20 Jun 2004 04:17:42 -0000	1.117
@@ -238,15 +238,16 @@
 /* Returns the index header. */
 int mail_index_get_header(struct mail_index_view *view,
 			  const struct mail_index_header **hdr_r);
-/* Returns the given message. */
+/* Returns the given message. Returns -1 if error, 1 if ok, 0 if mail was
+   expunged but data was returned from some older index.  */
 int mail_index_lookup(struct mail_index_view *view, uint32_t seq,
 		      const struct mail_index_record **rec_r);
 /* Returns the UID for given message. May be slightly faster than
-   mail_index_lookup()->uid */
+   mail_index_lookup()->uid. */
 int mail_index_lookup_uid(struct mail_index_view *view, uint32_t seq,
 			  uint32_t *uid_r);
 /* Returns the wanted extra data for given message. If it doesn't exist,
-   *data_r is set to NULL. */
+   *data_r is set to NULL. Return values are same as for mail_index_lookup(). */
 int mail_index_lookup_extra(struct mail_index_view *view, uint32_t seq,
 			    uint32_t data_id, const void **data_r);
 /* Convert UID range to sequence range. If no UIDs are found, sequences are



More information about the dovecot-cvs mailing list