libUPnP  1.6.17
Functions
node.c File Reference
#include "ixmlparser.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for node.c:

Functions

void ixmlNode_init (IXML_Node *nodeptr)
void ixmlCDATASection_init (IXML_CDATASection *nodeptr)
 Initializes a CDATASection node.
void ixmlCDATASection_free (IXML_CDATASection *nodeptr)
 Frees a CDATASection node.
static void ixmlNode_freeSingleNode (IXML_Node *nodeptr)
 Frees a node content.
void ixmlNode_free (IXML_Node *nodeptr)
 Frees a Node and all Nodes in its subtree.
const DOMString ixmlNode_getNodeName (IXML_Node *nodeptr)
 Returns the name of the Node, depending on what type of Node it is, in a read-only string.
const DOMString ixmlNode_getLocalName (IXML_Node *nodeptr)
 Retrieves the local name of a Node, if present.
static int ixmlNode_setNamespaceURI (IXML_Node *nodeptr, const char *namespaceURI)
 Sets the namespace URI of the node.
static int ixmlNode_setPrefix (IXML_Node *nodeptr, const char *prefix)
static int ixmlNode_setLocalName (IXML_Node *nodeptr, const char *localName)
 Set the localName of the node.
const DOMString ixmlNode_getNamespaceURI (IXML_Node *nodeptr)
 Retrieves the namespace URI for a Node as a DOMString.
const DOMString ixmlNode_getPrefix (IXML_Node *nodeptr)
 Retrieves the namespace prefix, if present.
const DOMString ixmlNode_getNodeValue (IXML_Node *nodeptr)
 Returns the value of the Node as a string.
int ixmlNode_setNodeValue (IXML_Node *nodeptr, const char *newNodeValue)
 Assigns a new value to a Node.
unsigned short ixmlNode_getNodeType (IXML_Node *nodeptr)
 Retrieves the type of a Node.
IXML_NodeixmlNode_getParentNode (IXML_Node *nodeptr)
 Retrieves the parent Node for a Node.
IXML_NodeixmlNode_getFirstChild (IXML_Node *nodeptr)
 Retrieves the first child Node of a Node.
IXML_NodeixmlNode_getLastChild (IXML_Node *nodeptr)
 Retrieves the last child Node of a Node.
IXML_NodeixmlNode_getPreviousSibling (IXML_Node *nodeptr)
 Retrieves the sibling Node immediately preceding this Node.
IXML_NodeixmlNode_getNextSibling (IXML_Node *nodeptr)
 Retrieves the sibling Node immediately following this Node.
IXML_DocumentixmlNode_getOwnerDocument (IXML_Node *nodeptr)
 Retrieves the document object associated with this Node.
static BOOL ixmlNode_isAncestor (IXML_Node *ancestorNode, IXML_Node *toFind)
 Check if ancestorNode is ancestor of toFind.
static BOOL ixmlNode_isParent (IXML_Node *nodeptr, IXML_Node *toFind)
 Check whether toFind is a children of nodeptr.
static BOOL ixmlNode_allowChildren (IXML_Node *nodeptr, IXML_Node *newChild)
 Check to see whether nodeptr allows children of type newChild.
BOOL ixmlNode_compare (IXML_Node *srcNode, IXML_Node *destNode)
 Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignored.
int ixmlNode_insertBefore (IXML_Node *nodeptr, IXML_Node *newChild, IXML_Node *refChild)
 Inserts a new child Node before the existing child Node.
int ixmlNode_replaceChild (IXML_Node *nodeptr, IXML_Node *newChild, IXML_Node *oldChild, IXML_Node **returnNode)
 Replaces an existing child Node with a new child Node in the list of children of a Node.
int ixmlNode_removeChild (IXML_Node *nodeptr, IXML_Node *oldChild, IXML_Node **returnNode)
 Removes a child from the list of children of a Node.
int ixmlNode_appendChild (IXML_Node *nodeptr, IXML_Node *newChild)
 Appends a child Node to the list of children of a Node.
static IXML_NodeixmlNode_cloneTextNode (IXML_Node *nodeptr)
 Returns a clone of nodeptr.
static IXML_CDATASectionixmlNode_cloneCDATASect (IXML_CDATASection *nodeptr)
 Return a clone of CDATASection node.
