1 |
|
---|
2 | /*
|
---|
3 | *@@sourcefile xml.h:
|
---|
4 | * header file for xml.c (XML parsing).
|
---|
5 | *
|
---|
6 | * See remarks there.
|
---|
7 | *
|
---|
8 | *@@added V0.9.6 (2000-10-29) [umoeller]
|
---|
9 | *@@include #include <os2.h>
|
---|
10 | *@@include #include "expat\expat.h"
|
---|
11 | *@@include #include "helpers\linklist.h"
|
---|
12 | *@@include #include "helpers\xstring.h"
|
---|
13 | *@@include #include "helpers\xml.h"
|
---|
14 | */
|
---|
15 |
|
---|
16 | #if __cplusplus
|
---|
17 | extern "C" {
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #ifndef XML_HEADER_INCLUDED
|
---|
21 | #define XML_HEADER_INCLUDED
|
---|
22 |
|
---|
23 | // define some basic things to make this work even with standard C
|
---|
24 | #if (!defined OS2_INCLUDED) && (!defined _OS2_H) && (!defined __SIMPLES_DEFINED) // changed V0.9.0 (99-10-22) [umoeller]
|
---|
25 | typedef unsigned long BOOL;
|
---|
26 | typedef unsigned long ULONG;
|
---|
27 | typedef unsigned char *PSZ;
|
---|
28 | #define TRUE (BOOL)1
|
---|
29 | #define FALSE (BOOL)0
|
---|
30 |
|
---|
31 | #ifdef __IBMCPP__ // added V0.9.0 (99-10-22) [umoeller]
|
---|
32 | #define APIENTRY _System
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #define __SIMPLES_DEFINED
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | #define ERROR_DOM_FIRST 14000
|
---|
39 |
|
---|
40 | #define ERROR_DOM_INDEX_SIZE (ERROR_DOM_FIRST + 1)
|
---|
41 | #define ERROR_DOM_DOMSTRING_SIZE (ERROR_DOM_FIRST + 2)
|
---|
42 | #define ERROR_DOM_HIERARCHY_REQUEST (ERROR_DOM_FIRST + 3)
|
---|
43 | #define ERROR_DOM_WRONG_DOCUMENT (ERROR_DOM_FIRST + 4)
|
---|
44 | #define ERROR_DOM_INVALID_CHARACTER (ERROR_DOM_FIRST + 5)
|
---|
45 | #define ERROR_DOM_NO_DATA_ALLOWED (ERROR_DOM_FIRST + 6)
|
---|
46 | #define ERROR_DOM_NO_MODIFICATION_ALLOWED (ERROR_DOM_FIRST + 7)
|
---|
47 | #define ERROR_DOM_NOT_FOUND (ERROR_DOM_FIRST + 8)
|
---|
48 | #define ERROR_DOM_NOT_SUPPORTED (ERROR_DOM_FIRST + 9)
|
---|
49 | #define ERROR_DOM_INUSE_ATTRIBUTE (ERROR_DOM_FIRST + 10)
|
---|
50 |
|
---|
51 | #define ERROR_DOM_PARSING (ERROR_DOM_FIRST + 11)
|
---|
52 |
|
---|
53 | #define DOMNODE_ELEMENT 1 // node is an ELEMENT
|
---|
54 | #define DOMNODE_ATTRIBUTE 2 // node is an ATTRIBUTE
|
---|
55 | #define DOMNODE_TEXT 3 // node is a TEXT node
|
---|
56 | // #define DOMNODE_CDATA_SECTION 4
|
---|
57 | // #define DOMNODE_ENTITY_REFERENCE 5
|
---|
58 | // #define DOMNODE_ENTITY 6
|
---|
59 | // #define DOMNODE_PROCESSING_INSTRUCTION 7
|
---|
60 | #define DOMNODE_COMMENT 8 // node is a COMMENT
|
---|
61 | #define DOMNODE_DOCUMENT 9 // node is a document
|
---|
62 | #define DOMNODE_DOCUMENT_TYPE 10 // node is a DOCUMENTTYPE
|
---|
63 | // #define DOMNODE_DOCUMENT_FRAGMENT 11
|
---|
64 | // #define DOMNODE_NOTATION 12
|
---|
65 |
|
---|
66 | /*
|
---|
67 | *@@ DOMNODE:
|
---|
68 | * this represents one node in an XML document.
|
---|
69 | *
|
---|
70 | * Per definition, each XML document is broken down into
|
---|
71 | * DOM nodes. The document itself is represented by a
|
---|
72 | * node with the DOMNODE_DOCUMENT type, which in turn
|
---|
73 | * contains all the other nodes. This thus forms a tree
|
---|
74 | * as shown with xmlParse.
|
---|
75 | *
|
---|
76 | * The contents of the members vary according
|
---|
77 | * to ulNodeType:
|
---|
78 | *
|
---|
79 | + ulNodeType pszNodeName pszNodeValue listAttributeNodes
|
---|
80 | +
|
---|
81 | + ELEMENT tag name 0 named node map
|
---|
82 | +
|
---|
83 | + ATTRIBUTE attribute name attribute value 0
|
---|
84 | +
|
---|
85 | + TEXT 0 text contents 0
|
---|
86 | +
|
---|
87 | + COMMENT 0 comment contents 0
|
---|
88 | +
|
---|
89 | + DOCUMENT 0 0 0
|
---|
90 | */
|
---|
91 |
|
---|
92 | typedef struct _DOMNODE
|
---|
93 | {
|
---|
94 | ULONG ulNodeType;
|
---|
95 | // one of:
|
---|
96 | // -- DOMNODE_ELEMENT
|
---|
97 | // -- DOMNODE_ATTRIBUTE
|
---|
98 | // -- DOMNODE_TEXT
|
---|
99 | // -- DOMNODE_CDATA_SECTION
|
---|
100 | // -- DOMNODE_ENTITY_REFERENCE
|
---|
101 | // -- DOMNODE_ENTITY
|
---|
102 | // -- DOMNODE_PROCESSING_INSTRUCTION
|
---|
103 | // -- DOMNODE_COMMENT
|
---|
104 | // -- DOMNODE_DOCUMENT: the root document. See @documents.
|
---|
105 | // -- DOMNODE_DOCUMENT_TYPE
|
---|
106 | // -- DOMNODE_DOCUMENT_FRAGMENT
|
---|
107 | // -- DOMNODE_NOTATION
|
---|
108 |
|
---|
109 | XSTRING strNodeName; // malloc()'d
|
---|
110 | XSTRING strNodeValue; // malloc()'d
|
---|
111 |
|
---|
112 | struct _DOMNODE *pParentNode;
|
---|
113 | // the parent node;
|
---|
114 | // NULL for DOCUMENT, DOCUMENT_FRAGMENT and ATTR
|
---|
115 |
|
---|
116 | LINKLIST llChildNodes; // of DOMNODE* pointers, no auto-free
|
---|
117 |
|
---|
118 | LINKLIST llAttributeNodes; // of DOMNODE* pointers, no auto-free
|
---|
119 |
|
---|
120 | } DOMNODE, *PDOMNODE;
|
---|
121 |
|
---|
122 | #define XMLACTION_BREAKUP 1
|
---|
123 | #define XMLACTION_COPYASTEXT 2
|
---|
124 |
|
---|
125 | typedef ULONG _Optlink FNVALIDATE(const char *pcszTag);
|
---|
126 | typedef FNVALIDATE *PFNVALIDATE;
|
---|
127 |
|
---|
128 | PDOMNODE xmlCreateNode(PDOMNODE pParentNode,
|
---|
129 | ULONG ulNodeType);
|
---|
130 |
|
---|
131 | ULONG xmlDeleteNode(PDOMNODE pNode);
|
---|
132 |
|
---|
133 | /* ******************************************************************
|
---|
134 | *
|
---|
135 | * DOM APIs
|
---|
136 | *
|
---|
137 | ********************************************************************/
|
---|
138 |
|
---|
139 | /*
|
---|
140 | *@@ XMLDOM:
|
---|
141 | * DOM instance returned by xmlCreateDOM.
|
---|
142 | *
|
---|
143 | *@@added V0.9.9 (2000-02-14) [umoeller]
|
---|
144 | */
|
---|
145 |
|
---|
146 | typedef struct _XMLDOM
|
---|
147 | {
|
---|
148 | /*
|
---|
149 | * Public fields (should be read only)
|
---|
150 | */
|
---|
151 |
|
---|
152 | PDOMNODE pDocumentNode;
|
---|
153 |
|
---|
154 | enum XML_Error Error;
|
---|
155 | const char *pcszErrorDescription;
|
---|
156 | ULONG ulErrorLine;
|
---|
157 | ULONG ulErrorColumn;
|
---|
158 |
|
---|
159 | /*
|
---|
160 | * Private fields (for xml* functions)
|
---|
161 | */
|
---|
162 |
|
---|
163 | XML_Parser pParser;
|
---|
164 | // expat parser instance
|
---|
165 |
|
---|
166 | LINKLIST llStack;
|
---|
167 | // stack for maintaining the current items;
|
---|
168 | // these point to the NODERECORDs (no auto-free)
|
---|
169 |
|
---|
170 | PDOMNODE pLastWasTextNode;
|
---|
171 | } XMLDOM, *PXMLDOM;
|
---|
172 |
|
---|
173 | APIRET xmlCreateDOM(ULONG flParserFlags,
|
---|
174 | PXMLDOM *ppDom);
|
---|
175 |
|
---|
176 | APIRET xmlParse(PXMLDOM pDom,
|
---|
177 | const char *pcszBuf,
|
---|
178 | ULONG cb,
|
---|
179 | BOOL fIsLast);
|
---|
180 |
|
---|
181 | APIRET xmlFreeDOM(PXMLDOM pDom);
|
---|
182 |
|
---|
183 | #endif
|
---|
184 |
|
---|
185 | #if __cplusplus
|
---|
186 | }
|
---|
187 | #endif
|
---|
188 |
|
---|