summaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 94536f1..d2ab740 100644
--- a/utils.c
+++ b/utils.c
@@ -215,6 +215,20 @@ yield_lua(lua_State *T)
}
static int
+sethandler_lua(lua_State *T)
+{
+ if (lua_gettop(T) > 0) {
+ luaL_checktype(T, 1, LUA_TFUNCTION);
+ lua_settop(T, 1);
+ } else
+ lua_pushboolean(T, 1);
+
+ lem_sethandler(T);
+
+ return 0;
+}
+
+static int
exit_lua(lua_State *T)
{
int status = (int)luaL_checknumber(T, 1);
@@ -265,6 +279,10 @@ int luaopen_lem_utils(lua_State *L)
lua_pushcfunction(L, yield_lua);
lua_setfield(L, 2, "yield");
+ /* set sethandler function */
+ lua_pushcfunction(L, sethandler_lua);
+ lua_setfield(L, 2, "sethandler");
+
/* set exit function */
lua_pushcfunction(L, exit_lua);
lua_setfield(L, 2, "exit");