X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-lua%2Fruntime.c;h=552587c3dc1e111eeef74b41b51c661d4bc5197d;hb=6f1bd3d49f9bb02c57e2c7a1ba8e5507edb28ad5;hp=a442401f6f06eb9b8f4184e118c72ca5de7849ed;hpb=0840ecb90bb99da0d6b0c028ace977dd1932e6e1;p=apps%2Fmadmutt.git diff --git a/lib-lua/runtime.c b/lib-lua/runtime.c index a442401..552587c 100644 --- a/lib-lua/runtime.c +++ b/lib-lua/runtime.c @@ -21,6 +21,7 @@ #include "lib-lua_priv.h" static lua_State *L; +static reg_entry registry[LTK_count]; static const luaL_Reg lualibs[] = { {"", luaopen_base}, @@ -66,18 +67,16 @@ int mlua_wrap(void (*errfun)(const char *fmt, ...), int status) return status; } -ssize_t mlua_value(char *buf, ssize_t len, - const char *table, const char *key) +const char *mlua_reggets(int tk) { - ssize_t res; - - lua_getglobal(L, table); - lua_pushstring(L, key); - lua_gettable(L, -2); - res = m_strcpy(buf, len, lua_tostring(L, -1)); - lua_remove(L, -1); - lua_remove(L, -1); - - return res; + if (registry[tk].type != REG_STR) + return NULL; + return registry[tk].s; } +void mlua_regsets(int tk, const char *s) +{ + reg_entry_wipe(registry + tk); + registry[tk].type = REG_STR; + registry[tk].s = m_strdup(s); +}