void printNodes(IXML_Node *tmpRoot, int depth) { unsigned long i; IXML_NodeList *NodeList1; IXML_Node *ChildNode1; unsigned short NodeType; const DOMString NodeValue; const DOMString NodeName; NodeList1 = ixmlNode_getChildNodes(tmpRoot); for (i = 0; i < 100; ++i) { ChildNode1 = ixmlNodeList_item(NodeList1, i); if (ChildNode1 == NULL) { break; } printNodes(ChildNode1, depth+1); NodeType = ixmlNode_getNodeType(ChildNode1); NodeValue = ixmlNode_getNodeValue(ChildNode1); NodeName = ixmlNode_getNodeName(ChildNode1); IxmlPrintf(__FILE__, __LINE__, "printNodes", "DEPTH-%2d-IXML_Node Type %d, " "IXML_Node Name: %s, IXML_Node Value: %s\n", depth, NodeType, NodeName, NodeValue); } }
v = (char*) ixmlNode_getNodeValue(l1_1_node); LoadConfigItem(Conf, sq_conf, n, v); } if (node_list) ixmlNodeList_free(node_list); } return node; } /*----------------------------------------------------------------------------*/ void *LoadConfig(char *name, tMRConfig *Conf, sq_dev_param_t *sq_conf) { IXML_Element *elm; IXML_Document *doc; doc = ixmlLoadDocument(name); if (!doc) return NULL; elm = ixmlDocument_getElementById(doc, "squeeze2upnp"); if (elm) { unsigned i; char *n, *v; IXML_NodeList *l1_node_list; l1_node_list = ixmlNode_getChildNodes((IXML_Node*) elm); for (i = 0; i < ixmlNodeList_length(l1_node_list); i++) { IXML_Node *l1_node, *l1_1_node; l1_node = ixmlNodeList_item(l1_node_list, i); n = (char*) ixmlNode_getNodeName(l1_node); l1_1_node = ixmlNode_getFirstChild(l1_node); v = (char*) ixmlNode_getNodeValue(l1_1_node); LoadGlobalItem(n, v); } if (l1_node_list) ixmlNodeList_free(l1_node_list); } elm = ixmlDocument_getElementById((IXML_Document *)elm, "common"); if (elm) { char *n, *v; IXML_NodeList *l1_node_list; unsigned i; l1_node_list = ixmlNode_getChildNodes((IXML_Node*) elm); for (i = 0; i < ixmlNodeList_length(l1_node_list); i++) { IXML_Node *l1_node, *l1_1_node; l1_node = ixmlNodeList_item(l1_node_list, i);
static std::string get_text(_IXML_Node *from) { std::ostringstream str; if (from) { IXML_NodeList * const children = ixmlNode_getChildNodes(from); for (IXML_NodeList *i = children; i; i = i->next) if (i->nodeItem->nodeValue) str << i->nodeItem->nodeValue; ixmlNodeList_free(children); } return str.str(); }
static IXML_Node * get_element(_IXML_Node *from, const char *name) { IXML_Node *result = NULL; IXML_NodeList * const children = ixmlNode_getChildNodes(from); for (IXML_NodeList *i = children; i && !result; i = i->next) { const char *n = strchr(i->nodeItem->nodeName, ':'); if (n == NULL) n = i->nodeItem->nodeName; else n++; if (strcmp(n, name) == 0) result = i->nodeItem; } ixmlNodeList_free(children); return result; }
if (v && !strcmp(v, UDN)) { device = ixmlNode_getParentNode(l1_node); break; } } if (l1_node_list) ixmlNodeList_free(l1_node_list); return device; } /*----------------------------------------------------------------------------*/ void *LoadMRConfig(void *ref, char *UDN, tMRConfig *Conf, sq_dev_param_t *sq_conf) { IXML_NodeList *node_list; IXML_Document *doc = (IXML_Document*) ref; IXML_Node *node; char *n, *v; unsigned i; node = (IXML_Node*) FindMRConfig(doc, UDN); if (node) { node_list = ixmlNode_getChildNodes(node); for (i = 0; i < ixmlNodeList_length(node_list); i++) { IXML_Node *l1_node, *l1_1_node; l1_node = ixmlNodeList_item(node_list, i);
RTPXML_NodeList *rtpxmlNode_getChildNodes(RTPXML_Node *nodeptr) { return (RTPXML_NodeList *)ixmlNode_getChildNodes((IXML_Node *)nodeptr); }
/************************************************************************** * Function: prepareParameter * Functionality: it will get the parameter from pipe and check it * @IN : fd: the file description id for the pipe * enable: enable or disable flag * @OUT: 0 success, else failed. * Used description: The parameter is a xml, it will get from the pipe * Date: 20080108 * Changed history: * Date Who Reason * 20080108 kelly First creation ***************************************************************************/ int prepareParameter(PSystemConfig **pList,int *count) { IXML_Document *rootDom = NULL; IXML_NodeList *nodeList = NULL; IXML_NodeList *nodeList2 = NULL; IXML_Node *node = NULL; IXML_Node *cmdNode = NULL; char buffer[1024] = {0}; char Str[1024] = {0}; int i = 0; int nodeLen = 0; PSystemConfig *pConfigList = NULL; while(1) { fgets(Str, 1024, stdin); strcat(buffer, Str); if(strstr(buffer,EndFlag)) break; } if(strlen(buffer) == 0) goto failed; if((rootDom = ixmlParseBuffer(buffer)) == NULL) goto failed; if((nodeList = ixmlDocument_getElementsByTagName(rootDom,"cmd")) != NULL) { cmdNode = ixmlGetFirstNodeByTagName(rootDom,"cmd"); nodeList2 = ixmlNode_getChildNodes(cmdNode); nodeLen = ixmlNodeList_length(nodeList2); /* fprintf(stderr, "=======nodeLen -> [%d]\n", nodeLen);*/ pConfigList = (PSystemConfig*)malloc(sizeof(PSystemConfig) * nodeLen); memset(pConfigList, 0, sizeof(PSystemConfig)*nodeLen); node = ixmlNodeList_item(nodeList, 0); node = ixmlNode_getFirstChild(node); for(i=0; i<nodeLen; i++) { if(node){ pConfigList[i] = (PSystemConfig)malloc(sizeof(SystemConfig)); memset(pConfigList[i],0,sizeof(SystemConfig)); pConfigList[i]->name = strdup(ixmlNode_getNodeName(node)); if(i != nodeLen-1) node = ixmlNode_getNextSibling(node); } else{ fprintf(stderr, "===== node is empty. i->[%d]\n", i); } } } *count = nodeLen; if(pConfigList){ *pList = pConfigList; } else{ fprintf(stderr, " !!!!!!pLIST is NULL"); } if (rootDom) ixmlDocument_free(rootDom); if (nodeList) ixmlNodeList_free(nodeList); if (nodeList2) ixmlNodeList_free(nodeList2); return i; failed: fprintf(stderr,"Got a command parameter->%s", buffer); //fprintf(stderr,"Got a command parameter->%s", buffer); return i; }
/************************************************************************** * Function: prepareParameter * Functionality: it will get the parameter from pipe and check it * @IN : fd: the file description id for the pipe * enable: enable or disable flag * @OUT: 0 success, else failed. * Used description: The parameter is a xml, it will get from the pipe * Date: 20080108 * Changed history: * Date Who Reason * 20080108 kelly First creation ***************************************************************************/ int prepareParameter(PSystemConfig **pList,int *count) { IXML_Document *rootDom = NULL; IXML_NodeList *nodeList = NULL; IXML_NodeList *nodeList2 = NULL; IXML_Node *node = NULL; IXML_Node *cmdNode = NULL; IXML_Node *node2 = NULL; char buffer[1024] = {0}; char Str[1024] = {0}; int i = 0; int i_ret=0; int nodeLen = 0; PSystemConfig *pConfigList = NULL; while(1) { fgets(Str, 1024, stdin); strcat(buffer, Str); if(strstr(buffer,EndFlag)) break; } if(strlen(buffer) == 0) goto failed; if((rootDom = ixmlParseBuffer(buffer)) == NULL){ i_ret = -1; goto Err_handler; } if((nodeList = ixmlDocument_getElementsByTagName(rootDom,"cmd")) != NULL) { cmdNode = ixmlGetFirstNodeByTagName(rootDom,"cmd"); nodeList2 = ixmlNode_getChildNodes(cmdNode); nodeLen = ixmlNodeList_length(nodeList2); pConfigList = (PSystemConfig*)malloc(sizeof(PSystemConfig) * nodeLen); memset(pConfigList, 0, sizeof(PSystemConfig)*nodeLen); node = ixmlNodeList_item(nodeList, 0); node = ixmlNode_getFirstChild(node); while (node != NULL) { pConfigList[i] = (PSystemConfig)malloc(sizeof(SystemConfig)); memset(pConfigList[i],0,sizeof(SystemConfig)); pConfigList[i]->name = strdup(ixmlNode_getNodeName(node)); node2 = ixmlNode_getFirstChild(node); pConfigList[i]->value = (ixmlNode_getNodeValue(node2))?strdup(ixmlNode_getNodeValue(node2)):strdup(""); /* fprintf(stderr, "name->%s , value ->%s\n" , pConfigList[i]->name , pConfigList[i]->value); */ i_ret=CheckVariable(pConfigList[i]->name,pConfigList[i]->value); if(i_ret<0) { i_ret = -3; goto Err_handler; } node = ixmlNode_getNextSibling(node); i++; } } *count = nodeLen; if(pConfigList){ *pList = pConfigList; } else{ fprintf(stderr, " !!!!!!pLIST is NULL"); } if (rootDom) ixmlDocument_free(rootDom); if (nodeList) ixmlNodeList_free(nodeList); if (nodeList2) ixmlNodeList_free(nodeList2); return i; failed: fprintf(stderr,"Got a command parameter->%s", buffer); //fprintf(stderr,"Got a command parameter->%s", buffer); return i; Err_handler: if (rootDom) ixmlDocument_free(rootDom); if (nodeList) ixmlNodeList_free(nodeList); if (nodeList2) ixmlNodeList_free(nodeList2); return i_ret; }