libUPnP  1.6.22
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 
33 #ifndef IXMLPARSER_H
34 #define IXMLPARSER_H
35 
36 
42 #include "autoconfig.h"
43 
44 #include "ixml.h"
45 #include "ixmlmembuf.h"
46 
47 
48 /* Parser definitions */
49 #define QUOT """
50 #define LT "<"
51 #define GT ">"
52 #define APOS "'"
53 #define AMP "&"
54 #define ESC_HEX "&#x"
55 #define ESC_DEC "&#"
56 
57 
58 typedef struct _IXML_NamespaceURI
59 {
60  char *nsURI;
61  char *prefix;
62  struct _IXML_NamespaceURI *nextNsURI;
64 
65 
66 typedef struct _IXML_ElementStack
67 {
68  char *element;
69  char *prefix;
70  char *namespaceUri;
71  IXML_NamespaceURI *pNsURI;
72  struct _IXML_ElementStack *nextElement;
74 
75 
76 typedef enum
77 {
78  eELEMENT,
79  eATTRIBUTE,
80  eCONTENT,
81 } PARSER_STATE;
82 
83 
84 typedef struct _Parser
85 {
87  char *dataBuffer;
89  char *curPtr;
91  char *savePtr;
92  ixml_membuf lastElem;
93  ixml_membuf tokenBuf;
94  IXML_Node *pNeedPrefixNode;
95  IXML_ElementStack *pCurElement;
96  IXML_Node *currentNodePtr;
97  PARSER_STATE state;
98  BOOL bHasTopLevel;
99 } Parser;
100 
101 
107  const DOMString name);
108 
109 
123  char c);
124 
125 
131  IXML_Node *IXML_Nodeptr);
132 
133 int Parser_LoadDocument(IXML_Document **retDoc, const char * xmlFile, BOOL file);
134 
135 int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr);
136 
137 
138 void ixmlAttr_init(IXML_Attr *attrNode);
139 
151  IXML_Element *element,
153  const char *tagName);
154 
155 
161  IXML_NamedNodeMap *nnMap);
162 
163 
170  /* [in] The named node map. */
171  IXML_NamedNodeMap **nnMap,
172  /* [in] The node to add. */
173  IXML_Node *add);
174 
180  IXML_NodeList **nList,
182  IXML_Node *add);
183 
184 
188 void ixmlNode_init(
190  IN IXML_Node *nodeptr);
191 
192 
201 BOOL ixmlNode_compare(
203  IXML_Node *srcNode,
205  IXML_Node *destNode);
206 
207 
215  IXML_Node *n,
217  const char *tagname,
219  IXML_NodeList **list);
220 
221 
229  IXML_Node *n,
231  const char *namespaceURI,
233  const char *localName,
235  IXML_NodeList **list);
236 
237 
245  IXML_Node *node,
247  const DOMString qualifiedName);
248 
249 
257  IXML_Node *destNode,
259  IXML_Node *src);
260 
261 
265 void ixmlNodeList_init(
267  IXML_NodeList *nList);
268 
269 
270 #endif /* IXMLPARSER_H */
271 
char * savePtr
Definition: ixmlparser.h:91
int ixmlNode_setNodeProperties(IXML_Node *destNode, IXML_Node *src)
Definition: node.c:1336
char * dataBuffer
Definition: ixmlparser.h:87
Definition: ixmlparser.h:58
void ixmlNode_init(IN IXML_Node *nodeptr)
Intializes a node.
int Parser_LoadDocument(IXML_Document **retDoc, const char *xmlFile, BOOL file)
Parses a xml file and return the DOM tree.
Definition: ixmlparser.c:2581
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:1222
BOOL ixmlNode_compare(IXML_Node *srcNode, IXML_Node *destNode)
Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignore...
Definition: node.c:466
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap)
Initializes a NamedNodeMap object.
Definition: namedNodeMap.c:77
void Parser_freeNodeContent(IXML_Node *IXML_Nodeptr)
Fees a node contents.
Definition: ixmlparser.c:2612
Definition: ixmlparser.h:84
int ixmlElement_setTagName(IXML_Element *element, const char *tagName)
Set the given element's tagName.
Definition: element.c:64
int ixmlNode_setNodeName(IXML_Node *node, const DOMString qualifiedName)
Definition: node.c:1306
int ixmlNodeList_addToNodeList(IXML_NodeList **nList, IXML_Node *add)
Add a node to nodelist.
Definition: nodeList.c:82
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:1278
char * curPtr
Definition: ixmlparser.h:89
int ixmlNamedNodeMap_addToNamedNodeMap(IXML_NamedNodeMap **nnMap, IXML_Node *add)
Add a node to a NamedNodeMap.
Definition: namedNodeMap.c:156
The ixml_membuf type.
Definition: ixmlmembuf.h:61
Data structure common to all types of nodes.
Definition: ixml.h:165
BOOL Parser_isValidXmlName(const DOMString name)
Check to see whether name is a valid xml name.
Definition: ixmlparser.c:2474
Data structure representing an Attribute node.
Definition: ixml.h:215
Data structure representing a list of nodes.
Definition: ixml.h:235
#define DOMString
The type of DOM strings.
Definition: ixml.h:59
Definition: ixmlparser.h:66
void ixmlNodeList_init(IXML_NodeList *nList)
Initializes a nodelist.
Definition: nodeList.c:46
Data structure representing the DOM Document.
Definition: ixml.h:187
Data structure representing an Element node.
Definition: ixml.h:205
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:2644
Data structure representing a list of named nodes.
Definition: ixml.h:245
void Parser_setErrorChar(char c)
Sets the error character.
Definition: ixmlparser.c:2497