1 /* @(#) $Id: ./src/os_xml/os_xml.h, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
21 #define XML_MAXSIZE 2048
22 #endif /* XML_MAXSIZE */
25 #define XML_VAR "xml_var"
30 #define XML_VARIABLE_BEGIN '$'
32 /* XML Node structure */
33 typedef struct _xml_node
44 typedef struct _OS_XML
46 int cur; /* Currently position (and last after reading) */
47 int fol; /* Currently position for the xml_access */
48 int *tp; /* Item type */
49 int *rl; /* Relation in the XML */
50 int *ck; /* If the item was closed or not */
51 int *ln; /* Currently xml file line */
52 int err_line; /* Line number of the possible error */
53 char **ct; /* Content is stored */
54 char **el; /* The element/attribute name is stored */
55 char err[128]; /* Error messages are stored in here */
58 typedef xml_node ** XML_NODE;
60 /* Start the XML structure reading a file */
61 int OS_ReadXML(char *file, OS_XML *lxml);
63 /* Clear the XML strucute memory */
64 void OS_ClearXML(OS_XML *_lxml);
67 void OS_ClearNode(xml_node **node);
70 /* Functions to read the XML */
72 /* Return 1 if element_name is a root element */
73 int OS_RootElementExist(OS_XML *_lxml, char *element_name);
75 /* Return 1 if the element_name exists */
76 int OS_ElementExist(OS_XML *_lxml, char **element_name);
78 /* Return the elements "children" of the element_name */
79 char **OS_GetElements(OS_XML *_lxml, char **element_name);
81 /* Return the elements "children" of the element_name */
82 xml_node **OS_GetElementsbyNode(OS_XML *_lxml, xml_node *node);
84 /* Return the attributes of the element name */
85 char **OS_GetAttributes(OS_XML *_lxml, char **element_name);
87 /* Return one value from element_name */
88 char *OS_GetOneContentforElement(OS_XML *_lxml, char **element_name);
90 /* Return an array with the content of all entries of element_name */
91 char **OS_GetElementContent(OS_XML *_lxml, char **element_name);
93 /* Return an array with the contents of an element_nane */
94 char **OS_GetContents(OS_XML *_lxml, char **element_name);
96 /* Return the value of a specific attribute of the element_name */
97 char *OS_GetAttributeContent(OS_XML *_lxml, char **element_name,
98 char *attribute_name);
100 /* Apply the variables to the xml */
101 int OS_ApplyVariables(OS_XML *_lxml);