/*================================================================ * ixmlNode_getElementsByTagNameNS * Returns a nodeList of all the descendant Elements with a given * local name and namespace URI in the order in which they are * encountered in a preorder traversal of this Elememt tree. * External function. * *=================================================================*/ void ixmlNode_getElementsByTagNameNS( IN IXML_Node * n, IN char *namespaceURI, IN char *localName, OUT IXML_NodeList ** list ) { DOMString nsURI; DOMString name; assert( n != NULL && namespaceURI != NULL && localName != NULL ); if( ixmlNode_getNodeType( n ) == eELEMENT_NODE ) { name = ixmlNode_getLocalName( n ); nsURI = ixmlNode_getNamespaceURI( n ); if( ( name != NULL ) && ( nsURI != NULL ) && ( strcmp( namespaceURI, nsURI ) == 0 || strcmp( namespaceURI, "*" ) == 0 ) && ( strcmp( name, localName ) == 0 || strcmp( localName, "*" ) == 0 ) ) { ixmlNodeList_addToNodeList( list, n ); } } ixmlNode_getElementsByTagNameNSRecursive( ixmlNode_getFirstChild( n ), namespaceURI, localName, list ); }
/*! * \brief */ static void ixmlNode_getElementsByTagNameNSRecursive( /*! [in] . */ IXML_Node *n, /*! [in] . */ const char *namespaceURI, /*! [in] . */ const char *localName, /*! [out] . */ IXML_NodeList **list) { const DOMString nsURI; const DOMString name; if (n != NULL) { if (ixmlNode_getNodeType(n) == eELEMENT_NODE) { name = ixmlNode_getLocalName(n); nsURI = ixmlNode_getNamespaceURI(n); if (name != NULL && nsURI != NULL && (strcmp(namespaceURI, nsURI) == 0 || strcmp(namespaceURI, "*") == 0 ) && (strcmp(name, localName) == 0 || strcmp(localName, "*") == 0)) { ixmlNodeList_addToNodeList(list, n); } } ixmlNode_getElementsByTagNameNSRecursive( ixmlNode_getFirstChild(n), namespaceURI, localName, list); ixmlNode_getElementsByTagNameNSRecursive( ixmlNode_getNextSibling(n), namespaceURI, localName, list); } }
/**************************************************************************** * Function : check_soap_body * * Parameters : * IN IXML_Document *doc : soap body xml document * IN const char *urn : * IN const char *actionName : Name of the requested action * * Description : This function checks the soap body xml came in the * SOAP request. * * Return : int * UPNP_E_SUCCESS if successful else returns appropriate error * * Note : ****************************************************************************/ static int check_soap_body( IN IXML_Document * doc, IN const char *urn, IN const char *actionName ) { IXML_NodeList *nl = NULL; IXML_Node *bodyNode = NULL; IXML_Node *actionNode = NULL; const DOMString ns = NULL; const DOMString name = NULL; int ret_code = UPNP_E_INVALID_ACTION; nl = ixmlDocument_getElementsByTagNameNS( doc, SOAP_URN, SOAP_BODY ); if( nl ) { bodyNode = ixmlNodeList_item( nl, 0 ); if( bodyNode ) { actionNode = ixmlNode_getFirstChild( bodyNode ); if( actionNode ) { ns = ixmlNode_getNamespaceURI( actionNode ); name = ixmlNode_getLocalName( actionNode ); if (name && ns && !strcmp( actionName, name ) && !strcmp( urn, ns ) ) { ret_code = UPNP_E_SUCCESS; } } } ixmlNodeList_free( nl ); } return ret_code; }
/*! * \brief Checks the soap body xml came in the SOAP request. * * \return UPNP_E_SUCCESS if successful else returns appropriate error. */ static int check_soap_body( /* [in] soap body xml document. */ IN IXML_Document *doc, /* [in] URN. */ IN const char *urn, /* [in] Name of the requested action. */ IN const char *actionName) { IXML_NodeList *nl = NULL; IXML_Node *bodyNode = NULL; IXML_Node *actionNode = NULL; const DOMString ns = NULL; const DOMString name = NULL; int ret_code = UPNP_E_INVALID_ACTION; nl = ixmlDocument_getElementsByTagNameNS(doc, SOAP_URN, SOAP_BODY); if (nl) { bodyNode = ixmlNodeList_item(nl, 0); if (bodyNode) { actionNode = ixmlNode_getFirstChild(bodyNode); if (actionNode) { ns = ixmlNode_getNamespaceURI(actionNode); name = ixmlNode_getLocalName(actionNode); /* Don't check version number, to accept a * request comming on a v1 service when * publishing a v2 service */ if (name && ns && !strcmp(actionName, name) && !strncmp(urn, ns, strlen (urn) - 2)) ret_code = UPNP_E_SUCCESS; } } ixmlNodeList_free(nl); } return ret_code; }