0001.00 /*-
0002.00 * Copyright (c) 2004-2005 Scott C. Klement
0003.00 * All rights reserved.
0004.00 *
0005.00 * Redistribution and use in source and binary forms, with or with
0006.00 * modification, are permitted provided that the following conditi
0007.00 * are met:
0008.00 * 1. Redistributions of source code must retain the above copyrig
0009.00 * notice, this list of conditions and the following disclaimer
0010.00 * 2. Redistributions in binary form must reproduce the above copy
0011.00 * notice, this list of conditions and the following disclaimer
0012.00 * documentation and/or other materials provided with the distr
0013.00 *
0014.00 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS I
0015.00 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED T
16.0* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICU
17.00017.00 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS B
18.00018.00 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CO
19.00019.00 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU
20.00020.00 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRU
21.00021.00 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTR
22.00022.00 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
23.00023.00 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
24.00024.00 * SUCH DAMAGE.
25.00025.00 */
26.00026.00
27.00027.00 *
28.00028.00 * This contains RPG definitions needed for calling routines from
29.00029.00 * the eXpat XML parser. This source member is distributed with
30.00030.00 * HTTPAPI for your convienience.
31.00031.00 *
32.00032.00
33.00033.00 /if defined(EXPAT_H)
34.00034.00 /eof
35.00035.00 /endif
36.00036.00 /define EXPAT_H
37.00037.00
38.00038.00 D XML_STATUS_OK...
39.00039.00 D C 1
40.00040.00 D XML_STATUS_ERROR...
41.00041.00 D C 0
42.00042.00
43.00043.00 *------
44.00044.00 * XML_Parser: opaque pointer to the XML Parser state informatio
45.00045.00 * that's used internally by eXpat
46.00046.00 *------
47.00047.00 D XML_Parser s * based(Template)
48.00048.00
49.00049.00 *------
50.00050.00 * Data structure to store XML Encoding Info
51.00051.00 *
52.00052.00 * typedef struct {
53.00053.00 * int map[256];
54.00054.00 * void *data;
55.00055.00 * int (XMLCALL *convert)(void *data, const char *s);
56.00056.00 * int (XMLCALL *release)(void *data);
57.00057.00 * } XML_Encoding;
58.00058.00 *
59.00059.00 *
60.00060.00 * map = map from the encoding to UTF-8. Each item in the map
61.00061.00 * corresponds to a code point of the encoding. map[0] is
62.00062.00 * codepoint 0, map[255] is codepoint 255, etc. When a
63.00063.00 * value is set to -1, it means that value is invalid as
64.00064.00 * an initial byte in a multibyte sequence. When it's
65.00065.00 * -n, then n is the number of bytes in a sequence, and
66.00066.00 * conversion is accomplished by calling the convert()
67.00067.00 * function.
68.0068.00 *
69.0069.00 * data = user-defined data that's passed to each call to
70.0070.00 * convert() and release()
71.0071.00 *
72.0072.00 * convert = procedure to call when converting multi-byte
73.0073.00 * characters. May be *NULL if no multibyte
74.0074.00 * chars are required.
75.0075.00 *
76.0076.00 * D myConvert PR 10I 0
77.0077.00 * D data * value
78.0078.00 * D string * value
79.0079.00 *
80.0080.00 * release = procedure that's called when the data pointer
81.0081.00 * is to be released. May be *NULL if no data
82.0082.00 * needs releasing.
83.0083.00 *
84.0084.00 * D myRelease PR
85.00085.00 * D data * value
86.00086.00 *
87.00087.00 *------
88.00088.00 D XML_Encoding ds based(Template)
89.00089.00 D map 10I 0 dim(256)
90.00090.00 D data *
91.00091.00 D convert * procptr
92.00092.00 D release * procptr
93.00093.00
94.00094.00 *------
95.00095.00 * XML_ParserCreate(): Creates a new XML_Parser object.
96.00096.00 *
97.00097.00 * encoding = (input) name of encoding to use.
98.00098.00 * or *NULL if no special encoding is used
99.00099.00 *
100.00100.00 * returns an XML_Parser, or *NULL upon failure.
101.00101.00 *------
102.00102.00 D XML_ParserCreate...
103.00103.00 D PR ExtProc('XML_ParserCreate')
104.00104.00 D like(XML_Parser)
105.00105.00 D encoding * value options(*string)
106.00106.00
107.00107.00 *------
108.00108.00 * XML_SetUserData(): Set user data to be sent to callbacks
109.00109.00 *
110.00110.00 * parser = (input) XML Parser to set user data for
111.00111.00 * userData = (input) pointer to user data that is to be
112.00112.00 * passed to each call-back procedure
113.00113.00 *------
114.00114.00 D XML_SetUserData...
115.00115.00 D PR ExtProc('XML_SetUserData')
116.00116.00 D parser like(XML_Parser) value
117.00117.00 D userData * value
118.00118.00
119.00119.00 *------
120.00120.00 * XML_SetElementHandler(): Set functions to be called for
121.00121.00 * each starting & ending element
122.00122.00 *
123.00123.00 * parser = (input) XML_Parser to set functions for
124.00124.00 * start = (input) pointer to call-back procedure for
125.00125.00 * start tags
126.00126.00 * end = (input) pointer to call-back procedure for
127.00127.00 * end tags
128.00128.00 *
129.00129.00 * D myStartHandler PR 10I 0
130.00130.00 * D userData * value
131.00131.00 * D elementName * value
132.00132.00 * D atts * dim(1000) options(*varsi
133.00133.00 *
134.00134.00 * userData = the pointer you supplied with XML_SetUserData
135.00135.00 * elementName = null-terminated string w/the element name
136.00136.00 * atts = null-terminated array of pointers, each
137.00137.00 * points to a null-terminated string containing
138.00138.00 * an attribute name or value (they alternate)
139.00139.00 *
140.00140.00 * D myEndHandler PR 10I 0
141.00141.00 * D userData * value
142.00142.00 * D elementName * value
143.00143.00 *
144.00144.00 * userData = the pointer you supplied with XML_SetUserData
145.00145.00 * elementName = null-terminated string w/the element name
146.00146.00 *
147.00147.00 * Note: This is a shortcut for calling XML_SetStartElementHandler
148.00148.00 * and XML_SetEndElementHandler()
149.00149.00 *------
150.00150.00 D XML_SetElementHandler...
151.00151.00 D PR ExtProc('XML_SetElementHandl
152.00152.00 D parser like(XML_Parser) value
153.00153.00 D start * procptr value
154.00154.00 D end * procptr value
155.00155.00
156.00156.00 D XML_SetStartElementHandler...
157.00157.00 D PR ExtProc('XML_SetStartElement
158.00158.00 D Handler')
159.00159.00 D parser like(XML_Parser) value
160.00160.00 D start * procptr value
161.00161.00
162.00162.00 D XML_SetEndElementHandler...
163.00163.00 D PR ExtProc('XML_SetEndElement-
164.00164.00 D Handler')
165.00165.00 D parser like(XML_Parser) value
166.00166.00 D end * procptr value
167.00167.00
168.00168.00 *------
169.00169.00 * XML_SetCharacterDataHandler(): Set handler for character data
170.00170.00 *
171.00171.00 * parser = (input) XML_Parser to set functions for
172.00172.00 * charhndl = (input) pointer to call-back procedure for
173.00173.00 * character data
174.00174.00 *
175.00175.00 * D myCharHandler PR
176.00176.00 * D userData * value
177.00177.00 * D string 65535A const options(*varsize)
178.00178.00 * D len 10I 0 value
179.00179.00 *
180.00180.00 *
181.00181.00 * Note: The string is options(*varsize). You MUST use the
182.00182.00 * "len" variable to determine how much was passed, and
183.00183.00 * use caution not to use data past that length.
184.00184.00 *
185.00185.00 * Note: This function might be called multiple times for a single
186.00186.00 * contiguous character data block. You should concatenate
187.00187.00 * the data together.
188.00188.00 *------
189.00189.00 D XML_SetCharacterDataHandler...
190.00190.00 D PR ExtProc('XML_SetCharacterDat
191.00191.00 D Handler')
192.00192.00 D parser like(XML_Parser) value
193.00193.00 D charhndl * procptr value
194.00194.00
195.00195.00 *------
196.00196.00 * XML_Parse(): Parse XML data in stream
197.00197.00 *
198.00198.00 * parser = (input) XML_Parser object that will do the parsing
199.00199.00 * s = (input) next chunk of data from XML stream
200.00200.00 * len = (input) length of XML data in 's'
201.00201.00 * isFinal = (input) flag that specifies whether this is the
202.00202.00 * final chunk of the stream. Set to 1 if it
203.00203.00 * is, or 0 otherwise.
204.00204.00 *
205.00205.00 * Returns XML_STATUS_OK if successful
206.00206.00 * or XML_STATUS_ERROR upon failure
207.00207.00 *------
208.00208.00 D XML_Parse...
209.00209.00 D PR 10I 0 ExtProc('XML_Parse')
210.00210.00 D parser like(XML_Parser) value
211.00211.00 D s * value options(*string)
212.00212.00 D len 10I 0 value
213.00213.00 D isFinal 10I 0 value
214.00214.00
215.00215.00 *------
216.00216.00 * XML_GetErrorCode(): Retrieves the error number of the
217.00217.00 * last error that occurred while parsing.
218.00218.00 *
219.00219.00 * parser = (input) XML_Parser object to retrieve error from
220.00220.00 *
221.00221.00 * returns the error number.
222.00222.00 *------
223.00223.00 D XML_GetErrorCode...
224.00224.00 D PR 10I 0 ExtProc('XML_GetErrorCode')
225.00225.00 D parser like(XML_Parser) value
226.00226.00
227.00227.00 *------
228.00228.00 * XML_ErrorString(): Returns the human-readable error message
229.00229.00 * that corresponds to an error number.
230.00230.00 *
231.00231.00 * code = (input) error number to get message for.
232.00232.00 *
233.00233.00 * returns a null-terminated error string.
234.00234.00 *------
235.00235.00 D XML_ErrorString...
236.00236.00 D PR * ExtProc('XML_ErrorString')
237.00237.00 D code 10I 0 value
238.00238.00
239.00239.00 *------
240.00240.00 * XML_GetCurrentLineNumber(): Get the line number of the XML
241.00241.00 * document that's currently being parsed.
242.00242.00 *
243.00243.00 * parser = (input) XML_Parser to retrieve line number from
244.00244.00 *
245.00245.00 * returns the line number.
246.00246.00 *------
247.00247.00 D XML_GetCurrentLineNumber...
248.00248.00 D PR 10I 0 ExtProc('XML_GetCurrentLine-
249.00249.00 D Number')
250.00250.00 D parser like(XML_Parser) value
251.00251.00
252.00252.00 *------
253.00253.00 * XML_GetCurrentColumnNumber(): Return the offset from the start
254.00254.00 * of the current line.
255.00255.00 *
256.00256.00 * parser = (input) XML_Parser to retrieve line number from
257.00257.00 *
258.00258.00 * returns the column number.
259.00259.00 *------
260.00260.00 D XML_GetCurrentColumnNumber...
261.00261.00 D PR 10I 0 ExtProc('XML_GetCurrentColum
262.00262.00 D Number')
263.00263.00 D parser like(XML_Parser) value
264.00264.00
265.00265.00 *------
266.00266.00 * XML_ParserFree(): Destroys & frees up resources used by an
267.00267.00 * XML_Parser object.
268.00268.00 *
269.00269.00 * parser = (input) XML_Parser to destroy
270.00270.00 *
271.00271.00 *------
272.00272.00 D XML_ParserFree...
273.00273.00 D PR ExtProc('XML_ParserFree')
274.00274.00 D parser like(XML_Parser) value
275.00275.00
276.00276.00
277.00277.00 *------
278.00278.00 * XML_SetUnknownEncodingHandler(): Set a handler to handle any
279.00279.00 * encodings that eXpat is not familiar with.
280.00280.00 *
281.00281.00 * parser = (input) XML_Parser that will use the encoding
282.00282.00 * enchandler = (input) procedure to call to initialize the
283.00283.00 * XML_Encoding structure for an unknown
284.00284.00 * encoding.
285.00285.00 * info = (input) XML_Encoding structure that will be set
286.00286.00 *
287.00287.00 * An encoding handler should be prototyped as:
288.00288.00 *
289.00289.00 * D myHandler PR 10I 0
290.00290.00 * D handlerData * value
291.00291.00 * D name * value
292.00292.00 * D info likeds(XML_Encoding)
293.00293.00 *
294.00294.00 *------
295.00295.00 D XML_SetUnknownEncodingHandler...
296.00296.00 D PR ExtProc('XML_SetUnknownEncod
297.00297.00 D Handler')
298.00298.00 D parser like(XML_Parser) value
299.00299.00 D enchandler * procptr value
300.00300.00 D info likeds(XML_Encoding)