]> andersk Git - libyaml.git/blame - tests/run-parser.c
Refactor internal and external API.
[libyaml.git] / tests / run-parser.c
CommitLineData
625fcfe9
KS
1#include <yaml.h>
2
3#include <stdlib.h>
4#include <stdio.h>
5#include <assert.h>
6
7int
8main(int argc, char *argv[])
9{
10 FILE *file;
11 yaml_parser_t parser;
12 yaml_event_t event;
13 int done = 0;
14 int count = 0;
15
16 if (argc != 2) {
17 printf("Usage: %s file.yaml\n", argv[0]);
18 return 0;
19 }
20 file = fopen(argv[1], "rb");
21 assert(file);
22
23 assert(yaml_parser_initialize(&parser));
24
25 yaml_parser_set_input_file(&parser, file);
26
27 while (!done)
28 {
29 assert(yaml_parser_parse(&parser, &event));
30
31 done = (event.type == YAML_STREAM_END_EVENT);
32
33 yaml_event_delete(&event);
34
35 count ++;
36 }
37
38 yaml_parser_delete(&parser);
39
40 fclose(file);
41
42 printf("Parsing the file '%s': %d events\n", argv[1], count);
43
44 return 0;
45}
46
This page took 0.044672 seconds and 5 git commands to generate.