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

EXPORT_SPEC int ixmlDocument_createCDATASectionEx ( IXML_Document doc,
const DOMString  data,
IXML_CDATASection **  cdNode 
)

Creates a new CDATASection node with given data.

The ixmlDocument_createCDATASectionEx API differs from the ixmlDocument_createCDATASection 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 CDATASection node.
cdNode  [out] A pointer to a Node where the new object will be stored.

Definition at line 383 of file document.c.

References ixmlCDATASection_free(), ixmlCDATASection_init(), _IXML_CDATASection::n, _IXML_Node::nodeName, _IXML_Node::nodeType, _IXML_Node::nodeValue, and _IXML_Node::ownerDocument.

Referenced by ixmlDocument_createCDATASection(), and Parser_parseDocument().

{
      int errCode = IXML_SUCCESS;
      IXML_CDATASection *cDSectionNode = NULL;

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

      cDSectionNode = (IXML_CDATASection *)malloc(sizeof (IXML_CDATASection));
      if (cDSectionNode == NULL) {
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }

      ixmlCDATASection_init(cDSectionNode);
      cDSectionNode->n.nodeType = eCDATA_SECTION_NODE;
      cDSectionNode->n.nodeName = strdup(CDATANODENAME);
      if (cDSectionNode->n.nodeName == NULL) {
            ixmlCDATASection_free(cDSectionNode);
            cDSectionNode = NULL;
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }

      cDSectionNode->n.nodeValue = strdup(data);
      if (cDSectionNode->n.nodeValue == NULL) {
            ixmlCDATASection_free( cDSectionNode );
            cDSectionNode = NULL;
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }

      cDSectionNode->n.ownerDocument = doc;

ErrorHandler:
      *rtCD = cDSectionNode;
      return errCode;
}


Generated by  Doxygen 1.6.0   Back to index