| 62 | } |
| 63 | |
| 64 | int main(int ac, char **av) |
| 65 | { |
| 66 | char str[1024*64]=""; |
| 67 | const char *fn; |
| 68 | int f; |
| 69 | uint len; |
| 70 | MY_XML_PARSER p; |
| 71 | |
| 72 | if (ac<2) |
| 73 | { |
| 74 | usage(av[0]); |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | fn=av[1]?av[1]:"test.xml"; |
| 79 | if ((f=open(fn,O_RDONLY))<0) |
| 80 | { |
| 81 | fprintf(stderr,"Err '%s'\n",fn); |
| 82 | return 1; |
| 83 | } |
| 84 | |
| 85 | len=read(f,str,sizeof(str)-1); |
| 86 | str[len]='\0'; |
| 87 | |
| 88 | my_xml_parser_create(&p); |
| 89 | |
| 90 | my_xml_set_enter_handler(&p,bstr); |
| 91 | my_xml_set_value_handler(&p,dstr); |
| 92 | my_xml_set_leave_handler(&p,estr); |
| 93 | |
| 94 | if (MY_XML_OK!=(f=my_xml_parse(&p,str,len))) |
| 95 | { |
| 96 | printf("ERROR at line %d pos %d '%s'\n", |
| 97 | my_xml_error_lineno(&p)+1, |
| 98 | my_xml_error_pos(&p), |
| 99 | my_xml_error_string(&p)); |
| 100 | } |
| 101 | |
| 102 | my_xml_parser_free(&p); |
| 103 | |
| 104 | return 0; |
| 105 | } |
nothing calls this directly
no test coverage detected