summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/xmlfile.c
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-06-07 17:37:34 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2015-06-07 17:37:34 +0200
commitb6ce8ee991c7e14ca214a2931bfbc4e4a5a0dc0f (patch)
treeda1e239053b7bfd9e841a103bbb36aefb71c4e7f /src/lib/util/xmlfile.c
parentb6a4cf45ca6fdf842b319806d61d638cf2d8b2d2 (diff)
Licenses for Raphael Nabet (nw)
Diffstat (limited to 'src/lib/util/xmlfile.c')
-rw-r--r--src/lib/util/xmlfile.c169
1 files changed, 169 insertions, 0 deletions
diff --git a/src/lib/util/xmlfile.c b/src/lib/util/xmlfile.c
index 7956654a984..193717b30aa 100644
--- a/src/lib/util/xmlfile.c
+++ b/src/lib/util/xmlfile.c
@@ -451,6 +451,18 @@ int xml_get_attribute_int_format(xml_data_node *node, const char *attribute)
found, return = the provided default
-------------------------------------------------*/
+/**
+ * @fn float xml_get_attribute_float(xml_data_node *node, const char *attribute, float defvalue)
+ *
+ * @brief XML get attribute float.
+ *
+ * @param [in,out] node If non-null, the node.
+ * @param attribute The attribute.
+ * @param defvalue The defvalue.
+ *
+ * @return A float.
+ */
+
float xml_get_attribute_float(xml_data_node *node, const char *attribute, float defvalue)
{
const char *string = xml_get_attribute_string(node, attribute, NULL);
@@ -467,6 +479,18 @@ float xml_get_attribute_float(xml_data_node *node, const char *attribute, float
string value on the node
-------------------------------------------------*/
+/**
+ * @fn xml_attribute_node *xml_set_attribute(xml_data_node *node, const char *name, const char *value)
+ *
+ * @brief XML set attribute.
+ *
+ * @param [in,out] node If non-null, the node.
+ * @param name The name.
+ * @param value The value.
+ *
+ * @return null if it fails, else an xml_attribute_node*.
+ */
+
xml_attribute_node *xml_set_attribute(xml_data_node *node, const char *name, const char *value)
{
xml_attribute_node *anode;
@@ -495,6 +519,18 @@ xml_attribute_node *xml_set_attribute(xml_data_node *node, const char *name, con
integer value on the node
-------------------------------------------------*/
+/**
+ * @fn xml_attribute_node *xml_set_attribute_int(xml_data_node *node, const char *name, int value)
+ *
+ * @brief XML set attribute int.
+ *
+ * @param [in,out] node If non-null, the node.
+ * @param name The name.
+ * @param value The value.
+ *
+ * @return null if it fails, else an xml_attribute_node*.
+ */
+
xml_attribute_node *xml_set_attribute_int(xml_data_node *node, const char *name, int value)
{
char buffer[100];
@@ -508,6 +544,18 @@ xml_attribute_node *xml_set_attribute_int(xml_data_node *node, const char *name,
float value on the node
-------------------------------------------------*/
+/**
+ * @fn xml_attribute_node *xml_set_attribute_float(xml_data_node *node, const char *name, float value)
+ *
+ * @brief XML set attribute float.
+ *
+ * @param [in,out] node If non-null, the node.
+ * @param name The name.
+ * @param value The value.
+ *
+ * @return null if it fails, else an xml_attribute_node*.
+ */
+
xml_attribute_node *xml_set_attribute_float(xml_data_node *node, const char *name, float value)
{
char buffer[100];
@@ -526,6 +574,16 @@ xml_attribute_node *xml_set_attribute_float(xml_data_node *node, const char *nam
to ensure it doesn't contain embedded tags
-------------------------------------------------*/
+/**
+ * @fn const char *xml_normalize_string(const char *string)
+ *
+ * @brief XML normalize string.
+ *
+ * @param string The string.
+ *
+ * @return null if it fails, else a char*.
+ */
+
const char *xml_normalize_string(const char *string)
{
static char buffer[1024];
@@ -564,6 +622,16 @@ const char *xml_normalize_string(const char *string)
systems
-------------------------------------------------*/
+/**
+ * @fn static void *expat_malloc(size_t size)
+ *
+ * @brief Expat malloc.
+ *
+ * @param size The size.
+ *
+ * @return null if it fails, else a void*.
+ */
+
static void *expat_malloc(size_t size)
{
UINT32 *result = (UINT32 *)malloc(size + 4 * sizeof(UINT32));
@@ -571,12 +639,31 @@ static void *expat_malloc(size_t size)
return &result[4];
}
+/**
+ * @fn static void expat_free(void *ptr)
+ *
+ * @brief Expat free.
+ *
+ * @param [in,out] ptr If non-null, the pointer.
+ */
+
static void expat_free(void *ptr)
{
if (ptr != NULL)
free(&((UINT32 *)ptr)[-4]);
}
+/**
+ * @fn static void *expat_realloc(void *ptr, size_t size)
+ *
+ * @brief Expat realloc.
+ *
+ * @param [in,out] ptr If non-null, the pointer.
+ * @param size The size.
+ *
+ * @return null if it fails, else a void*.
+ */
+
static void *expat_realloc(void *ptr, size_t size)
{
void *newptr = expat_malloc(size);
@@ -596,6 +683,17 @@ static void *expat_realloc(void *ptr, size_t size)
expat_setup_parser - set up expat for parsing
-------------------------------------------------*/
+/**
+ * @fn static int expat_setup_parser(xml_parse_info *parse_info, xml_parse_options *opts)
+ *
+ * @brief Expat setup parser.
+ *
+ * @param [in,out] parse_info If non-null, information describing the parse.
+ * @param [in,out] opts If non-null, options for controlling the operation.
+ *
+ * @return An int.
+ */
+
static int expat_setup_parser(xml_parse_info *parse_info, xml_parse_options *opts)
{
XML_Memory_Handling_Suite memcallbacks;
@@ -647,6 +745,16 @@ static int expat_setup_parser(xml_parse_info *parse_info, xml_parse_options *opt
element
-------------------------------------------------*/
+/**
+ * @fn static void expat_element_start(void *data, const XML_Char *name, const XML_Char **attributes)
+ *
+ * @brief Expat element start.
+ *
+ * @param [in,out] data If non-null, the data.
+ * @param name The name.
+ * @param attributes The attributes.
+ */
+
static void expat_element_start(void *data, const XML_Char *name, const XML_Char **attributes)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
@@ -676,6 +784,16 @@ static void expat_element_start(void *data, const XML_Char *name, const XML_Char
element data
-------------------------------------------------*/
+/**
+ * @fn static void expat_data(void *data, const XML_Char *s, int len)
+ *
+ * @brief Expat data.
+ *
+ * @param [in,out] data If non-null, the data.
+ * @param s The const XML_Char * to process.
+ * @param len The length.
+ */
+
static void expat_data(void *data, const XML_Char *s, int len)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
@@ -714,6 +832,15 @@ static void expat_data(void *data, const XML_Char *s, int len)
of an element
-------------------------------------------------*/
+/**
+ * @fn static void expat_element_end(void *data, const XML_Char *name)
+ *
+ * @brief Expat element end.
+ *
+ * @param [in,out] data If non-null, the data.
+ * @param name The name.
+ */
+
static void expat_element_end(void *data, const XML_Char *name)
{
xml_parse_info *parse_info = (xml_parse_info *) data;
@@ -764,6 +891,18 @@ static void expat_element_end(void *data, const XML_Char *name)
add_child - add a new node to the parent
-------------------------------------------------*/
+/**
+ * @fn static xml_data_node *add_child(xml_data_node *parent, const char *name, const char *value)
+ *
+ * @brief Adds a child.
+ *
+ * @param [in,out] parent If non-null, the parent.
+ * @param name The name.
+ * @param value The value.
+ *
+ * @return null if it fails, else an xml_data_node*.
+ */
+
static xml_data_node *add_child(xml_data_node *parent, const char *name, const char *value)
{
xml_data_node **pnode;
@@ -806,6 +945,18 @@ static xml_data_node *add_child(xml_data_node *parent, const char *name, const c
given node
-------------------------------------------------*/
+/**
+ * @fn static xml_attribute_node *add_attribute(xml_data_node *node, const char *name, const char *value)
+ *
+ * @brief Adds an attribute.
+ *
+ * @param [in,out] node If non-null, the node.
+ * @param name The name.
+ * @param value The value.
+ *
+ * @return null if it fails, else an xml_attribute_node*.
+ */
+
static xml_attribute_node *add_attribute(xml_data_node *node, const char *name, const char *value)
{
xml_attribute_node *anode, **panode;
@@ -849,6 +1000,16 @@ static xml_attribute_node *add_attribute(xml_data_node *node, const char *name,
an XML node and its children to a file
-------------------------------------------------*/
+/**
+ * @fn static void write_node_recursive(xml_data_node *node, int indent, core_file *file)
+ *
+ * @brief Writes a node recursive.
+ *
+ * @param [in,out] node If non-null, the node.
+ * @param indent The indent.
+ * @param [in,out] file If non-null, the file.
+ */
+
static void write_node_recursive(xml_data_node *node, int indent, core_file *file)
{
xml_attribute_node *anode;
@@ -892,6 +1053,14 @@ static void write_node_recursive(xml_data_node *node, int indent, core_file *fil
the data allocated to an XML node
-------------------------------------------------*/
+/**
+ * @fn static void free_node_recursive(xml_data_node *node)
+ *
+ * @brief Free node recursive.
+ *
+ * @param [in,out] node If non-null, the node.
+ */
+
static void free_node_recursive(xml_data_node *node)
{
xml_attribute_node *anode, *nanode;