libUPnP 22.1.2
ixmlparser.h
Go to the documentation of this file.
1/**************************************************************************
2 *
3 * Copyright (c) 2000-2003 Intel Corporation
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * - Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * - Neither name of Intel Corporation nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 **************************************************************************/
31
32#ifndef IXMLPARSER_H
33#define IXMLPARSER_H
34
38
39#include "ixml.h"
40#include "ixmlmembuf.h"
41
42/* Parser definitions */
43#define QUOT """
44#define LT "<"
45#define GT ">"
46#define APOS "'"
47#define AMP "&"
48#define ESC_HEX "&#x"
49#define ESC_DEC "&#"
50
54#define IXML_MAX_ATTRIBUTES 256
55
59#define IXML_MAX_NAMESPACES 256
60
61typedef struct _IXML_NamespaceURI
62{
63 char *nsURI;
64 char *prefix;
65 struct _IXML_NamespaceURI *nextNsURI;
66} IXML_NamespaceURI;
67
68typedef struct _IXML_ElementStack
69{
70 char *element;
71 char *prefix;
72 char *namespaceUri;
73 IXML_NamespaceURI *pNsURI;
74 struct _IXML_ElementStack *nextElement;
87} IXML_ElementStack;
88
89typedef enum
90{
91 eELEMENT,
92 eATTRIBUTE,
93 eCONTENT
94} PARSER_STATE;
95
96typedef struct _Parser
97{
101 char *curPtr;
103 char *savePtr;
104 ixml_membuf lastElem;
105 ixml_membuf tokenBuf;
106 IXML_Node *pNeedPrefixNode;
107 IXML_ElementStack *pCurElement;
108 IXML_Node *currentNodePtr;
113 PARSER_STATE state;
114 int bHasTopLevel;
115} Parser;
116
122 const DOMString name);
123
137 char c);
138
139#ifdef IXML_HAVE_SCRIPTSUPPORT
148void Parser_setBeforeFree(
150 IXML_BeforeFreeNode_t handler);
151
155IXML_BeforeFreeNode_t Parser_getBeforeFree(void);
156#endif
157
163 IXML_Node *IXML_Nodeptr);
164
165int Parser_LoadDocument(IXML_Document **retDoc, const char *xmlFile, int file);
166
167int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr);
168
169void ixmlAttr_init(IXML_Attr *attrNode);
170
182 IXML_Element *element,
184 const char *tagName);
185
191 IXML_NamedNodeMap *nnMap);
192
199 /* [in] The named node map. */
200 IXML_NamedNodeMap **nnMap,
201 /* [in] The node to add. */
202 IXML_Node *add);
203
209 IXML_NodeList **nList,
211 IXML_Node *add);
212
216void ixmlNode_init(
218 IXML_Node *nodeptr);
219
230 const IXML_Node *srcNode,
232 const IXML_Node *destNode);
233
241 IXML_Node *n,
243 const char *tagname,
245 IXML_NodeList **list);
246
254 IXML_Node *n,
256 const char *namespaceURI,
258 const char *localName,
260 IXML_NodeList **list);
261
269 IXML_Node *node,
271 const DOMString qualifiedName);
272
280 IXML_Node *destNode,
282 IXML_Node *src);
283
295 IXML_Node *nodeptr,
297 IXML_Node *newChild,
299 IXML_Node *lastChild);
300
306 IXML_NodeList *nList);
307
308#endif /* IXMLPARSER_H */
struct _IXML_Node IXML_Node
Data structure common to all types of nodes.
struct _IXML_NodeList IXML_NodeList
Data structure representing a list of nodes.
#define DOMString
The type of DOM strings.
Definition ixml.h:48
struct _IXML_Document IXML_Document
Data structure representing the DOM Document.
struct _IXML_ATTR IXML_Attr
Data structure representing an Attribute node.
struct _IXML_NamedNodeMap IXML_NamedNodeMap
Data structure representing a list of named nodes.
struct _IXML_Element IXML_Element
Data structure representing an Element node.
int ixmlNodeList_addToNodeList(IXML_NodeList **nList, IXML_Node *add)
Add a node to nodelist.
Definition nodeList.c:77
int ixmlNode_appendChildAfter(IXML_Node *nodeptr, IXML_Node *newChild, IXML_Node *lastChild)
Same as ixmlNode_appendChild(), but in constant time when the caller knows the current last child of ...
Definition node.c:666
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap)
Initializes a NamedNodeMap object.
Definition namedNodeMap.c:73
int ixmlNode_setNodeProperties(IXML_Node *destNode, IXML_Node *src)
Definition node.c:1392
void ixmlNode_getElementsByTagName(IXML_Node *n, const char *tagname, IXML_NodeList **list)
Returns a nodeList of all descendant Elements with a given tagName, in the order in which they are en...
Definition node.c:1279
void ixmlNode_init(IXML_Node *nodeptr)
Initializes a node.
Definition node.c:46
int ixmlNode_setNodeName(IXML_Node *node, const DOMString qualifiedName)
Definition node.c:1367
void ixmlNodeList_init(IXML_NodeList *nList)
Initializes a nodelist.
Definition nodeList.c:44
void Parser_freeNodeContent(IXML_Node *IXML_Nodeptr)
Fees a node contents.
Definition ixmlparser.c:2924
int ixmlElement_setTagName(IXML_Element *element, const char *tagName)
Set the given element's tagName.
Definition element.c:70
int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr)
Set the node prefix and localName as defined by the nodeName in the form of ns:name.
Definition ixmlparser.c:2955
int Parser_LoadDocument(IXML_Document **retDoc, const char *xmlFile, int file)
Parses a xml file and return the DOM tree.
Definition ixmlparser.c:2895
void Parser_setErrorChar(char c)
Sets the error character.
Definition ixmlparser.c:2798
int ixmlNamedNodeMap_addToNamedNodeMap(IXML_NamedNodeMap **nnMap, IXML_Node *add)
Add a node to a NamedNodeMap.
Definition namedNodeMap.c:146
int ixmlNode_compare(const IXML_Node *srcNode, const IXML_Node *destNode)
Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignore...
Definition node.c:530
int Parser_isValidXmlName(const DOMString name)
Check to see whether name is a valid xml name.
Definition ixmlparser.c:2776
void ixmlNode_getElementsByTagNameNS(IXML_Node *n, const char *namespaceURI, const char *localName, IXML_NodeList **list)
Returns a nodeList of all the descendant Elements with a given local name and namespace URI in the or...
Definition node.c:1341
Definition ixmlparser.h:69
struct _IXML_ElementStack * nsScopeElement
Definition ixmlparser.h:84
int prefixInherited
Definition ixmlparser.h:82
struct _IXML_ElementStack * defaultNsElement
Definition ixmlparser.h:77
int numNsURI
Definition ixmlparser.h:79
int nsInScope
Definition ixmlparser.h:86
Definition ixmlparser.h:62
Definition ixmlparser.h:97
int numAttributes
Definition ixmlparser.h:112
IXML_Node * lastChild
Definition ixmlparser.h:110
char * curPtr
Definition ixmlparser.h:101
char * dataBuffer
Definition ixmlparser.h:99
char * savePtr
Definition ixmlparser.h:103
The ixml_membuf type.
Definition ixmlmembuf.h:53