BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
xmltok_ns.c
Go to the documentation of this file.
1const ENCODING *NS(XmlGetUtf8InternalEncoding)()
2{
3 return &ns(internal_utf8_encoding).enc;
4}
5
7{
8#if XML_BYTE_ORDER == 12
9 return &ns(internal_little2_encoding).enc;
10#elif XML_BYTE_ORDER == 21
11 return &ns(internal_big2_encoding).enc;
12#else
13 const short n = 1;
14 return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc;
15#endif
16}
17
18static
19const ENCODING *NS(encodings)[] = {
20 &ns(latin1_encoding).enc,
21 &ns(ascii_encoding).enc,
22 &ns(utf8_encoding).enc,
23 &ns(big2_encoding).enc,
24 &ns(big2_encoding).enc,
25 &ns(little2_encoding).enc,
26 &ns(utf8_encoding).enc /* NO_ENC */
27};
28
29static
30int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
31 const char **nextTokPtr)
32{
33 return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
34}
35
36static
37int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
38 const char **nextTokPtr)
39{
40 return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
41}
42
43int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
44{
45 int i = getEncodingIndex(name);
46 if (i == UNKNOWN_ENC)
47 return 0;
48 INIT_ENC_INDEX(p) = (char)i;
49 p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
50 p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
51 p->initEnc.updatePosition = initUpdatePosition;
52 p->encPtr = encPtr;
53 *encPtr = &(p->initEnc);
54 return 1;
55}
56
57static
58const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
59{
60#define ENCODING_MAX 128
61 char buf[ENCODING_MAX];
62 char *p = buf;
63 int i;
64 XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
65 if (ptr != end)
66 return 0;
67 *p = 0;
68 if (streqci(buf, "UTF-16") && enc->minBytesPerChar == 2)
69 return enc;
70 i = getEncodingIndex(buf);
71 if (i == UNKNOWN_ENC)
72 return 0;
73 return NS(encodings)[i];
74}
75
76int NS(XmlParseXmlDecl)(int isGeneralTextEntity,
77 const ENCODING *enc,
78 const char *ptr,
79 const char *end,
80 const char **badPtr,
81 const char **versionPtr,
82 const char **encodingName,
83 const ENCODING **encoding,
84 int *standalone)
85{
86 return doParseXmlDecl(NS(findEncoding),
87 isGeneralTextEntity,
88 enc,
89 ptr,
90 end,
91 badPtr,
92 versionPtr,
93 encodingName,
94 encoding,
95 standalone);
96}
const Int_t n
#define NS(x)
Definition: xmltok.c:1503
#define INIT_ENC_INDEX(enc)
Definition: xmltok.c:1378
#define ns(x)
Definition: xmltok.c:1504
@ UNKNOWN_ENC
Definition: xmltok.c:1344
#define ENCODING_MAX
int NS() XmlInitEncoding(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
Definition: xmltok_ns.c:43
const ENCODING *NS() XmlGetUtf8InternalEncoding()
Definition: xmltok_ns.c:1
const ENCODING *NS() XmlGetUtf16InternalEncoding()
Definition: xmltok_ns.c:6
int NS() XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc, const char *ptr, const char *end, const char **badPtr, const char **versionPtr, const char **encodingName, const ENCODING **encoding, int *standalone)
Definition: xmltok_ns.c:76