Changeset 5115:8082e4c9f524 for imap/util.c
- Timestamp:
- 2007-04-10 17:40:11 (21 months ago)
- Branch:
- HEAD
- Files:
-
- 1 modified
-
imap/util.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
