]> granicus.if.org Git - neomutt/commitdiff
Harmonize hcache uidvalidity size to unsigned int (per IMAP RFC).
authorBrendan Cully <brendan@kublai.com>
Wed, 29 Jul 2009 20:26:55 +0000 (13:26 -0700)
committerBrendan Cully <brendan@kublai.com>
Wed, 29 Jul 2009 20:26:55 +0000 (13:26 -0700)
Closes #3296.

hcache.c
hcache.h
imap/util.c

index 56b1bc70be10c354382f2f1749448b39e5de28d3..d5da03f61620999261b9f9d242fc20bf627707ef 100644 (file)
--- 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);
index 14a6a9a255ec22374936109f4653c8af35ba4140..aab263bc6e086812add3690e88063eab5e024fd5 100644 (file)
--- 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));
index 48ba630b0cf1efae502254974597f301a1b4bbfa..611cbe926b01ebbac7648901cb18d6e64d609f11 100644 (file)
@@ -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);
   }