X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lua%2Fruntime.c;h=1e806c4240cf6586fefd5fec5f2bb91939bdd4ed;hp=f7401e2bbf355ac9d3c55cc1d241d17efbe4b3f9;hb=58e0ddff3bd5e1b9455e8c3ebb1f4b9e7dd71920;hpb=f4a82d92ca0d015424b203887579802f003cfac8 diff --git a/lib-lua/runtime.c b/lib-lua/runtime.c index f7401e2..1e806c4 100644 --- a/lib-lua/runtime.c +++ b/lib-lua/runtime.c @@ -22,6 +22,7 @@ #include "../alias.h" #include "../mutt.h" +#include "../charset.h" static lua_State *L; @@ -39,6 +40,8 @@ void luaM_initialize(void) {"MCore", luaopen_MCore}, {"MTransport", luaopen_MTransport}, {"MAlias", luaopen_MAlias}, + {"MCharset", luaopen_MCharset}, + {"Mime", luaopen_Mime}, }; int i; @@ -97,6 +100,17 @@ quadopt_t luaM_checkquadopt(lua_State *Ls, int narg) return i; } +void luaM_pushquadopt(lua_State *Ls, int val) +{ + switch (val) { + case M_YES: return lua_pushstring(Ls, "yes"); + case M_NO: return lua_pushstring(Ls, "no"); + case M_ASKYES: return lua_pushstring(Ls, "ask-yes"); + case M_ASKNO: return lua_pushstring(Ls, "ask-no"); + default: return lua_pushnil(Ls); + } +} + const char *luaM_checkrx(lua_State *Ls, int narg) { const char *s = luaL_checkstring(Ls, narg); @@ -111,6 +125,14 @@ const char *luaM_checkrx(lua_State *Ls, int narg) return s; } +rx_t *luaM_rxnew(const char *val) +{ + if (m_strisempty(val)) + val = "."; + + return rx_compile(val, mutt_which_case(val)); +} + char *luaM_pathnew(const char *val) { char path[PATH_MAX]; @@ -118,11 +140,10 @@ char *luaM_pathnew(const char *val) return m_strdup(path); } -rx_t *luaM_rxnew(const char *val) -{ - if (m_strisempty(val)) - val = "."; - return rx_compile(val, mutt_which_case(val)); +void luaM_pushaddr(lua_State *Ls, address_t *addr) +{ + char s[HUGE_STRING] = ""; + rfc822_addrcat(s, sizeof(s), addr, 0); + lua_pushstring(Ls, s); } -