X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lua%2Fruntime.c;h=0fb777c578ea0a807f43b09b4c13af26f3d1d527;hp=60a683535355e5cfbe3bbf4105bce89ee162e858;hb=a83b73d30397ee8e5c33668bcc0f1712ac74ff29;hpb=6729a8ab646a00a661858b7ac7ee21f770bff3d3 diff --git a/lib-lua/runtime.c b/lib-lua/runtime.c index 60a6835..0fb777c 100644 --- a/lib-lua/runtime.c +++ b/lib-lua/runtime.c @@ -21,9 +21,11 @@ #include "lib-lua_priv.h" static lua_State *L; +static reg_entry registry[LTK_count]; static const luaL_Reg lualibs[] = { {"", luaopen_base}, + {LUA_OSLIBNAME, luaopen_os}, {LUA_LOADLIBNAME, luaopen_package}, {LUA_TABLIBNAME, luaopen_table}, {LUA_IOLIBNAME, luaopen_io}, @@ -65,3 +67,30 @@ int mlua_wrap(void (*errfun)(const char *fmt, ...), int status) return status; } +const char *mlua_reggets(int tk) +{ + if (registry[tk].type != REG_STR) + return NULL; + return registry[tk].s; +} + +int mlua_reggeti(int tk) +{ + if (registry[tk].type != REG_INT) + return -1; + return registry[tk].i; +} + +void mlua_regsets(int tk, const char *s) +{ + reg_entry_wipe(registry + tk); + registry[tk].type = REG_STR; + registry[tk].s = m_strdup(s); +} + +void mlua_regseti(int tk, int i) +{ + reg_entry_wipe(registry + tk); + registry[tk].type = REG_INT; + registry[tk].i = i; +}