Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4261:8fd5dfa271ef HEAD
Added mail_cache_field_want_add() and mail_cache_field_can_add()
author | Timo Sirainen <timo.sirainen@movial.fi> |
---|---|
date | Mon, 08 May 2006 15:48:51 +0300 |
parents | 327abd67380d |
children | d7dd2f20c15c |
files | src/lib-index/mail-cache-transaction.c src/lib-index/mail-cache.h |
diffstat | 2 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-cache-transaction.c Mon May 08 14:25:14 2006 +0300 +++ b/src/lib-index/mail-cache-transaction.c Mon May 08 15:48:51 2006 +0300 @@ -747,6 +747,30 @@ buffer_append_zero(ctx->cache_data, 4 - (data_size & 3)); } +bool mail_cache_field_want_add(struct mail_cache_transaction_ctx *ctx, + uint32_t seq, unsigned int field) +{ + enum mail_cache_decision_type decision; + + decision = mail_cache_field_get_decision(ctx->view->cache, field); + if ((decision & ~MAIL_CACHE_DECISION_FORCED) == MAIL_CACHE_DECISION_NO) + return FALSE; + + return mail_cache_field_exists(ctx->view, seq, field) == 0; +} + +bool mail_cache_field_can_add(struct mail_cache_transaction_ctx *ctx, + uint32_t seq, unsigned int field) +{ + enum mail_cache_decision_type decision; + + decision = mail_cache_field_get_decision(ctx->view->cache, field); + if (decision == (MAIL_CACHE_DECISION_FORCED | MAIL_CACHE_DECISION_NO)) + return FALSE; + + return mail_cache_field_exists(ctx->view, seq, field) == 0; +} + static int mail_cache_link_unlocked(struct mail_cache *cache, uint32_t old_offset, uint32_t new_offset) {
--- a/src/lib-index/mail-cache.h Mon May 08 14:25:14 2006 +0300 +++ b/src/lib-index/mail-cache.h Mon May 08 15:48:51 2006 +0300 @@ -72,6 +72,15 @@ must be exactly the expected size. */ void mail_cache_add(struct mail_cache_transaction_ctx *ctx, uint32_t seq, unsigned int field, const void *data, size_t data_size); +/* Returns TRUE if field is wanted to be added and it doesn't already exist. + If current caching decisions say not to cache this field, FALSE is returned. + If seq is 0, the existence isn't checked. */ +bool mail_cache_field_want_add(struct mail_cache_transaction_ctx *ctx, + uint32_t seq, unsigned int field); +/* Like mail_cache_field_want_add(), but in caching decisions FALSE is + returned only if the decision is a forced no. */ +bool mail_cache_field_can_add(struct mail_cache_transaction_ctx *ctx, + uint32_t seq, unsigned int field); /* Retursn 1 if field exists, 0 if not, -1 if error. */ int mail_cache_field_exists(struct mail_cache_view *view, uint32_t seq,