diff options
Diffstat (limited to 'src/lib/util/xmlfile.c')
-rw-r--r-- | src/lib/util/xmlfile.c | 174 |
1 files changed, 172 insertions, 2 deletions
diff --git a/src/lib/util/xmlfile.c b/src/lib/util/xmlfile.c index 7956654a984..cb674abfa2b 100644 --- a/src/lib/util/xmlfile.c +++ b/src/lib/util/xmlfile.c @@ -411,13 +411,14 @@ int xml_get_attribute_int(xml_data_node *node, const char *attribute, int defval { const char *string = xml_get_attribute_string(node, attribute, NULL); int value; + unsigned int uvalue; if (string == NULL) return defvalue; if (string[0] == '$') - return (sscanf(&string[1], "%X", &value) == 1) ? value : defvalue; + return (sscanf(&string[1], "%X", &uvalue) == 1) ? uvalue : defvalue; if (string[0] == '0' && string[1] == 'x') - return (sscanf(&string[2], "%X", &value) == 1) ? value : defvalue; + return (sscanf(&string[2], "%X", &uvalue) == 1) ? uvalue : defvalue; if (string[0] == '#') return (sscanf(&string[1], "%d", &value) == 1) ? value : defvalue; return (sscanf(&string[0], "%d", &value) == 1) ? value : defvalue; @@ -451,6 +452,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 +480,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 +520,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 +545,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 +575,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 +623,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 +640,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 +684,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 +746,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 +785,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 +833,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 +892,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 +946,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 +1001,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 +1054,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; |