X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;ds=sidebyside;f=src%2Fos_xml%2Fexamples%2Fmem_test.c;fp=src%2Fos_xml%2Fexamples%2Fmem_test.c;h=fc3f3fc161ea2ce2b523d0dfe470da7d4a8badde;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=d6938db21a4061cac387924432f530448f4e9cf6;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b;p=ossec-hids.git diff --git a/src/os_xml/examples/mem_test.c b/src/os_xml/examples/mem_test.c old mode 100755 new mode 100644 index d6938db..fc3f3fc --- a/src/os_xml/examples/mem_test.c +++ b/src/os_xml/examples/mem_test.c @@ -1,54 +1,47 @@ #include #include #include +#include #include "os_xml.h" -int main(int argc, char ** argv) -{ - OS_XML xml; - xml_node **node=NULL; - int i = 0; - if(argc < 2) - { - printf("usage: %s file\n",argv[0]); - return(-1); +int main(int argc, char **argv) +{ + if (argc < 2) { + printf("usage: %s file\n", argv[0]); + return (-1); } - while(1) - { + while (1) { + OS_XML xml; + xml_node **node; + int i = 0; + usleep(10); printf("."); fflush(stdout); - if(OS_ReadXML(argv[1],&xml) < 0) - { - printf("Error reading XML!%s\n",xml.err); - return(1); + if (OS_ReadXML(argv[1], &xml) < 0) { + printf("Error reading XML(%u): %s\n", xml.err_line, xml.err); + return (1); } - node = OS_GetElementsbyNode(&xml,NULL); - if(node == NULL) - { + node = OS_GetElementsbyNode(&xml, NULL); + if (node == NULL) { printf("error reading xml\n"); - return(1); + return (1); } - i = 0; - - while(node[i]) - { + while (node[i]) { xml_node **cnode = NULL; - int j=0; - cnode = OS_GetElementsbyNode(&xml,node[i]); - if(cnode == NULL) - { + int j = 0; + cnode = OS_GetElementsbyNode(&xml, node[i]); + if (cnode == NULL) { i++; continue; } - while(cnode[j]) - { + while (cnode[j]) { /* */ j++; } @@ -63,5 +56,6 @@ int main(int argc, char ** argv) OS_ClearXML(&xml); } - return(0); + return (0); } +