static int generate_crc32(void)
{
- static int crc = 0;
+ int crc = 0;
crc = crc32(crc, "madmutt.2007.05.13", m_strlen("madmutt.2007.05.13"));
-#ifdef HAVE_LANGINFO_CODESET
- crc = crc32(crc, MCharset.charset, m_strlen(MCharset.charset));
- crc = crc32(crc, "HAVE_LANGINFO_CODESET",
- m_strlen("HAVE_LANGINFO_CODESET"));
+#ifdef HAVE_LANGINFO_H
+ crc = crc32(crc, mod_cset.charset, m_strlen(mod_cset.charset));
#endif
crc = crc32(crc, "USE_POP", m_strlen("USE_POP"));
- crc = crc32(crc, "MIXMASTER", m_strlen("MIXMASTER"));
crc = crc32(crc, "USE_IMAP", m_strlen("USE_IMAP"));
-#ifdef USE_NNTP
- crc = crc32(crc, "USE_NNTP", m_strlen("USE_NNTP"));
-#endif
return crc;
}
/* store and restore things {{{ */
+static void dump_int(buffer_t *buf, int i)
+{
+ buffer_add(buf, &i, sizeof(i));
+}
+
static const void *restore_int(const char *d, int *i)
{
memcpy(i, d, sizeof(*i));
int size = 0;
if (m_strisempty(s)) {
- buffer_add(buf, &size, sizeof(size));
+ dump_int(buf, size);
return;
}
size = strlen(s) + 1;
- buffer_add(buf, &size, sizeof(size));
+ dump_int(buf, size);
buffer_add(buf, s, size);
}
{
int counter = 0, pos = buf->len;
- buffer_add(buf, &counter, sizeof(counter));
+ dump_int(buf, counter);
for (; a; a = a->next, counter++) {
dump_cstr(buf, a->personal);
dump_cstr(buf, a->mailbox);
- buffer_add(buf, &a->group, sizeof(a->group));
+ dump_int(buf, a->group);
}
memcpy(buf->data + pos, &counter, sizeof(counter));
int pos = buf->len;
int counter = 0;
- buffer_add(buf, &counter, sizeof(counter));
+ dump_int(buf, counter);
for (; l; l = l->next, counter++) {
dump_cstr(buf, l->data);
{
int pos = buf->len, counter = 0;
- buffer_add(buf, &counter, sizeof(counter));
+ dump_int(buf, counter);
for (; p; p = p->next, counter++) {
dump_cstr(buf, p->attribute);
dump_cstr(buf, e->subject);
n = e->real_subj ? e->real_subj - e->subject : -1;
- buffer_add(buf, &n, sizeof(n));
+ dump_int(buf, n);
dump_cstr(buf, e->message_id);
dump_cstr(buf, e->supersedes);
dump_cstr(buf, e->x_label);
dump_cstr(buf, e->list_post);
-#ifdef USE_NNTP
- dump_cstr(buf, e->newsgroups);
- dump_cstr(buf, e->xref);
- dump_cstr(buf, e->followup_to);
- dump_cstr(buf, e->x_comment_to);
-#endif
-
dump_list(buf, e->references);
dump_list(buf, e->in_reply_to);
dump_list(buf, e->userhdrs);
d = restore_cstr(d, &e->x_label);
d = restore_cstr(d, &e->list_post);
-#ifdef USE_NNTP
- d = restore_cstr(d, &e->newsgroups);
- d = restore_cstr(d, &e->xref);
- d = restore_cstr(d, &e->followup_to);
- d = restore_cstr(d, &e->x_comment_to);
-#endif
-
d = restore_list(d, &e->references);
d = restore_list(d, &e->in_reply_to);
d = restore_list(d, &e->userhdrs);
-
return d;
}
uid_validity = time(NULL);
}
buffer_add(res, &uid_validity, sizeof(uid_validity));
- buffer_add(res, &db->crc, sizeof(db->crc));
+ dump_int(res, db->crc);
buffer_add(res, h, sizeof(*h));
dump_envelope(res, h->env);
/* }}} */
-hcache_t *mutt_hcache_open(const char *path, const char *folder)
+hcache_t *mutt_hcache_open(const char *folder)
{
- hcache_t *h = p_new(hcache_t, 1);
+ const char *path;
+ hcache_t *h;
- h->folder = m_strdup(folder);
- h->crc = generate_crc32();
-
- if (m_strisempty(path)) {
- p_delete(&h->folder);
- p_delete(&h);
+ if (m_strisempty(mod_core.cachedir)) {
return NULL;
}
- path = mutt_hcache_per_folder(path, folder);
+ h = p_new(hcache_t, 1);
+ h->folder = m_strdup(folder);
+ h->crc = generate_crc32();
+
+ path = mutt_hcache_per_folder(mod_core.cachedir, folder);
{
#if defined(HAVE_QDBM)
- int flags = VL_OWRITER | VL_OCREAT;
- if (option(OPTHCACHECOMPRESS))
- flags |= VL_OZCOMP;
-
- h->db = vlopen(path, flags, VL_CMPLEX);
+ h->db = vlopen(path, VL_OWRITER | VL_OCREAT, VL_CMPLEX);
#elif defined(HAVE_GDBM)
- int pagesize = atoi(HeaderCachePageSize) ?: 16384;
-
- h->db = gdbm_open((char *) path, pagesize, GDBM_WRCREAT, 00600, NULL);
+ h->db = gdbm_open((char *) path, 16384, GDBM_WRCREAT, 00600, NULL);
#endif
}
ssize_t (*keylen)(const char *fn))
{
char path[_POSIX_PATH_MAX];
- void *data = NULL;
+ char *data = NULL;
if (!db)
return NULL;