From 4e6102d1c2550b868b6eac4f58ef326692f6e9e8 Mon Sep 17 00:00:00 2001 From: Marcelo Roberto Jimenez Date: Mon, 5 May 2008 23:10:41 +0000 Subject: [PATCH] More doxygen. git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@370 119443c7-1b9e-41f8-b6fc-b9c35fce742c --- ixml/inc/ixml.h | 29 +++--- ixml/src/attr.c | 34 +++---- ixml/src/document.c | 220 ++++++++++++++++++-------------------------- 3 files changed, 113 insertions(+), 170 deletions(-) diff --git a/ixml/inc/ixml.h b/ixml/inc/ixml.h index 13f7be7..f6dcacb 100644 --- a/ixml/inc/ixml.h +++ b/ixml/inc/ixml.h @@ -296,21 +296,7 @@ EXPORT_SPEC int ixmlNode_setNodeValue( /*! * \brief Retrieves the type of a \b Node. * - * The defined \b Node constants are: - * \li \c eATTRIBUTE_NODE - * \li \c eCDATA_SECTION_NODE - * \li \c eCOMMENT_NODE - * \li \c eDOCUMENT_FRAGMENT_NODE - * \li \c eDOCUMENT_NODE - * \li \c eDOCUMENT_TYPE_NODE - * \li \c eELEMENT_NODE - * \li \c eENTITY_NODE - * \li \c eENTITY_REFERENCE_NODE - * \li \c eNOTATION_NODE - * \li \c ePROCESSING_INSTRUCTION_NODE - * \li \c eTEXT_NODE - * - * \return An integer representing the type of the \b Node. + * \return An enum IXML_NODE_TYPE representing the type of the \b Node. */ EXPORT_SPEC unsigned short ixmlNode_getNodeType( /*! The \b Node from which to retrieve the type. */ @@ -1035,9 +1021,18 @@ EXPORT_SPEC void ixmlDocument_free( /*! * \brief Imports a \b Node from another \b Document into this \b Document. * - * The new \b Node does not a have parent node: it is a clone of the original - * \b Node with the \c ownerDocument set to \b doc. + * The returned new \b Node does not a have parent node (parentNode is null): + * it is a clone of the original \b Node with the \c ownerDocument set to + * \b doc. The source node is not altered or removed from the original + * document. * + * For all nodes, importing a node creates a node object owned by the + * importing document, with attribute values identical to the source + * node's nodeName and nodeType, plus the attributes related to namespaces + * (prefix, localName, and namespaceURI). + * + * As in the cloneNode operation on a node, the source node is not altered. + * * The \b deep parameter controls whether all the children of the \b Node are * imported. * diff --git a/ixml/src/attr.c b/ixml/src/attr.c index 4f0732d..d1a7af8 100644 --- a/ixml/src/attr.c +++ b/ixml/src/attr.c @@ -29,32 +29,22 @@ // /////////////////////////////////////////////////////////////////////////// + #include "ixmlparser.h" -/*================================================================ -* Function: Attr_init -* Initializes an attribute node -* External function. -* -*=================================================================*/ -void -ixmlAttr_init( IN IXML_Attr * attr ) + +void ixmlAttr_init(IN IXML_Attr *attr) { - if( attr != NULL ) { - memset( attr, 0, sizeof( IXML_Attr ) ); - } + if (attr != NULL) { + memset(attr, 0, sizeof (IXML_Attr)); + } } -/*================================================================ -* Function: Attr_free -* Frees an attribute node. -* external function. -* -*=================================================================*/ -void -ixmlAttr_free( IN IXML_Attr * attr ) + +void ixmlAttr_free(IN IXML_Attr *attr) { - if( attr != NULL ) { - ixmlNode_free( ( IXML_Node * ) attr ); - } + if (attr != NULL) { + ixmlNode_free((IXML_Node *)attr); + } } + diff --git a/ixml/src/document.c b/ixml/src/document.c index 1f7f530..4de6da1 100644 --- a/ixml/src/document.c +++ b/ixml/src/document.c @@ -29,169 +29,126 @@ // /////////////////////////////////////////////////////////////////////////// + #include #include + #include "ixmlparser.h" -/*================================================================ -* ixmlDocument_init -* It initialize the document structure. -* External function. -* -*=================================================================*/ -void -ixmlDocument_init( IN IXML_Document * doc ) + +void ixmlDocument_init(IN IXML_Document *doc) { - memset( doc, 0, sizeof( IXML_Document ) ); + memset(doc, 0, sizeof(IXML_Document)); } -/*================================================================ -* ixmlDocument_free -* It frees the whole document tree. -* External function. -* -*=================================================================*/ -void -ixmlDocument_free( IN IXML_Document * doc ) -{ - if( doc != NULL ) { - ixmlNode_free( ( IXML_Node * ) doc ); - } +void ixmlDocument_free(IN IXML_Document *doc) +{ + if (doc != NULL) { + ixmlNode_free((IXML_Node *)doc); + } } -/*================================================================ -* ixmlDocument_setOwnerDocument -* -* When this function is called first time, nodeptr is the root -* of the subtree, so it is not necessay to do two steps -* recursion. -* -* Internal function called by ixmlDocument_importNode -* -*=================================================================*/ -void -ixmlDocument_setOwnerDocument( IN IXML_Document * doc, - IN IXML_Node * nodeptr ) + +/*! + * When this function is called first time, nodeptr is the root of the subtree, + * so it is not necessay to do two steps recursion. + * + * Internal function called by ixmlDocument_importNode + */ +void ixmlDocument_setOwnerDocument( + IN IXML_Document *doc, + IN IXML_Node *nodeptr) { - if( nodeptr != NULL ) { - nodeptr->ownerDocument = doc; - ixmlDocument_setOwnerDocument( doc, - ixmlNode_getFirstChild( nodeptr ) ); - ixmlDocument_setOwnerDocument( doc, - ixmlNode_getNextSibling - ( nodeptr ) ); - } + if (nodeptr != NULL) { + nodeptr->ownerDocument = doc; + ixmlDocument_setOwnerDocument( + doc, ixmlNode_getFirstChild(nodeptr)); + ixmlDocument_setOwnerDocument( + doc, ixmlNode_getNextSibling(nodeptr)); + } } -/*================================================================ -* ixmlDocument_importNode -* Imports a node from another document to this document. The -* returned node has no parent; (parentNode is null). The source -* node is not altered or removed from the original document; -* this method creates a new copy of the source node. - -* For all nodes, importing a node creates a node object owned -* by the importing document, with attribute values identical to -* the source node's nodeName and nodeType, plus the attributes -* related to namespaces (prefix, localName, and namespaceURI). -* As in the cloneNode operation on a node, the source node is -* not altered. -* -* External function. -* -*=================================================================*/ -int -ixmlDocument_importNode( IN IXML_Document * doc, - IN IXML_Node * importNode, - IN BOOL deep, - OUT IXML_Node ** rtNode ) + +int ixmlDocument_importNode( + IN IXML_Document *doc, + IN IXML_Node *importNode, + IN BOOL deep, + OUT IXML_Node **rtNode) { - unsigned short nodeType; - IXML_Node *newNode; + unsigned short nodeType; + IXML_Node *newNode; - *rtNode = NULL; + *rtNode = NULL; - if( ( doc == NULL ) || ( importNode == NULL ) ) { - return IXML_INVALID_PARAMETER; - } + if (doc == NULL || importNode == NULL) { + return IXML_INVALID_PARAMETER; + } - nodeType = ixmlNode_getNodeType( importNode ); - if( nodeType == eDOCUMENT_NODE ) { - return IXML_NOT_SUPPORTED_ERR; - } + nodeType = ixmlNode_getNodeType(importNode); + if (nodeType == eDOCUMENT_NODE) { + return IXML_NOT_SUPPORTED_ERR; + } - newNode = ixmlNode_cloneNode( importNode, deep ); - if( newNode == NULL ) { - return IXML_FAILED; - } + newNode = ixmlNode_cloneNode(importNode, deep); + if (newNode == NULL) { + return IXML_FAILED; + } - ixmlDocument_setOwnerDocument( doc, newNode ); - *rtNode = newNode; + ixmlDocument_setOwnerDocument(doc, newNode); + *rtNode = newNode; - return IXML_SUCCESS; + return IXML_SUCCESS; } -/*================================================================ -* ixmlDocument_createElementEx -* Creates an element of the type specified. -* External function. -* Parameters: -* doc: pointer to document -* tagName: The name of the element, it is case-sensitive. -* Return Value: -* IXML_SUCCESS -* IXML_INVALID_PARAMETER: if either doc or tagName is NULL -* IXML_INSUFFICIENT_MEMORY: if not enough memory to finish this operations. -* -*=================================================================*/ -int -ixmlDocument_createElementEx( IN IXML_Document * doc, - IN const DOMString tagName, - OUT IXML_Element ** rtElement ) + +int ixmlDocument_createElementEx( + IN IXML_Document *doc, + IN const DOMString tagName, + OUT IXML_Element **rtElement) { + int errCode = IXML_SUCCESS; + IXML_Element *newElement = NULL; - int errCode = IXML_SUCCESS; - IXML_Element *newElement = NULL; + if (doc == NULL || tagName == NULL) { + errCode = IXML_INVALID_PARAMETER; + goto ErrorHandler; + } - if( ( doc == NULL ) || ( tagName == NULL ) ) { - errCode = IXML_INVALID_PARAMETER; - goto ErrorHandler; - } + newElement = (IXML_Element *) malloc(sizeof(IXML_Element)); + if (newElement == NULL) { + errCode = IXML_INSUFFICIENT_MEMORY; + goto ErrorHandler; + } - newElement = ( IXML_Element * ) malloc( sizeof( IXML_Element ) ); - if( newElement == NULL ) { - errCode = IXML_INSUFFICIENT_MEMORY; - goto ErrorHandler; - } + ixmlElement_init(newElement); + newElement->tagName = strdup(tagName); + if (newElement->tagName == NULL) { + ixmlElement_free(newElement); + newElement = NULL; + errCode = IXML_INSUFFICIENT_MEMORY; + goto ErrorHandler; + } + // set the node fields + newElement->n.nodeType = eELEMENT_NODE; + newElement->n.nodeName = strdup(tagName); + if (newElement->n.nodeName == NULL) { + ixmlElement_free(newElement); + newElement = NULL; + errCode = IXML_INSUFFICIENT_MEMORY; + goto ErrorHandler; + } - ixmlElement_init( newElement ); - newElement->tagName = strdup( tagName ); - if( newElement->tagName == NULL ) { - ixmlElement_free( newElement ); - newElement = NULL; - errCode = IXML_INSUFFICIENT_MEMORY; - goto ErrorHandler; - } - // set the node fields - newElement->n.nodeType = eELEMENT_NODE; - newElement->n.nodeName = strdup( tagName ); - if( newElement->n.nodeName == NULL ) { - ixmlElement_free( newElement ); - newElement = NULL; - errCode = IXML_INSUFFICIENT_MEMORY; - goto ErrorHandler; - } + newElement->n.ownerDocument = doc; - newElement->n.ownerDocument = doc; - - ErrorHandler: - *rtElement = newElement; - return errCode; +ErrorHandler: + *rtElement = newElement; + return errCode; } + /*================================================================ * ixmlDocument_createElement * Creates an element of the type specified. @@ -802,3 +759,4 @@ ixmlDocument_getElementById( IN IXML_Document * doc, return rtElement; } +