1 /*
2 * Codepage tables
3 *
4 * Copyright 2000 Alexandre Julliard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include <stdlib.h>
22
23 #include "wine/unicode.h"
24
25 #ifndef ARRAY_SIZE
26 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
27 #endif
28
29 /* Everything below this line is generated automatically by make_unicode */
30 /* ### cpmap begin ### */
31 extern union cptable cptable_037;
32 extern union cptable cptable_424;
33 extern union cptable cptable_437;
34 extern union cptable cptable_500;
35 extern union cptable cptable_737;
36 extern union cptable cptable_775;
37 extern union cptable cptable_850;
38 extern union cptable cptable_852;
39 extern union cptable cptable_855;
40 extern union cptable cptable_856;
41 extern union cptable cptable_857;
42 extern union cptable cptable_860;
43 extern union cptable cptable_861;
44 extern union cptable cptable_862;
45 extern union cptable cptable_863;
46 extern union cptable cptable_864;
47 extern union cptable cptable_865;
48 extern union cptable cptable_866;
49 extern union cptable cptable_869;
50 extern union cptable cptable_874;
51 extern union cptable cptable_875;
52 extern union cptable cptable_878;
53 extern union cptable cptable_932;
54 extern union cptable cptable_936;
55 extern union cptable cptable_949;
56 extern union cptable cptable_950;
57 extern union cptable cptable_1006;
58 extern union cptable cptable_1026;
59 extern union cptable cptable_1250;
60 extern union cptable cptable_1251;
61 extern union cptable cptable_1252;
62 extern union cptable cptable_1253;
63 extern union cptable cptable_1254;
64 extern union cptable cptable_1255;
65 extern union cptable cptable_1256;
66 extern union cptable cptable_1257;
67 extern union cptable cptable_1258;
68 extern union cptable cptable_1361;
69 extern union cptable cptable_10000;
70 extern union cptable cptable_10001;
71 extern union cptable cptable_10002;
72 extern union cptable cptable_10003;
73 extern union cptable cptable_10004;
74 extern union cptable cptable_10005;
75 extern union cptable cptable_10006;
76 extern union cptable cptable_10007;
77 extern union cptable cptable_10008;
78 extern union cptable cptable_10010;
79 extern union cptable cptable_10017;
80 extern union cptable cptable_10021;
81 extern union cptable cptable_10029;
82 extern union cptable cptable_10079;
83 extern union cptable cptable_10081;
84 extern union cptable cptable_10082;
85 extern union cptable cptable_20127;
86 extern union cptable cptable_20866;
87 extern union cptable cptable_20932;
88 extern union cptable cptable_21866;
89 extern union cptable cptable_28591;
90 extern union cptable cptable_28592;
91 extern union cptable cptable_28593;
92 extern union cptable cptable_28594;
93 extern union cptable cptable_28595;
94 extern union cptable cptable_28596;
95 extern union cptable cptable_28597;
96 extern union cptable cptable_28598;
97 extern union cptable cptable_28599;
98 extern union cptable cptable_28600;
99 extern union cptable cptable_28601;
100 extern union cptable cptable_28603;
101 extern union cptable cptable_28604;
102 extern union cptable cptable_28605;
103 extern union cptable cptable_28606;
104
105 static const union cptable * const cptables[73] =
106 {
107 &cptable_037,
108 &cptable_424,
109 &cptable_437,
110 &cptable_500,
111 &cptable_737,
112 &cptable_775,
113 &cptable_850,
114 &cptable_852,
115 &cptable_855,
116 &cptable_856,
117 &cptable_857,
118 &cptable_860,
119 &cptable_861,
120 &cptable_862,
121 &cptable_863,
122 &cptable_864,
123 &cptable_865,
124 &cptable_866,
125 &cptable_869,
126 &cptable_874,
127 &cptable_875,
128 &cptable_878,
129 &cptable_932,
130 &cptable_936,
131 &cptable_949,
132 &cptable_950,
133 &cptable_1006,
134 &cptable_1026,
135 &cptable_1250,
136 &cptable_1251,
137 &cptable_1252,
138 &cptable_1253,
139 &cptable_1254,
140 &cptable_1255,
141 &cptable_1256,
142 &cptable_1257,
143 &cptable_1258,
144 &cptable_1361,
145 &cptable_10000,
146 &cptable_10001,
147 &cptable_10002,
148 &cptable_10003,
149 &cptable_10004,
150 &cptable_10005,
151 &cptable_10006,
152 &cptable_10007,
153 &cptable_10008,
154 &cptable_10010,
155 &cptable_10017,
156 &cptable_10021,
157 &cptable_10029,
158 &cptable_10079,
159 &cptable_10081,
160 &cptable_10082,
161 &cptable_20127,
162 &cptable_20866,
163 &cptable_20932,
164 &cptable_21866,
165 &cptable_28591,
166 &cptable_28592,
167 &cptable_28593,
168 &cptable_28594,
169 &cptable_28595,
170 &cptable_28596,
171 &cptable_28597,
172 &cptable_28598,
173 &cptable_28599,
174 &cptable_28600,
175 &cptable_28601,
176 &cptable_28603,
177 &cptable_28604,
178 &cptable_28605,
179 &cptable_28606,
180 };
181 /* ### cpmap end ### */
182 /* Everything above this line is generated automatically by make_unicode */
183
184
cmp_codepage(const void * codepage,const void * entry)185 static int cmp_codepage( const void *codepage, const void *entry )
186 {
187 return *(const unsigned int *)codepage - (*(const union cptable *const *)entry)->info.codepage;
188 }
189
190
191 /* get the table of a given code page */
wine_cp_get_table(unsigned int codepage)192 const union cptable *wine_cp_get_table( unsigned int codepage )
193 {
194 const union cptable **res;
195
196 if (!(res = bsearch( &codepage, cptables, ARRAY_SIZE( cptables ),
197 sizeof(cptables[0]), cmp_codepage ))) return NULL;
198 return *res;
199 }
200
201
202 /* enum valid codepages */
wine_cp_enum_table(unsigned int index)203 const union cptable *wine_cp_enum_table( unsigned int index )
204 {
205 if (index >= ARRAY_SIZE( cptables )) return NULL;
206 return cptables[index];
207 }
208