X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-lua%2Fmadmutt.c;h=6872096be4e63f60ee280bea1351b5284d5590dd;hb=0fa8ebfe1d97b31c7d137d6cd45d480fa544d8a5;hp=dfcf0840cdee21ae63e9238abf4a0c87b3b55481;hpb=0840ecb90bb99da0d6b0c028ace977dd1932e6e1;p=apps%2Fmadmutt.git diff --git a/lib-lua/madmutt.c b/lib-lua/madmutt.c index dfcf084..6872096 100644 --- a/lib-lua/madmutt.c +++ b/lib-lua/madmutt.c @@ -60,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; } @@ -162,20 +166,37 @@ 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 const char *madmutt_init_shell(void) +static void madmutt_init_shell(char *buf, ssize_t len) { struct passwd *pw = getpwuid(getuid()); - if (pw) - return pw->pw_shell; - return getenv("SHELL") ?: "/bin/sh"; + 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 *k; - const char *(*f)(void); + const char *key; + void (*fun)(char *buf, ssize_t len); } madmutt_module_vars2[] = { { "shell", madmutt_init_shell }, /* @@ -200,8 +221,10 @@ int luaopen_madmutt(lua_State *L) } for (i = 0; i < countof(madmutt_module_vars2); i++) { - lua_pushstring(L, madmutt_module_vars2[i].f()); - lua_setfield(L, -2, madmutt_module_vars2[i].k); + 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");