add yaml library, example
This commit is contained in:
parent
edbe4eb8ae
commit
03da03d679
5 changed files with 96 additions and 2 deletions
26
kubo_file.c
Normal file
26
kubo_file.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "kubo_file.h"
|
||||
|
||||
void kubo_file_parse(char *file_name) {
|
||||
static const cyaml_config_t config = {
|
||||
.log_fn = cyaml_log,
|
||||
.mem_fn = cyaml_mem,
|
||||
.log_level = CYAML_LOG_WARNING,
|
||||
};
|
||||
|
||||
struct numbers *n;
|
||||
|
||||
cyaml_err_t err = cyaml_load_file(file_name, &config, &top_schema, (cyaml_data_t **)&n, NULL);
|
||||
if (err != CYAML_OK) {
|
||||
printf("cyaml err\n");
|
||||
}
|
||||
|
||||
printf("%s:\n", n->name);
|
||||
for (unsigned i = 0; i < n->data_count; i++) {
|
||||
printf(" - %i\n", n->data[i]);
|
||||
}
|
||||
|
||||
err = cyaml_free(&config, &top_schema, n, 0);
|
||||
if (err != CYAML_OK) {
|
||||
printf("cyaml free err\n");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue