From 10ddc97d221989e107c5283e3d5df8c48a23dc26 Mon Sep 17 00:00:00 2001 From: ame Date: Fri, 1 Aug 2025 14:20:08 -0500 Subject: write file, and code should be an int --- src/lua.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lua.c') diff --git a/src/lua.c b/src/lua.c index 4fe9962..3d35858 100644 --- a/src/lua.c +++ b/src/lua.c @@ -73,7 +73,7 @@ int _stream_file(lua_State* L){ const char* filename = lua_tostring(L, 2); FILE *f; - f = fopen(filename, "a"); + f = fopen(filename, "w"); if(f == NULL){ luaI_error(L, -1, "unable to open file"); } -- cgit v1.2.3 From 19afaa2feedaa6ec1e1774174ce752e7f2583484 Mon Sep 17 00:00:00 2001 From: ame Date: Fri, 1 Aug 2025 14:25:07 -0500 Subject: change stream modes --- src/lua.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lua.c') diff --git a/src/lua.c b/src/lua.c index 3d35858..ef3c032 100644 --- a/src/lua.c +++ b/src/lua.c @@ -59,10 +59,15 @@ int _stream_file(lua_State* L){ const int CHUNK_SIZE = 4096; uint64_t maxlen = 0; uint64_t totallen = 0; + const char* mode = "w"; if(lua_gettop(L) > 2){ maxlen = lua_tointeger(L, 3); } + if(lua_gettop(L) > 3){ + mode = lua_tostring(L, 4); + } + lua_pushstring(L, "_read"); lua_gettable(L, 1); stream_read_function rf = lua_touserdata(L, -1); @@ -73,7 +78,7 @@ int _stream_file(lua_State* L){ const char* filename = lua_tostring(L, 2); FILE *f; - f = fopen(filename, "w"); + f = fopen(filename, mode); if(f == NULL){ luaI_error(L, -1, "unable to open file"); } -- cgit v1.2.3 From cd1c124e2def659dd2919e4387047de733afcc59 Mon Sep 17 00:00:00 2001 From: ame Date: Fri, 1 Aug 2025 21:27:11 -0500 Subject: make user-agent editable with default header values --- src/lua.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/lua.c') diff --git a/src/lua.c b/src/lua.c index ef3c032..e138f77 100644 --- a/src/lua.c +++ b/src/lua.c @@ -374,19 +374,21 @@ int env_table(lua_State* L, int provide_table){ return 1; } -//top table is prioritized -void luaI_jointable(lua_State* L){ - int idx = lua_gettop(L) - 1; +//main is the default values, merge is the new and overridden ones +void luaI_jointable(lua_State* L, int main, int merge){ + int idx = lua_gettop(L); + + lua_pushvalue(L, merge); lua_pushnil(L); for(;lua_next(L, -2) != 0;){ lua_pushvalue(L, -2); lua_pushvalue(L, -2); - lua_settable(L, idx); + lua_settable(L, main); lua_pop(L, 1); } - lua_pushvalue(L, idx); + lua_settop(L, idx); } //copys all variables from state A to B, including locals (stored in _locals) -- cgit v1.2.3