X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fos_xml%2Fexamples%2Ftest.c;fp=src%2Fos_xml%2Fexamples%2Ftest.c;h=2fa85ae5a84b3d22190f2f016bcf79f40d8dca8e;hp=166a2b6cf1acccf50d1c66e802933c657ae36b51;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b diff --git a/src/os_xml/examples/test.c b/src/os_xml/examples/test.c old mode 100755 new mode 100644 index 166a2b6..2fa85ae --- a/src/os_xml/examples/test.c +++ b/src/os_xml/examples/test.c @@ -4,66 +4,56 @@ #include "os_xml.h" -int main(int argc, char ** argv) + +int main(int argc, char **argv) { int i = 0; OS_XML xml; XML_NODE node = NULL; - /* File name must be given */ - if(argc < 2) - { - printf("Usage: %s file\n",argv[0]); - return(-1); + if (argc < 2) { + printf("Usage: %s file\n", argv[0]); + return (-1); } - - /* Reading the XML. Printing error and line number */ - if(OS_ReadXML(argv[1],&xml) < 0) - { - printf("OS_ReadXML error: %s, line :%d\n",xml.err, xml.err_line); - return(1); + /* Read the XML. Print error and line number */ + if (OS_ReadXML(argv[1], &xml) < 0) { + printf("OS_ReadXML error: %s, line :%d\n", xml.err, xml.err_line); + return (1); } - if(OS_ApplyVariables(&xml) != 0) - { + if (OS_ApplyVariables(&xml) != 0) { printf("OS_ReadXML error: Applying variables: %s\n", xml.err); - return(1); + return (1); } - /* Getting all nodes */ - node = OS_GetElementsbyNode(&xml,NULL); - if(node == NULL) - { + /* Get all nodes */ + node = OS_GetElementsbyNode(&xml, NULL); + if (node == NULL) { printf("OS_GetElementsbyNode error: %s, line: %d\n", xml.err, xml.err_line); - return(1); + return (1); } i = 0; - while(node[i]) - { + while (node[i]) { int j = 0; XML_NODE cnode; cnode = OS_GetElementsbyNode(&xml, node[i]); - if(cnode == NULL) - { + if (cnode == NULL) { i++; continue; } - while(cnode[j]) - { + while (cnode[j]) { printf("Element: %s -> %s\n", - cnode[j]->element, - cnode[j]->content); - if(cnode[j]->attributes && cnode[j]->values) - { + cnode[j]->element, + cnode[j]->content); + if (cnode[j]->attributes && cnode[j]->values) { int k = 0; - while(cnode[j]->attributes[k]) - { + while (cnode[j]->attributes[k]) { printf("attr %s:%s\n", cnode[j]->attributes[k], cnode[j]->values[k]); @@ -77,12 +67,13 @@ int main(int argc, char ** argv) i++; } - /* Clearing the nodes */ + /* Clear the nodes */ OS_ClearNode(node); node = NULL; OS_ClearXML(&xml); - return(0); + return (0); } +