new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / os_xml / examples / mem_test.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <unistd.h>
5
6 #include "os_xml.h"
7
8
9 int main(int argc, char **argv)
10 {
11     if (argc < 2) {
12         printf("usage: %s file\n", argv[0]);
13         return (-1);
14     }
15
16     while (1) {
17         OS_XML xml;
18         xml_node **node;
19         int i = 0;
20
21         usleep(10);
22         printf(".");
23         fflush(stdout);
24
25         if (OS_ReadXML(argv[1], &xml) < 0) {
26             printf("Error reading XML(%u): %s\n", xml.err_line, xml.err);
27             return (1);
28         }
29
30         node = OS_GetElementsbyNode(&xml, NULL);
31         if (node == NULL) {
32             printf("error reading xml\n");
33             return (1);
34         }
35
36         while (node[i]) {
37             xml_node **cnode = NULL;
38             int j = 0;
39             cnode = OS_GetElementsbyNode(&xml, node[i]);
40             if (cnode == NULL) {
41                 i++;
42                 continue;
43             }
44             while (cnode[j]) {
45                 /* */
46                 j++;
47             }
48
49             OS_ClearNode(cnode);
50             i++;
51         }
52
53         OS_ClearNode(node);
54
55         node = NULL;
56
57         OS_ClearXML(&xml);
58     }
59     return (0);
60 }
61