revert between 56095 -> 55830 in arch
[AROS.git] / tools / flexcat / src / include / libraries / codesets.h
blobedbf886ea76cb5ab64684a3a4b0dc161e636c81f
1 #ifndef LIBRARIES_CODESETS_H
2 #define LIBRARIES_CODESETS_H
4 /***************************************************************************
6 codesets.library - Amiga shared library for handling different codesets
7 Copyright (C) 2001-2005 by Alfonso [alfie] Ranieri <alforan@tin.it>.
8 Copyright (C) 2005-2014 codesets.library Open Source Team
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 codesets.library project: http://sourceforge.net/projects/codesetslib/
22 $Id$
24 ***************************************************************************/
26 #ifndef EXEC_SEMAPHORES_H
27 #include <exec/semaphores.h>
28 #endif
30 #ifndef UTILITY_TAGITEM_H
31 #include <utility/tagitem.h>
32 #endif
34 #ifndef UTILITY_HOOKS_H
35 #include <utility/hooks.h>
36 #endif
38 #ifdef __GNUC__
39 #ifdef __PPC__
40 #pragma pack(2)
41 #endif
42 #elif defined(__VBCC__)
43 #pragma amiga-align
44 #endif
46 /***********************************************************************/
48 ** Actual library name and version.
51 #define CODESETSNAME "codesets.library"
52 #define CODESETSVER 6
54 /***********************************************************************/
56 * Types
59 #ifndef UTF32_TYPEDEF
60 #define UTF32_TYPEDEF
61 typedef ULONG UTF32; /* at least 32 bits */
62 #endif
64 #ifndef UTF16_TYPEDEF
65 #define UTF16_TYPEDEF
66 typedef UWORD UTF16; /* at least 16 bits */
67 #endif
69 #ifndef UTF8_TYPEDEF
70 #define UTF8_TYPEDEF
71 typedef UBYTE UTF8; /* typically 8 bits */
72 #endif
74 /***********************************************************************/
76 * single_convert
79 struct single_convert
81 unsigned char code; /* the code in this representation */
82 UTF8 utf8[8]; /* the utf8 string, first byte is alway the length of the string */
83 unsigned int ucs4; /* the full 32 bit unicode */
86 /***********************************************************************/
88 * codeset
91 struct codeset
93 struct MinNode node;
94 char *name;
95 char *alt_name;
96 char *characterization;
97 int read_only;
98 struct single_convert table[256];
99 struct single_convert table_sorted[256];
102 /***********************************************************************/
104 * codesetList
107 struct codesetList
109 struct MinList list;
112 /***********************************************************************/
114 enum
116 CSR_ConversionOK=0, /* conversion successful */
117 CSR_SourceExhausted, /* partial character in source, but hit end */
118 CSR_TargetExhausted, /* insuff. room in target for conversion */
119 CSR_SourceIllegal /* source sequence is illegal/malformed */
122 enum
124 CSF_StrictConversion=0,
125 CSF_LenientConversion
128 /***********************************************************************/
131 ** Enumerations for CSA_CodesetFamily
133 enum
135 CSV_CodesetFamily_Latin=0, /* Latin Family */
136 CSV_CodesetFamily_Cyrillic /* Cyrillic Family */
139 /***********************************************************************/
141 ** Tags
144 #define CODESETSLIB_TAG(n) ((ULONG)0xfec901f4+(n))
146 #define CSA_Base CODESETSLIB_TAG(0)
148 #define CSA_SourceLen CODESETSLIB_TAG(1)
149 #define CSA_Source CODESETSLIB_TAG(2)
150 #define CSA_Dest CODESETSLIB_TAG(3)
151 #define CSA_DestLen CODESETSLIB_TAG(4)
152 #define CSA_DestHook CODESETSLIB_TAG(5)
153 #define CSA_DestLenPtr CODESETSLIB_TAG(6)
154 #define CSA_SourceCodeset CODESETSLIB_TAG(7)
155 #define CSA_Pool CODESETSLIB_TAG(8)
156 #define CSA_PoolSem CODESETSLIB_TAG(9)
157 #define CSA_AllocIfNeeded CODESETSLIB_TAG(10)
158 #define CSA_Save CODESETSLIB_TAG(11)
159 #define CSA_FallbackToDefault CODESETSLIB_TAG(12)
160 #define CSA_DestCodeset CODESETSLIB_TAG(13)
161 #define CSA_CodesetDir CODESETSLIB_TAG(14)
162 #define CSA_CodesetFile CODESETSLIB_TAG(15)
163 #define CSA_CodesetList CODESETSLIB_TAG(16)
164 #define CSA_FreeCodesets CODESETSLIB_TAG(17)
165 #define CSA_CodesetFamily CODESETSLIB_TAG(18)
166 #define CSA_ErrPtr CODESETSLIB_TAG(19)
168 #define CSA_B64SourceString CODESETSLIB_TAG(20)
169 #define CSA_B64SourceLen CODESETSLIB_TAG(21)
170 #define CSA_B64SourceFile CODESETSLIB_TAG(22)
171 #define CSA_B64DestPtr CODESETSLIB_TAG(23)
172 #define CSA_B64DestFile CODESETSLIB_TAG(24)
173 #define CSA_B64MaxLineLen CODESETSLIB_TAG(25)
174 #define CSA_B64Unix CODESETSLIB_TAG(26)
175 #define CSA_B64FLG_NtCheckErr CODESETSLIB_TAG(27)
177 #define CSA_MapForeignChars CODESETSLIB_TAG(28)
178 #define CSA_MapForeignCharsHook CODESETSLIB_TAG(29)
180 #define CSA_AllowMultibyteCodesets CODESETSLIB_TAG(30)
182 /***********************************************************************/
184 ** Returns code from CodesetsEncodeB64A() CodesetsDecodeB64A()
187 enum
189 CSR_B64_ERROR_OK = 0,
190 CSR_B64_ERROR_MEM,
191 CSR_B64_ERROR_DOS,
192 CSR_B64_ERROR_INCOMPLETE,
193 CSR_B64_ERROR_ILLEGAL,
196 /***********************************************************************/
198 struct convertMsg
200 ULONG state;
201 ULONG len;
204 enum
206 CSV_Translating,
207 CSV_End,
210 /***********************************************************************/
213 ** the message passed to a CSA_MapForeignCharsHook hook
214 ** the hook function must return the length of the replacement string
215 ** == 0 signals 'no replacement found'
216 ** > 0 will use the supplied string directly
217 ** < 0 signals an UTF8 replacement of negated length
219 struct replaceMsg
221 char **dst; /* place the replace string here */
222 unsigned char *src; /* the source UTF8 string */
223 int srclen; /* length of the UTF8 sequence */
226 /***********************************************************************/
228 #ifdef __GNUC__
229 #ifdef __PPC__
230 #pragma pack()
231 #endif
232 #elif defined(__VBCC__)
233 #pragma default-align
234 #endif
236 #endif /* LIBRARIES_CODESETS_H */