+static char *madmutt_init_shorthost(void)
+{
+ struct utsname utsname;
+ const char *p;
+
+ /* some systems report the FQDN instead of just the hostname */
+ uname(&utsname);
+ p = m_strchrnul(utsname.nodename, '.');
+ return p_dupstr(utsname.nodename, p - utsname.nodename);
+}
+
+static char *madmutt_init_os(void)
+{
+ struct utsname un;
+ return m_strdup(uname(&un) < 0 ? "Unix" : un.sysname);
+}
+
+static char *madmutt_init_hostname(void)
+{
+ char buffer[STRING];
+
+ if (getdnsdomainname(buffer, sizeof(buffer)) < 0)
+ return m_strdup("@");
+
+ if (*buffer != '@') {
+ int len = m_strlen(buffer) + m_strlen(mod_core.shorthost) + 2;
+ char *res = p_new(char, len);
+ snprintf(res, len, "%s.%s", NONULL(mod_core.shorthost), buffer);
+ return res;
+ }
+
+ return m_strdup(NONULL(mod_core.shorthost));
+}
+
+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)