1 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
5 /* This file is included! */
9 NS(XmlGetUtf8InternalEncoding
)(void)
11 return &ns(internal_utf8_encoding
).enc
;
15 NS(XmlGetUtf16InternalEncoding
)(void)
18 return &ns(internal_little2_encoding
).enc
;
19 #elif BYTEORDER == 4321
20 return &ns(internal_big2_encoding
).enc
;
23 return (*(const char *)&n
24 ? &ns(internal_little2_encoding
).enc
25 : &ns(internal_big2_encoding
).enc
);
29 static const ENCODING
* const NS(encodings
)[] = {
30 &ns(latin1_encoding
).enc
,
31 &ns(ascii_encoding
).enc
,
32 &ns(utf8_encoding
).enc
,
33 &ns(big2_encoding
).enc
,
34 &ns(big2_encoding
).enc
,
35 &ns(little2_encoding
).enc
,
36 &ns(utf8_encoding
).enc
/* NO_ENC */
40 NS(initScanProlog
)(const ENCODING
*enc
, const char *ptr
, const char *end
,
41 const char **nextTokPtr
)
43 return initScan(NS(encodings
), (const INIT_ENCODING
*)enc
,
44 XML_PROLOG_STATE
, ptr
, end
, nextTokPtr
);
48 NS(initScanContent
)(const ENCODING
*enc
, const char *ptr
, const char *end
,
49 const char **nextTokPtr
)
51 return initScan(NS(encodings
), (const INIT_ENCODING
*)enc
,
52 XML_CONTENT_STATE
, ptr
, end
, nextTokPtr
);
56 NS(XmlInitEncoding
)(INIT_ENCODING
*p
, const ENCODING
**encPtr
,
59 int i
= getEncodingIndex(name
);
62 SET_INIT_ENC_INDEX(p
, i
);
63 p
->initEnc
.scanners
[XML_PROLOG_STATE
] = NS(initScanProlog
);
64 p
->initEnc
.scanners
[XML_CONTENT_STATE
] = NS(initScanContent
);
65 p
->initEnc
.updatePosition
= initUpdatePosition
;
67 *encPtr
= &(p
->initEnc
);
71 static const ENCODING
*
72 NS(findEncoding
)(const ENCODING
*enc
, const char *ptr
, const char *end
)
74 #define ENCODING_MAX 128
75 char buf
[ENCODING_MAX
];
78 XmlUtf8Convert(enc
, &ptr
, end
, &p
, p
+ ENCODING_MAX
- 1);
82 if (streqci(buf
, KW_UTF_16
) && enc
->minBytesPerChar
== 2)
84 i
= getEncodingIndex(buf
);
87 return NS(encodings
)[i
];
91 NS(XmlParseXmlDecl
)(int isGeneralTextEntity
,
96 const char **versionPtr
,
97 const char **versionEndPtr
,
98 const char **encodingName
,
99 const ENCODING
**encoding
,
102 return doParseXmlDecl(NS(findEncoding
),
115 #endif /* XML_TOK_NS_C */