1 /* @(#) $Id: os_xml.h,v 1.8 2009/06/24 17:06:32 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
20 #define XML_MAXSIZE 2048
21 #endif /* XML_MAXSIZE */
24 #define XML_VAR "xml_var"
29 #define XML_VARIABLE_BEGIN '$'
31 /* XML Node structure */
32 typedef struct _xml_node
43 typedef struct _OS_XML
45 int cur; /* Currently position (and last after reading) */
46 int fol; /* Currently position for the xml_access */
47 int *tp; /* Item type */
48 int *rl; /* Relation in the XML */
49 int *ck; /* If the item was closed or not */
50 int *ln; /* Currently xml file line */
51 int err_line; /* Line number of the possible error */
52 char **ct; /* Content is stored */
53 char **el; /* The element/attribute name is stored */
54 char err[128]; /* Error messages are stored in here */
57 typedef xml_node ** XML_NODE;
59 /* Start the XML structure reading a file */
60 int OS_ReadXML(char *file, OS_XML *lxml);
62 /* Clear the XML strucute memory */
63 void OS_ClearXML(OS_XML *_lxml);
66 void OS_ClearNode(xml_node **node);
69 /* Functions to read the XML */
71 /* Return 1 if element_name is a root element */
72 int OS_RootElementExist(OS_XML *_lxml, char *element_name);
74 /* Return 1 if the element_name exists */
75 int OS_ElementExist(OS_XML *_lxml, char **element_name);
77 /* Return the elements "children" of the element_name */
78 char **OS_GetElements(OS_XML *_lxml, char **element_name);
80 /* Return the elements "children" of the element_name */
81 xml_node **OS_GetElementsbyNode(OS_XML *_lxml, xml_node *node);
83 /* Return the attributes of the element name */
84 char **OS_GetAttributes(OS_XML *_lxml, char **element_name);
86 /* Return one value from element_name */
87 char *OS_GetOneContentforElement(OS_XML *_lxml, char **element_name);
89 /* Return an array with the content of all entries of element_name */
90 char **OS_GetElementContent(OS_XML *_lxml, char **element_name);
92 /* Return an array with the contents of an element_nane */
93 char **OS_GetContents(OS_XML *_lxml, char **element_name);
95 /* Return the value of a specific attribute of the element_name */
96 char *OS_GetAttributeContent(OS_XML *_lxml, char **element_name,
97 char *attribute_name);
99 /* Apply the variables to the xml */
100 int OS_ApplyVariables(OS_XML *_lxml);