#include <stdlib.h>
#include <stdio.h>
#include <libfyaml.h>
int main(int argc, char *argv[])
{
struct fy_document *fyd = NULL;
const char *input_file = (argc > 1) ? argv[1] : "config.yaml";
fyd = fy_document_build_from_file(NULL, input_file);
if (!fyd) {
fprintf(stderr, "Failed to parse YAML from %s\n", input_file);
return EXIT_FAILURE;
}
printf("Successfully parsed: %s\n\n", input_file);
printf("Compact format:\n");
fy_emit_document_to_fp(fyd, FYECF_MODE_FLOW_ONELINE, stdout);
printf("\n\n");
printf("Block format:\n");
fy_emit_document_to_fp(fyd, FYECF_MODE_BLOCK, stdout);
printf("\n");
printf("JSON format:\n");
fy_emit_document_to_fp(fyd, FYECF_MODE_JSON, stdout);
printf("\n");
fy_document_destroy(fyd);
return EXIT_SUCCESS;
}