Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@425 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
a9064dc0ca
commit
680db7c78d
148
ixml/inc/ixml.h
148
ixml/inc/ixml.h
@ -273,7 +273,7 @@ extern "C" {
|
||||
* \return A constant \b DOMString of the node name.
|
||||
*/
|
||||
EXPORT_SPEC const DOMString ixmlNode_getNodeName(
|
||||
/*! Pointer to the node to retrieve the name. */
|
||||
/*! [in] Pointer to the node to retrieve the name. */
|
||||
IXML_Node *nodeptr);
|
||||
|
||||
|
||||
@ -457,7 +457,7 @@ ixmlNode_getPrefix(
|
||||
* \c NULL.
|
||||
*/
|
||||
EXPORT_SPEC const DOMString ixmlNode_getLocalName(
|
||||
/*! The \b Node from which to retrieve the local name. */
|
||||
/*! [in] The \b Node from which to retrieve the local name. */
|
||||
IXML_Node *nodeptr);
|
||||
|
||||
/*!
|
||||
@ -1111,7 +1111,7 @@ EXPORT_SPEC int ixmlDocument_importNode(
|
||||
* \brief Initializes a \b IXML_Element node.
|
||||
*/
|
||||
EXPORT_SPEC void ixmlElement_init(
|
||||
/*! The \b Element to initialize.*/
|
||||
/*! [in] The \b Element to initialize.*/
|
||||
IXML_Element *element);
|
||||
|
||||
|
||||
@ -1121,27 +1121,29 @@ EXPORT_SPEC void ixmlElement_init(
|
||||
* \return The name of the \b Element.
|
||||
*/
|
||||
EXPORT_SPEC const DOMString ixmlElement_getTagName(
|
||||
/*! The \b Element from which to retrieve the name. */
|
||||
/*! [in] The \b Element from which to retrieve the name. */
|
||||
IXML_Element *element);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Retrieves an attribute of an \b Element by name.
|
||||
*
|
||||
* \return The value of the attribute.
|
||||
* \return The value of the attribute, or \b NULL if that attribute
|
||||
* does not have a specified value.
|
||||
*/
|
||||
EXPORT_SPEC const DOMString ixmlElement_getAttribute(
|
||||
/*! The \b Element from which to retrieve the attribute. */
|
||||
/*! [in] The \b Element from which to retrieve the attribute. */
|
||||
IXML_Element* element,
|
||||
/*! The name of the attribute to retrieve. */
|
||||
/*! [in] The name of the attribute to retrieve. */
|
||||
const DOMString name);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Adds a new attribute to an \b Element.
|
||||
*
|
||||
* If an attribute with the same name already exists, the attribute value will
|
||||
* be updated with the new value in \b value.
|
||||
* If an attribute with the same name already exists in the element, the
|
||||
* attribute value will be updated with the new value parameter. Otherwise,
|
||||
* a new attribute is inserted into the element.
|
||||
*
|
||||
* \return An integer representing of the following:
|
||||
* \li \c IXML_SUCCESS: The operation completed successfully.
|
||||
@ -1163,7 +1165,7 @@ EXPORT_SPEC int ixmlElement_setAttribute(
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Removes an attribute by name.
|
||||
* \brief Removes an attribute value by name. The attribute node is not removed.
|
||||
*
|
||||
* \return An integer representing one of the following:
|
||||
* \li \c IXML_SUCCESS: The operation completed successfully.
|
||||
@ -1182,7 +1184,8 @@ EXPORT_SPEC int ixmlElement_removeAttribute(
|
||||
* See \b ixmlElement_getAttributeNodeNS to retrieve an attribute node using
|
||||
* a qualified name or namespace URI.
|
||||
*
|
||||
* \return A pointer to the attribute matching \b name or \c NULL on an error.
|
||||
* \return A pointer to the attribute matching \b name or \c NULL on if there
|
||||
* is no such attribute.
|
||||
*/
|
||||
EXPORT_SPEC IXML_Attr *ixmlElement_getAttributeNode(
|
||||
/*! [in] The \b Element from which to get the attribute node. */
|
||||
@ -1191,11 +1194,15 @@ EXPORT_SPEC IXML_Attr *ixmlElement_getAttributeNode(
|
||||
const DOMString name);
|
||||
|
||||
|
||||
/*!Adds a new attribute node to an \b Element. If an attribute already
|
||||
* exists with \b newAttr as a name, it will be replaced with the
|
||||
* new one and the old one will be returned in \b rtAttr.
|
||||
/*!
|
||||
* \brief Adds a new attribute node to an \b Element.
|
||||
*
|
||||
* \return An integer representing one of the following:
|
||||
* If an attribute already exists with \b newAttr as a name, it will be
|
||||
* replaced with the new one and the old one will be returned in \b rtAttr.
|
||||
*
|
||||
* \return If successfull, the replaced attribute node is returned in rtAttr,
|
||||
* otherwise, \b NULL is returned in this pointer. The function return value
|
||||
* is an integer representing one of the following:
|
||||
* \li \c IXML_SUCCESS: The operation completed successfully.
|
||||
* \li \c IXML_INVALID_PARAMETER: Either \b element or
|
||||
* \b newAttr is \c NULL.
|
||||
@ -1205,11 +1212,11 @@ EXPORT_SPEC IXML_Attr *ixmlElement_getAttributeNode(
|
||||
* an attribute of another \b Element.
|
||||
*/
|
||||
EXPORT_SPEC int ixmlElement_setAttributeNode(
|
||||
/*! The \b Element in which to add the new attribute. */
|
||||
/*! [in] The \b Element in which to add the new attribute. */
|
||||
IXML_Element *element,
|
||||
/*! The new \b Attr to add. */
|
||||
/*! [in] The new \b Attr to add. */
|
||||
IXML_Attr* newAttr,
|
||||
/*! A pointer to an \b Attr where the old \b Attr will be stored.
|
||||
/*! [out] A pointer to an \b Attr where the old \b Attr will be stored.
|
||||
* This will have a \c NULL if no prior node existed. */
|
||||
IXML_Attr** rtAttr);
|
||||
|
||||
@ -1225,11 +1232,11 @@ EXPORT_SPEC int ixmlElement_setAttributeNode(
|
||||
* attributes of \b element.
|
||||
*/
|
||||
EXPORT_SPEC int ixmlElement_removeAttributeNode(
|
||||
/*! The \b Element from which to remove the attribute. */
|
||||
/*! [in] The \b Element from which to remove the attribute. */
|
||||
IXML_Element *element,
|
||||
/*! The attribute to remove from the \b Element. */
|
||||
/*! [in] The attribute to remove from the \b Element. */
|
||||
IXML_Attr* oldAttr,
|
||||
/*! A pointer to an attribute in which to place the removed attribute. */
|
||||
/*! [out] A pointer to an attribute in which to place the removed attribute. */
|
||||
IXML_Attr** rtAttr);
|
||||
|
||||
|
||||
@ -1255,14 +1262,15 @@ EXPORT_SPEC IXML_NodeList *ixmlElement_getElementsByTagName(
|
||||
/*!
|
||||
* \brief Retrieves an attribute value using the local name and namespace URI.
|
||||
*
|
||||
* \return A \b DOMString representing the value of the matching attribute.
|
||||
* \return A \b DOMString representing the value of the matching attribute, or
|
||||
* \b NULL if that attribute does not have the specified value.
|
||||
*/
|
||||
EXPORT_SPEC const DOMString ixmlElement_getAttributeNS(
|
||||
/*! The \b Element from which to get the attribute value. */
|
||||
/*! [in] The \b Element from which to get the attribute value. */
|
||||
IXML_Element *element,
|
||||
/*! The namespace URI of the attribute. */
|
||||
/*! [in] The namespace URI of the attribute. */
|
||||
const DOMString namespaceURI,
|
||||
/*! The local name of the attribute. */
|
||||
/*! [in] The local name of the attribute. */
|
||||
const DOMString localname);
|
||||
|
||||
|
||||
@ -1289,55 +1297,63 @@ EXPORT_SPEC const DOMString ixmlElement_getAttributeNS(
|
||||
* \li \c IXML_FAILED: The operation could not be completed.
|
||||
*/
|
||||
EXPORT_SPEC int ixmlElement_setAttributeNS(
|
||||
/*! The \b Element on which to set the attribute. */
|
||||
/*! [in] The \b Element on which to set the attribute. */
|
||||
IXML_Element *element,
|
||||
/*! The namespace URI of the new attribute. */
|
||||
/*! [in] The namespace URI of the new attribute. */
|
||||
const DOMString namespaceURI,
|
||||
/*! The qualified name of the attribute. */
|
||||
/*! [in] The qualified name of the attribute. */
|
||||
const DOMString qualifiedName,
|
||||
/*! The new value for the attribute. */
|
||||
/*! [in] The new value for the attribute. */
|
||||
const DOMString value);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Removes an attribute using the namespace URI and local name.
|
||||
*
|
||||
* The replacing attribute has the same namespace URI and local name, as well
|
||||
* as the original prefix.
|
||||
*
|
||||
* \return An integer representing one of the following:
|
||||
* \li \c IXML_SUCCESS: The operation completed successfully.
|
||||
* \li \c IXML_INVALID_PARAMETER: Either \b element,
|
||||
* \b namespaceURI, or \b localName is \c NULL.
|
||||
*/
|
||||
EXPORT_SPEC int ixmlElement_removeAttributeNS(
|
||||
/*! The \b Element from which to remove the the attribute. */
|
||||
/*! [in] The \b Element from which to remove the the attribute. */
|
||||
IXML_Element *element,
|
||||
/*! The namespace URI of the attribute. */
|
||||
/*! [in] The namespace URI of the attribute. */
|
||||
const DOMString namespaceURI,
|
||||
/*! The local name of the attribute.*/
|
||||
/*! [in] The local name of the attribute.*/
|
||||
const DOMString localName);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Retrieves an \b Attr node by local name and namespace URI.
|
||||
*
|
||||
* \return A pointer to an \b Attr or \c NULL on an error.
|
||||
* \return A pointer to an \b Attribute node with the specified attribute
|
||||
* local name and namespace URI or \c NULL if there is no such attribute.
|
||||
*/
|
||||
EXPORT_SPEC IXML_Attr *ixmlElement_getAttributeNodeNS(
|
||||
/*! The \b Element from which to get the attribute. */
|
||||
/*! [in] The \b Element from which to get the attribute. */
|
||||
IXML_Element *element,
|
||||
/*! The namespace URI of the attribute. */
|
||||
/*! [in] The namespace URI of the attribute. */
|
||||
const DOMString namespaceURI,
|
||||
/*! The local name of the attribute. */
|
||||
/*! [in] The local name of the attribute. */
|
||||
const DOMString localName);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Adds a new attribute node.
|
||||
* \brief Adds a new attribute node to the element node specified.
|
||||
*
|
||||
* If an attribute with the same local name and namespace URI already exists in
|
||||
* the \b Element, the existing attribute node is replaced with \b newAttr and
|
||||
* the old returned in \b rcAttr.
|
||||
*
|
||||
* \return An integer representing one of the following:
|
||||
* \return The output parameter rcAttr receives the replaced attribute node if
|
||||
* the newAttr attribute replaces an existing attribute with the same local name
|
||||
* and namespace, otherwise rcAttr receives \b NULL.
|
||||
*
|
||||
* The function return value is an integer representing one of the following:
|
||||
* \li \c IXML_SUCCESS: The operation completed successfully.
|
||||
* \li \c IXML_INVALID_PARAMETER: Either \b element or
|
||||
* \b newAttr is \c NULL.
|
||||
@ -1347,27 +1363,29 @@ EXPORT_SPEC IXML_Attr *ixmlElement_getAttributeNodeNS(
|
||||
* attribute of another \b Element.
|
||||
*/
|
||||
EXPORT_SPEC int ixmlElement_setAttributeNodeNS(
|
||||
/*! The \b Element in which to add the attribute node. */
|
||||
/*! [in] The \b Element in which to add the attribute node. */
|
||||
IXML_Element *element,
|
||||
/*! The new \b Attr to add. */
|
||||
/*! [in] The new \b Attr to add. */
|
||||
IXML_Attr *newAttr,
|
||||
/*! A pointer to the replaced \b Attr, if it exists. */
|
||||
/*! [out] A pointer to the replaced \b Attr, if it exists. */
|
||||
IXML_Attr **rcAttr);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Returns a \b NodeList of all \em descendant \b Elements with a
|
||||
* given tag name, in the order in which they are encountered in the
|
||||
* pre-order traversal of the \b Element tree.
|
||||
* given local name and namespace in the order in which they are encountered in
|
||||
* the pre-order traversal of the \b Element tree.
|
||||
*
|
||||
* \return A \b NodeList of matching \b Elements or \c NULL on an error.
|
||||
*/
|
||||
EXPORT_SPEC IXML_NodeList *ixmlElement_getElementsByTagNameNS(
|
||||
/*! The \b Element from which to start the search. */
|
||||
/*! [in] The \b Element from which to start the search. */
|
||||
IXML_Element *element,
|
||||
/*! The namespace URI of the \b Elements to find. */
|
||||
/*! [in] The namespace URI of the \b Elements to find. The special value
|
||||
* "*" matches all namespaces. */
|
||||
const DOMString namespaceURI,
|
||||
/*! The local name of the \b Elements to find. */
|
||||
/*! [in] The local name of the \b Elements to find. The special value "*"
|
||||
* matches all local names. */
|
||||
const DOMString localName);
|
||||
|
||||
|
||||
@ -1379,9 +1397,9 @@ EXPORT_SPEC IXML_NodeList *ixmlElement_getElementsByTagNameNS(
|
||||
* default value for that attribute, otherwise \c FALSE.
|
||||
*/
|
||||
EXPORT_SPEC BOOL ixmlElement_hasAttribute(
|
||||
/*! The \b Element on which to check for an attribute. */
|
||||
/*! [in] The \b Element on which to check for an attribute. */
|
||||
IXML_Element *element,
|
||||
/*! The name of the attribute for which to check. */
|
||||
/*! [in] The name of the attribute for which to check. */
|
||||
const DOMString name);
|
||||
|
||||
|
||||
@ -1393,11 +1411,11 @@ EXPORT_SPEC BOOL ixmlElement_hasAttribute(
|
||||
* and local name or has a default value for that attribute, otherwise \c FALSE.
|
||||
*/
|
||||
EXPORT_SPEC BOOL ixmlElement_hasAttributeNS(
|
||||
/*! The \b Element on which to check for the attribute. */
|
||||
/*! [in] The \b Element on which to check for the attribute. */
|
||||
IXML_Element *element,
|
||||
/*! The namespace URI of the attribute. */
|
||||
/*! [in] The namespace URI of the attribute. */
|
||||
const DOMString namespaceURI,
|
||||
/*! The local name of the attribute. */
|
||||
/*! [in] The local name of the attribute. */
|
||||
const DOMString localName);
|
||||
|
||||
|
||||
@ -1405,7 +1423,7 @@ EXPORT_SPEC BOOL ixmlElement_hasAttributeNS(
|
||||
* \brief Frees the given \b Element and any subtree of the \b Element.
|
||||
*/
|
||||
EXPORT_SPEC void ixmlElement_free(
|
||||
/*! The \b Element to free. */
|
||||
/*! [in] The \b Element to free. */
|
||||
IXML_Element *element);
|
||||
|
||||
|
||||
@ -1431,14 +1449,15 @@ EXPORT_SPEC void ixmlElement_free(
|
||||
* \return The number of nodes in this map.
|
||||
*/
|
||||
EXPORT_SPEC unsigned long ixmlNamedNodeMap_getLength(
|
||||
/*! The \b NamedNodeMap from which to retrieve the size. */
|
||||
/*! [in] The \b NamedNodeMap from which to retrieve the size. */
|
||||
IXML_NamedNodeMap *nnMap);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Retrieves a \b Node from the \b NamedNodeMap by name.
|
||||
*
|
||||
* \return A \b Node or \c NULL if there is an error.
|
||||
* \return A Node with the specified nodeName, or \b NULL if it
|
||||
* does not identify any node in this map.
|
||||
*/
|
||||
EXPORT_SPEC IXML_Node *ixmlNamedNodeMap_getNamedItem(
|
||||
/*! [in] The \b NamedNodeMap to search. */
|
||||
@ -1474,15 +1493,16 @@ EXPORT_SPEC IXML_Node *ixmlNamedNodeMap_removeNamedItem(
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Retrieves a \b Node from a \b NamedNodeMap specified by a numerical
|
||||
* index.
|
||||
* \brief Retrieves the indexth item in the map. If index is greater than or
|
||||
* equal to the number of nodes in this map, this returns \b NULL.
|
||||
*
|
||||
* \return A pointer to the \b Node, if found, or \c NULL if it wasn't.
|
||||
* \return The node at the indexth position in the map, or \b NULL if that is
|
||||
* not a valid index.
|
||||
*/
|
||||
EXPORT_SPEC IXML_Node *ixmlNamedNodeMap_item(
|
||||
/*! The \b NamedNodeMap from which to remove the \b Node. */
|
||||
/*! [in] The \b NamedNodeMap from which to remove the \b Node. */
|
||||
IXML_NamedNodeMap *nnMap,
|
||||
/*! The index into the map to remove. */
|
||||
/*! [in] The index into the map to remove. */
|
||||
unsigned long index);
|
||||
|
||||
|
||||
@ -1540,7 +1560,7 @@ EXPORT_SPEC IXML_Node *ixmlNamedNodeMap_removeNamedItemNS(
|
||||
* The \b Nodes inside the map are not freed, just the \b NamedNodeMap object.
|
||||
*/
|
||||
EXPORT_SPEC void ixmlNamedNodeMap_free(
|
||||
/*! The \b NamedNodeMap to free. */
|
||||
/*! [in] The \b NamedNodeMap to free. */
|
||||
IXML_NamedNodeMap *nnMap);
|
||||
|
||||
|
||||
@ -1567,9 +1587,9 @@ EXPORT_SPEC void ixmlNamedNodeMap_free(
|
||||
* \return A pointer to a \b Node or \c NULL if there was an error.
|
||||
*/
|
||||
EXPORT_SPEC IXML_Node *ixmlNodeList_item(
|
||||
/*! The \b NodeList from which to retrieve the \b Node. */
|
||||
/*! [in] The \b NodeList from which to retrieve the \b Node. */
|
||||
IXML_NodeList *nList,
|
||||
/*! The index into the \b NodeList to retrieve. */
|
||||
/*! [in] The index into the \b NodeList to retrieve. */
|
||||
unsigned long index);
|
||||
|
||||
|
||||
@ -1579,7 +1599,7 @@ EXPORT_SPEC IXML_Node *ixmlNodeList_item(
|
||||
* \return The number of \b Nodes in the \b NodeList.
|
||||
*/
|
||||
EXPORT_SPEC unsigned long ixmlNodeList_length(
|
||||
/*! The \b NodeList for which to retrieve the number of \b Nodes. */
|
||||
/*! [in] The \b NodeList for which to retrieve the number of \b Nodes. */
|
||||
IXML_NodeList *nList);
|
||||
|
||||
|
||||
@ -1590,7 +1610,7 @@ EXPORT_SPEC unsigned long ixmlNodeList_length(
|
||||
* operation. This only frees the \b NodeList object.
|
||||
*/
|
||||
EXPORT_SPEC void ixmlNodeList_free(
|
||||
/*! The \b NodeList to free. */
|
||||
/*! [in] The \b NodeList to free. */
|
||||
IXML_NodeList *nList);
|
||||
|
||||
|
||||
|
@ -9,13 +9,15 @@
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*
|
||||
* \brief Auxiliar routines to aid debugging.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Prints the debug statement either on the standard output or log file
|
||||
* along with the information from where this debug statement is coming.
|
||||
**/
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
void IxmlPrintf(
|
||||
/*! [in] Printf like format specification. */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,73 +1,173 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef IXML_MEMBUF_H
|
||||
#define IXML_MEMBUF_H
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
#ifndef _IXML_MEMBUF_H
|
||||
#define _IXML_MEMBUF_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "ixml.h"
|
||||
|
||||
#define MINVAL( a, b ) ( (a) < (b) ? (a) : (b) )
|
||||
#define MAXVAL( a, b ) ( (a) > (b) ? (a) : (b) )
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define MINVAL(a, b) ( (a) < (b) ? (a) : (b) )
|
||||
#define MAXVAL(a, b) ( (a) > (b) ? (a) : (b) )
|
||||
|
||||
|
||||
#define MEMBUF_DEF_SIZE_INC 20
|
||||
|
||||
|
||||
typedef struct // ixml_membuf
|
||||
/*!
|
||||
* \brief The ixml_membuf type.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *buf;
|
||||
|
||||
size_t length;
|
||||
size_t capacity;
|
||||
size_t size_inc;
|
||||
|
||||
} ixml_membuf;
|
||||
|
||||
//--------------------------------------------------
|
||||
//////////////// functions /////////////////////////
|
||||
//--------------------------------------------------
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
*/
|
||||
|
||||
void ixml_membuf_init(INOUT ixml_membuf *m);
|
||||
void ixml_membuf_destroy(INOUT ixml_membuf *m);
|
||||
int ixml_membuf_assign(INOUT ixml_membuf *m, IN const void *buf,
|
||||
IN size_t buf_len );
|
||||
int ixml_membuf_assign_str(INOUT ixml_membuf *m, IN const char *c_str );
|
||||
int ixml_membuf_append(INOUT ixml_membuf *m, IN const void *buf);
|
||||
int ixml_membuf_append_str(INOUT ixml_membuf *m, IN const char *c_str);
|
||||
int ixml_membuf_insert(INOUT ixml_membuf *m, IN const void* buf,
|
||||
IN size_t buf_len, int index );
|
||||
/*!
|
||||
* \brief ixml_membuf initialization routine.
|
||||
*/
|
||||
void ixml_membuf_init(
|
||||
/*! [in,out] The memory buffer to initializa. */
|
||||
ixml_membuf *m);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief ixml_membuf clearing routine.
|
||||
*
|
||||
* The internal buffer is deleted and ixml_membuf_init() is called in the end
|
||||
* to reinitialize the buffer.
|
||||
*/
|
||||
void ixml_membuf_destroy(
|
||||
/*! [in,out] The memory buffer to clear. */
|
||||
ixml_membuf *m);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Copies the contents o a buffer to the designated ixml_membuf.
|
||||
*
|
||||
* The previous contents of the ixml_membuf are destroyed.
|
||||
*
|
||||
* \return IXML_SUCCESS if successfull, or the error code returned
|
||||
* by ixml_membuf_set_size().
|
||||
*
|
||||
* \sa ixml_membuf_assign_str().
|
||||
*/
|
||||
int ixml_membuf_assign(
|
||||
/*! [in,out] The memory buffer on which to operate. */
|
||||
ixml_membuf *m,
|
||||
/*! [in] The input buffer to copy from. */
|
||||
const void *buf,
|
||||
/*! [in] The number of bytes to copy from the input buffer. */
|
||||
size_t buf_len);
|
||||
|
||||
/*!
|
||||
* \brief Copies a \b NULL terminated string to the ixml_buffer.
|
||||
*
|
||||
* This is a convenience function that internally uses ixml_membuf_assign().
|
||||
*
|
||||
* \return The return value of ixml_membuf_assign().
|
||||
*
|
||||
* \sa ixml_membuf_assign().
|
||||
*/
|
||||
int ixml_membuf_assign_str(
|
||||
/*! [in,out] The memory buffer on which to operate. */
|
||||
ixml_membuf *m,
|
||||
/*! [in] The input string to copy from. */
|
||||
const char *c_str);
|
||||
|
||||
/*!
|
||||
* \brief Appends one byte to the designated ixml_membuffer.
|
||||
*
|
||||
* This is a convenience function that internally uses ixml_membuf_insert().
|
||||
*
|
||||
* \return The return value of ixml_membuf_insert().
|
||||
*
|
||||
* \sa ixml_membuf_insert()
|
||||
*/
|
||||
int ixml_membuf_append(
|
||||
/*! [in,out] The memory buffer on which to operate. */
|
||||
ixml_membuf *m,
|
||||
/*! [in] The pointer to the byte to append. */
|
||||
const void *buf);
|
||||
|
||||
/*!
|
||||
* \brief Appends the contents of a \b NULL terminated string to the designated
|
||||
* ixml_membuf.
|
||||
*
|
||||
* This is a convenience function that internally uses ixml_membuf_insert().
|
||||
*
|
||||
* \return The return value of ixml_membuf_insert().
|
||||
*
|
||||
* \sa ixml_membuf_insert().
|
||||
*/
|
||||
int ixml_membuf_append_str(
|
||||
/*! [in,out] The memory buffer on which to operate. */
|
||||
ixml_membuf *m,
|
||||
/*! [in] The input string to copy from. */
|
||||
const char *c_str);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
*
|
||||
* \return
|
||||
* \li 0 if successfull.
|
||||
* \li IXML_INDEX_SIZE_ERR if the index parameter is out of range.
|
||||
* \li Or the return code of ixml_membuf_set_size()
|
||||
*
|
||||
* \sa ixml_membuf_set_size()
|
||||
*/
|
||||
int ixml_membuf_insert(
|
||||
/*! [in,out] The memory buffer on which to operate. */
|
||||
ixml_membuf *m,
|
||||
/*! [in] The pointer to the input buffer. */
|
||||
const void *buf,
|
||||
/*! [in] The buffer length. */
|
||||
size_t buf_len,
|
||||
/*! [in] The point of insertion relative to the beggining of the
|
||||
* ixml_membuf internal buffer. */
|
||||
int index);
|
||||
|
||||
|
||||
#endif /* IXML_MEMBUF_H */
|
||||
|
||||
#endif // _IXML_MEMBUF_H
|
||||
|
@ -1,41 +1,49 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef _IXMLPARSER_H
|
||||
#define _IXMLPARSER_H
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "ixml.h"
|
||||
#include "ixmlmembuf.h"
|
||||
|
||||
// Parser definitions
|
||||
|
||||
/* Parser definitions */
|
||||
#define QUOT """
|
||||
#define LT "<"
|
||||
#define GT ">"
|
||||
@ -44,6 +52,7 @@
|
||||
#define ESC_HEX "&#x"
|
||||
#define ESC_DEC "&#"
|
||||
|
||||
|
||||
typedef struct _IXML_NamespaceURI
|
||||
{
|
||||
char *nsURI;
|
||||
@ -69,52 +78,121 @@ typedef enum
|
||||
eCONTENT,
|
||||
} PARSER_STATE;
|
||||
|
||||
|
||||
typedef struct _Parser
|
||||
{
|
||||
char *dataBuffer; //data buffer
|
||||
char *curPtr; //ptr to the token parsed
|
||||
char *savePtr; //Saves for backup
|
||||
/*! Data buffer. */
|
||||
char *dataBuffer;
|
||||
/*! Pointer to the token parsed. */
|
||||
char *curPtr;
|
||||
/*! Saves for backup. */
|
||||
char *savePtr;
|
||||
ixml_membuf lastElem;
|
||||
ixml_membuf tokenBuf;
|
||||
|
||||
IXML_Node *pNeedPrefixNode;
|
||||
IXML_ElementStack *pCurElement;
|
||||
IXML_Node *currentNodePtr;
|
||||
PARSER_STATE state;
|
||||
|
||||
BOOL bHasTopLevel;
|
||||
|
||||
} Parser;
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Check to see whether name is a valid xml name.
|
||||
*/
|
||||
BOOL Parser_isValidXmlName(
|
||||
/*! [in] The string to be checked. */
|
||||
const DOMString name);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Sets the error character.
|
||||
*
|
||||
* If 'c' is 0 (default), the parser is strict about XML encoding:
|
||||
* invalid UTF-8 sequences or "&" entities are rejected, and the parsing
|
||||
* aborts.
|
||||
*
|
||||
* If 'c' is not 0, the parser is relaxed: invalid UTF-8 characters
|
||||
* are replaced by this character, and invalid "&" entities are left
|
||||
* untranslated. The parsing is then allowed to continue.
|
||||
*/
|
||||
void Parser_setErrorChar(
|
||||
/*! [in] The character to become the error character. */
|
||||
char c);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Fees a node contents.
|
||||
*/
|
||||
void Parser_freeNodeContent(
|
||||
/*! [in] The Node to process. */
|
||||
IXML_Node *IXML_Nodeptr);
|
||||
|
||||
int Parser_LoadDocument(IXML_Document **retDoc, const char * xmlFile, BOOL file);
|
||||
|
||||
int Parser_LoadDocument( IXML_Document **retDoc, const char * xmlFile, BOOL file);
|
||||
BOOL Parser_isValidXmlName( const DOMString name);
|
||||
int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr);
|
||||
void Parser_freeNodeContent( IXML_Node *IXML_Nodeptr);
|
||||
|
||||
void Parser_setErrorChar( char c );
|
||||
|
||||
void ixmlAttr_free(IXML_Attr *attrNode);
|
||||
void ixmlAttr_init(IXML_Attr *attrNode);
|
||||
|
||||
int ixmlElement_setTagName(IXML_Element *element, const char *tagName);
|
||||
/*!
|
||||
* \brief Set the given element's tagName.
|
||||
*
|
||||
* \return One of the following:
|
||||
* \li \b IXML_SUCCESS, if successfull.
|
||||
* \li \b IXML_FAILED, if element of tagname is \b NULL.
|
||||
* \li \b IXML_INSUFFICIENT_MEMORY, if there is no memory to allocate the
|
||||
* buffer for the element's tagname.
|
||||
*/
|
||||
int ixmlElement_setTagName(
|
||||
/*! [in] The element to change the tagname. */
|
||||
IXML_Element *element,
|
||||
/*! [in] The new tagName for the element. */
|
||||
const char *tagName);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Initializes a NamedNodeMap object.
|
||||
*/
|
||||
void ixmlNamedNodeMap_init(
|
||||
/*! [in] The named node map to process. */
|
||||
IXML_NamedNodeMap *nnMap);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Add a node to a NamedNodeMap.
|
||||
*
|
||||
* \return IXML_SUCCESS or failure.
|
||||
*/
|
||||
int ixmlNamedNodeMap_addToNamedNodeMap(
|
||||
/* [in] The named node map. */
|
||||
IXML_NamedNodeMap **nnMap,
|
||||
/* [in] The node to add. */
|
||||
IXML_Node *add);
|
||||
|
||||
/*!
|
||||
* \brief Add a node to nodelist.
|
||||
*/
|
||||
int ixmlNodeList_addToNodeList(
|
||||
/*! [in] The pointer to the nodelist. */
|
||||
IXML_NodeList **nList,
|
||||
/*! [in] The node to add. */
|
||||
IXML_Node *add);
|
||||
|
||||
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap);
|
||||
int ixmlNamedNodeMap_addToNamedNodeMap(IXML_NamedNodeMap **nnMap, IXML_Node *add);
|
||||
|
||||
void ixmlNode_init(IXML_Node *IXML_Nodeptr);
|
||||
BOOL ixmlNode_compare(IXML_Node *srcIXML_Node, IXML_Node *destIXML_Node);
|
||||
|
||||
void ixmlNode_getElementsByTagName( IXML_Node *n, const char *tagname, IXML_NodeList **list);
|
||||
void ixmlNode_getElementsByTagNameNS( IXML_Node *IXML_Node, const char *namespaceURI,
|
||||
void ixmlNode_getElementsByTagName(IXML_Node *n, const char *tagname, IXML_NodeList **list);
|
||||
void ixmlNode_getElementsByTagNameNS(IXML_Node *IXML_Node, const char *namespaceURI,
|
||||
const char *localName, IXML_NodeList **list);
|
||||
|
||||
int ixmlNode_setNodeProperties(IXML_Node* node, IXML_Node *src);
|
||||
int ixmlNode_setNodeName( IXML_Node* node, const DOMString qualifiedName);
|
||||
|
||||
void ixmlNodeList_init(IXML_NodeList *nList);
|
||||
int ixmlNodeList_addToNodeList(IXML_NodeList **nList, IXML_Node *add);
|
||||
|
||||
|
||||
#endif // _IXMLPARSER_H
|
||||
|
||||
|
@ -44,12 +44,13 @@
|
||||
|
||||
|
||||
/*!
|
||||
* \todo Documentation.
|
||||
* \brief Appends a string to a buffer, substituting some characters by escape
|
||||
* sequences.
|
||||
*/
|
||||
static void copy_with_escape(
|
||||
/*! [in,out] \todo documentation. */
|
||||
/*! [in,out] The input/output buffer. */
|
||||
ixml_membuf *buf,
|
||||
/*! [in] \todo documentation. */
|
||||
/*! [in] The string to copy from. */
|
||||
const char *p)
|
||||
{
|
||||
int i;
|
||||
@ -90,6 +91,7 @@ static void copy_with_escape(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Recursive function to print all the node in a tree.
|
||||
* Internal to parser only.
|
||||
@ -193,6 +195,7 @@ static void ixmlPrintDomTreeRecursive(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Print a DOM tree.
|
||||
*
|
||||
@ -263,6 +266,7 @@ static void ixmlPrintDomTree(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Converts a DOM tree into a text string Element, and Attribute nodes
|
||||
* are handled differently. We don't want to print the Element and Attribute
|
||||
|
@ -1,5 +1,10 @@
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "autoconfig.h"
|
||||
|
||||
|
||||
@ -10,15 +15,10 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
void IxmlPrintf(
|
||||
const char *FmtStr,
|
||||
... )
|
||||
...)
|
||||
{
|
||||
va_list ArgList;
|
||||
|
||||
|
@ -1,109 +1,112 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "ixmlmembuf.h"
|
||||
#include "ixml.h"
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ixmlmembuf.h"
|
||||
#include "ixml.h"
|
||||
|
||||
/*================================================================
|
||||
* ixml_membuf_set_size
|
||||
*
|
||||
* Increases or decreases buffer cap so that at least
|
||||
* 'new_length' bytes can be stored
|
||||
*
|
||||
* On error, m's fields do not change.
|
||||
*
|
||||
* returns:
|
||||
* UPNP_E_SUCCESS
|
||||
* UPNP_E_OUTOF_MEMORY
|
||||
*
|
||||
*=================================================================*/
|
||||
static int
|
||||
ixml_membuf_set_size( INOUT ixml_membuf * m,
|
||||
IN size_t new_length )
|
||||
|
||||
/*!
|
||||
* \brief Increases or decreases buffer capacity so that at least 'new_length'
|
||||
* bytes can be stored.
|
||||
*
|
||||
* On error, m's fields do not change.
|
||||
*
|
||||
* \return
|
||||
* \li UPNP_E_SUCCESS
|
||||
* \li UPNP_E_OUTOF_MEMORY
|
||||
*/
|
||||
static int ixml_membuf_set_size(
|
||||
/*! [in,out] The memory buffer. */
|
||||
INOUT ixml_membuf *m,
|
||||
/*! [in] The new lenght. */
|
||||
IN size_t new_length)
|
||||
{
|
||||
size_t diff;
|
||||
size_t alloc_len;
|
||||
char *temp_buf;
|
||||
|
||||
if( new_length >= m->length ) // increase length
|
||||
{
|
||||
// need more mem?
|
||||
if( new_length <= m->capacity ) {
|
||||
return 0; // have enough mem; done
|
||||
if (new_length >= m->length) {
|
||||
/* increase length */
|
||||
/* need more mem? */
|
||||
if (new_length <= m->capacity) {
|
||||
/* have enough mem; done */
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff = new_length - m->length;
|
||||
alloc_len = MAXVAL( m->size_inc, diff ) + m->capacity;
|
||||
} else // decrease length
|
||||
{
|
||||
assert( new_length <= m->length );
|
||||
alloc_len = MAXVAL(m->size_inc, diff) + m->capacity;
|
||||
} else {
|
||||
// decrease length
|
||||
assert(new_length <= m->length);
|
||||
|
||||
// if diff is 0..m->size_inc, don't free
|
||||
if( ( m->capacity - new_length ) <= m->size_inc ) {
|
||||
if ((m->capacity - new_length) <= m->size_inc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
alloc_len = new_length + m->size_inc;
|
||||
}
|
||||
|
||||
assert( alloc_len >= new_length );
|
||||
assert(alloc_len >= new_length);
|
||||
|
||||
temp_buf = realloc( m->buf, alloc_len + 1 );
|
||||
if( temp_buf == NULL ) {
|
||||
// try smaller size
|
||||
temp_buf = realloc(m->buf, alloc_len + 1);
|
||||
if (temp_buf == NULL) {
|
||||
/* try smaller size */
|
||||
alloc_len = new_length;
|
||||
temp_buf = realloc( m->buf, alloc_len + 1 );
|
||||
|
||||
if( temp_buf == NULL ) {
|
||||
temp_buf = realloc(m->buf, alloc_len + 1);
|
||||
if (temp_buf == NULL) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
}
|
||||
// save
|
||||
/* save */
|
||||
m->buf = temp_buf;
|
||||
m->capacity = alloc_len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* membuffer_init
|
||||
*
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixml_membuf_init( INOUT ixml_membuf * m )
|
||||
|
||||
void ixml_membuf_init(ixml_membuf *m)
|
||||
{
|
||||
assert( m != NULL );
|
||||
assert(m != NULL);
|
||||
|
||||
m->size_inc = MEMBUF_DEF_SIZE_INC;
|
||||
m->buf = NULL;
|
||||
@ -111,126 +114,105 @@ ixml_membuf_init( INOUT ixml_membuf * m )
|
||||
m->capacity = 0;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* membuffer_destroy
|
||||
*
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixml_membuf_destroy( INOUT ixml_membuf * m )
|
||||
|
||||
void ixml_membuf_destroy(ixml_membuf *m)
|
||||
{
|
||||
if( m == NULL ) {
|
||||
if (m == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
free( m->buf );
|
||||
ixml_membuf_init( m );
|
||||
free(m->buf);
|
||||
ixml_membuf_init(m);
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixml_membuf_assign
|
||||
*
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixml_membuf_assign( INOUT ixml_membuf * m,
|
||||
IN const void *buf,
|
||||
IN size_t buf_len )
|
||||
|
||||
int ixml_membuf_assign(
|
||||
ixml_membuf *m,
|
||||
const void *buf,
|
||||
size_t buf_len)
|
||||
{
|
||||
int return_code;
|
||||
|
||||
assert( m != NULL );
|
||||
assert(m != NULL);
|
||||
|
||||
// set value to null
|
||||
if( buf == NULL ) {
|
||||
ixml_membuf_destroy( m );
|
||||
if (buf == NULL) {
|
||||
ixml_membuf_destroy(m);
|
||||
return IXML_SUCCESS;
|
||||
}
|
||||
// alloc mem
|
||||
return_code = ixml_membuf_set_size( m, buf_len );
|
||||
if( return_code != 0 ) {
|
||||
return_code = ixml_membuf_set_size(m, buf_len);
|
||||
if (return_code != 0) {
|
||||
return return_code;
|
||||
}
|
||||
// copy
|
||||
memcpy( m->buf, buf, buf_len );
|
||||
m->buf[buf_len] = 0; // null-terminate
|
||||
|
||||
// copy
|
||||
memcpy(m->buf, buf, buf_len);
|
||||
|
||||
// null-terminate
|
||||
m->buf[buf_len] = 0;
|
||||
m->length = buf_len;
|
||||
|
||||
return IXML_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixml_membuf_assign_str
|
||||
*
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixml_membuf_assign_str( INOUT ixml_membuf * m,
|
||||
IN const char *c_str )
|
||||
|
||||
int ixml_membuf_assign_str(
|
||||
ixml_membuf *m,
|
||||
const char *c_str)
|
||||
{
|
||||
return ixml_membuf_assign( m, c_str, strlen( c_str ) );
|
||||
return ixml_membuf_assign(m, c_str, strlen(c_str));
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixml_membuf_append
|
||||
*
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixml_membuf_append( INOUT ixml_membuf * m,
|
||||
IN const void *buf )
|
||||
|
||||
int ixml_membuf_append(
|
||||
INOUT ixml_membuf *m,
|
||||
IN const void *buf)
|
||||
{
|
||||
assert( m != NULL );
|
||||
assert(m != NULL);
|
||||
|
||||
return ixml_membuf_insert( m, buf, 1, m->length );
|
||||
return ixml_membuf_insert(m, buf, 1, m->length);
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixml_membuf_append_str
|
||||
*
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixml_membuf_append_str( INOUT ixml_membuf * m,
|
||||
IN const char *c_str )
|
||||
|
||||
int ixml_membuf_append_str(
|
||||
INOUT ixml_membuf *m,
|
||||
IN const char *c_str)
|
||||
{
|
||||
return ixml_membuf_insert( m, c_str, strlen( c_str ), m->length );
|
||||
return ixml_membuf_insert(m, c_str, strlen(c_str), m->length);
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixml_membuf_insert
|
||||
*
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixml_membuf_insert( INOUT ixml_membuf * m,
|
||||
|
||||
int ixml_membuf_insert(
|
||||
INOUT ixml_membuf *m,
|
||||
IN const void *buf,
|
||||
IN size_t buf_len,
|
||||
int index )
|
||||
int index)
|
||||
{
|
||||
int return_code;
|
||||
int return_code = 0;
|
||||
|
||||
assert( m != NULL );
|
||||
assert(m != NULL);
|
||||
|
||||
if( index < 0 || index > ( int )m->length )
|
||||
if (index < 0 || index > (int)m->length) {
|
||||
return IXML_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
if( buf == NULL || buf_len == 0 ) {
|
||||
if (buf == NULL || buf_len == 0) {
|
||||
return 0;
|
||||
}
|
||||
// alloc mem
|
||||
return_code = ixml_membuf_set_size( m, m->length + buf_len );
|
||||
if( return_code != 0 ) {
|
||||
/* alloc mem */
|
||||
return_code = ixml_membuf_set_size(m, m->length + buf_len);
|
||||
if (return_code != 0) {
|
||||
return return_code;
|
||||
}
|
||||
// insert data
|
||||
// move data to right of insertion point
|
||||
memmove( m->buf + index + buf_len, m->buf + index, m->length - index );
|
||||
memcpy( m->buf + index, buf, buf_len );
|
||||
/* insert data */
|
||||
/* move data to right of insertion point */
|
||||
memmove(m->buf + index + buf_len, m->buf + index, m->length - index);
|
||||
memcpy(m->buf + index, buf, buf_len);
|
||||
m->length += buf_len;
|
||||
m->buf[m->length] = 0; // null-terminate
|
||||
/* Null terminate */
|
||||
m->buf[m->length] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -30,6 +30,11 @@
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "ixmlparser.h"
|
||||
|
||||
|
||||
@ -37,32 +42,28 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*================================================================
|
||||
* NamedNodeMap_getItemNumber
|
||||
* return the item number of a item in NamedNodeMap.
|
||||
* Internal to parser only.
|
||||
* Parameters:
|
||||
* name: the name of the item to find
|
||||
*
|
||||
*=================================================================*/
|
||||
unsigned long
|
||||
ixmlNamedNodeMap_getItemNumber( IN IXML_NamedNodeMap * nnMap,
|
||||
IN const char *name )
|
||||
/*!
|
||||
* \brief Return the item number of a item in NamedNodeMap.
|
||||
*/
|
||||
static unsigned long ixmlNamedNodeMap_getItemNumber(
|
||||
/*! [in] The named node map to process. */
|
||||
IN IXML_NamedNodeMap *nnMap,
|
||||
/*! [in] The name of the item to find. */
|
||||
IN const char *name)
|
||||
{
|
||||
IXML_Node *tempNode;
|
||||
unsigned long returnItemNo = 0;
|
||||
|
||||
assert( nnMap != NULL && name != NULL );
|
||||
if( ( nnMap == NULL ) || ( name == NULL ) ) {
|
||||
assert(nnMap != NULL && name != NULL);
|
||||
if (nnMap == NULL || name == NULL) {
|
||||
return IXML_INVALID_ITEM_NUMBER;
|
||||
}
|
||||
|
||||
tempNode = nnMap->nodeItem;
|
||||
while( tempNode != NULL ) {
|
||||
if( strcmp( name, tempNode->nodeName ) == 0 ) {
|
||||
while (tempNode != NULL) {
|
||||
if (strcmp(name, tempNode->nodeName) == 0) {
|
||||
return returnItemNo;
|
||||
}
|
||||
|
||||
tempNode = tempNode->nextSibling;
|
||||
returnItemNo++;
|
||||
}
|
||||
@ -70,173 +71,117 @@ ixmlNamedNodeMap_getItemNumber( IN IXML_NamedNodeMap * nnMap,
|
||||
return IXML_INVALID_ITEM_NUMBER;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* NamedNodeMap_init
|
||||
* Initializes a NamedNodeMap object.
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNamedNodeMap_init( IN IXML_NamedNodeMap * nnMap )
|
||||
|
||||
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap)
|
||||
{
|
||||
assert( nnMap != NULL );
|
||||
memset( nnMap, 0, sizeof( IXML_NamedNodeMap ) );
|
||||
assert(nnMap != NULL);
|
||||
|
||||
memset(nnMap, 0, sizeof (IXML_NamedNodeMap));
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* NamedNodeMap_getNamedItem
|
||||
* Retrieves a node specified by name.
|
||||
* External function.
|
||||
*
|
||||
* Parameter:
|
||||
* name: type nodeName of a node to retrieve.
|
||||
*
|
||||
* Return Value:
|
||||
* A Node with the specified nodeName, or null if it
|
||||
* does not identify any node in this map.
|
||||
*
|
||||
*=================================================================*/
|
||||
IXML_Node *
|
||||
ixmlNamedNodeMap_getNamedItem(IXML_NamedNodeMap *nnMap,
|
||||
|
||||
IXML_Node *ixmlNamedNodeMap_getNamedItem(
|
||||
IXML_NamedNodeMap *nnMap,
|
||||
const DOMString name)
|
||||
{
|
||||
long index;
|
||||
|
||||
if( ( nnMap == NULL ) || ( name == NULL ) ) {
|
||||
if (nnMap == NULL || name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
index = ixmlNamedNodeMap_getItemNumber( nnMap, name );
|
||||
if( index == IXML_INVALID_ITEM_NUMBER ) {
|
||||
index = ixmlNamedNodeMap_getItemNumber(nnMap, name);
|
||||
if (index == IXML_INVALID_ITEM_NUMBER) {
|
||||
return NULL;
|
||||
} else {
|
||||
return ( ixmlNamedNodeMap_item( nnMap, ( unsigned long )index ) );
|
||||
return ixmlNamedNodeMap_item(nnMap, (unsigned long)index);
|
||||
}
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* NamedNodeMap_item
|
||||
* Returns the indexth item in the map. If index is greater than or
|
||||
* equal to the number of nodes in this map, this returns null.
|
||||
* External function.
|
||||
*
|
||||
* Parameter:
|
||||
* index: index into this map.
|
||||
*
|
||||
* Return Value:
|
||||
* The node at the indexth position in the map, or null if that is
|
||||
* not a valid index.
|
||||
*
|
||||
*=================================================================*/
|
||||
IXML_Node *
|
||||
ixmlNamedNodeMap_item( IN IXML_NamedNodeMap * nnMap,
|
||||
|
||||
IXML_Node *ixmlNamedNodeMap_item(
|
||||
IN IXML_NamedNodeMap *nnMap,
|
||||
IN unsigned long index )
|
||||
{
|
||||
IXML_Node *tempNode;
|
||||
unsigned int i;
|
||||
|
||||
if( nnMap == NULL ) {
|
||||
if (nnMap == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( index > ixmlNamedNodeMap_getLength( nnMap ) - 1 ) {
|
||||
if (index > ixmlNamedNodeMap_getLength(nnMap) - 1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tempNode = nnMap->nodeItem;
|
||||
for( i = 0; i < index && tempNode != NULL; ++i ) {
|
||||
for (i = 0; i < index && tempNode != NULL; ++i) {
|
||||
tempNode = tempNode->nextSibling;
|
||||
}
|
||||
|
||||
return tempNode;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* NamedNodeMap_getLength
|
||||
* Return the number of Nodes in this map.
|
||||
* External function.
|
||||
*
|
||||
* Parameters:
|
||||
*
|
||||
*=================================================================*/
|
||||
unsigned long
|
||||
ixmlNamedNodeMap_getLength( IN IXML_NamedNodeMap * nnMap )
|
||||
|
||||
unsigned long ixmlNamedNodeMap_getLength(IXML_NamedNodeMap *nnMap)
|
||||
{
|
||||
IXML_Node *tempNode;
|
||||
unsigned long length = 0;
|
||||
|
||||
if( nnMap != NULL ) {
|
||||
if (nnMap != NULL) {
|
||||
tempNode = nnMap->nodeItem;
|
||||
for( length = 0; tempNode != NULL; ++length ) {
|
||||
for (length = 0; tempNode != NULL; ++length) {
|
||||
tempNode = tempNode->nextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNamedNodeMap_free
|
||||
* frees a NamedNodeMap.
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNamedNodeMap_free( IXML_NamedNodeMap * nnMap )
|
||||
|
||||
void ixmlNamedNodeMap_free(IXML_NamedNodeMap *nnMap)
|
||||
{
|
||||
IXML_NamedNodeMap *pNext;
|
||||
|
||||
while( nnMap != NULL ) {
|
||||
while (nnMap != NULL) {
|
||||
pNext = nnMap->next;
|
||||
free( nnMap );
|
||||
free(nnMap);
|
||||
nnMap = pNext;
|
||||
}
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* NamedNodeMap_addToNamedNodeMap
|
||||
* add a node to a NamedNodeMap.
|
||||
* Internal to parser only.
|
||||
* Parameters:
|
||||
* add: the node to add into NamedNodeMap.
|
||||
* Return:
|
||||
* IXML_SUCCESS or failure.
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNamedNodeMap_addToNamedNodeMap( IN IXML_NamedNodeMap ** nnMap,
|
||||
IN IXML_Node * add )
|
||||
|
||||
int ixmlNamedNodeMap_addToNamedNodeMap(
|
||||
IXML_NamedNodeMap **nnMap,
|
||||
IXML_Node *add)
|
||||
{
|
||||
IXML_NamedNodeMap *traverse = NULL,
|
||||
*p = NULL;
|
||||
IXML_NamedNodeMap *traverse = NULL;
|
||||
IXML_NamedNodeMap *p = NULL;
|
||||
IXML_NamedNodeMap *newItem = NULL;
|
||||
|
||||
if( add == NULL ) {
|
||||
if(add == NULL) {
|
||||
return IXML_SUCCESS;
|
||||
}
|
||||
|
||||
if( *nnMap == NULL ) // nodelist is empty
|
||||
{
|
||||
*nnMap =
|
||||
( IXML_NamedNodeMap * ) malloc( sizeof( IXML_NamedNodeMap ) );
|
||||
if( *nnMap == NULL ) {
|
||||
if (*nnMap == NULL) {
|
||||
// nodelist is empty
|
||||
*nnMap = (IXML_NamedNodeMap *)malloc(sizeof (IXML_NamedNodeMap));
|
||||
if (*nnMap == NULL) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
ixmlNamedNodeMap_init( *nnMap );
|
||||
ixmlNamedNodeMap_init(*nnMap);
|
||||
}
|
||||
|
||||
if( ( *nnMap )->nodeItem == NULL ) {
|
||||
( *nnMap )->nodeItem = add;
|
||||
if ((*nnMap)->nodeItem == NULL) {
|
||||
(*nnMap)->nodeItem = add;
|
||||
} else {
|
||||
traverse = *nnMap;
|
||||
p = traverse;
|
||||
while( traverse != NULL ) {
|
||||
while (traverse != NULL) {
|
||||
p = traverse;
|
||||
traverse = traverse->next;
|
||||
}
|
||||
|
||||
newItem =
|
||||
( IXML_NamedNodeMap * ) malloc( sizeof( IXML_NamedNodeMap ) );
|
||||
if( newItem == NULL ) {
|
||||
newItem = (IXML_NamedNodeMap *)malloc(sizeof (IXML_NamedNodeMap));
|
||||
if (newItem == NULL) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
p->next = newItem;
|
||||
@ -246,3 +191,4 @@ ixmlNamedNodeMap_addToNamedNodeMap( IN IXML_NamedNodeMap ** nnMap,
|
||||
|
||||
return IXML_SUCCESS;
|
||||
}
|
||||
|
||||
|
148
ixml/src/node.c
148
ixml/src/node.c
@ -30,6 +30,11 @@
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "ixmlparser.h"
|
||||
|
||||
|
||||
@ -63,28 +68,21 @@ ixmlCDATASection_init( IN IXML_CDATASection * nodeptr )
|
||||
memset( nodeptr, 0, sizeof( IXML_CDATASection ) );
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlCDATASection_free
|
||||
* frees a CDATASection node.
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlCDATASection_free( IN IXML_CDATASection * nodeptr )
|
||||
|
||||
void ixmlCDATASection_free(IXML_CDATASection *nodeptr)
|
||||
{
|
||||
if( nodeptr != NULL ) {
|
||||
ixmlNode_free( ( IXML_Node * ) nodeptr );
|
||||
}
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNode_freeSingleNode
|
||||
* frees a node content.
|
||||
* Internal to parser only.
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNode_freeSingleNode( IN IXML_Node * nodeptr )
|
||||
|
||||
/*!
|
||||
* \brief Frees a node content.
|
||||
*/
|
||||
static void ixmlNode_freeSingleNode(
|
||||
/*! [in] The node to free. */
|
||||
IXML_Node *nodeptr)
|
||||
{
|
||||
IXML_Element *element = NULL;
|
||||
|
||||
@ -119,34 +117,20 @@ ixmlNode_freeSingleNode( IN IXML_Node * nodeptr )
|
||||
}
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNode_free
|
||||
* Frees all nodes under nodeptr subtree.
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNode_free( IN IXML_Node * nodeptr )
|
||||
{
|
||||
if( nodeptr != NULL ) {
|
||||
ixmlNode_free( nodeptr->firstChild );
|
||||
ixmlNode_free( nodeptr->nextSibling );
|
||||
ixmlNode_free( nodeptr->firstAttr );
|
||||
|
||||
ixmlNode_freeSingleNode( nodeptr );
|
||||
void ixmlNode_free(IXML_Node *nodeptr)
|
||||
{
|
||||
if (nodeptr != NULL) {
|
||||
ixmlNode_free(nodeptr->firstChild);
|
||||
ixmlNode_free(nodeptr->nextSibling);
|
||||
ixmlNode_free(nodeptr->firstAttr);
|
||||
ixmlNode_freeSingleNode(nodeptr);
|
||||
}
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNode_getNodeName
|
||||
* Returns the nodename(the qualified name)
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
const DOMString
|
||||
ixmlNode_getNodeName( IN IXML_Node * nodeptr )
|
||||
{
|
||||
|
||||
const DOMString ixmlNode_getNodeName(IXML_Node *nodeptr)
|
||||
{
|
||||
if( nodeptr != NULL ) {
|
||||
return ( nodeptr->nodeName );
|
||||
}
|
||||
@ -154,34 +138,24 @@ ixmlNode_getNodeName( IN IXML_Node * nodeptr )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNode_getLocalName
|
||||
* Returns the node local name
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
const DOMString
|
||||
ixmlNode_getLocalName( IN IXML_Node * nodeptr )
|
||||
{
|
||||
|
||||
if( nodeptr != NULL ) {
|
||||
return ( nodeptr->localName );
|
||||
const DOMString ixmlNode_getLocalName(IXML_Node *nodeptr)
|
||||
{
|
||||
if (nodeptr != NULL) {
|
||||
return nodeptr->localName;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNode_setNamespaceURI
|
||||
* sets the namespace URI of the node.
|
||||
* Internal function.
|
||||
* Return:
|
||||
* IXML_SUCCESS or failure
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNode_setNamespaceURI( IN IXML_Node * nodeptr,
|
||||
IN const char *namespaceURI )
|
||||
/*!
|
||||
* \brief Sets the namespace URI of the node.
|
||||
*/
|
||||
static int ixmlNode_setNamespaceURI(
|
||||
/*! [in] . */
|
||||
IN IXML_Node *nodeptr,
|
||||
/*! [in] . */
|
||||
IN const char *namespaceURI)
|
||||
{
|
||||
|
||||
if( nodeptr == NULL ) {
|
||||
@ -203,50 +177,44 @@ ixmlNode_setNamespaceURI( IN IXML_Node * nodeptr,
|
||||
return IXML_SUCCESS;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNode_setPrefix
|
||||
* set the prefix of the node.
|
||||
* Internal to parser only.
|
||||
* Returns:
|
||||
* IXML_SUCCESS or failure.
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNode_setPrefix( IN IXML_Node * nodeptr,
|
||||
IN const char *prefix )
|
||||
|
||||
/*
|
||||
* \brief Set the prefix of the node.
|
||||
*/
|
||||
int ixmlNode_setPrefix(
|
||||
IN IXML_Node *nodeptr,
|
||||
IN const char *prefix)
|
||||
{
|
||||
|
||||
if( nodeptr == NULL ) {
|
||||
if (nodeptr == NULL) {
|
||||
return IXML_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if( nodeptr->prefix != NULL ) {
|
||||
free( nodeptr->prefix );
|
||||
if (nodeptr->prefix != NULL) {
|
||||
free(nodeptr->prefix);
|
||||
nodeptr->prefix = NULL;
|
||||
}
|
||||
|
||||
if( prefix != NULL ) {
|
||||
nodeptr->prefix = strdup( prefix );
|
||||
if( nodeptr->prefix == NULL ) {
|
||||
if (prefix != NULL) {
|
||||
nodeptr->prefix = strdup(prefix);
|
||||
if(nodeptr->prefix == NULL) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return IXML_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNode_setLocalName
|
||||
* set the localName of the node.
|
||||
* Internal to parser only.
|
||||
* Returns:
|
||||
* IXML_SUCCESS or failure.
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNode_setLocalName( IN IXML_Node * nodeptr,
|
||||
IN const char *localName )
|
||||
/*!
|
||||
* \brief Set the localName of the node.
|
||||
*
|
||||
* \return IXML_SUCCESS or failure.
|
||||
*/
|
||||
static int ixmlNode_setLocalName(
|
||||
/*! [in] The pointer to the node. */
|
||||
IN IXML_Node *nodeptr,
|
||||
/*! [in] The local name to set. */
|
||||
IN const char *localName)
|
||||
{
|
||||
|
||||
assert( nodeptr != NULL );
|
||||
|
@ -30,6 +30,11 @@
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "ixmlparser.h"
|
||||
|
||||
|
||||
@ -37,98 +42,80 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*================================================================
|
||||
* ixmlNodeList_init
|
||||
* initializes a nodelist
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNodeList_init( IXML_NodeList * nList )
|
||||
/*!
|
||||
* \brief Initializes a nodelist
|
||||
*/
|
||||
void ixmlNodeList_init(IXML_NodeList *nList)
|
||||
{
|
||||
assert( nList != NULL );
|
||||
|
||||
memset( nList, 0, sizeof( IXML_NodeList ) );
|
||||
assert(nList != NULL);
|
||||
|
||||
memset(nList, 0, sizeof (IXML_NodeList));
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNodeList_item
|
||||
* Returns the indexth item in the collection. If index is greater
|
||||
* than or equal to the number of nodes in the list, this returns
|
||||
* null.
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
IXML_Node *
|
||||
ixmlNodeList_item( IXML_NodeList * nList,
|
||||
unsigned long index )
|
||||
|
||||
IXML_Node *ixmlNodeList_item(
|
||||
IXML_NodeList *nList,
|
||||
unsigned long index)
|
||||
{
|
||||
IXML_NodeList *next;
|
||||
unsigned int i;
|
||||
|
||||
// if the list ptr is NULL
|
||||
if( nList == NULL ) {
|
||||
if (nList == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
// if index is more than list length
|
||||
if( index > ixmlNodeList_length( nList ) - 1 ) {
|
||||
if (index > ixmlNodeList_length(nList) - 1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
next = nList;
|
||||
for( i = 0; i < index && next != NULL; ++i ) {
|
||||
for (i = 0; i < index && next != NULL; ++i) {
|
||||
next = next->next;
|
||||
}
|
||||
|
||||
if( next == NULL ) return NULL;
|
||||
if (next == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return next->nodeItem;
|
||||
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNodeList_addToNodeList
|
||||
* Add a node to nodelist
|
||||
* Internal to parser only.
|
||||
*
|
||||
*=================================================================*/
|
||||
int
|
||||
ixmlNodeList_addToNodeList( IN IXML_NodeList ** nList,
|
||||
IN IXML_Node * add )
|
||||
int ixmlNodeList_addToNodeList(
|
||||
IXML_NodeList **nList,
|
||||
IXML_Node *add)
|
||||
{
|
||||
IXML_NodeList *traverse,
|
||||
*p = NULL;
|
||||
IXML_NodeList *traverse = NULL;
|
||||
IXML_NodeList *p = NULL;
|
||||
IXML_NodeList *newListItem;
|
||||
|
||||
assert( add != NULL );
|
||||
assert(add != NULL);
|
||||
|
||||
if( add == NULL ) {
|
||||
if (add == NULL) {
|
||||
return IXML_FAILED;
|
||||
}
|
||||
|
||||
if( *nList == NULL ) // nodelist is empty
|
||||
{
|
||||
*nList = ( IXML_NodeList * ) malloc( sizeof( IXML_NodeList ) );
|
||||
if( *nList == NULL ) {
|
||||
if (*nList == NULL) {
|
||||
// nodelist is empty
|
||||
*nList = (IXML_NodeList *)malloc(sizeof (IXML_NodeList));
|
||||
if (*nList == NULL) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
|
||||
ixmlNodeList_init( *nList );
|
||||
ixmlNodeList_init(*nList);
|
||||
}
|
||||
|
||||
if( ( *nList )->nodeItem == NULL ) {
|
||||
( *nList )->nodeItem = add;
|
||||
if ((*nList)->nodeItem == NULL) {
|
||||
(*nList)->nodeItem = add;
|
||||
} else {
|
||||
traverse = *nList;
|
||||
while( traverse != NULL ) {
|
||||
while (traverse != NULL) {
|
||||
p = traverse;
|
||||
traverse = traverse->next;
|
||||
}
|
||||
|
||||
newListItem =
|
||||
( IXML_NodeList * ) malloc( sizeof( IXML_NodeList ) );
|
||||
if( newListItem == NULL ) {
|
||||
newListItem = (IXML_NodeList *)malloc(sizeof (IXML_NodeList));
|
||||
if (newListItem == NULL) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
}
|
||||
p->next = newListItem;
|
||||
@ -139,21 +126,14 @@ ixmlNodeList_addToNodeList( IN IXML_NodeList ** nList,
|
||||
return IXML_SUCCESS;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNodeList_length
|
||||
* Returns the number of nodes in the list. The range of valid
|
||||
* child node indices is 0 to length-1 inclusive.
|
||||
* External function.
|
||||
*
|
||||
*=================================================================*/
|
||||
unsigned long
|
||||
ixmlNodeList_length( IN IXML_NodeList * nList )
|
||||
|
||||
unsigned long ixmlNodeList_length(IXML_NodeList *nList)
|
||||
{
|
||||
IXML_NodeList *list;
|
||||
unsigned long length = 0;
|
||||
|
||||
list = nList;
|
||||
while( list != NULL ) {
|
||||
while (list != NULL) {
|
||||
++length;
|
||||
list = list->next;
|
||||
}
|
||||
@ -161,22 +141,15 @@ ixmlNodeList_length( IN IXML_NodeList * nList )
|
||||
return length;
|
||||
}
|
||||
|
||||
/*================================================================
|
||||
* ixmlNodeList_free
|
||||
* frees a nodeList
|
||||
* External function
|
||||
*
|
||||
*=================================================================*/
|
||||
void
|
||||
ixmlNodeList_free( IN IXML_NodeList * nList )
|
||||
|
||||
void ixmlNodeList_free(IXML_NodeList *nList)
|
||||
{
|
||||
IXML_NodeList *next;
|
||||
|
||||
while( nList != NULL ) {
|
||||
while (nList != NULL) {
|
||||
next = nList->next;
|
||||
|
||||
free( nList );
|
||||
free(nList);
|
||||
nList = next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user