Move score_* to mod_score
[apps/madmutt.git] / lib-lua / runtime.c
index f7401e2..1957a9c 100644 (file)
 #include <lib-lib/lib-lib.h>
 #include <lib-lua/lib-lua.h>
 
-#include "../alias.h"
 #include "../mutt.h"
+#include "../alias.li"
+#include "../buffy.li"
+#include "../charset.li"
+#include "../crypt.li"
+#include "../score.li"
+#include <lib-sys/mutt_ssl.li>
 
 static lua_State *L;
 
@@ -39,6 +44,12 @@ void luaM_initialize(void)
         {"MCore",         luaopen_MCore},
         {"MTransport",    luaopen_MTransport},
         {"MAlias",        luaopen_MAlias},
+        {"MCharset",      luaopen_MCharset},
+        {"Mime",          luaopen_Mime},
+        {"Buffy",         luaopen_Buffy},
+        {"mod_ssl",       luaopen_mod_ssl},
+        {"mod_crypt",     luaopen_mod_crypt},
+        {"mod_score",     luaopen_mod_score},
     };
 
     int i;
@@ -56,6 +67,10 @@ void luaM_shutdown(void)
     lua_close(L);
 }
 
+lua_State *luaM_getruntime(void)
+{
+    return L;
+}
 
 int luaM_dofile(const char *filename)
 {
@@ -97,6 +112,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 +137,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 +152,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);
 }
-