/*! * \brief Separates the action node from the root DOM node. * * \return 0 if successful, or -1 if fails. */ static UPNP_INLINE int get_action_node( /*! [in] The root DOM node. */ IXML_Document *TempDoc, /*! [in] IXML_Node name to be searched. */ char *NodeName, /*! [out] Response/Output node. */ IXML_Document **RespNode) { IXML_Node *EnvpNode = NULL; IXML_Node *BodyNode = NULL; IXML_Node *ActNode = NULL; DOMString ActNodeName = NULL; const DOMString nodeName; int ret_code = -1; /* error, by default */ IXML_NodeList *nl = NULL; UpnpPrintf(UPNP_INFO, SOAP, __FILE__, __LINE__, "get_action_node(): node name =%s\n ", NodeName); *RespNode = NULL; /* Got the Envelope node here */ EnvpNode = ixmlNode_getFirstChild((IXML_Node *) TempDoc); if (!EnvpNode) goto error_handler; nl = ixmlElement_getElementsByTagNameNS((IXML_Element *)EnvpNode, "*", "Body"); if (!nl) goto error_handler; BodyNode = ixmlNodeList_item(nl, 0); if (!BodyNode) goto error_handler; /* Got action node here */ ActNode = ixmlNode_getFirstChild(BodyNode); if (!ActNode) goto error_handler; /* Test whether this is the action node */ nodeName = ixmlNode_getNodeName(ActNode); if (!nodeName) goto error_handler; if (!strstr(nodeName, NodeName)) goto error_handler; else { ActNodeName = ixmlPrintNode(ActNode); if (!ActNodeName) goto error_handler; ret_code = ixmlParseBufferEx(ActNodeName, RespNode); if (ret_code != IXML_SUCCESS) { ixmlFreeDOMString(ActNodeName); ret_code = -1; goto error_handler; } } /* success */ ret_code = 0; error_handler: ixmlFreeDOMString(ActNodeName); if (nl) ixmlNodeList_free(nl); return ret_code; }
/******************************************************************************** * upnp_igd_state_update * * Description: * Handle a uPnP event that was received. Process the event and update * the appropriate service state table. * * Parameters: * igd_ctxt -- The upnp igd context * device_node -- The device updated * service -- The service updated * changed_variables -- The updated variables * values -- The values of variables to update * ********************************************************************************/ void upnp_igd_state_update(upnp_igd_context* igd_ctxt, upnp_igd_device_node *device_node, int service, IXML_Document *changed_variables, char **values) { IXML_NodeList *properties; IXML_NodeList *variables; IXML_Element *property; IXML_Element *variable; long unsigned int length; long unsigned int length1; long unsigned int i; int j; char *tmpstate = NULL; upnp_igd_print(igd_ctxt, UPNP_IGD_DEBUG, "IGD State Update (service %d):", service); /* Find all of the e:property tags in the document */ properties = ixmlDocument_getElementsByTagNameNS(changed_variables, UPNPDeviceType, "property"); if (properties) { length = ixmlNodeList_length(properties); for (i = 0; i < length; i++) { /* Loop through each property change found */ property = (IXML_Element *)ixmlNodeList_item(properties, i); /* For each variable name in the state table, * check if this is a corresponding property change */ for (j = 0; j < IGDVarCount[service]; j++) { variables = ixmlElement_getElementsByTagNameNS(property, IGDServiceType[service], IGDVarName[service][j]); /* If a match is found, extract * the value, and update the state table */ if (variables) { length1 = ixmlNodeList_length(variables); if (length1) { variable = (IXML_Element *) ixmlNodeList_item(variables, 0); tmpstate = upnp_igd_get_element_value(igd_ctxt, variable); if (tmpstate) { if(strcmp(values[j], tmpstate)) { upnp_igd_strncpy(values[j], tmpstate, IGD_MAX_VAR_LEN); upnp_igd_var_updated(igd_ctxt, device_node, service, j, values[j]); } } if (tmpstate) { free(tmpstate); } tmpstate = NULL; } ixmlNodeList_free(variables); variables = NULL; } } } ixmlNodeList_free(properties); } return; }
RTPXML_NodeList *rtpxmlElement_getElementsByTagNameNS(RTPXML_Element* element,DOMString namespaceURI,DOMString localName) { return (RTPXML_NodeList *)ixmlElement_getElementsByTagNameNS((IXML_Element *)element, namespaceURI, localName); }
int L_getElementsByTagNameNS_Element(lua_State *L) { pushLuaNodeList(L, ixmlElement_getElementsByTagNameNS(checkelement(L, 1), luaL_checkstring(L,2), luaL_checkstring(L,3))); return 1; }
/**************************************************************************** * Function : get_action_node * * Parameters : * IN IXML_Document *TempDoc : The root DOM node. * IN char *NodeName : IXML_Node name to be searched. * OUT IXML_Document ** RespNode : Response/Output node. * * Description : This function separates the action node from * the root DOM node. * * Return : static UPNP_INLINE int * 0 if successful, or -1 if fails. * * Note : ****************************************************************************/ static UPNP_INLINE int get_action_node( IN IXML_Document * TempDoc, IN char *NodeName, OUT IXML_Document ** RespNode ) { IXML_Node *EnvpNode = NULL; IXML_Node *BodyNode = NULL; IXML_Node *ActNode = NULL; DOMString ActNodeName = NULL; const DOMString nodeName; int ret_code = -1; // error, by default IXML_NodeList *nl = NULL; UpnpPrintf( UPNP_INFO, SOAP, __FILE__, __LINE__, "get_action_node(): node name =%s\n ", NodeName ); *RespNode = NULL; // Got the Envelope node here EnvpNode = ixmlNode_getFirstChild( ( IXML_Node * ) TempDoc ); if( EnvpNode == NULL ) { goto error_handler; } nl = ixmlElement_getElementsByTagNameNS( ( IXML_Element * ) EnvpNode, "*", "Body" ); if( nl == NULL ) { goto error_handler; } BodyNode = ixmlNodeList_item( nl, 0 ); if( BodyNode == NULL ) { goto error_handler; } // Got action node here ActNode = ixmlNode_getFirstChild( BodyNode ); if( ActNode == NULL ) { goto error_handler; } //Test whether this is the action node nodeName = ixmlNode_getNodeName( ActNode ); if( nodeName == NULL ) { goto error_handler; } if( strstr( nodeName, NodeName ) == NULL ) { goto error_handler; } else { ActNodeName = ixmlPrintNode( ActNode ); if( ActNodeName == NULL ) { goto error_handler; } ret_code = ixmlParseBufferEx( ActNodeName, RespNode ); if( ret_code != IXML_SUCCESS ) { ixmlFreeDOMString( ActNodeName ); ret_code = -1; goto error_handler; } } ret_code = 0; // success error_handler: ixmlFreeDOMString( ActNodeName ); if( nl ) ixmlNodeList_free( nl ); return ret_code; }