00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef XmlTok_INCLUDED
00032 #define XmlTok_INCLUDED 1
00033
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037
00038 #ifndef XMLTOKAPI
00039 #define XMLTOKAPI
00040 #endif
00041
00042
00043 #define XML_TOK_TRAILING_RSQB -5
00044
00045
00046 #define XML_TOK_NONE -4
00047 #define XML_TOK_TRAILING_CR -3
00048
00049 #define XML_TOK_PARTIAL_CHAR -2
00050 #define XML_TOK_PARTIAL -1
00051 #define XML_TOK_INVALID 0
00052
00053
00054
00055
00056 #define XML_TOK_START_TAG_WITH_ATTS 1
00057 #define XML_TOK_START_TAG_NO_ATTS 2
00058 #define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3
00059 #define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
00060 #define XML_TOK_END_TAG 5
00061 #define XML_TOK_DATA_CHARS 6
00062 #define XML_TOK_DATA_NEWLINE 7
00063 #define XML_TOK_CDATA_SECT_OPEN 8
00064 #define XML_TOK_ENTITY_REF 9
00065 #define XML_TOK_CHAR_REF 10
00066
00067
00068 #define XML_TOK_PI 11
00069 #define XML_TOK_XML_DECL 12
00070 #define XML_TOK_COMMENT 13
00071 #define XML_TOK_BOM 14
00072
00073
00074 #define XML_TOK_PROLOG_S 15
00075 #define XML_TOK_DECL_OPEN 16
00076 #define XML_TOK_DECL_CLOSE 17
00077 #define XML_TOK_NAME 18
00078 #define XML_TOK_NMTOKEN 19
00079 #define XML_TOK_POUND_NAME 20
00080 #define XML_TOK_OR 21
00081 #define XML_TOK_PERCENT 22
00082 #define XML_TOK_OPEN_PAREN 23
00083 #define XML_TOK_CLOSE_PAREN 24
00084 #define XML_TOK_OPEN_BRACKET 25
00085 #define XML_TOK_CLOSE_BRACKET 26
00086 #define XML_TOK_LITERAL 27
00087 #define XML_TOK_PARAM_ENTITY_REF 28
00088 #define XML_TOK_INSTANCE_START 29
00089
00090
00091 #define XML_TOK_NAME_QUESTION 30
00092 #define XML_TOK_NAME_ASTERISK 31
00093 #define XML_TOK_NAME_PLUS 32
00094 #define XML_TOK_COND_SECT_OPEN 33
00095 #define XML_TOK_COND_SECT_CLOSE 34
00096 #define XML_TOK_CLOSE_PAREN_QUESTION 35
00097 #define XML_TOK_CLOSE_PAREN_ASTERISK 36
00098 #define XML_TOK_CLOSE_PAREN_PLUS 37
00099 #define XML_TOK_COMMA 38
00100
00101
00102 #define XML_TOK_ATTRIBUTE_VALUE_S 39
00103
00104
00105 #define XML_TOK_CDATA_SECT_CLOSE 40
00106
00107
00108
00109 #define XML_TOK_PREFIXED_NAME 41
00110
00111 #define XML_N_STATES 3
00112 #define XML_PROLOG_STATE 0
00113 #define XML_CONTENT_STATE 1
00114 #define XML_CDATA_SECTION_STATE 2
00115
00116 #define XML_N_LITERAL_TYPES 2
00117 #define XML_ATTRIBUTE_VALUE_LITERAL 0
00118 #define XML_ENTITY_VALUE_LITERAL 1
00119
00120
00121 #define XML_UTF8_ENCODE_MAX 4
00122
00123 #define XML_UTF16_ENCODE_MAX 2
00124
00125 typedef struct position {
00126
00127 unsigned long lineNumber;
00128 unsigned long columnNumber;
00129 } POSITION;
00130
00131 typedef struct {
00132 const char *name;
00133 const char *valuePtr;
00134 const char *valueEnd;
00135 char normalized;
00136 } ATTRIBUTE;
00137
00138 struct encoding;
00139 typedef struct encoding ENCODING;
00140
00141 struct encoding {
00142 int (*scanners[XML_N_STATES])(const ENCODING *,
00143 const char *,
00144 const char *,
00145 const char **);
00146 int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
00147 const char *,
00148 const char *,
00149 const char **);
00150 int (*sameName)(const ENCODING *,
00151 const char *, const char *);
00152 int (*nameMatchesAscii)(const ENCODING *,
00153 const char *, const char *);
00154 int (*nameLength)(const ENCODING *, const char *);
00155 const char *(*skipS)(const ENCODING *, const char *);
00156 int (*getAtts)(const ENCODING *enc, const char *ptr,
00157 int attsMax, ATTRIBUTE *atts);
00158 int (*charRefNumber)(const ENCODING *enc, const char *ptr);
00159 int (*predefinedEntityName)(const ENCODING *, const char *, const char *);
00160 void (*updatePosition)(const ENCODING *,
00161 const char *ptr,
00162 const char *end,
00163 POSITION *);
00164 int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
00165 const char **badPtr);
00166 void (*utf8Convert)(const ENCODING *enc,
00167 const char **fromP,
00168 const char *fromLim,
00169 char **toP,
00170 const char *toLim);
00171 void (*utf16Convert)(const ENCODING *enc,
00172 const char **fromP,
00173 const char *fromLim,
00174 unsigned short **toP,
00175 const unsigned short *toLim);
00176 int minBytesPerChar;
00177 char isUtf8;
00178 char isUtf16;
00179 };
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 #define XmlTok(enc, state, ptr, end, nextTokPtr) \
00203 (((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
00204
00205 #define XmlPrologTok(enc, ptr, end, nextTokPtr) \
00206 XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
00207
00208 #define XmlContentTok(enc, ptr, end, nextTokPtr) \
00209 XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
00210
00211 #define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
00212 XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
00213
00214
00215
00216
00217 #define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
00218 (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
00219
00220 #define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
00221 XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
00222
00223 #define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
00224 XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
00225
00226 #define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
00227
00228 #define XmlNameMatchesAscii(enc, ptr1, ptr2) \
00229 (((enc)->nameMatchesAscii)(enc, ptr1, ptr2))
00230
00231 #define XmlNameLength(enc, ptr) \
00232 (((enc)->nameLength)(enc, ptr))
00233
00234 #define XmlSkipS(enc, ptr) \
00235 (((enc)->skipS)(enc, ptr))
00236
00237 #define XmlGetAttributes(enc, ptr, attsMax, atts) \
00238 (((enc)->getAtts)(enc, ptr, attsMax, atts))
00239
00240 #define XmlCharRefNumber(enc, ptr) \
00241 (((enc)->charRefNumber)(enc, ptr))
00242
00243 #define XmlPredefinedEntityName(enc, ptr, end) \
00244 (((enc)->predefinedEntityName)(enc, ptr, end))
00245
00246 #define XmlUpdatePosition(enc, ptr, end, pos) \
00247 (((enc)->updatePosition)(enc, ptr, end, pos))
00248
00249 #define XmlIsPublicId(enc, ptr, end, badPtr) \
00250 (((enc)->isPublicId)(enc, ptr, end, badPtr))
00251
00252 #define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
00253 (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
00254
00255 #define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
00256 (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
00257
00258 typedef struct {
00259 ENCODING initEnc;
00260 const ENCODING **encPtr;
00261 } INIT_ENCODING;
00262
00263 int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity,
00264 const ENCODING *enc,
00265 const char *ptr,
00266 const char *end,
00267 const char **badPtr,
00268 const char **versionPtr,
00269 const char **encodingNamePtr,
00270 const ENCODING **namedEncodingPtr,
00271 int *standalonePtr);
00272
00273 int XMLTOKAPI XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
00274 const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncoding();
00275 const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncoding();
00276 int XMLTOKAPI XmlUtf8Encode(int charNumber, char *buf);
00277 int XMLTOKAPI XmlUtf16Encode(int charNumber, unsigned short *buf);
00278
00279 int XMLTOKAPI XmlSizeOfUnknownEncoding();
00280 ENCODING XMLTOKAPI *
00281 XmlInitUnknownEncoding(void *mem,
00282 int *table,
00283 int (*conv)(void *userData, const char *p),
00284 void *userData);
00285
00286 int XMLTOKAPI XmlParseXmlDeclNS(int isGeneralTextEntity,
00287 const ENCODING *enc,
00288 const char *ptr,
00289 const char *end,
00290 const char **badPtr,
00291 const char **versionPtr,
00292 const char **encodingNamePtr,
00293 const ENCODING **namedEncodingPtr,
00294 int *standalonePtr);
00295 int XMLTOKAPI XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
00296 const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncodingNS();
00297 const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncodingNS();
00298 ENCODING XMLTOKAPI *
00299 XmlInitUnknownEncodingNS(void *mem,
00300 int *table,
00301 int (*conv)(void *userData, const char *p),
00302 void *userData);
00303 #ifdef __cplusplus
00304 }
00305 #endif
00306
00307 #endif