]>
Commit | Line | Data |
---|---|---|
e27a3c88 KS |
1 | #include <yaml.h> |
2 | ||
3 | #include <stdlib.h> | |
4 | #include <stdio.h> | |
5 | #include <assert.h> | |
6 | ||
7 | int | |
8 | main(int argc, char *argv[]) | |
9 | { | |
10 | int number; | |
11 | ||
12 | if (argc < 2) { | |
13 | printf("Usage: %s file1.yaml ...\n", argv[0]); | |
14 | return 0; | |
15 | } | |
16 | ||
17 | for (number = 1; number < argc; number ++) | |
18 | { | |
19 | FILE *file; | |
20 | yaml_parser_t parser; | |
21 | yaml_document_t document; | |
22 | int done = 0; | |
23 | int count = 0; | |
24 | int error = 0; | |
25 | ||
26 | printf("[%d] Loading '%s': ", number, argv[number]); | |
27 | fflush(stdout); | |
28 | ||
29 | file = fopen(argv[number], "rb"); | |
30 | assert(file); | |
31 | ||
32 | assert(yaml_parser_initialize(&parser)); | |
33 | ||
34 | yaml_parser_set_input_file(&parser, file); | |
35 | ||
36 | while (!done) | |
37 | { | |
38 | if (!yaml_parser_load(&parser, &document)) { | |
39 | error = 1; | |
40 | break; | |
41 | } | |
42 | ||
43 | done = (!yaml_document_get_root_node(&document)); | |
44 | ||
45 | yaml_document_delete(&document); | |
46 | ||
47 | if (!done) count ++; | |
48 | } | |
49 | ||
50 | yaml_parser_delete(&parser); | |
51 | ||
52 | assert(!fclose(file)); | |
53 | ||
54 | printf("%s (%d documents)\n", (error ? "FAILURE" : "SUCCESS"), count); | |
55 | } | |
56 | ||
57 | return 0; | |
58 | } | |
59 |