#include <pwd.h>
#include <lib-lua/lib-lua.h>
+#include <lib-ui/lib-ui.h>
#include <lib-sys/unix.h>
#include "../mutt.h"
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_QDBM)
# define HCACHE_BACKEND "qdbm"
#elif defined(HAVE_GDBM)
# define HCACHE_BACKEND NULL
#endif
+static void mod_core_init2(void)
+{
+ madmutt_update_cachedir("~/.cache/madmutt");
+}
+#define mod_core_init() do { (mod_core_init)(); mod_core_init2(); } while (0)
+
@package mod_core {
/*
** .pp
*/
const string_t hcache_backend = HCACHE_BACKEND;
- /*
- ** .pp
- ** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by
- ** Madmutt.
- */
- path_t dotlock = m_strdup(BINDIR "/mutt_dotlock");
/*
** .pp
** This variable specifies which editor is used by Madmutt.
** Please be sure to really know what you are doing when changing this variable
** to configure a custom domain part of Message-IDs.
*/
- string_t hostname = madmutt_init_hostname();
string_t shorthost = madmutt_init_shorthost();
+ string_t hostname = madmutt_init_hostname();
/*
** .pp
RETURN(p ? p + 1 : (CurrentFolder ?: ""));
}
};
+
+
+ const string_t cachedir = NULL;
+ void setcachedir(const string_t path) {
+ madmutt_update_cachedir(path);
+ RETURN();
+ };
};
@package MTransport {