2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * Copyright (C) 1998-1999 The Jabber Team http://jabber.org/
20 const ENCODING
*NS(XmlGetUtf8InternalEncoding
)()
22 return &ns(internal_utf8_encoding
).enc
;
25 const ENCODING
*NS(XmlGetUtf16InternalEncoding
)()
27 #if XML_BYTE_ORDER == 12
28 return &ns(internal_little2_encoding
).enc
;
29 #elif XML_BYTE_ORDER == 21
30 return &ns(internal_big2_encoding
).enc
;
33 return *(const char *)&n
? &ns(internal_little2_encoding
).enc
: &ns(internal_big2_encoding
).enc
;
38 const ENCODING
*NS(encodings
)[] = {
39 &ns(latin1_encoding
).enc
,
40 &ns(ascii_encoding
).enc
,
41 &ns(utf8_encoding
).enc
,
42 &ns(big2_encoding
).enc
,
43 &ns(big2_encoding
).enc
,
44 &ns(little2_encoding
).enc
,
45 &ns(utf8_encoding
).enc
/* NO_ENC */
49 int NS(initScanProlog
)(const ENCODING
*enc
, const char *ptr
, const char *end
,
50 const char **nextTokPtr
)
52 return initScan(NS(encodings
), (const INIT_ENCODING
*)enc
, XML_PROLOG_STATE
, ptr
, end
, nextTokPtr
);
56 int NS(initScanContent
)(const ENCODING
*enc
, const char *ptr
, const char *end
,
57 const char **nextTokPtr
)
59 return initScan(NS(encodings
), (const INIT_ENCODING
*)enc
, XML_CONTENT_STATE
, ptr
, end
, nextTokPtr
);
62 int NS(XmlInitEncoding
)(INIT_ENCODING
*p
, const ENCODING
**encPtr
, const char *name
)
64 int i
= getEncodingIndex(name
);
67 INIT_ENC_INDEX(p
) = (char)i
;
68 p
->initEnc
.scanners
[XML_PROLOG_STATE
] = NS(initScanProlog
);
69 p
->initEnc
.scanners
[XML_CONTENT_STATE
] = NS(initScanContent
);
70 p
->initEnc
.updatePosition
= initUpdatePosition
;
72 *encPtr
= &(p
->initEnc
);
77 const ENCODING
*NS(findEncoding
)(const ENCODING
*enc
, const char *ptr
, const char *end
)
79 #define ENCODING_MAX 128
80 char buf
[ENCODING_MAX
];
83 XmlUtf8Convert(enc
, &ptr
, end
, &p
, p
+ ENCODING_MAX
- 1);
87 if (streqci(buf
, "UTF-16") && enc
->minBytesPerChar
== 2)
89 i
= getEncodingIndex(buf
);
92 return NS(encodings
)[i
];
95 int NS(XmlParseXmlDecl
)(int isGeneralTextEntity
,
100 const char **versionPtr
,
101 const char **encodingName
,
102 const ENCODING
**encoding
,
105 return doParseXmlDecl(NS(findEncoding
),