X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lua%2Fmadmutt.c;h=6872096be4e63f60ee280bea1351b5284d5590dd;hp=31ee28a5af15f635d4fd9fc154031e26c912a936;hb=0fa8ebfe1d97b31c7d137d6cd45d480fa544d8a5;hpb=88d22daa9c1316d5ccc4b4bb60d40cc96c767757 diff --git a/lib-lua/madmutt.c b/lib-lua/madmutt.c index 31ee28a..6872096 100644 --- a/lib-lua/madmutt.c +++ b/lib-lua/madmutt.c @@ -18,6 +18,10 @@ */ #include + +#include +#include + #include "lib-lua_priv.h" #include "../mutt.h" @@ -56,14 +60,18 @@ static int madmutt_assign(lua_State *L) { const char *idx = luaL_checkstring(L, 2); const char *val = luaL_checkstring(L, 3); + char buf[STRING]; switch (lua_which_token(idx, -1)) { default: luaL_error(L, "bad subscript to madmutt: %s", val); return 0; + case LTK_DOTLOCK: case LTK_SENDMAIL: case LTK_SHELL: + _mutt_expand_path(buf, sizeof(buf), val, 0); + val = buf; break; } @@ -144,13 +152,13 @@ static const struct { */ #ifdef USE_HCACHE #if defined(HAVE_QDBM) - {"hcache_backend", "qdbm" }, + { "hcache_backend", "qdbm" }, #elif defined(HAVE_GDBM) - {"hcache_backend", "gdbm" }, + { "hcache_backend", "gdbm" }, #elif defined(HAVE_DB4) - {"hcache_backend", "db4" }, + { "hcache_backend", "db4" }, #else - {"hcache_backend", "unknown" }, + { "hcache_backend", "unknown" }, #endif /* ** .pp @@ -158,6 +166,44 @@ static const struct { ** header chaching's database backend.\fP */ #endif + + {"dotlock", BINDIR "/mutt_dotlock"}, + /* + ** .pp + ** Contains the path of the \fTmadmutt_dotlock(1)\fP binary to be used by + ** Madmutt. + */ + {"sendmail", SENDMAIL " -oem -oi"}, + /* + ** .pp + ** Specifies the program and arguments used to deliver mail sent by Madmutt. + ** Madmutt expects that the specified program interprets additional + ** arguments as recipient addresses. + */ +}; + +static void madmutt_init_shell(char *buf, ssize_t len) +{ + struct passwd *pw = getpwuid(getuid()); + + if (pw) { + m_strcpy(buf, len, pw->pw_shell); + _mutt_expand_path(buf, len, pw->pw_shell, 0); + } else { + m_strcpy(buf, len, getenv("SHELL") ?: "/bin/sh"); + } +} + +static const struct { + const char *key; + void (*fun)(char *buf, ssize_t len); +} madmutt_module_vars2[] = { + { "shell", madmutt_init_shell }, + /* + ** .pp + ** Command to use when spawning a subshell. By default, the user's login + ** shell from \fT/etc/passwd\fP is used. + */ }; int luaopen_madmutt(lua_State *L) @@ -174,6 +220,13 @@ int luaopen_madmutt(lua_State *L) lua_setfield(L, -2, madmutt_module_vars[i].key); } + for (i = 0; i < countof(madmutt_module_vars2); i++) { + char buf[STRING]; + (madmutt_module_vars2[i].fun)(buf, sizeof(buf)); + lua_pushstring(L, buf); + lua_setfield(L, -2, madmutt_module_vars2[i].key); + } + lua_pushstring(L, "__index"); lua_pushvalue(L, -2); lua_settable(L, -3);