Ejemplo n.º 1
0
/*================================================================
*   ixmlNode_cloneDoc
*       Returns a clone of document node
*       Internal to parser only.
*
*=================================================================*/
IXML_Document *
ixmlNode_cloneDoc( IN IXML_Document * nodeptr )
{
    IXML_Document *newDoc;
    IXML_Node *docNode;
    int rc;

    assert( nodeptr != NULL );
    newDoc = ( IXML_Document * ) ixml_malloc( sizeof( IXML_Document ) );
    if( newDoc == NULL ) {
        return NULL;
    }

    ixmlDocument_init( newDoc );
    docNode = ( IXML_Node * ) newDoc;

    rc = ixmlNode_setNodeName( docNode, DOCUMENTNODENAME );
    if( rc != IXML_SUCCESS ) {
        ixmlDocument_free( newDoc );
        return NULL;
    }

    newDoc->n.nodeType = eDOCUMENT_NODE;

    return newDoc;

}
Ejemplo n.º 2
0
/*================================================================
*   ixmlNode_cloneElement
*       returns a clone of element node
*       Internal to parser only.
*
*=================================================================*/
IXML_Element *
ixmlNode_cloneElement( IN IXML_Element * nodeptr )
{
    IXML_Element *newElement;
    IXML_Node *elementNode;
    IXML_Node *srcNode;
    int rc;

    assert( nodeptr != NULL );

    newElement = ( IXML_Element * ) malloc( sizeof( IXML_Element ) );
    if( newElement == NULL ) {
        return NULL;
    }

    ixmlElement_init( newElement );
    rc = ixmlElement_setTagName( newElement, nodeptr->tagName );
    if( rc != IXML_SUCCESS ) {
        ixmlElement_free( newElement );
        return NULL;
    }

    elementNode = ( IXML_Node * ) newElement;
    srcNode = ( IXML_Node * ) nodeptr;
    rc = ixmlNode_setNodeName( elementNode, srcNode->nodeName );
    if( rc != IXML_SUCCESS ) {
        ixmlElement_free( newElement );
        return NULL;
    }

    rc = ixmlNode_setNodeValue( elementNode, srcNode->nodeValue );
    if( rc != IXML_SUCCESS ) {
        ixmlElement_free( newElement );
        return NULL;
    }

    rc = ixmlNode_setNamespaceURI( elementNode, srcNode->namespaceURI );
    if( rc != IXML_SUCCESS ) {
        ixmlElement_free( newElement );
        return NULL;
    }

    rc = ixmlNode_setPrefix( elementNode, srcNode->prefix );
    if( rc != IXML_SUCCESS ) {
        ixmlElement_free( newElement );
        return NULL;
    }

    rc = ixmlNode_setLocalName( elementNode, srcNode->localName );
    if( rc != IXML_SUCCESS ) {
        ixmlElement_free( newElement );
        return NULL;
    }

    elementNode->nodeType = eELEMENT_NODE;

    return newElement;

}
Ejemplo n.º 3
0
Archivo: node.c Proyecto: rxwen/pupnp
/*!
 * \brief Returns a clone of an attribute node.
 *
 * \return A clone of an attribute node.
 */
