diff options
| author | Federico Angelilli <code@fedang.net> | 2024-09-08 13:07:22 +0200 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-09-08 13:07:22 +0200 |
| commit | 43238419974e599a84f17b5faa8fb52401bdfe90 (patch) | |
| tree | 6b27b61d081e4f4c8399b3caf8551d1ba75adf1e /src/config.h | |
| parent | 6d0ce31b0ae5df97d4a340c54b66d95598b336a4 (diff) | |
Refactor config parsing
Diffstat (limited to 'src/config.h')
| -rw-r--r-- | src/config.h | 21 |
1 files changed, 10 insertions, 11 deletions
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 <stdio.h> #include <stdint.h> -#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); |
