added Info.plist
[TestXSLT.git] / libsablot / src / engine / encoding.h
1 /* 
2  * The contents of this file are subject to the Mozilla Public
3  * License Version 1.1 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of
5  * the License at http://www.mozilla.org/MPL/
6  * 
7  * Software distributed under the License is distributed on an "AS
8  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9  * implied. See the License for the specific language governing
10  * rights and limitations under the License.
11  * 
12  * The Original Code is the Sablotron XSLT Processor.
13  * 
14  * The Initial Developer of the Original Code is Ginger Alliance Ltd.
15  * Portions created by Ginger Alliance are Copyright (C) 2000-2002
16  * Ginger Alliance Ltd. All Rights Reserved.
17  * 
18  * Contributor(s):
19  * 
20  * Alternatively, the contents of this file may be used under the
21  * terms of the GNU General Public License Version 2 or later (the
22  * "GPL"), in which case the provisions of the GPL are applicable 
23  * instead of those above.  If you wish to allow use of your 
24  * version of this file only under the terms of the GPL and not to
25  * allow others to use your version of this file under the MPL,
26  * indicate your decision by deleting the provisions above and
27  * replace them with the notice and other provisions required by
28  * the GPL.  If you do not delete the provisions above, a recipient
29  * may use your version of this file under either the MPL or the
30  * GPL.
31  */
32
33 #ifndef EncodingHIncl
34 #define EncodingHIncl
35
36 // GP: clean :-)
37
38 #include "base.h"
39
40 enum EncMethod
41 {
42     ENC_ICONV,
43     ENC_INTERNAL,
44     ENC_HANDLER,
45     ENC_NONE
46 };
47
48 enum EncResult
49 {
50     ENC_OK,
51     ENC_EINVAL,
52     ENC_E2BIG,
53     ENC_EILSEQ
54 };
55
56
57 struct ConvInfo
58 {
59     EncMethod method;
60     void* physCD;
61 };
62
63 typedef ConvInfo* CDesc;
64
65 //  Recoder
66 //  covers all the encoding stuff, dispatching requests to either iconv, the internal
67 //  routine (sabconv), or the external encoding handler
68
69 class Recoder
70 {
71 public:
72     Recoder();
73     Bool handledByExpat(const Str& enc) const;
74     eFlag openFromUTF8(Sit S, const Str& enc, CDesc& cd);
75     eFlag openToUTF8(Sit S, const Str& enc, CDesc& cd);
76     eFlag conv(Sit S, CDesc cd, const char *&inbuf, size_t &inbytesleft, 
77         char *&outbuf, size_t &outbytesleft, EncResult& result);
78     eFlag close(Sit S, CDesc cd);
79     void clear(Sit S);
80     ~Recoder();
81 private:
82     eFlag open(Sit S, const Str& enc, Bool toUTF8, CDesc& cd);
83     PList<ConvInfo*> items;
84     void report(Sit S, MsgType type, MsgCode code, const Str& arg1, const Str& arg2);   
85 };
86
87 #endif // EncodingHIncl