libUPnP  1.8.0
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 #ifdef IXML_HAVE_SCRIPTSUPPORT
124 
132 void Parser_setBeforeFree(
134  IXML_BeforeFreeNode_t hndlr);
135 
139 IXML_BeforeFreeNode_t Parser_getBeforeFree();
140 #endif
141 
142 
148  IXML_Node *IXML_Nodeptr);
149 
150 int Parser_LoadDocument(IXML_Document **retDoc, const char * xmlFile, BOOL file);
151 
152 int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr);
153 
154 
155 void ixmlAttr_init(IXML_Attr *attrNode);
156 
168  IXML_Element *element,
170  const char *tagName);
171 
172 
178  IXML_NamedNodeMap *nnMap);
179 
180 
187  /* [in] The named node map. */
188  IXML_NamedNodeMap **nnMap,
189  /* [in] The node to add. */
190  IXML_Node *add);
191 
197  IXML_NodeList **nList,
199  IXML_Node *add);
200 
201 
205 void ixmlNode_init(
207  IN IXML_Node *nodeptr);
208 
209 
218 BOOL ixmlNode_compare(
220  IXML_Node *srcNode,
222  IXML_Node *destNode);
223 
224 
232  IXML_Node *n,
234  const char *tagname,
236  IXML_NodeList **list);
237 
238 
246  IXML_Node *n,
248  const char *namespaceURI,
250  const char *localName,
252  IXML_NodeList **list);
253 
254 
262  IXML_Node *node,
264  const DOMString qualifiedName);
265 
266 
274  IXML_Node *destNode,
276  IXML_Node *src);
277 
278 
282 void ixmlNodeList_init(
284  IXML_NodeList *nList);
285 
286 
287 #endif /* IXMLPARSER_H */
288 
char * savePtr
Definition: ixmlparser.h:89
int ixmlNode_setNodeProperties(IXML_Node *destNode, IXML_Node *src)
Definition: node.c:1340
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:2595
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:1226
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:470
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:2626
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:1310
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:1282
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:172
BOOL Parser_isValidXmlName(const DOMString name)
Check to see whether name is a valid xml name.
Definition: ixmlparser.c:2477
Data structure representing an Attribute node.
Definition: ixml.h:225
Data structure representing a list of nodes.
Definition: ixml.h:245
#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:197
Data structure representing an Element node.
Definition: ixml.h:215
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:2658
Data structure representing a list of named nodes.
Definition: ixml.h:255
void Parser_setErrorChar(char c)
Sets the error character.
Definition: ixmlparser.c:2500