30 lines
980 B
C
30 lines
980 B
C
#include "../cfg.h"
|
|
|
|
int main() {
|
|
config c = new_config();
|
|
string key;
|
|
config_add_number(&c, string_from_cstr("mynum"), 42);
|
|
config_add_string(&c, string_from_cstr("mystring"), string_from_cstr("cfg is pretty awesome"));
|
|
list_config_value* l = malloc(sizeof(list_config_value));
|
|
*l = new_list_config_value();
|
|
for (int i = 0; i < 10; i += 2) {
|
|
list_push_config_value(l, config_number(i));
|
|
}
|
|
list_push_config_value(l, config_string(string_from_cstr("value")));
|
|
config_add_list(&c, string_from_cstr("mylist"), l);
|
|
config* sub = malloc(sizeof(config));
|
|
*sub = new_config();
|
|
config_add_number(sub, string_from_cstr("mysecondnum"), 23);
|
|
config_add_string(sub, string_from_cstr("mysecondstring"), string_from_cstr("\"inner\"\"quoted\""));
|
|
config_add_section(&c, string_from_cstr("mysection"), sub);
|
|
|
|
string s = config_str(&c, 0);
|
|
char* cstr = string_cstr(&s);
|
|
|
|
printf("%s\n", cstr);
|
|
free_string(s);
|
|
free(cstr);
|
|
free_config(c);
|
|
return 0;
|
|
}
|