|
GnuCash 2.4.99
|
00001 #include "config.h" 00002 00003 #include <stdlib.h> 00004 #include <string.h> 00005 00006 #include <glib.h> 00007 00008 #include "test-stuff.h" 00009 00010 #include "gnc-xml-helper.h" 00011 #include "sixtp.h" 00012 #include "sixtp-parsers.h" 00013 #include "sixtp-utils.h" 00014 00015 static void parse_file(char *filename, sixtp *parser); 00016 00017 static sixtp* 00018 get_parser1_1_parser1(void) 00019 { 00020 sixtp *ret; 00021 00022 ret = sixtp_new(); 00023 g_return_val_if_fail(ret, NULL); 00024 sixtp_set_chars(ret, allow_and_ignore_only_whitespace); 00025 00026 sixtp_add_sub_parser(ret, "foobar", 00027 sixtp_dom_parser_new(print_dom_tree, NULL, NULL)); 00028 00029 return ret; 00030 } 00031 00032 static sixtp* 00033 simple_parser(void) 00034 { 00035 sixtp*ret; 00036 ret = sixtp_new(); 00037 sixtp_set_chars(ret, allow_and_ignore_only_whitespace); 00038 return ret; 00039 } 00040 00041 static sixtp* 00042 get_parser1_1_parser2(void) 00043 { 00044 sixtp *ret; 00045 sixtp *foobarer; 00046 00047 ret = simple_parser(); 00048 foobarer = simple_parser(); 00049 00050 sixtp_add_sub_parser(ret, "foobar", foobarer); 00051 sixtp_add_sub_parser(foobarer, "blah", 00052 sixtp_dom_parser_new(print_dom_tree, NULL, NULL)); 00053 sixtp_add_sub_parser(foobarer, "you", 00054 sixtp_dom_parser_new(print_dom_tree, NULL, NULL)); 00055 return ret; 00056 } 00057 00058 int 00059 main(int argc, char **argv) 00060 { 00061 parse_file("test-dom-parser1-1.xml", get_parser1_1_parser1()); 00062 parse_file("test-dom-parser1-1.xml", get_parser1_1_parser2()); 00063 exit(get_rv()); 00064 } 00065 00066 static void 00067 parse_file(char *filename, sixtp* parser) 00068 { 00069 printf("STARTING: %s\n", filename); 00070 sixtp_parse_file(parser, filename, NULL, (gpointer)stdout, NULL); 00071 printf("\nENDING: %s\n", filename); 00072 sixtp_destroy(parser); 00073 }
1.7.4