aboutsummaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorforever2k38 <forever2k38@noreply.codeberg.org>2026-08-30 18:05:26 +0200
committerforever2k38 <forever2k38@noreply.codeberg.org>2026-08-30 18:05:26 +0200
commit02fd79105a7fe5ac6a04e76db27b163e4064f759 (patch)
treeb4cdc0ad498078555259bf71c0fe8b445f23217d /src/config.c
parent5e2367bfbe6a06c493d4b8e50917fb599a9ee5af (diff)
work on config and args
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
new file mode 100644
index 0000000..33d59b8
--- /dev/null
+++ b/src/config.c
@@ -0,0 +1,31 @@
+#include "config.h"
+
+#include "lauxlib.h"
+
+int open_config(pow_config *cfg, char *path) {
+ int err;
+
+ cfg->L = luaL_newstate();
+
+ if (!cfg->L) {
+ return 1;
+ }
+
+ lua_State *L = cfg->L; // just easier to access
+
+ err = luaL_loadfile(L, path);
+
+ if (err) {
+ return 1;
+ }
+
+ err = lua_pcall(L, 0, 0, 0);
+
+ if (err) {
+ printf("%s\n", lua_tostring(L, -1));
+
+ return 1;
+ }
+
+ return 0;
+}