GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test-dom-parser1.c
1 #include "config.h"
2 
3 #include <stdlib.h>
4 #include <string.h>
5 
6 #include <glib.h>
7 
8 #include "test-stuff.h"
9 
10 #include "gnc-xml-helper.h"
11 #include "sixtp.h"
12 #include "sixtp-parsers.h"
13 #include "sixtp-utils.h"
14 
15 static void parse_file(char *filename, sixtp *parser);
16 
17 static sixtp*
18 get_parser1_1_parser1(void)
19 {
20  sixtp *ret;
21 
22  ret = sixtp_new();
23  g_return_val_if_fail(ret, NULL);
24  sixtp_set_chars(ret, allow_and_ignore_only_whitespace);
25 
26  sixtp_add_sub_parser(ret, "foobar",
27  sixtp_dom_parser_new(print_dom_tree, NULL, NULL));
28 
29  return ret;
30 }
31 
32 static sixtp*
33 simple_parser(void)
34 {
35  sixtp*ret;
36  ret = sixtp_new();
37  sixtp_set_chars(ret, allow_and_ignore_only_whitespace);
38  return ret;
39 }
40 
41 static sixtp*
42 get_parser1_1_parser2(void)
43 {
44  sixtp *ret;
45  sixtp *foobarer;
46 
47  ret = simple_parser();
48  foobarer = simple_parser();
49 
50  sixtp_add_sub_parser(ret, "foobar", foobarer);
51  sixtp_add_sub_parser(foobarer, "blah",
52  sixtp_dom_parser_new(print_dom_tree, NULL, NULL));
53  sixtp_add_sub_parser(foobarer, "you",
54  sixtp_dom_parser_new(print_dom_tree, NULL, NULL));
55  return ret;
56 }
57 
58 int
59 main(int argc, char **argv)
60 {
61  parse_file("test-dom-parser1-1.xml", get_parser1_1_parser1());
62  parse_file("test-dom-parser1-1.xml", get_parser1_1_parser2());
63  exit(get_rv());
64 }
65 
66 static void
67 parse_file(char *filename, sixtp* parser)
68 {
69  printf("STARTING: %s\n", filename);
70  sixtp_parse_file(parser, filename, NULL, (gpointer)stdout, NULL);
71  printf("\nENDING: %s\n", filename);
72  sixtp_destroy(parser);
73 }
Definition: sixtp.h:93