xref: /dragonfly/contrib/expat/lib/xmltok.h (revision 0c65ac1d)
1*0c65ac1dSAntonio Huete Jimenez /*
2*0c65ac1dSAntonio Huete Jimenez                             __  __            _
3*0c65ac1dSAntonio Huete Jimenez                          ___\ \/ /_ __   __ _| |_
4*0c65ac1dSAntonio Huete Jimenez                         / _ \\  /| '_ \ / _` | __|
5*0c65ac1dSAntonio Huete Jimenez                        |  __//  \| |_) | (_| | |_
6*0c65ac1dSAntonio Huete Jimenez                         \___/_/\_\ .__/ \__,_|\__|
7*0c65ac1dSAntonio Huete Jimenez                                  |_| XML parser
8*0c65ac1dSAntonio Huete Jimenez 
9*0c65ac1dSAntonio Huete Jimenez    Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10*0c65ac1dSAntonio Huete Jimenez    Copyright (c) 2000      Clark Cooper <coopercc@users.sourceforge.net>
11*0c65ac1dSAntonio Huete Jimenez    Copyright (c) 2002      Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
12*0c65ac1dSAntonio Huete Jimenez    Copyright (c) 2002-2005 Karl Waclawek <karl@waclawek.net>
13*0c65ac1dSAntonio Huete Jimenez    Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
14*0c65ac1dSAntonio Huete Jimenez    Copyright (c) 2017      Rhodri James <rhodri@wildebeest.org.uk>
15*0c65ac1dSAntonio Huete Jimenez    Licensed under the MIT license:
16*0c65ac1dSAntonio Huete Jimenez 
17*0c65ac1dSAntonio Huete Jimenez    Permission is  hereby granted,  free of charge,  to any  person obtaining
18*0c65ac1dSAntonio Huete Jimenez    a  copy  of  this  software   and  associated  documentation  files  (the
19*0c65ac1dSAntonio Huete Jimenez    "Software"),  to  deal in  the  Software  without restriction,  including
20*0c65ac1dSAntonio Huete Jimenez    without  limitation the  rights  to use,  copy,  modify, merge,  publish,
21*0c65ac1dSAntonio Huete Jimenez    distribute, sublicense, and/or sell copies of the Software, and to permit
22*0c65ac1dSAntonio Huete Jimenez    persons  to whom  the Software  is  furnished to  do so,  subject to  the
23*0c65ac1dSAntonio Huete Jimenez    following conditions:
24*0c65ac1dSAntonio Huete Jimenez 
25*0c65ac1dSAntonio Huete Jimenez    The above copyright  notice and this permission notice  shall be included
26*0c65ac1dSAntonio Huete Jimenez    in all copies or substantial portions of the Software.
27*0c65ac1dSAntonio Huete Jimenez 
28*0c65ac1dSAntonio Huete Jimenez    THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
29*0c65ac1dSAntonio Huete Jimenez    EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
30*0c65ac1dSAntonio Huete Jimenez    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
31*0c65ac1dSAntonio Huete Jimenez    NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
32*0c65ac1dSAntonio Huete Jimenez    DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
33*0c65ac1dSAntonio Huete Jimenez    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
34*0c65ac1dSAntonio Huete Jimenez    USE OR OTHER DEALINGS IN THE SOFTWARE.
35fb9a9224SMatthew Dillon */
36fb9a9224SMatthew Dillon 
37fb9a9224SMatthew Dillon #ifndef XmlTok_INCLUDED
38fb9a9224SMatthew Dillon #define XmlTok_INCLUDED 1
39fb9a9224SMatthew Dillon 
40fb9a9224SMatthew Dillon #ifdef __cplusplus
41fb9a9224SMatthew Dillon extern "C" {
42fb9a9224SMatthew Dillon #endif
43fb9a9224SMatthew Dillon 
44fb9a9224SMatthew Dillon /* The following token may be returned by XmlContentTok */
45*0c65ac1dSAntonio Huete Jimenez #define XML_TOK_TRAILING_RSQB                                                  \
46*0c65ac1dSAntonio Huete Jimenez   -5 /* ] or ]] at the end of the scan; might be                               \
47fb9a9224SMatthew Dillon         start of illegal ]]> sequence */
48fb9a9224SMatthew Dillon /* The following tokens may be returned by both XmlPrologTok and
49fb9a9224SMatthew Dillon    XmlContentTok.
50fb9a9224SMatthew Dillon */
51fb9a9224SMatthew Dillon #define XML_TOK_NONE -4 /* The string to be scanned is empty */
52*0c65ac1dSAntonio Huete Jimenez #define XML_TOK_TRAILING_CR                                                    \
53*0c65ac1dSAntonio Huete Jimenez   -3                            /* A CR at the end of the scan;                \
54fb9a9224SMatthew Dillon                                    might be part of CRLF sequence */
55fb9a9224SMatthew Dillon #define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
56fb9a9224SMatthew Dillon #define XML_TOK_PARTIAL -1      /* only part of a token */
57fb9a9224SMatthew Dillon #define XML_TOK_INVALID 0
58fb9a9224SMatthew Dillon 
59fb9a9224SMatthew Dillon /* The following tokens are returned by XmlContentTok; some are also
60fb9a9224SMatthew Dillon    returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
61fb9a9224SMatthew Dillon */
62fb9a9224SMatthew Dillon #define XML_TOK_START_TAG_WITH_ATTS 1
63fb9a9224SMatthew Dillon #define XML_TOK_START_TAG_NO_ATTS 2
64fb9a9224SMatthew Dillon #define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
65fb9a9224SMatthew Dillon #define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
66fb9a9224SMatthew Dillon #define XML_TOK_END_TAG 5
67fb9a9224SMatthew Dillon #define XML_TOK_DATA_CHARS 6
68fb9a9224SMatthew Dillon #define XML_TOK_DATA_NEWLINE 7
69fb9a9224SMatthew Dillon #define XML_TOK_CDATA_SECT_OPEN 8
70fb9a9224SMatthew Dillon #define XML_TOK_ENTITY_REF 9
71fb9a9224SMatthew Dillon #define XML_TOK_CHAR_REF 10 /* numeric character reference */
72fb9a9224SMatthew Dillon 
73fb9a9224SMatthew Dillon /* The following tokens may be returned by both XmlPrologTok and
74fb9a9224SMatthew Dillon    XmlContentTok.
75fb9a9224SMatthew Dillon */
76fb9a9224SMatthew Dillon #define XML_TOK_PI 11       /* processing instruction */
77fb9a9224SMatthew Dillon #define XML_TOK_XML_DECL 12 /* XML decl or text decl */
78fb9a9224SMatthew Dillon #define XML_TOK_COMMENT 13
79fb9a9224SMatthew Dillon #define XML_TOK_BOM 14 /* Byte order mark */
80fb9a9224SMatthew Dillon 
81fb9a9224SMatthew Dillon /* The following tokens are returned only by XmlPrologTok */
82fb9a9224SMatthew Dillon #define XML_TOK_PROLOG_S 15
83fb9a9224SMatthew Dillon #define XML_TOK_DECL_OPEN 16  /* <!foo */
84fb9a9224SMatthew Dillon #define XML_TOK_DECL_CLOSE 17 /* > */
85fb9a9224SMatthew Dillon #define XML_TOK_NAME 18
86fb9a9224SMatthew Dillon #define XML_TOK_NMTOKEN 19
87fb9a9224SMatthew Dillon #define XML_TOK_POUND_NAME 20 /* #name */
88fb9a9224SMatthew Dillon #define XML_TOK_OR 21         /* | */
89fb9a9224SMatthew Dillon #define XML_TOK_PERCENT 22
90fb9a9224SMatthew Dillon #define XML_TOK_OPEN_PAREN 23
91fb9a9224SMatthew Dillon #define XML_TOK_CLOSE_PAREN 24
92fb9a9224SMatthew Dillon #define XML_TOK_OPEN_BRACKET 25
93fb9a9224SMatthew Dillon #define XML_TOK_CLOSE_BRACKET 26
94fb9a9224SMatthew Dillon #define XML_TOK_LITERAL 27
95fb9a9224SMatthew Dillon #define XML_TOK_PARAM_ENTITY_REF 28
96fb9a9224SMatthew Dillon #define XML_TOK_INSTANCE_START 29
97fb9a9224SMatthew Dillon 
98fb9a9224SMatthew Dillon /* The following occur only in element type declarations */
99fb9a9224SMatthew Dillon #define XML_TOK_NAME_QUESTION 30        /* name? */
100fb9a9224SMatthew Dillon #define XML_TOK_NAME_ASTERISK 31        /* name* */
101fb9a9224SMatthew Dillon #define XML_TOK_NAME_PLUS 32            /* name+ */
102fb9a9224SMatthew Dillon #define XML_TOK_COND_SECT_OPEN 33       /* <![ */
103fb9a9224SMatthew Dillon #define XML_TOK_COND_SECT_CLOSE 34      /* ]]> */
104fb9a9224SMatthew Dillon #define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
105fb9a9224SMatthew Dillon #define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
106fb9a9224SMatthew Dillon #define XML_TOK_CLOSE_PAREN_PLUS 37     /* )+ */
107fb9a9224SMatthew Dillon #define XML_TOK_COMMA 38
108fb9a9224SMatthew Dillon 
109fb9a9224SMatthew Dillon /* The following token is returned only by XmlAttributeValueTok */
110fb9a9224SMatthew Dillon #define XML_TOK_ATTRIBUTE_VALUE_S 39
111fb9a9224SMatthew Dillon 
112fb9a9224SMatthew Dillon /* The following token is returned only by XmlCdataSectionTok */
113fb9a9224SMatthew Dillon #define XML_TOK_CDATA_SECT_CLOSE 40
114fb9a9224SMatthew Dillon 
115fb9a9224SMatthew Dillon /* With namespace processing this is returned by XmlPrologTok for a
116fb9a9224SMatthew Dillon    name with a colon.
117fb9a9224SMatthew Dillon */
118fb9a9224SMatthew Dillon #define XML_TOK_PREFIXED_NAME 41
119fb9a9224SMatthew Dillon 
120fb9a9224SMatthew Dillon #ifdef XML_DTD
121fb9a9224SMatthew Dillon #  define XML_TOK_IGNORE_SECT 42
122fb9a9224SMatthew Dillon #endif /* XML_DTD */
123fb9a9224SMatthew Dillon 
124fb9a9224SMatthew Dillon #ifdef XML_DTD
125fb9a9224SMatthew Dillon #  define XML_N_STATES 4
126fb9a9224SMatthew Dillon #else /* not XML_DTD */
127fb9a9224SMatthew Dillon #  define XML_N_STATES 3
128fb9a9224SMatthew Dillon #endif /* not XML_DTD */
129fb9a9224SMatthew Dillon 
130fb9a9224SMatthew Dillon #define XML_PROLOG_STATE 0
131fb9a9224SMatthew Dillon #define XML_CONTENT_STATE 1
132fb9a9224SMatthew Dillon #define XML_CDATA_SECTION_STATE 2
133fb9a9224SMatthew Dillon #ifdef XML_DTD
134fb9a9224SMatthew Dillon #  define XML_IGNORE_SECTION_STATE 3
135fb9a9224SMatthew Dillon #endif /* XML_DTD */
136fb9a9224SMatthew Dillon 
137fb9a9224SMatthew Dillon #define XML_N_LITERAL_TYPES 2
138fb9a9224SMatthew Dillon #define XML_ATTRIBUTE_VALUE_LITERAL 0
139fb9a9224SMatthew Dillon #define XML_ENTITY_VALUE_LITERAL 1
140fb9a9224SMatthew Dillon 
141fb9a9224SMatthew Dillon /* The size of the buffer passed to XmlUtf8Encode must be at least this. */
142fb9a9224SMatthew Dillon #define XML_UTF8_ENCODE_MAX 4
143fb9a9224SMatthew Dillon /* The size of the buffer passed to XmlUtf16Encode must be at least this. */
144fb9a9224SMatthew Dillon #define XML_UTF16_ENCODE_MAX 2
145fb9a9224SMatthew Dillon 
146fb9a9224SMatthew Dillon typedef struct position {
147fb9a9224SMatthew Dillon   /* first line and first column are 0 not 1 */
148fb9a9224SMatthew Dillon   XML_Size lineNumber;
149fb9a9224SMatthew Dillon   XML_Size columnNumber;
150fb9a9224SMatthew Dillon } POSITION;
151fb9a9224SMatthew Dillon 
152fb9a9224SMatthew Dillon typedef struct {
153fb9a9224SMatthew Dillon   const char *name;
154fb9a9224SMatthew Dillon   const char *valuePtr;
155fb9a9224SMatthew Dillon   const char *valueEnd;
156fb9a9224SMatthew Dillon   char normalized;
157fb9a9224SMatthew Dillon } ATTRIBUTE;
158fb9a9224SMatthew Dillon 
159fb9a9224SMatthew Dillon struct encoding;
160fb9a9224SMatthew Dillon typedef struct encoding ENCODING;
161fb9a9224SMatthew Dillon 
162*0c65ac1dSAntonio Huete Jimenez typedef int(PTRCALL *SCANNER)(const ENCODING *, const char *, const char *,
163fb9a9224SMatthew Dillon                               const char **);
164fb9a9224SMatthew Dillon 
165*0c65ac1dSAntonio Huete Jimenez enum XML_Convert_Result {
166*0c65ac1dSAntonio Huete Jimenez   XML_CONVERT_COMPLETED = 0,
167*0c65ac1dSAntonio Huete Jimenez   XML_CONVERT_INPUT_INCOMPLETE = 1,
168*0c65ac1dSAntonio Huete Jimenez   XML_CONVERT_OUTPUT_EXHAUSTED
169*0c65ac1dSAntonio Huete Jimenez   = 2 /* and therefore potentially input remaining as well */
170*0c65ac1dSAntonio Huete Jimenez };
171*0c65ac1dSAntonio Huete Jimenez 
172fb9a9224SMatthew Dillon struct encoding {
173fb9a9224SMatthew Dillon   SCANNER scanners[XML_N_STATES];
174fb9a9224SMatthew Dillon   SCANNER literalScanners[XML_N_LITERAL_TYPES];
175*0c65ac1dSAntonio Huete Jimenez   int(PTRCALL *nameMatchesAscii)(const ENCODING *, const char *, const char *,
176fb9a9224SMatthew Dillon                                  const char *);
177fb9a9224SMatthew Dillon   int(PTRFASTCALL *nameLength)(const ENCODING *, const char *);
178fb9a9224SMatthew Dillon   const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
179*0c65ac1dSAntonio Huete Jimenez   int(PTRCALL *getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
180fb9a9224SMatthew Dillon                         ATTRIBUTE *atts);
181fb9a9224SMatthew Dillon   int(PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
182*0c65ac1dSAntonio Huete Jimenez   int(PTRCALL *predefinedEntityName)(const ENCODING *, const char *,
183fb9a9224SMatthew Dillon                                      const char *);
184*0c65ac1dSAntonio Huete Jimenez   void(PTRCALL *updatePosition)(const ENCODING *, const char *ptr,
185*0c65ac1dSAntonio Huete Jimenez                                 const char *end, POSITION *);
186*0c65ac1dSAntonio Huete Jimenez   int(PTRCALL *isPublicId)(const ENCODING *enc, const char *ptr,
187*0c65ac1dSAntonio Huete Jimenez                            const char *end, const char **badPtr);
188*0c65ac1dSAntonio Huete Jimenez   enum XML_Convert_Result(PTRCALL *utf8Convert)(const ENCODING *enc,
189fb9a9224SMatthew Dillon                                                 const char **fromP,
190*0c65ac1dSAntonio Huete Jimenez                                                 const char *fromLim, char **toP,
191fb9a9224SMatthew Dillon                                                 const char *toLim);
192*0c65ac1dSAntonio Huete Jimenez   enum XML_Convert_Result(PTRCALL *utf16Convert)(const ENCODING *enc,
193fb9a9224SMatthew Dillon                                                  const char **fromP,
194fb9a9224SMatthew Dillon                                                  const char *fromLim,
195fb9a9224SMatthew Dillon                                                  unsigned short **toP,
196fb9a9224SMatthew Dillon                                                  const unsigned short *toLim);
197fb9a9224SMatthew Dillon   int minBytesPerChar;
198fb9a9224SMatthew Dillon   char isUtf8;
199fb9a9224SMatthew Dillon   char isUtf16;
200fb9a9224SMatthew Dillon };
201fb9a9224SMatthew Dillon 
202fb9a9224SMatthew Dillon /* Scan the string starting at ptr until the end of the next complete
203fb9a9224SMatthew Dillon    token, but do not scan past eptr.  Return an integer giving the
204fb9a9224SMatthew Dillon    type of token.
205fb9a9224SMatthew Dillon 
206fb9a9224SMatthew Dillon    Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
207fb9a9224SMatthew Dillon 
208fb9a9224SMatthew Dillon    Return XML_TOK_PARTIAL when the string does not contain a complete
209fb9a9224SMatthew Dillon    token; nextTokPtr will not be set.
210fb9a9224SMatthew Dillon 
211fb9a9224SMatthew Dillon    Return XML_TOK_INVALID when the string does not start a valid
212fb9a9224SMatthew Dillon    token; nextTokPtr will be set to point to the character which made
213fb9a9224SMatthew Dillon    the token invalid.
214fb9a9224SMatthew Dillon 
215fb9a9224SMatthew Dillon    Otherwise the string starts with a valid token; nextTokPtr will be
216fb9a9224SMatthew Dillon    set to point to the character following the end of that token.
217fb9a9224SMatthew Dillon 
218fb9a9224SMatthew Dillon    Each data character counts as a single token, but adjacent data
219fb9a9224SMatthew Dillon    characters may be returned together.  Similarly for characters in
220fb9a9224SMatthew Dillon    the prolog outside literals, comments and processing instructions.
221fb9a9224SMatthew Dillon */
222fb9a9224SMatthew Dillon 
223fb9a9224SMatthew Dillon #define XmlTok(enc, state, ptr, end, nextTokPtr)                               \
224fb9a9224SMatthew Dillon   (((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
225fb9a9224SMatthew Dillon 
226fb9a9224SMatthew Dillon #define XmlPrologTok(enc, ptr, end, nextTokPtr)                                \
227fb9a9224SMatthew Dillon   XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
228fb9a9224SMatthew Dillon 
229fb9a9224SMatthew Dillon #define XmlContentTok(enc, ptr, end, nextTokPtr)                               \
230fb9a9224SMatthew Dillon   XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
231fb9a9224SMatthew Dillon 
232fb9a9224SMatthew Dillon #define XmlCdataSectionTok(enc, ptr, end, nextTokPtr)                          \
233fb9a9224SMatthew Dillon   XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
234fb9a9224SMatthew Dillon 
235fb9a9224SMatthew Dillon #ifdef XML_DTD
236fb9a9224SMatthew Dillon 
237fb9a9224SMatthew Dillon #  define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr)                       \
238fb9a9224SMatthew Dillon     XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
239fb9a9224SMatthew Dillon 
240fb9a9224SMatthew Dillon #endif /* XML_DTD */
241fb9a9224SMatthew Dillon 
242fb9a9224SMatthew Dillon /* This is used for performing a 2nd-level tokenization on the content
243fb9a9224SMatthew Dillon    of a literal that has already been returned by XmlTok.
244fb9a9224SMatthew Dillon */
245fb9a9224SMatthew Dillon #define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr)                  \
246fb9a9224SMatthew Dillon   (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
247fb9a9224SMatthew Dillon 
248fb9a9224SMatthew Dillon #define XmlAttributeValueTok(enc, ptr, end, nextTokPtr)                        \
249fb9a9224SMatthew Dillon   XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
250fb9a9224SMatthew Dillon 
251fb9a9224SMatthew Dillon #define XmlEntityValueTok(enc, ptr, end, nextTokPtr)                           \
252fb9a9224SMatthew Dillon   XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
253fb9a9224SMatthew Dillon 
254fb9a9224SMatthew Dillon #define XmlNameMatchesAscii(enc, ptr1, end1, ptr2)                             \
255fb9a9224SMatthew Dillon   (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
256fb9a9224SMatthew Dillon 
257*0c65ac1dSAntonio Huete Jimenez #define XmlNameLength(enc, ptr) (((enc)->nameLength)(enc, ptr))
258fb9a9224SMatthew Dillon 
259*0c65ac1dSAntonio Huete Jimenez #define XmlSkipS(enc, ptr) (((enc)->skipS)(enc, ptr))
260fb9a9224SMatthew Dillon 
261fb9a9224SMatthew Dillon #define XmlGetAttributes(enc, ptr, attsMax, atts)                              \
262fb9a9224SMatthew Dillon   (((enc)->getAtts)(enc, ptr, attsMax, atts))
263fb9a9224SMatthew Dillon 
264*0c65ac1dSAntonio Huete Jimenez #define XmlCharRefNumber(enc, ptr) (((enc)->charRefNumber)(enc, ptr))
265fb9a9224SMatthew Dillon 
266fb9a9224SMatthew Dillon #define XmlPredefinedEntityName(enc, ptr, end)                                 \
267fb9a9224SMatthew Dillon   (((enc)->predefinedEntityName)(enc, ptr, end))
268fb9a9224SMatthew Dillon 
269fb9a9224SMatthew Dillon #define XmlUpdatePosition(enc, ptr, end, pos)                                  \
270fb9a9224SMatthew Dillon   (((enc)->updatePosition)(enc, ptr, end, pos))
271fb9a9224SMatthew Dillon 
272fb9a9224SMatthew Dillon #define XmlIsPublicId(enc, ptr, end, badPtr)                                   \
273fb9a9224SMatthew Dillon   (((enc)->isPublicId)(enc, ptr, end, badPtr))
274fb9a9224SMatthew Dillon 
275fb9a9224SMatthew Dillon #define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim)                        \
276fb9a9224SMatthew Dillon   (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
277fb9a9224SMatthew Dillon 
278fb9a9224SMatthew Dillon #define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim)                       \
279fb9a9224SMatthew Dillon   (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
280fb9a9224SMatthew Dillon 
281fb9a9224SMatthew Dillon typedef struct {
282fb9a9224SMatthew Dillon   ENCODING initEnc;
283fb9a9224SMatthew Dillon   const ENCODING **encPtr;
284fb9a9224SMatthew Dillon } INIT_ENCODING;
285fb9a9224SMatthew Dillon 
286*0c65ac1dSAntonio Huete Jimenez int XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc,
287*0c65ac1dSAntonio Huete Jimenez                     const char *ptr, const char *end, const char **badPtr,
288*0c65ac1dSAntonio Huete Jimenez                     const char **versionPtr, const char **versionEndPtr,
289fb9a9224SMatthew Dillon                     const char **encodingNamePtr,
290*0c65ac1dSAntonio Huete Jimenez                     const ENCODING **namedEncodingPtr, int *standalonePtr);
291fb9a9224SMatthew Dillon 
292fb9a9224SMatthew Dillon int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
293fb9a9224SMatthew Dillon const ENCODING *XmlGetUtf8InternalEncoding(void);
294fb9a9224SMatthew Dillon const ENCODING *XmlGetUtf16InternalEncoding(void);
295fb9a9224SMatthew Dillon int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
296fb9a9224SMatthew Dillon int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
297fb9a9224SMatthew Dillon int XmlSizeOfUnknownEncoding(void);
298fb9a9224SMatthew Dillon 
299fb9a9224SMatthew Dillon typedef int(XMLCALL *CONVERTER)(void *userData, const char *p);
300fb9a9224SMatthew Dillon 
301*0c65ac1dSAntonio Huete Jimenez ENCODING *XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert,
302fb9a9224SMatthew Dillon                                  void *userData);
303fb9a9224SMatthew Dillon 
304*0c65ac1dSAntonio Huete Jimenez int XmlParseXmlDeclNS(int isGeneralTextEntity, const ENCODING *enc,
305*0c65ac1dSAntonio Huete Jimenez                       const char *ptr, const char *end, const char **badPtr,
306*0c65ac1dSAntonio Huete Jimenez                       const char **versionPtr, const char **versionEndPtr,
307fb9a9224SMatthew Dillon                       const char **encodingNamePtr,
308*0c65ac1dSAntonio Huete Jimenez                       const ENCODING **namedEncodingPtr, int *standalonePtr);
309fb9a9224SMatthew Dillon 
310fb9a9224SMatthew Dillon int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
311fb9a9224SMatthew Dillon const ENCODING *XmlGetUtf8InternalEncodingNS(void);
312fb9a9224SMatthew Dillon const ENCODING *XmlGetUtf16InternalEncodingNS(void);
313*0c65ac1dSAntonio Huete Jimenez ENCODING *XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert,
314fb9a9224SMatthew Dillon                                    void *userData);
315fb9a9224SMatthew Dillon #ifdef __cplusplus
316fb9a9224SMatthew Dillon }
317fb9a9224SMatthew Dillon #endif
318fb9a9224SMatthew Dillon 
319fb9a9224SMatthew Dillon #endif /* not XmlTok_INCLUDED */
320