add yaml library, example

This commit is contained in:
Luka Jankovic 2025-07-24 11:55:03 +02:00
parent edbe4eb8ae
commit 03da03d679
5 changed files with 96 additions and 2 deletions

26
kubo_file.c Normal file
View 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");
}
}