X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lua%2Fruntime.c;h=21503a8f863a1f1da7342187166ec4d2d4e3b896;hp=8788ed5848cc608b756b22737116beb81c4baab8;hb=0dc3054df348d3c9788ecf6aba028668c684a7bc;hpb=88d22daa9c1316d5ccc4b4bb60d40cc96c767757 diff --git a/lib-lua/runtime.c b/lib-lua/runtime.c index 8788ed5..21503a8 100644 --- a/lib-lua/runtime.c +++ b/lib-lua/runtime.c @@ -18,24 +18,25 @@ */ #include -#include "lib-lua_priv.h" +#include static lua_State *L; -static const luaL_Reg lualibs[] = { - {"", luaopen_base}, - {LUA_OSLIBNAME, luaopen_os}, - {LUA_LOADLIBNAME, luaopen_package}, - {LUA_TABLIBNAME, luaopen_table}, - {LUA_IOLIBNAME, luaopen_io}, - {LUA_STRLIBNAME, luaopen_string}, - {LUA_MATHLIBNAME, luaopen_math}, - {LUA_DBLIBNAME, luaopen_debug}, - {LUA_MADMUTT, luaopen_madmutt}, -}; - -void mlua_initialize(void) +void luaM_initialize(void) { + static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {"MCore", luaopen_MCore}, + {"MTransport", luaopen_MTransport}, + }; + int i; L = lua_open(); @@ -46,18 +47,18 @@ void mlua_initialize(void) } } -void mlua_shutdown(void) +void luaM_shutdown(void) { lua_close(L); } -int mlua_dofile(const char *filename) +int luaM_dofile(const char *filename) { return luaL_dofile(L, filename); } -int mlua_wrap(void (*errfun)(const char *fmt, ...), int status) +int luaM_wrap(void (*errfun)(const char *fmt, ...), int status) { if (status) { (*errfun)("-[lua]-: %s\n", lua_tostring(L, -1)); @@ -66,3 +67,16 @@ int mlua_wrap(void (*errfun)(const char *fmt, ...), int status) return status; } + +quadopt_t luaM_checkquadopt(lua_State *Ls, int narg) +{ + const char *s; + int 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; +} +