Changeset 5074:d10bc7f74089
- Timestamp:
- 2007-04-05 18:03:05 (22 months ago)
- Author:
- Brendan Cully <brendan@…>
- Branch:
- HEAD
- Message:
-
IMAP header cache API improvements.
- Location:
- imap
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5073
|
r5074
|
|
| 261 | 261 | #ifdef USE_HCACHE |
| 262 | 262 | header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path); |
| | 263 | HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid); |
| | 264 | int imap_hcache_put (IMAP_DATA* idata, HEADER* h); |
| 263 | 265 | #endif |
| 264 | 266 | |
-
|
r5073
|
r5074
|
|
| 79 | 79 | unsigned int *uidnext = NULL; |
| 80 | 80 | int evalhc = 0; |
| 81 | | char uid_buf[64]; |
| 82 | 81 | #endif /* USE_HCACHE */ |
| 83 | 82 | |
| … |
… |
|
| 169 | 168 | |
| 170 | 169 | idx = h.sid - 1; |
| 171 | | sprintf(uid_buf, "/%u", h.data->uid); /* XXX --tg 21:41 04-07-11 */ |
| 172 | | uid_validity = (unsigned int*)mutt_hcache_fetch (idata->hcache, uid_buf, &imap_hcache_keylen); |
| 173 | | |
| 174 | | if (uid_validity != NULL && *uid_validity == idata->uid_validity) |
| | 170 | ctx->hdrs[idx] = imap_hcache_get (idata, h.data->uid); |
| | 171 | if (ctx->hdrs[idx]) |
| 175 | 172 | { |
| 176 | | ctx->hdrs[idx] = mutt_hcache_restore((unsigned char *) uid_validity, 0); |
| 177 | 173 | ctx->hdrs[idx]->index = idx; |
| 178 | 174 | /* messages which have not been expunged are ACTIVE (borrowed from mh |
| … |
… |
|
| 195 | 191 | * TODO: consider the possibility of a holey cache. */ |
| 196 | 192 | imap_free_header_data((void**) &h.data); |
| 197 | | |
| 198 | | FREE(&uid_validity); |
| 199 | 193 | } |
| 200 | 194 | while (rc != IMAP_CMD_OK && mfhrc == -1); |
| … |
… |
|
| 294 | 288 | |
| 295 | 289 | #if USE_HCACHE |
| 296 | | sprintf(uid_buf, "/%u", h.data->uid); |
| 297 | | mutt_hcache_store(idata->hcache, uid_buf, ctx->hdrs[idx], idata->uid_validity, &imap_hcache_keylen); |
| | 290 | imap_hcache_put (idata, ctx->hdrs[idx]); |
| 298 | 291 | #endif /* USE_HCACHE */ |
| 299 | 292 | |
-
|
r5073
|
r5074
|
|
| 29 | 29 | #include "mutt_ssl.h" |
| 30 | 30 | #ifdef USE_HCACHE |
| | 31 | #include "message.h" |
| 31 | 32 | #include "hcache.h" |
| 32 | 33 | #endif |
| … |
… |
|
| 86 | 87 | |
| 87 | 88 | return mutt_hcache_open (HeaderCache, cachepath); |
| | 89 | } |
| | 90 | |
| | 91 | HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid) |
| | 92 | { |
| | 93 | char key[16]; |
| | 94 | unsigned int* uv; |
| | 95 | HEADER* h = NULL; |
| | 96 | |
| | 97 | sprintf(key, "/%u", uid); |
| | 98 | uv = (unsigned int*)mutt_hcache_fetch (idata->hcache, key, |
| | 99 | imap_hcache_keylen); |
| | 100 | if (uv) |
| | 101 | { |
| | 102 | if (*uv == idata->uid_validity) |
| | 103 | h = mutt_hcache_restore ((unsigned char*)uv, NULL); |
| | 104 | FREE (&uv); |
| | 105 | } |
| | 106 | |
| | 107 | return h; |
| | 108 | } |
| | 109 | |
| | 110 | int imap_hcache_put (IMAP_DATA* idata, HEADER* h) |
| | 111 | { |
| | 112 | char key[16]; |
| | 113 | |
| | 114 | sprintf(key, "/%u", HEADER_DATA (h)->uid); |
| | 115 | return mutt_hcache_store (idata->hcache, key, h, idata->uid_validity, |
| | 116 | imap_hcache_keylen); |
| 88 | 117 | } |
| 89 | 118 | #endif |