libUPnP  1.6.17
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 "ixml.h"
43 #include "ixmlmembuf.h"
44 
45 
46 /* Parser definitions */
47 #define QUOT """
48 #define LT "<"
49 #define GT ">"
50 #define APOS "'"
51 #define AMP "&"
52 #define ESC_HEX "&#x"
53 #define ESC_DEC "&#"
54 
55 
56 typedef struct _IXML_NamespaceURI
57 {
58  char *nsURI;
59  char *prefix;
60  struct _IXML_NamespaceURI *nextNsURI;
62 
63 
64 typedef struct _IXML_ElementStack
65 {
66  char *element;
67  char *prefix;
68  char *namespaceUri;
69  IXML_NamespaceURI *pNsURI;
70  struct _IXML_ElementStack *nextElement;
72 
73 
74 typedef enum
75 {
76  eELEMENT,
77  eATTRIBUTE,
78  eCONTENT,
79 } PARSER_STATE;
80 
81 
82 typedef struct _Parser
83 {
85  char *dataBuffer;
87  char *curPtr;
89  char *savePtr;
90  ixml_membuf lastElem;
91  ixml_membuf tokenBuf;
92  IXML_Node *pNeedPrefixNode;
93  IXML_ElementStack *pCurElement;
94  IXML_Node *currentNodePtr;
95  PARSER_STATE state;
96  BOOL bHasTopLevel;
97 } Parser;
98 
99 
105  const DOMString name);
106 
107 
121  char c);
122 
123 
129  IXML_Node *IXML_Nodeptr);
130 
131 int Parser_LoadDocument(IXML_Document **retDoc, const char * xmlFile, BOOL file);
132 
133 int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr);
134 
135 
136 void ixmlAttr_init(IXML_Attr *attrNode);
137 
149  IXML_Element *element,
151  const char *tagName);
152 
153 
159  IXML_NamedNodeMap *nnMap);
160 
161 
168  /* [in] The named node map. */
169  IXML_NamedNodeMap **nnMap,
170  /* [in] The node to add. */
171  IXML_Node *add);
172 
178  IXML_NodeList **nList,
180  IXML_Node *add);
181 
182 
186 void ixmlNode_init(
188  IN IXML_Node *nodeptr);
189 
190 
199 BOOL ixmlNode_compare(
201  IXML_Node *srcNode,
203  IXML_Node *destNode);
204 
205 
213  IXML_Node *n,
215  const char *tagname,
217  IXML_NodeList **list);
218 
219 
227  IXML_Node *n,
229  const char *namespaceURI,
231  const char *localName,
233  IXML_NodeList **list);
234 
235 
243  IXML_Node *node,
245  const DOMString qualifiedName);
246 
247 
255  IXML_Node *destNode,
257  IXML_Node *src);
258 
259 
263 void ixmlNodeList_init(
265  IXML_NodeList *nList);
266 
267 
268 #endif /* IXMLPARSER_H */
269 
char * savePtr
Definition: ixmlparser.h:89
int ixmlNode_setNodeProperties(IXML_Node *destNode, IXML_Node *src)
Definition: node.c:1336
char * dataBuffer
Definition: ixmlparser.h:85
Definition: ixmlparser.h:56
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:2580
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:2611
Definition: ixmlparser.h:82
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:87
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:59
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:2473
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:64
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:2643
Data structure representing a list of named nodes.
Definition: ixml.h:245
void Parser_setErrorChar(char c)
Sets the error character.
Definition: ixmlparser.c:2496