void mupnp_xml_node_copy(mUpnpXmlNode *dstNode, mUpnpXmlNode *srcNode) { mUpnpXmlAttribute *attr; mUpnpXmlNode *dstChildNode; mUpnpXmlNode *srcChildNode; mupnp_log_debug_l4("Entering...\n"); if (!dstNode || !srcNode) return; mupnp_xml_node_setname(dstNode, mupnp_xml_node_getname(srcNode)); mupnp_xml_node_setvalue(dstNode, mupnp_xml_node_getvalue(srcNode)); for (attr = mupnp_xml_node_getattributes(srcNode); attr != NULL; attr = mupnp_xml_attribute_next(attr)) mupnp_xml_node_setattribute(dstNode, mupnp_xml_attribute_getname(attr), mupnp_xml_attribute_getvalue(attr)); for (srcChildNode = mupnp_xml_node_getchildnodes(srcNode); srcChildNode != NULL; srcChildNode = mupnp_xml_node_next(srcChildNode)) { dstChildNode = mupnp_xml_node_new(); mupnp_xml_node_copy(dstChildNode, srcChildNode); mupnp_xml_node_addchildnode(dstNode, dstChildNode); } mupnp_log_debug_l4("Leaving...\n"); }
mUpnpXmlNode *mupnp_soap_createenvelopebodynode() { mUpnpXmlNode *envNode; mUpnpXmlNode *bodyNode; mupnp_log_debug_l4("Entering...\n"); envNode = mupnp_xml_node_new(); mupnp_xml_node_setname(envNode, CG_SOAP_XMLNS CG_SOAP_DELIM CG_SOAP_ENVELOPE); mupnp_xml_node_setattribute(envNode, CG_SOAP_ATTRIBUTE_XMLNS CG_SOAP_DELIM CG_SOAP_XMLNS, CG_SOAP_XMLNS_URL); mupnp_xml_node_setattribute(envNode, CG_SOAP_XMLNS CG_SOAP_DELIM CG_SOAP_ENCORDING, CG_SOAP_ENCSTYLE_URL); bodyNode = mupnp_xml_node_new(); mupnp_xml_node_setname(bodyNode, CG_SOAP_XMLNS CG_SOAP_DELIM CG_SOAP_BODY); mupnp_xml_node_addchildnode(envNode, bodyNode); return envNode; mupnp_log_debug_l4("Leaving...\n"); }
static mUpnpXmlNode *mupnp_control_action_response_createresponsenode(mUpnpAction *action) { mUpnpXmlNode *actionNameResNode; char nodeName[MUPNP_ACTOINNAME_LEN_MAX + sizeof(MUPNP_SOAP_METHODNS) + sizeof(MUPNP_SOAP_DELIM) + sizeof(MUPNP_SOAP_RESPONSE) + 1]; char attrName[sizeof(MUPNP_SOAP_ATTRIBUTE_XMLNS) + sizeof(MUPNP_SOAP_DELIM) + sizeof(MUPNP_SOAP_METHODNS) + 1]; const char *actionName; mUpnpXmlNode *serviceNode; mUpnpService *service; mUpnpArgumentList *argList; mUpnpArgument *arg; mUpnpXmlNode *argNode; mupnp_log_debug_l4("Entering...\n"); actionNameResNode = mupnp_xml_node_new(); /* action name */ actionName = mupnp_action_getname(action); mupnp_strcpy(nodeName, MUPNP_SOAP_METHODNS); mupnp_strcat(nodeName, MUPNP_SOAP_DELIM); mupnp_strncat(nodeName, actionName, MUPNP_ACTOINNAME_LEN_MAX); mupnp_strcat(nodeName, MUPNP_SOAP_RESPONSE); mupnp_xml_node_setname(actionNameResNode, nodeName); /* service attribute */ serviceNode = mupnp_service_getservicenode(mupnp_action_getservice(action)); if (serviceNode != NULL) { service = mupnp_service_new(); mupnp_service_setservicenode(service, serviceNode); mupnp_strcpy(attrName, MUPNP_SOAP_ATTRIBUTE_XMLNS); mupnp_strcat(attrName, MUPNP_SOAP_DELIM); mupnp_strcat(attrName, MUPNP_SOAP_METHODNS); mupnp_xml_node_setattribute(actionNameResNode, attrName, mupnp_service_getservicetype(service)); mupnp_service_delete(service); } /* arguments */ argList = mupnp_action_getargumentlist(action); for (arg = mupnp_argumentlist_gets(argList); arg != NULL; arg = mupnp_argument_next(arg)) { if (mupnp_argument_isoutdirection(arg) == false) continue; argNode = mupnp_xml_node_new(); mupnp_xml_node_setname(argNode, mupnp_argument_getname(arg)); mupnp_xml_node_setvalue(argNode, mupnp_argument_getvalue(arg)); mupnp_xml_node_addchildnode(actionNameResNode, argNode); } return actionNameResNode; mupnp_log_debug_l4("Leaving...\n"); }
static void XMLCALL mupnp_expat_element_start(void* userData, const char* el, const char** attr) { mUpnpExpatData* expatData; mUpnpXmlNode* node; int n; #if defined DEBUG_XML int out, j; char* outbuf; char* lpout; #endif mupnp_log_debug_l4("Entering...\n"); #if defined DEBUG_XML outbuf = (char*)malloc(4096); lpout = outbuf; outbuf[4095] = (char)0; for (out = 0; out < indent; out++) outbuf[out] = (char)' '; lpout += out; for (j = 0; attr[j]; j += 2) { lpout += sprintf(lpout, "%s='%s'", attr[j], attr[j + 1]); } lpout[0] = 0; printf("%8x XML Node start %s - %d Attribute %s\n", userData, el, j / 2, outbuf); free(outbuf); ++indent; #endif //memdiags_memlist_report_unmarkedsize(); expatData = (mUpnpExpatData*)userData; node = mupnp_xml_node_new(); mupnp_xml_node_setname(node, (char*)el); for (n = 0; attr[n]; n += 2) mupnp_xml_node_setattribute(node, (char*)attr[n], (char*)attr[n + 1]); if (expatData->rootNode != NULL) { if (expatData->currNode != NULL) mupnp_xml_node_addchildnode(expatData->currNode, node); else mupnp_xml_node_addchildnode(expatData->rootNode, node); } else expatData->rootNode = node; expatData->currNode = node; mupnp_log_debug_l4("Leaving...\n"); }