From 86403a05c8a71b5a5ba12ac5804567ca6af6359a Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Wed, 29 Jul 2009 13:26:55 -0700 Subject: [PATCH] Harmonize hcache uidvalidity size to unsigned int (per IMAP RFC). Closes #3296. --- hcache.c | 12 ++++++------ hcache.h | 3 ++- imap/util.c | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hcache.c b/hcache.c index 56b1bc70b..d5da03f61 100644 --- a/hcache.c +++ b/hcache.c @@ -86,7 +86,7 @@ static void mutt_hcache_dbt_empty_init(DBT * dbt); typedef union { struct timeval timeval; - unsigned long uid_validity; + unsigned int uidvalidity; } validate; static void * @@ -589,7 +589,7 @@ mutt_hcache_per_folder(const char *path, const char *folder, * db_store */ static void * mutt_hcache_dump(header_cache_t *h, HEADER * header, int *off, - unsigned long uid_validity) + unsigned int uidvalidity) { unsigned char *d = NULL; HEADER nh; @@ -598,8 +598,8 @@ mutt_hcache_dump(header_cache_t *h, HEADER * header, int *off, *off = 0; d = lazy_malloc(sizeof (validate)); - if (uid_validity) - memcpy(d, &uid_validity, sizeof (unsigned long)); + if (uidvalidity) + memcpy(d, &uidvalidity, sizeof (uidvalidity)); else { struct timeval now; @@ -758,7 +758,7 @@ mutt_hcache_fetch_raw (header_cache_t *h, const char *filename, int mutt_hcache_store(header_cache_t *h, const char *filename, HEADER * header, - unsigned long uid_validity, + unsigned int uidvalidity, size_t(*keylen) (const char *fn)) { char* data; @@ -768,7 +768,7 @@ mutt_hcache_store(header_cache_t *h, const char *filename, HEADER * header, if (!h) return -1; - data = mutt_hcache_dump(h, header, &dlen, uid_validity); + data = mutt_hcache_dump(h, header, &dlen, uidvalidity); ret = mutt_hcache_store_raw (h, filename, data, dlen, keylen); FREE(&data); diff --git a/hcache.h b/hcache.h index 14a6a9a25..aab263bc6 100644 --- a/hcache.h +++ b/hcache.h @@ -33,8 +33,9 @@ HEADER *mutt_hcache_restore(const unsigned char *d, HEADER **oh); void *mutt_hcache_fetch(header_cache_t *h, const char *filename, size_t (*keylen)(const char *fn)); void *mutt_hcache_fetch_raw (header_cache_t *h, const char *filename, size_t (*keylen)(const char *fn)); +/* uidvalidity is an IMAP-specific unsigned 32 bit number */ int mutt_hcache_store(header_cache_t *h, const char *filename, HEADER *header, - unsigned long uid_validity, size_t (*keylen)(const char *fn)); + unsigned int uidvalidity, size_t (*keylen)(const char *fn)); int mutt_hcache_store_raw (header_cache_t *h, const char* filename, void* data, size_t dlen, size_t(*keylen) (const char* fn)); int mutt_hcache_delete(header_cache_t *h, const char *filename, size_t (*keylen)(const char *fn)); diff --git a/imap/util.c b/imap/util.c index 48ba630b0..611cbe926 100644 --- a/imap/util.c +++ b/imap/util.c @@ -129,6 +129,8 @@ HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid) { if (*uv == idata->uid_validity) h = mutt_hcache_restore ((unsigned char*)uv, NULL); + else + dprint (3, (debugfile, "hcache uidvalidity mismatch: %u", *uv)); FREE (&uv); } -- 2.40.0