static IXML_Attr *ixmlNode_cloneAttr(
    /*! [in] The \b Node to clone. */
    IXML_Attr *nodeptr)
{
    IXML_Attr *newAttr;
    IXML_Node *attrNode;
    IXML_Node *srcNode;
    int rc;

    assert(nodeptr != NULL);

    newAttr = (IXML_Attr *)malloc(sizeof (IXML_Attr));
    if (newAttr == NULL) {
        return NULL;
    }

    ixmlAttr_init(newAttr);
    attrNode = (IXML_Node *)newAttr;
    srcNode = (IXML_Node *)nodeptr;

    rc = ixmlNode_setNodeName(attrNode, srcNode->nodeName);
    if (rc != IXML_SUCCESS) {
        ixmlAttr_free(newAttr);
        return NULL;
    }

    rc = ixmlNode_setNodeValue(attrNode, srcNode->nodeValue);
    if (rc != IXML_SUCCESS) {
        ixmlAttr_free(newAttr);
        return NULL;
    }

    /* Check to see whether we need to split prefix and localname for attribute */
    rc = ixmlNode_setNamespaceURI(attrNode, srcNode->namespaceURI);
    if (rc != IXML_SUCCESS) {
        ixmlAttr_free(newAttr);
        return NULL;
    }

    rc = ixmlNode_setPrefix(attrNode, srcNode->prefix);
    if (rc != IXML_SUCCESS) {
        ixmlAttr_free(newAttr);
        return NULL;
    }

    rc = ixmlNode_setLocalName(attrNode, srcNode->localName);
    if (rc != IXML_SUCCESS) {
        ixmlAttr_free(newAttr);
        return NULL;
    }

    attrNode->nodeType = eATTRIBUTE_NODE;

    return newAttr;
}
Ejemplo n.º 4
0
int ixmlDocument_createElementNSEx(
	IXML_Document *doc,
	const DOMString namespaceURI,
	const DOMString qualifiedName,
	IXML_Element **rtElement)
{
	IXML_Element *newElement = NULL;
	int ret = IXML_SUCCESS;
	int line = 0;

	if (doc == NULL || namespaceURI == NULL || qualifiedName == NULL) {
		line = __LINE__;
		ret = IXML_INVALID_PARAMETER;
		goto ErrorHandler;
	}

	ret = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
	if (ret != IXML_SUCCESS) {
		line = __LINE__;
		goto ErrorHandler;
	}
	/* set the namespaceURI field */
	newElement->n.namespaceURI = _strdup(namespaceURI);
	if (newElement->n.namespaceURI == NULL) {
		line = __LINE__;
		ixmlElement_free(newElement);
		newElement = NULL;
		ret = IXML_INSUFFICIENT_MEMORY;
		goto ErrorHandler;
	}
	/* set the localName and prefix */
	ret = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
	if (ret != IXML_SUCCESS) {
		line = __LINE__;
		ixmlElement_free(newElement);
		newElement = NULL;
		ret = IXML_INSUFFICIENT_MEMORY;
		goto ErrorHandler;
	}

	newElement->n.nodeValue = NULL;

ErrorHandler:
	*rtElement = newElement;
	if (ret != IXML_SUCCESS) {
		IxmlPrintf(__FILE__, line, "ixmlDocument_createElementNSEx", "Error %d\n", ret);
	}

	return ret;
}
Ejemplo n.º 5
0
/*================================================================
*   ixmlDocument_createElementNSEx
*       Creates an element of the given qualified name and namespace URI.
*       External function.
*   Parameters:
*       namespaceURI: the namespace URI of the element to create.
*       qualifiedName: the qualified name of the element to instantiate.
*   Return Value:
*   Return Value:
*       IXML_SUCCESS
*       IXML_INVALID_PARAMETER:     if either doc,namespaceURI or qualifiedName is NULL
*       IXML_INSUFFICIENT_MEMORY:   if not enough memory to finish this operations.
*
*=================================================================*/
int
ixmlDocument_createElementNSEx( IN IXML_Document * doc,
                                IN DOMString namespaceURI,
                                IN DOMString qualifiedName,
                                OUT IXML_Element ** rtElement )
{

    IXML_Element *newElement = NULL;
    int errCode = IXML_SUCCESS;

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

    errCode =
        ixmlDocument_createElementEx( doc, qualifiedName, &newElement );
    if( errCode != IXML_SUCCESS ) {
        goto ErrorHandler;
    }
    /* set the namespaceURI field */
    newElement->n.namespaceURI = strdup( namespaceURI );
    if( newElement->n.namespaceURI == NULL ) {
        ixmlElement_free( newElement );
        newElement = NULL;
        errCode = IXML_INSUFFICIENT_MEMORY;
        goto ErrorHandler;
    }
    /* set the localName and prefix */
    errCode =
        ixmlNode_setNodeName( ( IXML_Node * ) newElement, qualifiedName );
    if( errCode != IXML_SUCCESS ) {
        ixmlElement_free( newElement );
        newElement = NULL;
        errCode = IXML_INSUFFICIENT_MEMORY;
        goto ErrorHandler;
    }

    newElement->n.nodeValue = NULL;

  ErrorHandler:
    *rtElement = newElement;
    return errCode;

}
Ejemplo n.º 6
0
/*================================================================
*   ixmlDocument_createAttributeNSEx
*       Creates an attrbute of the given name and namespace URI
*       External function.
*   Parameters:
*       namespaceURI: the namespace fo the attribute to create
*       qualifiedName: qualifiedName of the attribute to instantiate
*   Return Value:
*       IXML_SUCCESS
*       IXML_INVALID_PARAMETER:     if either doc,namespaceURI or qualifiedName is NULL
*       IXML_INSUFFICIENT_MEMORY:   if not enough memory to finish this operations.
*
*=================================================================*/
int
ixmlDocument_createAttributeNSEx( IN IXML_Document * doc,
                                  IN DOMString namespaceURI,
                                  IN DOMString qualifiedName,
                                  OUT IXML_Attr ** rtAttr )
{
    IXML_Attr *attrNode = NULL;
    int errCode = IXML_SUCCESS;

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

    errCode =
        ixmlDocument_createAttributeEx( doc, qualifiedName, &attrNode );
    if( errCode != IXML_SUCCESS ) {
        goto ErrorHandler;
    }
    /* set the namespaceURI field */
    attrNode->n.namespaceURI = strdup( namespaceURI );
    if( attrNode->n.namespaceURI == NULL ) {
        ixmlAttr_free( attrNode );
        attrNode = NULL;
        errCode = IXML_INSUFFICIENT_MEMORY;
        goto ErrorHandler;
    }
    /* set the localName and prefix */
    errCode =
        ixmlNode_setNodeName( ( IXML_Node * ) attrNode, qualifiedName );
    if( errCode != IXML_SUCCESS ) {
        ixmlAttr_free( attrNode );
        attrNode = NULL;
        goto ErrorHandler;
    }

  ErrorHandler:
    *rtAttr = attrNode;
    return errCode;

}
Ejemplo n.º 7
0
/*================================================================
*   ixmlNode_cloneTextNode
*       Returns a clone of nodeptr
*       Internal to parser only.
*
*=================================================================*/
IXML_Node *
ixmlNode_cloneTextNode( IN IXML_Node * nodeptr )
{
    IXML_Node *newNode = NULL;

    assert( nodeptr != NULL );

    newNode = ( IXML_Node * ) ixml_malloc( sizeof( IXML_Node ) );
    if( newNode == NULL ) {
        return NULL;
    } else {
        ixmlNode_init( newNode );

        ixmlNode_setNodeName( newNode, nodeptr->nodeName );
        ixmlNode_setNodeValue( newNode, nodeptr->nodeValue );
        newNode->nodeType = eTEXT_NODE;
    }

    return newNode;
}
Ejemplo n.º 8
0
Archivo: node.c Proyecto: rxwen/pupnp
/*!
 * \brief Return a clone of CDATASection node.
 *
 * \return A clone of CDATASection node.
 */
static IXML_CDATASection *ixmlNode_cloneCDATASect(
    /*! [in] The \b Node to clone. */
    IXML_CDATASection *nodeptr)
{
    IXML_CDATASection *newCDATA = NULL;
    IXML_Node *newNode;
    IXML_Node *srcNode;

    assert(nodeptr != NULL);
    newCDATA = (IXML_CDATASection *)malloc(sizeof (IXML_CDATASection));
    if (newCDATA != NULL) {
        newNode = (IXML_Node *)newCDATA;
        ixmlNode_init(newNode);
        srcNode = (IXML_Node *)nodeptr;
        ixmlNode_setNodeName(newNode, srcNode->nodeName);
        ixmlNode_setNodeValue(newNode, srcNode->nodeValue);
        newNode->nodeType = eCDATA_SECTION_NODE;
    }

    return newCDATA;
}