#include "../alias.h"
#include "../mutt.h"
+#include "../charset.h"
+#include "../buffy.h"
static lua_State *L;
{"MCore", luaopen_MCore},
{"MTransport", luaopen_MTransport},
{"MAlias", luaopen_MAlias},
+ {"MCharset", luaopen_MCharset},
+ {"Mime", luaopen_Mime},
+ {"Buffy", luaopen_Buffy},
};
int i;
lua_close(L);
}
+lua_State *luaM_getruntime(void)
+{
+ return L;
+}
int luaM_dofile(const char *filename)
{
quadopt_t luaM_checkquadopt(lua_State *Ls, int narg)
{
const char *s;
- int i = luaL_checkinteger(Ls, narg);
+ int i;
+ if (lua_type(Ls, narg) == LUA_TSTRING) {
+ s = lua_tostring(Ls, narg);
+ switch (mlua_which_token(s, -1)) {
+ case LTK_YES: return M_YES;
+ case LTK_NO: return M_NO;
+ case LTK_ASK_YES: return M_ASKYES;
+ case LTK_ASK_NO: return M_ASKNO;
+ default:
+ break;
+ }
+ }
+
+ i = luaL_checkinteger(Ls, narg);
if (i & ~3) {
s = lua_pushfstring(Ls, "int in [0-3] expected, got %d", i);
return luaL_argerror(Ls, narg, s);
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);
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];
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);
}
-