push username, homedir and tmpdir in lua too.
[apps/madmutt.git] / lib-lua / madmutt.cpkg
index f11fc65..89ff6f2 100644 (file)
@@ -31,6 +31,18 @@ static const char *madmutt_init_shell(void)
     return pw ? pw->pw_shell : (getenv("SHELL") ?: "/bin/sh");
 }
 
+static const char *madmutt_init_username(void)
+{
+    struct passwd *pw = getpwuid(getuid());
+    return pw ? pw->pw_name : (getenv("USER") ?: "john_doe");
+}
+
+static const char *madmutt_init_homedir(void)
+{
+    struct passwd *pw = getpwuid(getuid());
+    return pw ? pw->pw_dir : (getenv("HOME") ?: "/");
+}
+
 static const char *madmutt_pwd(void)
 {
     char path[_POSIX_PATH_MAX];
@@ -45,6 +57,11 @@ static const char *luaM_path_post(const char *val)
     return path;
 }
 
+@type bool = {
+    .kind = 'b';
+    .ctype = unsigned : 1;
+};
+
 @type string_t = {
     .kind = 's';
     .ctype = const char *;
@@ -59,22 +76,45 @@ static const char *luaM_path_post(const char *val)
 @type quadopt_t = {
     .kind  = 'i';
     .check = luaM_checkquadopt($L, $$);
-    .ctype = quadopt_t;
+    .ctype = unsigned : 2;
 };
 
-@package madmutt {
+#if defined(HAVE_QDBM)
+#  define HCACHE_BACKEND "qdbm"
+#elif defined(HAVE_GDBM)
+#  define HCACHE_BACKEND "gdbm"
+#elif defined(HAVE_DB4)
+#  define HCACHE_BACKEND "db4"
+#else
+#  define HCACHE_BACKEND "unknown"
+#endif
+
+@package MCore {
     const string_t version    = VERSION;
     const string_t sysconfdir = SYSCONFDIR;
     const string_t bindir     = BINDIR;
     const string_t docdir     = PKGDOCDIR;
+    const string_t hcache_backend = HCACHE_BACKEND;
 
     path_t dotlock  = BINDIR "/mutt_dotlock";
     path_t editor   = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi";
-    path_t sendmail = SENDMAIL " -eom -oi";
     path_t shell    = madmutt_init_shell();
+    path_t username = madmutt_init_username();
+    path_t homedir  = madmutt_init_homedir();
+    path_t tmpdir   = getenv("TMPDIR") ?: "/tmp";
 
-    quadopt_t quit  = M_YES;
+    quadopt_t quit     = M_YES;
+    bool      beep     = 1;
+    bool      beep_new = 0;
 
     const string_t pwd(void) = madmutt_pwd();
-} ml_core;
+} MCore;
+
+@package MTransport {
+    path_t   sendmail = SENDMAIL " -eom -oi";
+
+    string_t dsn_notify = NULL;
+    string_t dsn_return = NULL;
+} MTransport;
 
+/* vim:set ft=c: */