ark_parser.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef ARK_PARSER_H
  2. #define ARK_PARSER_H
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #define MAX_LINE_LEN 1024
  7. #define MAX_KEYS 128
  8. #define MAX_SECTIONS 32
  9. #define MAX_STANDALONE 32
  10. typedef struct {
  11. char key[256];
  12. char value[512];
  13. } ArkKeyValuePair;
  14. typedef struct {
  15. char name[256];
  16. ArkKeyValuePair pairs[MAX_KEYS];
  17. int pair_count;
  18. } ArkSection;
  19. typedef struct {
  20. char filepath[512];
  21. ArkKeyValuePair global_pairs[MAX_KEYS];
  22. int global_count;
  23. ArkSection sections[MAX_SECTIONS];
  24. int section_count;
  25. char standalone[MAX_STANDALONE][512];
  26. int standalone_count;
  27. } ArkConfig;
  28. ArkConfig* ark_parse(const char* filepath);
  29. const char* ark_get_global(ArkConfig* config, const char* key);
  30. const char* ark_get_section_val(ArkConfig* config, const char* section, const char* key);
  31. void ark_set_global(ArkConfig* config, const char* key, const char* value);
  32. void ark_dump(ArkConfig* config, const char* filepath);
  33. void ark_free(ArkConfig* config);
  34. #endif // ARK_PARSER_H