22 static void mstr(
char *str,
const char *src,uint l1,uint l2)
33 mstr(str,attr,len,
sizeof(str)-1);
34 printf(
"VALUE '%s'\n",str);
42 mstr(str,attr,len,
sizeof(str)-1);
43 printf(
"ENTER %s\n",str);
52 mstr(str,attr,len,
sizeof(str)-1);
53 printf(
"LEAVE %s\n",str);
57 static void usage(
const char *prog)
60 printf(
"%s xmlfile\n",prog);
63 int main(
int ac,
char **av)
77 fn=av[1]?av[1]:
"test.xml";
78 if ((f=open(fn,O_RDONLY))<0)
80 fprintf(stderr,
"Err '%s'\n",fn);
84 len=read(f,str,
sizeof(str)-1);
87 my_xml_parser_create(&p);
89 my_xml_set_enter_handler(&p,bstr);
90 my_xml_set_value_handler(&p,dstr);
91 my_xml_set_leave_handler(&p,estr);
93 if (MY_XML_OK!=(f=my_xml_parse(&p,str,len)))
95 printf(
"ERROR at line %d pos %d '%s'\n",
96 my_xml_error_lineno(&p)+1,
98 my_xml_error_string(&p));
101 my_xml_parser_free(&p);