Logo Search packages:      
Sourcecode: libupnp4 version File versions  Download package

EXPORT_SPEC int ixmlDocument_createTextNodeEx ( IXML_Document doc,
const DOMString  data,
IXML_Node **  textNode 
)

Creates a new Text node with the given data.

The ixmlDocument_createTextNodeEx() API differs from the ixmlDocument_createTextNode API in that it returns an error code describing the reason for failure rather than just NULL.

Returns:
An integer representing one of the following:
  • IXML_SUCCESS: The operation completed successfully.
  • IXML_INVALID_PARAMETER: Either doc or data is NULL.
  • IXML_INSUFFICIENT_MEMORY: Not enough free memory exists to complete this operation.
Parameters:
doc  [in] The owner Document of the new node.
data  [in] The data to associate with the new Text node. It is stored in nodeValue field.
textNode  [out] A pointer to a Node where the new object will be stored.

Definition at line 213 of file document.c.

References ixmlNode_free(), ixmlNode_init(), _IXML_Node::nodeName, _IXML_Node::nodeType, _IXML_Node::nodeValue, and _IXML_Node::ownerDocument.

Referenced by ixmlDocument_createTextNode(), and Parser_parseDocument().

{
      IXML_Node *returnNode;
      int rc = IXML_SUCCESS;

      returnNode = NULL;
      if (doc == NULL || data == NULL) {
            rc = IXML_INVALID_PARAMETER;
            goto ErrorHandler;
      }

      returnNode = (IXML_Node *)malloc(sizeof (IXML_Node));
      if (returnNode == NULL) {
            rc = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }
      // initialize the node
      ixmlNode_init(returnNode);

      returnNode->nodeName = strdup(TEXTNODENAME);
      if (returnNode->nodeName == NULL) {
            ixmlNode_free(returnNode);
            returnNode = NULL;
            rc = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }
      // add in node value
      if (data != NULL) {
            returnNode->nodeValue = strdup(data);
            if (returnNode->nodeValue == NULL) {
                  ixmlNode_free(returnNode);
                  returnNode = NULL;
                  rc = IXML_INSUFFICIENT_MEMORY;
                  goto ErrorHandler;
            }
      }

      returnNode->nodeType = eTEXT_NODE;
      returnNode->ownerDocument = doc;

ErrorHandler:
      *textNode = returnNode;
      return rc;
}


Generated by  Doxygen 1.6.0   Back to index