aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorame <[email protected]>2024-02-12 15:32:07 -0600
committerame <[email protected]>2024-02-12 15:32:07 -0600
commit04b1b0fc52287228a2c9bc6a3cbf9a85bdd1f2fc (patch)
tree56f4e10d97f62cf1d937038b2ad78f38f7d53a48
parent5b4723f51f4a0f514959038e58c36c70a82e363f (diff)
no clue what i changed
-rw-r--r--readme.md2
-rw-r--r--src/i_util.c2
-rw-r--r--src/lua.c6
-rw-r--r--src/net.c2
-rw-r--r--src/parray.c4
-rw-r--r--src/reg.c21
6 files changed, 23 insertions, 14 deletions
diff --git a/readme.md b/readme.md
index c8f42aa..d2458c0 100644
--- a/readme.md
+++ b/readme.md
@@ -1,6 +1,8 @@
build with `clang -shared src/{*.c,*/*.c} -o llib.so -fPIC`
+or `clang -shared src/{*.c,*/*.c} -o llib.dll -L/mingw64/lib -llua -lws2_32 -fPIC` for my msys2 build
+
useage and docs coming soon:3
todo:
diff --git a/src/i_util.c b/src/i_util.c
index 3e077f4..0a20224 100644
--- a/src/i_util.c
+++ b/src/i_util.c
@@ -1,7 +1,7 @@
#include "i_util.h"
#include <stdio.h>
#include <stdlib.h>
-
+#include "lua.h"
void p_fatal(const char* m){
fprintf(stderr, "%s[ fatal ] %s %s\n",color_red, m, color_reset);
exit(EXIT_FAILURE);
diff --git a/src/lua.c b/src/lua.c
index e7ff11b..91c667b 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -21,8 +21,10 @@ int writer(lua_State *L, const void* p, size_t sz, void* ud){
}
void i_dcopy(lua_State* src, lua_State* dest, void* _seen){
parray_t* seen = (parray_t*)_seen;
- if(seen == NULL) seen = parray_init();
+ int wnull = seen == NULL;
+ if(wnull) seen = parray_init();
size_t len;
+ //printf("%i\n",seen->len);
int at, at2;
//int *sp = malloc(1);
//int *sp;
@@ -123,5 +125,7 @@ void i_dcopy(lua_State* src, lua_State* dest, void* _seen){
lua_pushnil(dest);
break;
}
+ if(wnull) parray_clear(seen, 1);
//lua_settop(src, old_top);
+ _seen = seen;
} \ No newline at end of file
diff --git a/src/net.c b/src/net.c
index 420f229..e39685b 100644
--- a/src/net.c
+++ b/src/net.c
@@ -368,7 +368,9 @@ void* handle_client(void *_arg){
pthread_mutex_lock(&mutex);
int old_top = lua_gettop(args->L);
lua_getglobal(args->L, "_G");
+
i_dcopy(args->L, L, NULL);
+
lua_settop(args->L, old_top);
//l_pprint(L);
lua_setglobal(L, "_G");
diff --git a/src/parray.c b/src/parray.c
index 637bc0b..d0e38ff 100644
--- a/src/parray.c
+++ b/src/parray.c
@@ -42,8 +42,8 @@ void parray_lclear(parray_t* p){
void parray_clear(parray_t* p, int clear_val){
for(int i = 0; i != p->len; i++){
- str_free(p[i].P->key);
- if(clear_val) free(p[i].P->value);
+ str_free(p->P[i].key);
+ if(clear_val) free(p->P[i].value);
}
parray_lclear(p);
}
diff --git a/src/reg.c b/src/reg.c
index 38d5ee9..a364813 100644
--- a/src/reg.c
+++ b/src/reg.c
@@ -6,21 +6,22 @@
#include "math.h"
#include "net.h"
#include <signal.h>
+#include <stdlib.h>
-static int lua_exit(lua_State* L){
- printf("hi\n");
- return 0;
+void sigHandle(int s){
+ //signal(s, SIG_IGN);
+
+ //signal(s, sigHandle);
+ exit(s);
}
-void sigHandle(int s){
- signal(s, SIG_IGN);
- printf("meow\n");
- signal(s, sigHandle);
+static int lua_exit(lua_State* L){
+
+ sigHandle(0);
+ return 0;
}
int luaopen_llib(lua_State* L) {
- /*
-
lua_newuserdata(L, sizeof(void*));
luaL_newmetatable(L, "gc");
lua_pushstring(L, "__gc");
@@ -31,7 +32,7 @@ int luaopen_llib(lua_State* L) {
lua_setfield(L, LUA_REGISTRYINDEX, "grr");
signal(SIGTERM, sigHandle);
signal(SIGINT, sigHandle);
-*/
+
//create <lib>.array functions
lua_newtable(L);