/* util.c */
#ifdef USE_HCACHE
header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path);
+HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid);
+int imap_hcache_put (IMAP_DATA* idata, HEADER* h);
#endif
int imap_continue (const char* msg, const char* resp);
unsigned int *uid_validity = NULL;
unsigned int *uidnext = NULL;
int evalhc = 0;
- char uid_buf[64];
#endif /* USE_HCACHE */
ctx = idata->ctx;
}
idx = h.sid - 1;
- sprintf(uid_buf, "/%u", h.data->uid); /* XXX --tg 21:41 04-07-11 */
- uid_validity = (unsigned int*)mutt_hcache_fetch (idata->hcache, uid_buf, &imap_hcache_keylen);
-
- if (uid_validity != NULL && *uid_validity == idata->uid_validity)
+ ctx->hdrs[idx] = imap_hcache_get (idata, h.data->uid);
+ if (ctx->hdrs[idx])
{
- ctx->hdrs[idx] = mutt_hcache_restore((unsigned char *) uid_validity, 0);
ctx->hdrs[idx]->index = idx;
/* messages which have not been expunged are ACTIVE (borrowed from mh
* folders) */
/* bad header in the cache, we'll have to refetch.
* TODO: consider the possibility of a holey cache. */
imap_free_header_data((void**) &h.data);
-
- FREE(&uid_validity);
}
while (rc != IMAP_CMD_OK && mfhrc == -1);
if (rc == IMAP_CMD_OK)
ctx->size += h.content_length;
#if USE_HCACHE
- sprintf(uid_buf, "/%u", h.data->uid);
- mutt_hcache_store(idata->hcache, uid_buf, ctx->hdrs[idx], idata->uid_validity, &imap_hcache_keylen);
+ imap_hcache_put (idata, ctx->hdrs[idx]);
#endif /* USE_HCACHE */
ctx->msgcount++;
#include "imap_private.h"
#include "mutt_ssl.h"
#ifdef USE_HCACHE
+#include "message.h"
#include "hcache.h"
#endif
return mutt_hcache_open (HeaderCache, cachepath);
}
+
+HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid)
+{
+ char key[16];
+ unsigned int* uv;
+ HEADER* h = NULL;
+
+ sprintf(key, "/%u", uid);
+ uv = (unsigned int*)mutt_hcache_fetch (idata->hcache, key,
+ imap_hcache_keylen);
+ if (uv)
+ {
+ if (*uv == idata->uid_validity)
+ h = mutt_hcache_restore ((unsigned char*)uv, NULL);
+ FREE (&uv);
+ }
+
+ return h;
+}
+
+int imap_hcache_put (IMAP_DATA* idata, HEADER* h)
+{
+ char key[16];
+
+ sprintf(key, "/%u", HEADER_DATA (h)->uid);
+ return mutt_hcache_store (idata->hcache, key, h, idata->uid_validity,
+ imap_hcache_keylen);
+}
#endif
/* imap_parse_path: given an IMAP mailbox name, return host, port