aboutsummaryrefslogtreecommitdiff
path: root/src/reg.c
diff options
context:
space:
mode:
authorame <[email protected]>2024-01-21 19:35:25 -0600
committerame <[email protected]>2024-01-21 19:35:25 -0600
commit85c4718212e44b0e01485260b5f1574d5c7411a9 (patch)
treeadeb629adaa7078c598385f96c013282b10c9c74 /src/reg.c
parentf27507a6cc914b04746f4608a217f5da21aa86a7 (diff)
stuff
Diffstat (limited to 'src/reg.c')
-rw-r--r--src/reg.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/src/reg.c b/src/reg.c
index a9c07bb..030a93f 100644
--- a/src/reg.c
+++ b/src/reg.c
@@ -5,33 +5,61 @@
#include "io.h"
#include "math.h"
#include "net.h"
+#include <signal.h>
+
+static int lua_exit(lua_State* L){
+ printf("hi\n");
+ return 0;
+}
+
+void sigHandle(int s){
+ signal(s, SIG_IGN);
+ printf("meow\n");
+ signal(s, sigHandle);
+}
+
int luaopen_llib(lua_State* L) {
- lua_newtable(L);
+ /*
+ lua_newuserdata(L, sizeof(void*));
+ luaL_newmetatable(L, "gc");
+ lua_pushstring(L, "__gc");
+ lua_pushcfunction(L, &lua_exit);
+ lua_settable(L, -3);
+
+ lua_setmetatable(L, -2);
+ lua_setfield(L, LUA_REGISTRYINDEX, "grr");
+ signal(SIGTERM, sigHandle);
+ signal(SIGINT, sigHandle);
+*/
//create <lib>.array functions
lua_newtable(L);
+
+ //lua_newtable(L);
+ lua_pushstring(L, "array");
luaL_register(L, NULL, array_function_list);
- lua_setfield(L, 2, "array");
-
- lua_newtable(L);
+ lua_settable(L, -3);
+
+ lua_pushstring(L, "crypto");
luaL_register(L, NULL, crypto_function_list);
- lua_setfield(L, 2, "crypto");
-
- lua_newtable(L);
+ lua_settable(L, -3);
+
+ lua_pushstring(L, "io");
luaL_register(L, NULL, io_function_list);
- lua_setfield(L, 2, "io");
+ lua_settable(L, -3);
- lua_newtable(L);
+ lua_pushstring(L, "math");
luaL_register(L, NULL, math_function_list);
- lua_setfield(L, 2, "math");
+ lua_settable(L, -3);
- lua_newtable(L);
+ lua_pushstring(L, "config");
luaL_register(L, NULL, config_function_list);
- lua_setfield(L, 2, "config");
+ lua_settable(L, -3);
- lua_newtable(L);
+ lua_pushstring(L, "net");
luaL_register(L, NULL, net_function_list);
- lua_setfield(L, 2, "net");
+ lua_settable(L, -3);
+
//make llib global
lua_setglobal(L, "llib");
return 1;