parse yaml as a lib
[protos/libecoli.git] / examples / yaml / parse-yaml.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018, Olivier MATZ <zer0@droids-corp.org>
3  */
4
5 #include <stdlib.h>
6 #include <stdio.h>
7
8 #include <ecoli_node.h>
9 #include <ecoli_yaml.h>
10
11 int
12 main(int argc, char *argv[])
13 {
14         struct ec_node *node = NULL;
15
16         if (argc != 2) {
17                 fprintf(stderr, "Invalid args\n");
18                 goto fail;
19         }
20         node = ec_yaml_import(argv[1]);
21         if (node == NULL) {
22                 fprintf(stderr, "Failed to parse file\n");
23                 goto fail;
24         }
25         ec_node_dump(stdout, node);
26         ec_node_free(node);
27
28         return 0;
29
30 fail:
31         ec_node_free(node);
32         return 1;
33 }