void imap_free_idata (IMAP_DATA** idata);
char* imap_fix_path (IMAP_DATA* idata, const char* mailbox, char* path,
size_t plen);
-void imap_cachepath(IMAP_DATA* idata, const char* mailbox, char* dest,
- size_t dlen);
+void imap_cachepath(IMAP_DATA *idata, const char *mailbox, BUFFER *dest);
int imap_get_literal_count (const char* buf, unsigned int* bytes);
char* imap_get_qualifier (char* buf);
int imap_mxcmp (const char* mx1, const char* mx2);
static body_cache_t *msg_cache_open (IMAP_DATA *idata)
{
- char mailbox[_POSIX_PATH_MAX];
+ BUFFER *mailbox;
+ body_cache_t *rv;
if (idata->bcache)
return idata->bcache;
- imap_cachepath (idata, idata->mailbox, mailbox, sizeof (mailbox));
+ mailbox = mutt_buffer_pool_get ();
+ imap_cachepath (idata, idata->mailbox, mailbox);
+ rv = mutt_bcache_open (&idata->conn->account, mutt_b2s (mailbox));
+ mutt_buffer_pool_release (&mailbox);
- return mutt_bcache_open (&idata->conn->account, mailbox);
+ return rv;
}
static FILE* msg_cache_get (IMAP_DATA* idata, HEADER* h)
{
IMAP_MBOX mx;
ciss_url_t url;
- char cachepath[LONG_STRING];
- char mbox[LONG_STRING];
+ BUFFER *cachepath = NULL;
+ BUFFER *mbox = NULL;
size_t len;
+ header_cache_t *rv = NULL;
+
+ mbox = mutt_buffer_pool_get ();
+ cachepath = mutt_buffer_pool_get ();
if (path)
- imap_cachepath (idata, path, mbox, sizeof (mbox));
+ imap_cachepath (idata, path, mbox);
else
{
if (!idata->ctx || imap_parse_path (idata->ctx->path, &mx) < 0)
- return NULL;
+ goto cleanup;
- imap_cachepath (idata, mx.mbox, mbox, sizeof (mbox));
+ imap_cachepath (idata, mx.mbox, mbox);
FREE (&mx.mbox);
}
- if (strstr(mbox, "/../") || (strcmp(mbox, "..") == 0) || (strncmp(mbox, "../", 3) == 0))
- return NULL;
- len = strlen(mbox);
- if ((len > 3) && (strcmp(mbox + len - 3, "/..") == 0))
- return NULL;
+ if (strstr (mutt_b2s (mbox), "/../") ||
+ (strcmp (mutt_b2s (mbox), "..") == 0) ||
+ (strncmp(mutt_b2s (mbox), "../", 3) == 0))
+ goto cleanup;
+ len = mutt_buffer_len (mbox);
+ if ((len > 3) && (strcmp(mutt_b2s (mbox) + len - 3, "/..") == 0))
+ goto cleanup;
mutt_account_tourl (&idata->conn->account, &url);
- url.path = mbox;
- url_ciss_tostring (&url, cachepath, sizeof (cachepath), U_PATH);
+ url.path = mbox->data;
+ url_ciss_tobuffer (&url, cachepath, U_PATH);
- return mutt_hcache_open (HeaderCache, cachepath, imap_hcache_namer);
+ rv = mutt_hcache_open (HeaderCache, mutt_b2s (cachepath), imap_hcache_namer);
+
+cleanup:
+ mutt_buffer_pool_release (&mbox);
+ mutt_buffer_pool_release (&cachepath);
+ return rv;
}
void imap_hcache_close (IMAP_DATA* idata)
return path;
}
-void imap_cachepath(IMAP_DATA* idata, const char* mailbox, char* dest,
- size_t dlen)
+void imap_cachepath (IMAP_DATA *idata, const char *mailbox, BUFFER *dest)
{
- char* s;
- const char* p = mailbox;
+ const char *p = mailbox;
- for (s = dest; p && *p && dlen; dlen--)
+ mutt_buffer_clear (dest);
+ if (!p)
+ return;
+
+ while (*p)
{
if (*p == idata->delim)
{
- *s = '/';
+ mutt_buffer_addch (dest, '/');
/* simple way to avoid collisions with UIDs */
if (*(p + 1) >= '0' && *(p + 1) <= '9')
- {
- if (--dlen)
- *++s = '_';
- }
+ mutt_buffer_addch (dest, '_');
}
else
- *s = *p;
+ mutt_buffer_addch (dest, *p);
p++;
- s++;
}
- *s = '\0';
}
/* imap_get_literal_count: write number of bytes in an IMAP literal into