From 43238419974e599a84f17b5faa8fb52401bdfe90 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Sun, 8 Sep 2024 13:07:22 +0200 Subject: Refactor config parsing --- src/config.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/config.h') diff --git a/src/config.h b/src/config.h index d76c515..024b6f6 100644 --- a/src/config.h +++ b/src/config.h @@ -4,7 +4,9 @@ #include #include -#include "block.h" +#include "util.h" + +typedef struct block block_t; typedef enum { CONFIG_STRING, @@ -13,24 +15,16 @@ typedef enum { CONFIG_DOUBLE, CONFIG_BOOL, CONFIG_COLOR, + CONFIG_ENUM, } config_type_t; typedef struct { const char *key; config_type_t type; + void *data; size_t offset; } config_entry_t; -typedef bool (*config_block_apply_t)(block_t *block, void *result); - -typedef struct { - const char *type_name; - size_t type_size; - block_t base; - const config_entry_t *entries; - config_block_apply_t apply; -} config_block_t; - typedef struct { size_t n_blocks; block_t *blocks; @@ -42,6 +36,11 @@ typedef struct { color_t background; } config_t; +typedef struct { + const char *label; + int value; +} config_enum_t; + void config_init(config_t *config); void config_read(config_t *config, FILE *file); -- cgit v1.2.3