+static void madmutt_update_cachedir(const char *dir)
+{
+ static char *cachedir = NULL;
+ char path[_POSIX_PATH_MAX];
+ char buf[HUGE_STRING];
+ struct stat st;
+
+ _mutt_expand_path(path, sizeof(path), dir, 0);
+ if (lstat(path, &st) || !S_ISDIR(st.st_mode)) {
+ snprintf(buf, sizeof(buf), _("Directory %s not exist. Create it?"),
+ dir);
+ if (mutt_yesorno(buf, M_YES) == M_YES)
+ mkdir(path, 0750);
+ }
+
+ if (lstat(path, &st) || !S_ISDIR(st.st_mode)) {
+ mutt_error(_("Cache directory not created!"));
+ return;
+ }
+ if (st.st_mode & 0027) {
+ snprintf(buf, sizeof(buf),
+ _("Directory %s is unsafe, do you want to use it ?"), dir);
+ if (mutt_yesorno(buf, M_YES) != M_YES)
+ return;
+ }
+
+ m_strreplace(&cachedir, path);
+ mod_core.cachedir = cachedir;
+}
+
+
+#if defined(HAVE_TOKYOCABINET)
+# define HCACHE_BACKEND "tokyocabinet"
+#elif defined(HAVE_QDBM)