static IXML_ElementixmlNode_cloneElement (IXML_Element *nodeptr)
 Returns a clone of element node.
static IXML_DocumentixmlNode_newDoc (void)
 Returns a new document node.
static IXML_AttrixmlNode_cloneAttr (IXML_Attr *nodeptr)
 Returns a clone of an attribute node.
static IXML_AttrixmlNode_cloneAttrDirect (IXML_Attr *nodeptr)
 Return a clone of attribute node, with specified field set to TRUE.
static void ixmlNode_setSiblingNodesParent (IXML_Node *nodeptr)
 Sets siblings nodes parent to be the same as this node's.
static IXML_NodeixmlNode_cloneNodeTreeRecursive (IXML_Node *nodeptr, BOOL deep)
 Recursive function that clones a node tree of nodeptr.
static IXML_NodeixmlNode_cloneNodeTree (IXML_Node *nodeptr, BOOL deep)
 Function that clones a node tree of nodeptr.
IXML_NodeixmlNode_cloneNode (IXML_Node *nodeptr, BOOL deep)
 Clones a Node.
IXML_NodeListixmlNode_getChildNodes (IXML_Node *nodeptr)
 Retrieves the list of children of a Node in a NodeList structure.
IXML_NamedNodeMapixmlNode_getAttributes (IXML_Node *nodeptr)
 Retrieves the attributes of a Node, if it is an Element node, in a NamedNodeMap structure.
BOOL ixmlNode_hasChildNodes (IXML_Node *nodeptr)
 Queries whether or not a Node has children.
BOOL ixmlNode_hasAttributes (IXML_Node *nodeptr)
 Queries whether this Node has attributes.
static void ixmlNode_getElementsByTagNameRecursive (IXML_Node *n, const char *tagname, IXML_NodeList **list)
 Recursively traverse the whole tree, search for element with the given tagname.
void ixmlNode_getElementsByTagName (IXML_Node *n, const char *tagname, IXML_NodeList **list)
 Returns a nodeList of all descendant Elements with a given tagName, in the order in which they are encountered in a traversal of this element tree.
static void ixmlNode_getElementsByTagNameNSRecursive (IXML_Node *n, const char *namespaceURI, const char *localName, IXML_NodeList **list)
void ixmlNode_getElementsByTagNameNS (IXML_Node *n, const char *namespaceURI, const char *localName, IXML_NodeList **list)
 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.
int ixmlNode_setNodeName (IXML_Node *node, const DOMString qualifiedName)
int ixmlNode_setNodeProperties (IXML_Node *destNode, IXML_Node *src)

Detailed Description


Function Documentation

static BOOL ixmlNode_allowChildren ( IXML_Node nodeptr,
IXML_Node newChild 
) [static]

Check to see whether nodeptr allows children of type newChild.

Returns:
  • TRUE, if nodeptr can have newChild as children.
  • FALSE, if nodeptr cannot have newChild as children.
Parameters:
[in]nodeptrThe Node to check.
[in]newChildThe child Node to check.

References FALSE.

Referenced by ixmlNode_appendChild(), ixmlNode_insertBefore(), and ixmlNode_replaceChild().

static IXML_Attr* ixmlNode_cloneAttr ( IXML_Attr nodeptr) [static]

Returns a clone of an attribute node.

Returns:
A clone of an attribute node.
Parameters:
[in]nodeptrThe Node to clone.

References ixmlAttr_free(), ixmlNode_setLocalName(), ixmlNode_setNamespaceURI(), ixmlNode_setNodeName(), ixmlNode_setNodeValue(), and ixmlNode_setPrefix().

Referenced by ixmlNode_cloneAttrDirect(), and ixmlNode_cloneNodeTreeRecursive().

static IXML_Attr* ixmlNode_cloneAttrDirect ( IXML_Attr nodeptr) [static]

Return a clone of attribute node, with specified field set to TRUE.

Returns:
A clone of attribute node, with specified field set to TRUE.
Parameters:
[in]nodeptrThe Node to clone.

References ixmlNode_cloneAttr().

Referenced by ixmlNode_cloneNode().

Return a clone of CDATASection node.

