From: Timo Sirainen Date: Sun, 20 Jun 2004 04:17:42 +0000 (+0300) Subject: mail_index_lookup() and mail_index_lookup_extra() now returns 0 if message X-Git-Tag: 1.1.alpha1~3915 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5ea11802f2bafbec06282a7b3b6704dc5fae584;p=thirdparty%2Fdovecot%2Fcore.git mail_index_lookup() and mail_index_lookup_extra() now returns 0 if message has been expunged, 1 if not. --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-index-view.c b/src/lib-index/mail-index-view.c index eb8a1f49e1..8db2418c41 100644 --- a/src/lib-index/mail-index-view.c +++ b/src/lib-index/mail-index-view.c @@ -178,7 +178,7 @@ static int mail_index_lookup_int(struct mail_index_view *view, uint32_t seq, 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 @@ static int mail_index_lookup_int(struct mail_index_view *view, uint32_t seq, if (seq == 0) { *rec_r = NULL; - return 0; + return 1; } do { @@ -204,8 +204,13 @@ static int mail_index_lookup_int(struct mail_index_view *view, uint32_t seq, 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 @@ int mail_index_lookup(struct mail_index_view *view, uint32_t seq, { 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 @@ int mail_index_lookup_extra(struct mail_index_view *view, uint32_t seq, 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, diff --git a/src/lib-index/mail-index.h b/src/lib-index/mail-index.h index 6df0b31290..0067da8de6 100644 --- a/src/lib-index/mail-index.h +++ b/src/lib-index/mail-index.h @@ -238,15 +238,16 @@ void mail_index_view_sync_end(struct mail_index_view_sync_ctx *ctx); /* 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