diff options
author | quou <quou@disroot.org> | 2024-06-01 12:19:16 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-06-01 12:20:17 +1000 |
commit | ea7cd94f7aeb177618db3907a6c86b7252e018f0 (patch) | |
tree | e972f9cf590ef756c2e41f3eac5b03e16db08300 /cfgparse.h |
Initial commit.
Diffstat (limited to 'cfgparse.h')
-rw-r--r-- | cfgparse.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/cfgparse.h b/cfgparse.h new file mode 100644 index 0000000..f8eeedb --- /dev/null +++ b/cfgparse.h @@ -0,0 +1,58 @@ +#ifndef cfgparse_h +#define cfgparse_h + +#include "memory.h" + +typedef enum { + cfg_type_int, + cfg_type_string, + cfg_type_data, + cfg_type_none +} cfg_Type; + +typedef struct { + int size; + char* data; +} cfg_Data; + +typedef struct cfg_Prop { + char name[28]; + cfg_Type type; + union { + int num; + cfg_Data data; + char* str; + } as; + struct cfg_Prop* next; +} cfg_Prop; + +typedef struct cfg_Object { + char name[28]; + int prop_count; + cfg_Prop* props; + struct cfg_Object* next; +} cfg_Object; + +cfg_Object* cfg_parse(const char* src, Arena* arena); +const cfg_Prop* find_prop( + const cfg_Object* obj, + const char* name +); +const cfg_Prop* find_prop_of( + const cfg_Object* obj, + const char* name, + cfg_Type type +); + +int find_int_default( + const cfg_Object* obj, + const char* name, + int def +); +const char* find_string_default( + const cfg_Object* obj, + const char* name, + const char* def +); + +#endif |