Returns:
A clone of CDATASection node.
Parameters:
[in]nodeptrThe Node to clone.

References ixmlCDATASection_free(), ixmlCDATASection_init(), ixmlNode_setNodeName(), and ixmlNode_setNodeValue().

Referenced by ixmlNode_cloneNodeTreeRecursive().

static IXML_Element* ixmlNode_cloneElement ( IXML_Element nodeptr) [static]

Returns a clone of element node.

Returns:
A clone of element node.
Parameters:
[in]nodeptrThe Node to clone.

References ixmlElement_free(), ixmlElement_init(), ixmlElement_setTagName(), ixmlNode_setLocalName(), ixmlNode_setNamespaceURI(), ixmlNode_setNodeName(), ixmlNode_setNodeValue(), and ixmlNode_setPrefix().

Referenced by ixmlNode_cloneNodeTree(), and ixmlNode_cloneNodeTreeRecursive().

static IXML_Node* ixmlNode_cloneNodeTree ( IXML_Node nodeptr,
BOOL  deep 
) [static]

Function that clones a node tree of nodeptr.

Returns:
The cloned node/tree.
Parameters:
[in]nodeptrNode tree to clone.
[in]deepTRUE if you want to clone the tree.

References ixmlNode_cloneElement(), and ixmlNode_cloneNodeTreeRecursive().

Referenced by ixmlNode_cloneNode().

static IXML_Node* ixmlNode_cloneNodeTreeRecursive ( IXML_Node nodeptr,
BOOL  deep 
) [static]

Recursive function that clones a node tree of nodeptr.

Returns:
The cloned node/tree.
Parameters:
[in]nodeptrNode tree to clone.
[in]deepTRUE if you want to clone the tree.

References ixmlNode_cloneAttr(), ixmlNode_cloneCDATASect(), ixmlNode_cloneElement(), ixmlNode_cloneTextNode(), ixmlNode_newDoc(), and ixmlNode_setSiblingNodesParent().

Referenced by ixmlNode_cloneNodeTree().

static IXML_Node* ixmlNode_cloneTextNode ( IXML_Node nodeptr) [static]

Returns a clone of nodeptr.

Returns:
A cloned node of nodeptr.
Parameters:
[in]nodeptrThe Node to clone.

References ixmlNode_free(), ixmlNode_init(), ixmlNode_setNodeName(), and ixmlNode_setNodeValue().

Referenced by ixmlNode_cloneNodeTreeRecursive().

BOOL ixmlNode_compare ( IXML_Node srcNode,
IXML_Node destNode 
)

Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignored.

Returns:
  • TRUE, the two nodes are the same.
  • FALSE, the two nodes are not the same.
Parameters:
[in]srcNodeThe first Node.
[in]destNodeThe second Node.

Referenced by ixmlElement_findAttributeNode().

static void ixmlNode_freeSingleNode ( IXML_Node nodeptr) [static]

Frees a node content.

Parameters:
[in]nodeptrThe node to free.

Referenced by ixmlNode_free().

void ixmlNode_getElementsByTagName ( IXML_Node n,
const char *  tagname,
IXML_NodeList **  list 
)

Returns a nodeList of all descendant Elements with a given tagName, in the order in which they are encountered in a traversal of this element tree.

Parameters:
[in]nThe Node tree.
[in]tagnameThe tag name to match.
[out]listThe output NodeList.

References ixmlNode_getElementsByTagNameRecursive(), ixmlNode_getFirstChild(), ixmlNode_getNodeName(), ixmlNode_getNodeType(), and ixmlNodeList_addToNodeList().

void ixmlNode_getElementsByTagNameNS ( IXML_Node n,
const char *  namespaceURI,
const char *  localName,
IXML_NodeList **  list 
)

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.

Parameters:
[in]nThe Element tree.
[in]namespaceURIThe name space to match.
[in]localNameThe local name to match.
[out]listThe output NodeList.

References DOMString, ixmlNode_getElementsByTagNameNSRecursive(), ixmlNode_getFirstChild(), ixmlNode_getLocalName(), ixmlNode_getNamespaceURI(), ixmlNode_getNodeType(), and ixmlNodeList_addToNodeList().

