-static inline int __get_model_from_model_config_xml(const char *field, char **value)
-{
- char *node_name = NULL;
- char *node_value = NULL;
- xmlNode *cur_node = NULL;
- xmlNodePtr cur_ptr = NULL;
- xmlNodePtr model_ptr = NULL;
- xmlDocPtr xml_doc = NULL;
-
- xml_doc = xmlParseFile(MODEL_CONFIG_FILE);
- if (xml_doc == NULL)
- return -1;
-
- cur_ptr = xmlDocGetRootElement(xml_doc);
- if (cur_ptr == NULL) {
- xmlFreeDoc(xml_doc);
- return -1;
- }
-
- for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) {
- if (!xmlStrcmp(cur_ptr->name, (const xmlChar*)MODEL_CONFIG_TAG))
- break;
- }
-
- cur_ptr = cur_ptr->xmlChildrenNode;
- for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) {
- if (!xmlStrcmp(cur_node->name, (const xmlChar*)FEATURE_TAG)) {
- model_ptr = cur_node;
- break;
- }
- }
-
- if (model_ptr == NULL) {
- xmlFreeDoc(xml_doc);
- return -1;
- }
-
- if (model_ptr) {
- cur_ptr = model_ptr->xmlChildrenNode;
-
- for (cur_node = cur_ptr; cur_node; cur_node = cur_node->next) {
- if (cur_node->type == XML_ELEMENT_NODE) {
- node_name = (char *)xmlGetProp(cur_node, (const xmlChar*)"name");
- if (node_name == NULL) {
- xmlFreeDoc(xml_doc);
- return -1;
- }
-
- if (!strncmp(node_name, field, strlen(node_name))) {
- node_value = (char *)xmlNodeListGetString(xml_doc, cur_node->xmlChildrenNode, 1);
- if (node_value) {
- *value = strdup(node_value);
- free(node_name);
- free(node_value);
- break;
- }
- }
- free(node_name);
- }
- }
- }
-
- xmlFreeDoc(xml_doc);
- return 0;
-}
-