Changeset 5115:8082e4c9f524 for imap
Legend:
- Unmodified
- Added
- Removed
-
imap/imap.c
r5114 r5115 250 250 251 251 #ifdef USE_HCACHE 252 i map_hcache_open (idata);252 idata->hcache = imap_hcache_open (idata, NULL); 253 253 #endif 254 254 … … 1147 1147 1148 1148 #if USE_HCACHE 1149 i map_hcache_open (idata);1149 idata->hcache = imap_hcache_open (idata, NULL); 1150 1150 #endif 1151 1151 … … 1570 1570 ciss_url_t url; 1571 1571 char urlstr[LONG_STRING]; 1572 char cpath[LONG_STRING]; 1572 1573 unsigned int *uidvalidity = NULL; 1573 1574 unsigned int *uidnext = NULL; … … 1595 1596 1596 1597 #ifdef USE_HCACHE 1597 mutt_account_tourl (&idata->conn->account, &url); 1598 url.path = (char*)mbox; 1599 url_ciss_tostring (&url, urlstr, sizeof (urlstr), 0); 1600 hc = mutt_hcache_open (HeaderCache, urlstr, NULL); 1598 hc = imap_hcache_open (idata, mbox); 1601 1599 if (hc) 1602 1600 { -
imap/imap_private.h
r5112 r5115 260 260 /* util.c */ 261 261 #ifdef USE_HCACHE 262 int imap_hcache_open (IMAP_DATA* idata);262 header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path); 263 263 void imap_hcache_close (IMAP_DATA* idata); 264 264 HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid); … … 273 273 char* imap_fix_path (IMAP_DATA* idata, char* mailbox, char* path, 274 274 size_t plen); 275 void imap_cachepath(IMAP_DATA* idata, const char* mailbox, char* dest, 276 size_t dlen); 275 277 int imap_get_literal_count (const char* buf, long* bytes); 276 278 char* imap_get_qualifier (char* buf); -
imap/message.c
r5112 r5115 120 120 121 121 #if USE_HCACHE 122 i map_hcache_open (idata);122 idata->hcache = imap_hcache_open (idata, NULL); 123 123 124 124 if (idata->hcache && !msgbegin) … … 848 848 static body_cache_t *msg_cache_open (IMAP_DATA *idata) 849 849 { 850 char *s;851 char *p = idata->mailbox;852 850 char mailbox[_POSIX_PATH_MAX]; 853 size_t mlen = sizeof (mailbox);854 851 855 852 if (idata->bcache) 856 853 return idata->bcache; 857 854 858 mailbox[0] = '\0'; 859 860 for (s = mailbox; p && *p && mlen; mlen--) 861 { 862 if (*p == idata->delim) 863 { 864 *s = '/'; 865 /* simple way to avoid collisions with UIDs */ 866 if (*(p + 1) >= '0' && *(p + 1) <= '9') 867 { 868 mlen--; 869 if (mlen) 870 *++s = '_'; 871 } 872 } 873 else 874 *s = *p; 875 p++; 876 s++; 877 } 878 *s = '\0'; 855 imap_cachepath (idata, idata->mailbox, mailbox, sizeof (mailbox)); 879 856 880 857 return mutt_bcache_open (&idata->conn->account, mailbox); -
imap/util.c
r5114 r5115 72 72 73 73 #ifdef USE_HCACHE 74 int imap_hcache_open (IMAP_DATA* idata) 74 static int imap_hcache_namer (const char* path, char* dest, size_t dlen) 75 { 76 return snprintf (dest, dlen, "%s.hcache", path); 77 } 78 79 header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path) 75 80 { 76 81 IMAP_MBOX mx; 77 82 ciss_url_t url; 78 83 char cachepath[LONG_STRING]; 84 char mbox[LONG_STRING]; 79 85 80 86 if (imap_parse_path (idata->ctx->path, &mx) < 0) 81 87 return -1; 82 88 89 if (path) 90 imap_cachepath (idata, path, mbox, sizeof (mbox)); 91 else 92 { 93 imap_cachepath (idata, mx.mbox, mbox, sizeof (mbox)); 94 FREE (&mx.mbox); 95 } 96 83 97 mutt_account_tourl (&idata->conn->account, &url); 84 url.path = mx.mbox; 85 url_ciss_tostring (&url, cachepath, sizeof (cachepath), 0); 86 FREE (&mx.mbox); 87 88 idata->hcache = mutt_hcache_open (HeaderCache, cachepath, NULL); 89 90 return idata->hcache != NULL ? 0 : -1; 98 url.path = mbox; 99 url_ciss_tostring (&url, cachepath, sizeof (cachepath), U_PATH); 100 101 return mutt_hcache_open (HeaderCache, cachepath, imap_hcache_namer); 91 102 } 92 103 … … 397 408 398 409 return path; 410 } 411 412 void imap_cachepath(IMAP_DATA* idata, const char* mailbox, char* dest, 413 size_t dlen) 414 { 415 char* s; 416 const char* p = mailbox; 417 418 for (s = dest; p && *p && dlen; dlen--) 419 { 420 if (*p == idata->delim) 421 { 422 *s = '/'; 423 /* simple way to avoid collisions with UIDs */ 424 if (*(p + 1) >= '0' && *(p + 1) <= '9') 425 { 426 if (--dlen) 427 *++s = '_'; 428 } 429 } 430 else 431 *s = *p; 432 p++; 433 s++; 434 } 435 *s = '\0'; 399 436 } 400 437