static void ixmlNode_getElementsByTagNameNSRecursive ( IXML_Node n,
const char *  namespaceURI,
const char *  localName,
IXML_NodeList **  list 
) [static]
static void ixmlNode_getElementsByTagNameRecursive ( IXML_Node n,
const char *  tagname,
IXML_NodeList **  list 
) [static]

Recursively traverse the whole tree, search for element with the given tagname.

Parameters:
[in]nThe Node tree.
[in]tagnameThe tag name to match.
[out]listThe output NodeList.

References ixmlNode_getFirstChild(), ixmlNode_getNextSibling(), ixmlNode_getNodeName(), ixmlNode_getNodeType(), and ixmlNodeList_addToNodeList().

Referenced by ixmlNode_getElementsByTagName().

static BOOL ixmlNode_isAncestor ( IXML_Node ancestorNode,
IXML_Node toFind 
) [static]

Check if ancestorNode is ancestor of toFind.

Returns:
TRUE or FALSE.
Parameters:
[in]ancestorNodeThe candidate to ancestor Node.
[in]toFindThe Node to check for an ancestor.

References FALSE.

Referenced by ixmlNode_appendChild(), ixmlNode_insertBefore(), and ixmlNode_replaceChild().

static BOOL ixmlNode_isParent ( IXML_Node nodeptr,
IXML_Node toFind 
) [static]

Check whether toFind is a children of nodeptr.

Returns:
TRUE or FALSE.
Parameters:
[in]nodeptrThe candidate to parent Node.
[in]toFindThe Node to check for his parent.

References FALSE.

Referenced by ixmlNode_appendChild(), ixmlNode_insertBefore(), ixmlNode_removeChild(), and ixmlNode_replaceChild().

static IXML_Document* ixmlNode_newDoc ( void  ) [static]

Returns a new document node.

Currently, the IXML_Document struct is just a node, so this function just mallocs the IXML_Document, sets the node type and name.

Returns:
A new document node.

References ixmlDocument_free(), ixmlDocument_init(), and ixmlNode_setNodeName().

Referenced by ixmlNode_cloneNodeTreeRecursive().

static int ixmlNode_setLocalName ( IXML_Node nodeptr,
const char *  localName 
) [static]

Set the localName of the node.

Returns:
IXML_SUCCESS or failure.
Parameters:
[in]nodeptrThe pointer to the node.
[in]localNameThe local name to set.

Referenced by ixmlNode_cloneAttr(), ixmlNode_cloneElement(), and ixmlNode_setNodeProperties().

static int ixmlNode_setNamespaceURI ( IXML_Node nodeptr,
const char *  namespaceURI 
) [static]

Sets the namespace URI of the node.

Parameters:
[in]nodeptrThe Node on which to operate.
[in]namespaceURIThe name space string to set.

Referenced by ixmlNode_cloneAttr(), and ixmlNode_cloneElement().

int ixmlNode_setNodeName ( IXML_Node node,
const DOMString  qualifiedName 
)
Returns:
Parameters:
[in]nodeThe Node.
[in]qualifiedName.

References Parser_setNodePrefixAndLocalName().

Referenced by ixmlNode_cloneAttr(), ixmlNode_cloneCDATASect(), ixmlNode_cloneElement(), ixmlNode_cloneTextNode(), and ixmlNode_newDoc().

int ixmlNode_setNodeProperties ( IXML_Node destNode,
IXML_Node src 
)
Returns:
Parameters:
[in]destNode.
[in]src.

References ixmlNode_setLocalName(), ixmlNode_setNodeValue(), and ixmlNode_setPrefix().

Referenced by Parser_processAttributeName(), and Parser_processElementName().

static int ixmlNode_setPrefix ( IXML_Node nodeptr,
const char *  prefix 
) [static]
Parameters:
[in]nodeptrThe Node on which to operate.
[in]prefixThe prefix string to set.

Referenced by ixmlNode_cloneAttr(), ixmlNode_cloneElement(), and ixmlNode_setNodeProperties().

static void ixmlNode_setSiblingNodesParent ( IXML_Node nodeptr) [static]

Sets siblings nodes parent to be the same as this node's.

Parameters:
[in]nodeptrThe node to operate on.

Referenced by ixmlNode_cloneNodeTreeRecursive().