diff options
| author | ame <[email protected]> | 2023-12-18 13:55:13 -0600 |
|---|---|---|
| committer | ame <[email protected]> | 2023-12-18 13:55:13 -0600 |
| commit | 9a4d5574a89c4a7842211238d8b9b30b905cc056 (patch) | |
| tree | 17506097f415d4bddcdf3566d3ce0de08ab9a377 /src/config.c | |
| parent | 9607c2fff47e764efba9ec0e12291d9368ae9073 (diff) | |
config and io functions
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c new file mode 100644 index 0000000..46beca7 --- /dev/null +++ b/src/config.c @@ -0,0 +1,28 @@ +#include "config.h" +#include <string.h> + +int _print_type = 0; +int _max_depth = 2; +int _start_nl_at = 3; + +int get_config_map(const char* key){ + for(int i = 0; config_map[i].key != NULL; i++){ + if(strcmp(config_map[i].key,key) == 0) return i; + } + return -1; +} + +int l_set(lua_State* L) { + luaL_checktype(L, 1, LUA_TTABLE); + get_config_map("print_type"); + lua_pushnil(L); + for(;lua_next(L,1) != 0;){ + int ind = get_config_map(lua_tostring(L,-2)); + + if(ind != -1) { + *config_map[ind].value = lua_tonumber(L,-1); + } + lua_pop(L,1); + } + return 0; +} |
