ReactOS  0.4.12-dev-934-g9a4676f
mlang.c
Go to the documentation of this file.
1 /*
2  * MLANG Class Factory
3  *
4  * Copyright 2002 Lionel Ulmer
5  * Copyright 2003,2004 Mike McCormack
6  * Copyright 2004,2005 Dmitry Timoshkov
7  * Copyright 2009 Detlef Riekenberg
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include "config.h"
25 
26 #include <stdarg.h>
27 #include <stdio.h>
28 
29 #define COBJMACROS
30 
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "winuser.h"
35 #include "ole2.h"
36 #include "objbase.h"
37 #include "rpcproxy.h"
38 #include "mlang.h"
39 #include "mimeole.h"
40 
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
43 #include "wine/list.h"
44 
46 
47 #include "initguid.h"
48 
49 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj);
50 static HRESULT MLangConvertCharset_create(IUnknown *outer, void **obj);
51 static HRESULT EnumRfc1766_create(LANGID LangId, IEnumRfc1766 **ppEnum);
52 
54 static DWORD MLANG_tls_index; /* to store various per thead data */
55 
56 /* FIXME:
57  * Under what circumstances HKEY_CLASSES_ROOT\MIME\Database\Codepage and
58  * HKEY_CLASSES_ROOT\MIME\Database\Charset are used?
59  */
60 
61 typedef struct
62 {
63  const char *description;
66  const char *web_charset;
67  const char *header_charset;
68  const char *body_charset;
69  const WCHAR *alias;
70 } MIME_CP_INFO;
71 
72 /* These data are based on the codepage info in libs/unicode/cpmap.pl */
73 /* FIXME: Add 28604 (Celtic), 28606 (Balkan) */
74 
75 static const MIME_CP_INFO arabic_cp[] =
76 {
77  { "Arabic (864)",
78  864, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
79  MIMECONTF_MIME_LATEST,
80  "ibm864", "ibm864", "ibm864" },
81  { "Arabic (1006)",
82  1006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
83  MIMECONTF_MIME_LATEST,
84  "ibm1006", "ibm1006", "ibm1006" },
85  { "Arabic (Windows)",
86  1256, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
87  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
88  MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
89  "windows-1256", "windows-1256", "windows-1256" },
90  { "Arabic (ISO)",
91  28596, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
92  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
93  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
94  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
95  "iso-8859-6", "iso-8859-6", "iso-8859-6" }
96 };
97 static const MIME_CP_INFO baltic_cp[] =
98 {
99  { "Baltic (DOS)",
100  775, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
101  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
102  "ibm775", "ibm775", "ibm775" },
103  { "Baltic (Windows)",
104  1257, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
105  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
106  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
107  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
108  "windows-1257", "windows-1257", "windows-1257" },
109  { "Baltic (ISO)",
110  28594, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
111  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
112  MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
113  MIMECONTF_MIME_LATEST,
114  "iso-8859-4", "iso-8859-4", "iso-8859-4" },
115  { "Estonian (ISO)",
116  28603, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
117  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
118  "iso-8859-13", "iso-8859-13", "iso-8859-13" }
119 };
121 {
122  { "Chinese Simplified (Auto-Select)",
123  50936, MIMECONTF_IMPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
124  MIMECONTF_MIME_LATEST,
125  "_autodetect_chs", "_autodetect_chs", "_autodetect_chs" },
126  { "Chinese Simplified (GB2312)",
127  936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
128  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_VALID |
129  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
130  MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
131  "gb2312", "gb2312", "gb2312" },
132  { "Chinese Simplified (GB2312-80)",
133  20936, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
134  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
135  "x-cp20936", "x-cp20936", "x-cp20936" },
136  { "Chinese Simplified (HZ)",
137  52936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
138  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
139  MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
140  MIMECONTF_MIME_LATEST,
141  "hz-gb-2312", "hz-gb-2312", "hz-gb-2312" },
142  { "Chinese Simplified (GB18030)",
143  54936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
144  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
145  MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
146  MIMECONTF_MIME_LATEST,
147  "GB18030", "GB18030", "GB18030" },
148  { "Chinese Simplified (GBK)",
149  936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
150  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
151  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
152  MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
153  "gbk", "gbk", "gbk" }
154 };
156 {
157  { "Chinese Traditional (Auto-Select)",
158  50950, MIMECONTF_IMPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
159  MIMECONTF_MIME_LATEST,
160  "_autodetect_cht", "_autodetect_cht", "_autodetect_cht" },
161  { "Chinese Traditional (Big5)",
162  950, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
163  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
164  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
165  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
166  "big5", "big5", "big5" },
167  { "Chinese Traditional (CNS)",
168  20000, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
169  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
170  "x-Chinese-CNS", "x-Chinese-CNS", "x-Chinese-CNS" }
171 };
173 {
174  { "Central European (DOS)",
175  852, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
176  MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
177  MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
178  "ibm852", "ibm852", "ibm852" },
179  { "Central European (Windows)",
180  1250, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
181  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
182  MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
183  MIMECONTF_MIME_LATEST,
184  "windows-1250", "windows-1250", "windows-1250" },
185  { "Central European (Mac)",
186  10029, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
187  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
188  "x-mac-ce", "x-mac-ce", "x-mac-ce" },
189  { "Central European (ISO)",
190  28592, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
191  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
192  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
193  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
194  "iso-8859-2", "iso-8859-2", "iso-8859-2" }
195 };
196 static const MIME_CP_INFO cyrillic_cp[] =
197 {
198  { "OEM Cyrillic",
199  855, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
200  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
201  "ibm855", "ibm855", "ibm855" },
202  { "Cyrillic (DOS)",
203  866, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
204  MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
205  MIMECONTF_MIME_LATEST,
206  "cp866", "cp866", "cp866" },
207 #if 0 /* Windows has 20866 as an official code page for KOI8-R */
208  { "Cyrillic (KOI8-R)",
209  878, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
210  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
211  "koi8-r", "koi8-r", "koi8-r" },
212 #endif
213  { "Cyrillic (Windows)",
214  1251, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
215  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
216  MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
217  "windows-1251", "windows-1251", "windows-1251" },
218  { "Cyrillic (Mac)",
219  10007, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
220  MIMECONTF_MIME_LATEST,
221  "x-mac-cyrillic", "x-mac-cyrillic", "x-mac-cyrillic" },
222  { "Cyrillic (KOI8-R)",
223  20866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
224  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
225  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
226  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
227  "koi8-r", "koi8-r", "koi8-r" },
228  { "Cyrillic (KOI8-U)",
229  21866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
230  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
231  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
232  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
233  "koi8-u", "koi8-u", "koi8-u" },
234  { "Cyrillic (ISO)",
235  28595, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
236  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
237  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
238  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
239  "iso-8859-5", "iso-8859-5", "iso-8859-5" }
240 };
241 static const MIME_CP_INFO greek_cp[] =
242 {
243  { "Greek (DOS)",
244  737, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
245  MIMECONTF_MIME_LATEST,
246  "ibm737", "ibm737", "ibm737" },
247  { "Greek, Modern (DOS)",
248  869, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
249  MIMECONTF_MIME_LATEST,
250  "ibm869", "ibm869", "ibm869" },
251  { "IBM EBCDIC (Greek Modern)",
252  875, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
253  MIMECONTF_MIME_LATEST,
254  "cp875", "cp875", "cp875" },
255  { "Greek (Windows)",
256  1253, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
257  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
258  MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
259  "windows-1253", "windows-1253", "windows-1253" },
260  { "Greek (Mac)",
261  10006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
262  MIMECONTF_MIME_LATEST,
263  "x-mac-greek", "x-mac-greek", "x-mac-greek" },
264  { "Greek (ISO)",
265  28597, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
266  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
267  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
268  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
269  "iso-8859-7", "iso-8859-7", "iso-8859-7" }
270 };
271 static const MIME_CP_INFO hebrew_cp[] =
272 {
273  { "Hebrew (424)",
274  424, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
275  MIMECONTF_MIME_LATEST,
276  "ibm424", "ibm424", "ibm424" },
277  { "Hebrew (856)",
278  856, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
279  MIMECONTF_MIME_LATEST,
280  "cp856", "cp856", "cp856" },
281  { "Hebrew (DOS)",
282  862, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
283  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
284  MIMECONTF_MIME_LATEST,
285  "dos-862", "dos-862", "dos-862" },
286  { "Hebrew (Windows)",
287  1255, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
288  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
289  MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
290  "windows-1255", "windows-1255", "windows-1255" },
291  { "Hebrew (ISO-Visual)",
292  28598, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
293  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
294  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
295  "iso-8859-8", "iso-8859-8", "iso-8859-8" }
296 };
297 static const MIME_CP_INFO japanese_cp[] =
298 {
299  { "Japanese (Auto-Select)",
300  50932, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
301  MIMECONTF_IMPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
302  MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
303  "_autodetect", "_autodetect", "_autodetect" },
304  { "Japanese (EUC)",
305  51932, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
306  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
307  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
308  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
309  "euc-jp", "euc-jp", "euc-jp" },
310  { "Japanese (JIS)",
311  50220, MIMECONTF_IMPORT | MIMECONTF_MAILNEWS | MIMECONTF_EXPORT |
312  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_VALID_NLS |
313  MIMECONTF_PRIVCONVERTER | MIMECONTF_MIME_LATEST |
314  MIMECONTF_MIME_IE4,
315  "iso-2022-jp","iso-2022-jp","iso-2022-jp"},
316  { "Japanese (JIS 0208-1990 and 0212-1990)",
317  20932, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
318  MIMECONTF_VALID | MIMECONTF_PRIVCONVERTER | MIMECONTF_MIME_LATEST,
319  "EUC-JP","EUC-JP","EUC-JP"},
320  { "Japanese (JIS-Allow 1 byte Kana)",
321  50221, MIMECONTF_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_SAVABLE_BROWSER |
322  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_VALID_NLS |
323  MIMECONTF_VALID | MIMECONTF_PRIVCONVERTER | MIMECONTF_MIME_LATEST,
324  "csISO2022JP","iso-2022-jp","iso-2022-jp"},
325  { "Japanese (JIS-Allow 1 byte Kana - SO/SI)",
326  50222, MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_VALID |
327  MIMECONTF_PRIVCONVERTER | MIMECONTF_MIME_LATEST,
328  "iso-2022-jp","iso-2022-jp","iso-2022-jp"},
329  { "Japanese (Mac)",
330  10001, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
331  MIMECONTF_VALID | MIMECONTF_PRIVCONVERTER | MIMECONTF_MIME_LATEST,
332  "x-mac-japanese","x-mac-japanese","x-mac-japanese"},
333  { "Japanese (Shift-JIS)",
334  932, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
335  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
336  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
337  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
338  "shift_jis", "iso-2022-jp", "iso-2022-jp" }
339 };
340 static const MIME_CP_INFO korean_cp[] =
341 {
342  { "Korean",
343  949, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
344  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
345  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
346  MIMECONTF_MIME_LATEST,
347  "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
348 };
349 static const MIME_CP_INFO thai_cp[] =
350 {
351  { "Thai (Windows)",
352  874, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_MIME_LATEST,
353  "ibm-thai", "ibm-thai", "ibm-thai" }
354 };
355 static const MIME_CP_INFO turkish_cp[] =
356 {
357  { "Turkish (DOS)",
358  857, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
359  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
360  "ibm857", "ibm857", "ibm857" },
361  { "IBM EBCDIC (Turkish Latin-5)",
362  1026, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
363  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
364  "ibm1026", "ibm1026", "ibm1026" },
365  { "Turkish (Windows)",
366  1254, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
367  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
368  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
369  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
370  "windows-1254", "windows-1254", "windows-1254" },
371  { "Turkish (Mac)",
372  10081, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
373  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
374  "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
375  { "Latin 3 (ISO)",
376  28593, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
377  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
378  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
379  "iso-8859-3", "iso-8859-3", "iso-8859-3" },
380  { "Turkish (ISO)",
381  28599, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
382  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
383  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
384  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
385  "iso-8859-9", "iso-8859-9", "iso-8859-9" }
386 };
387 static const MIME_CP_INFO vietnamese_cp[] =
388 {
389  { "Vietnamese (Windows)",
390  1258, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
391  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
392  MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
393  MIMECONTF_MIME_LATEST,
394  "windows-1258", "windows-1258", "windows-1258" }
395 };
396 
397 static const WCHAR asciiW[] = {'a','s','c','i','i',0};
398 
399 static const MIME_CP_INFO western_cp[] =
400 {
401  { "IBM EBCDIC (US-Canada)",
402  37, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
403  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
404  "ibm037", "ibm037", "ibm037" },
405  { "OEM United States",
406  437, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
407  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
408  "ibm437", "ibm437", "ibm437" },
409  { "IBM EBCDIC (International)",
410  500, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
411  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
412  "ibm500", "ibm500", "ibm500" },
413  { "Western European (DOS)",
414  850, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
415  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
416  "ibm850", "ibm850", "ibm850" },
417  { "Portuguese (DOS)",
418  860, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
419  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
420  "ibm860", "ibm860", "ibm860" },
421  { "Icelandic (DOS)",
422  861, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
423  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
424  "ibm861", "ibm861", "ibm861" },
425  { "French Canadian (DOS)",
426  863, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
427  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
428  "ibm863", "ibm863", "ibm863" },
429  { "Nordic (DOS)",
430  865, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
431  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
432  "ibm865", "ibm865", "ibm865" },
433  { "Western European (Windows)",
434  1252, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
435  MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
436  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
437  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
438  "windows-1252", "windows-1252", "iso-8859-1" },
439  { "Western European (Mac)",
440  10000, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
441  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
442  "macintosh", "macintosh", "macintosh" },
443  { "Icelandic (Mac)",
444  10079, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
445  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
446  "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
447  { "US-ASCII",
448  20127, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT | MIMECONTF_EXPORT |
449  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_VALID |
450  MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
451  "us-ascii", "us-ascii", "us-ascii", asciiW },
452  { "Western European (ISO)",
453  28591, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
454  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
455  MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
456  MIMECONTF_MIME_LATEST,
457  "iso-8859-1", "iso-8859-1", "iso-8859-1" },
458  { "Latin 9 (ISO)",
459  28605, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
460  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
461  MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
462  MIMECONTF_MIME_LATEST,
463  "iso-8859-15", "iso-8859-15", "iso-8859-15" }
464 };
465 static const MIME_CP_INFO unicode_cp[] =
466 {
467  { "Unicode",
468  CP_UNICODE, MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
469  MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
470  MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
471  MIMECONTF_MIME_LATEST,
472  "unicode", "unicode", "unicode" },
473  { "Unicode (UTF-7)",
474  CP_UTF7, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
475  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
476  MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
477  "utf-7", "utf-7", "utf-7" },
478  { "Unicode (UTF-8)",
479  CP_UTF8, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
480  MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
481  MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
482  MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
483  "utf-8", "utf-8", "utf-8" }
484 };
485 
486 static const struct mlang_data
487 {
488  const char *description;
492  const char *fixed_font;
493  const char *proportional_font;
494  SCRIPT_ID sid;
495 } mlang_data[] =
496 {
497  { "Arabic", 1256, ARRAY_SIZE(arabic_cp), arabic_cp,
498  "Simplified Arabic Fixed","Simplified Arabic", sidArabic },
499  { "Baltic", 1257, ARRAY_SIZE(baltic_cp), baltic_cp,
500  "Courier New","Arial", sidAsciiLatin },
501  { "Chinese Simplified", 936, ARRAY_SIZE(chinese_simplified_cp), chinese_simplified_cp,
502  "Simsun","Simsun", sidHan },
503  { "Chinese Traditional", 950, ARRAY_SIZE(chinese_traditional_cp), chinese_traditional_cp,
504  "MingLiu","New MingLiu", sidBopomofo },
505  { "Central European", 1250, ARRAY_SIZE(central_european_cp), central_european_cp,
506  "Courier New","Arial", sidAsciiLatin },
507  { "Cyrillic", 1251, ARRAY_SIZE(cyrillic_cp), cyrillic_cp,
508  "Courier New","Arial", sidCyrillic },
509  { "Greek", 1253, ARRAY_SIZE(greek_cp), greek_cp,
510  "Courier New","Arial", sidGreek },
511  { "Hebrew", 1255, ARRAY_SIZE(hebrew_cp), hebrew_cp,
512  "Miriam Fixed","David", sidHebrew },
513  { "Japanese", 932, ARRAY_SIZE(japanese_cp), japanese_cp,
514  "MS Gothic","MS PGothic", sidKana },
515  { "Korean", 949, ARRAY_SIZE(korean_cp), korean_cp,
516  "GulimChe","Gulim", sidHangul },
517  { "Thai", 874, ARRAY_SIZE(thai_cp), thai_cp,
518  "Tahoma","Tahoma", sidThai },
519  { "Turkish", 1254, ARRAY_SIZE(turkish_cp), turkish_cp,
520  "Courier New","Arial", sidAsciiLatin },
521  { "Vietnamese", 1258, ARRAY_SIZE(vietnamese_cp), vietnamese_cp,
522  "Courier New","Arial", sidAsciiLatin },
523  { "Western European", 1252, ARRAY_SIZE(western_cp), western_cp,
524  "Courier New","Arial", sidAsciiLatin },
525  { "Unicode", CP_UNICODE, ARRAY_SIZE(unicode_cp), unicode_cp,
526  "Courier New","Arial" }
527 };
528 
529 struct font_list
530 {
531  struct list list_entry;
535 };
536 
540 {
541  0, 0, &font_cache_critical,
543  0, 0, { (DWORD_PTR)(__FILE__ ": font_cache_critical") }
544 };
546 
547 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info);
548 
550 
551 /*
552  * Japanese Detection and Conversion Functions
553  */
554 
555 #define HANKATA(A) ((A >= 161) && (A <= 223))
556 #define ISEUC(A) ((A >= 161) && (A <= 254))
557 #define NOTEUC(A,B) (((A >= 129) && (A <= 159)) && ((B >= 64) && (B <= 160)))
558 #define SJIS1(A) (((A >= 129) && (A <= 159)) || ((A >= 224) && (A <= 239)))
559 #define SJIS2(A) ((A >= 64) && (A <= 252))
560 #define ISMARU(A) ((A >= 202) && (A <= 206))
561 #define ISNIGORI(A) (((A >= 182) && (A <= 196)) || ((A >= 202) && (A <= 206)))
562 
564 {
565  UINT code = 0;
566  DWORD i = 0;
567  unsigned char c1,c2;
568 
569  while ((code == 0 || code == 51932) && i < count)
570  {
571  c1 = input[i];
572  if (c1 == 0x1b /* ESC */)
573  {
574  i++;
575  if (i >= count)
576  return code;
577  c1 = input[i];
578  if (c1 == '$')
579  {
580  i++;
581  if (i >= count)
582  return code;
583  c1 = input[i];
584  if (c1 =='B' || c1 == '@')
585  code = 50220;
586  }
587  if (c1 == 'K')
588  code = 50220;
589  }
590  else if (c1 >= 129)
591  {
592  i++;
593  if (i >= count)
594  return code;
595  c2 = input[i];
596  if NOTEUC(c1,c2)
597  code = 932;
598  else if (ISEUC(c1) && ISEUC(c2))
599  code = 51932;
600  else if (((c1 == 142)) && HANKATA(c2))
601  code = 51932;
602  }
603  i++;
604  }
605  return code;
606 }
607 
608 static inline void jis2sjis(unsigned char *p1, unsigned char *p2)
609 {
610  unsigned char c1 = *p1;
611  unsigned char c2 = *p2;
612  int row = c1 < 95 ? 112 : 176;
613  int cell = c1 % 2 ? 31 + (c2 > 95) : 126;
614 
615  *p1 = ((c1 + 1) >> 1) + row;
616  *p2 = c2 + cell;
617 }
618 
619 static inline void sjis2jis(unsigned char *p1, unsigned char *p2)
620 {
621  unsigned char c1 = *p1;
622  unsigned char c2 = *p2;
623  int shift = c2 < 159;
624  int row = c1 < 160 ? 112 : 176;
625  int cell = shift ? (31 + (c2 > 127)): 126;
626 
627  *p1 = ((c1 - row) << 1) - shift;
628  *p2 -= cell;
629 }
630 
631 static int han2zen(unsigned char *p1, unsigned char *p2)
632 {
633  BOOL maru = FALSE;
634  BOOL nigori = FALSE;
635  static const unsigned char char1[] = {129,129,129,129,129,131,131,131,131,
636  131,131,131,131,131,131,129,131,131,131,131,131,131,131,131,131,131,
637  131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,
638  131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,
639  131,129,129 };
640  static const unsigned char char2[] = {66,117,118,65,69,146,64,66,68,70,
641  72,131,133,135,98,91,65,67,69,71,73,74,76,78,80,82,84,86,88,90,92,94,
642  96,99,101,103,105,106,107,108,109,110,113,116,119,122,125,126,128,
643  129,130,132,134,136,137,138,139,140,141,143,147,74,75};
644 
645  if (( *p2 == 222) && ((ISNIGORI(*p1) || (*p1 == 179))))
646  nigori = TRUE;
647  else if ((*p2 == 223) && (ISMARU(*p1)))
648  maru = TRUE;
649 
650  if (*p1 >= 161 && *p1 <= 223)
651  {
652  unsigned char index = *p1 - 161;
653  *p1 = char1[index];
654  *p2 = char2[index];
655  }
656 
657  if (maru || nigori)
658  {
659  if (nigori)
660  {
661  if (((*p2 >= 74) && (*p2 <= 103)) || ((*p2 >= 110) && (*p2 <= 122)))
662  (*p2)++;
663  else if ((*p1 == 131) && (*p2 == 69))
664  *p2 = 148;
665  }
666  else if ((maru) && ((*p2 >= 110) && (*p2 <= 122)))
667  *p2+= 2;
668 
669  return 1;
670  }
671 
672  return 0;
673 }
674 
675 
677 {
678  DWORD i = 0;
679  int j = 0;
680  unsigned char p2,p;
681  BOOL shifted = FALSE;
682 
683  while (i < count)
684  {
685  p = input[i];
686  if (p == 0x1b /* ESC */)
687  {
688  i++;
689  if (i >= count)
690  return 0;
691  p2 = input[i];
692  if (p2 == '$' || p2 =='(')
693  i++;
694  if (p2 == 'K' || p2 =='$')
695  shifted = TRUE;
696  else
697  shifted = FALSE;
698  }
699  else
700  {
701  if (shifted)
702  {
703  i++;
704  if (i >= count)
705  return 0;
706  p2 = input[i];
707  jis2sjis(&p,&p2);
708  output[j++]=p;
709  output[j++]=p2;
710  }
711  else
712  {
713  output[j++] = p;
714  }
715  }
716  i++;
717  }
718  return j;
719 }
720 
721 static inline int exit_shift(LPSTR out, int c)
722 {
723  if (out)
724  {
725  out[c] = 0x1b;
726  out[c+1] = '(';
727  out[c+2] = 'B';
728  }
729  return 3;
730 }
731 
732 static inline int enter_shift(LPSTR out, int c)
733 {
734  if (out)
735  {
736  out[c] = 0x1b;
737  out[c+1] = '$';
738  out[c+2] = 'B';
739  }
740  return 3;
741 }
742 
743 
745 {
746  DWORD i = 0;
747  int j = 0;
748  unsigned char p2,p;
749  BOOL shifted = FALSE;
750 
751  while (i < count)
752  {
753  p = input[i] & 0xff;
754  if (p == 10 || p == 13) /* NL and CR */
755  {
756  if (shifted)
757  {
758  shifted = FALSE;
759  j += exit_shift(output,j);
760  }
761  if (output)
762  output[j++] = p;
763  else
764  j++;
765  }
766  else
767  {
768  if (SJIS1(p))
769  {
770  i++;
771  if (i >= count)
772  return 0;
773  p2 = input[i] & 0xff;
774  if (SJIS2(p2))
775  {
776  sjis2jis(&p,&p2);
777  if (!shifted)
778  {
779  shifted = TRUE;
780  j+=enter_shift(output,j);
781  }
782  }
783 
784  if (output)
785  {
786  output[j++]=p;
787  output[j++]=p2;
788  }
789  else
790  j+=2;
791  }
792  else
793  {
794  if (HANKATA(p))
795  {
796  if ((i+1) >= count)
797  return 0;
798  p2 = input[i+1] & 0xff;
799  i+=han2zen(&p,&p2);
800  sjis2jis(&p,&p2);
801  if (!shifted)
802  {
803  shifted = TRUE;
804  j+=enter_shift(output,j);
805  }
806  if (output)
807  {
808  output[j++]=p;
809  output[j++]=p2;
810  }
811  else
812  j+=2;
813  }
814  else
815  {
816  if (shifted)
817  {
818  shifted = FALSE;
819  j += exit_shift(output,j);
820  }
821  if (output)
822  output[j++]=p;
823  else
824  j++;
825  }
826  }
827  }
828  i++;
829  }
830  if (shifted)
831  j += exit_shift(output,j);
832  return j;
833 }
834 
837 {
838  CHAR *sjis_string;
839  UINT rc = 0;
840  sjis_string = HeapAlloc(GetProcessHeap(),0,count);
841  rc = ConvertJIS2SJIS(input,count,sjis_string);
842  if (rc)
843  {
844  TRACE("%s\n",debugstr_an(sjis_string,rc));
845  if (output)
846  rc = MultiByteToWideChar(932,0,sjis_string,rc,output,out_count);
847  else
848  rc = MultiByteToWideChar(932,0,sjis_string,rc,0,0);
849  }
850  HeapFree(GetProcessHeap(),0,sjis_string);
851  return rc;
852 
853 }
854 
857 {
858  CHAR *sjis_string;
859  UINT rc = 0;
861  TRACE("Japanese code %i\n",code);
862 
863  switch (code)
864  {
865  case 0:
866  if (output)
868  else
870  break;
871 
872  case 932:
873  if (output)
875  else
876  rc = MultiByteToWideChar(932,0,input,count,0,0);
877  break;
878 
879  case 51932:
880  if (output)
882  else
883  rc = MultiByteToWideChar(20932,0,input,count,0,0);
884  break;
885 
886  case 50220:
887  sjis_string = HeapAlloc(GetProcessHeap(),0,count);
888  rc = ConvertJIS2SJIS(input,count,sjis_string);
889  if (rc)
890  {
891  TRACE("%s\n",debugstr_an(sjis_string,rc));
892  if (output)
893  rc = MultiByteToWideChar(932,0,sjis_string,rc,output,out_count);
894  else
895  rc = MultiByteToWideChar(932,0,sjis_string,rc,0,0);
896  }
897  HeapFree(GetProcessHeap(),0,sjis_string);
898  break;
899  }
900  return rc;
901 }
902 
905 {
906  CHAR *sjis_string;
907  INT len;
908  UINT rc = 0;
909 
911  sjis_string = HeapAlloc(GetProcessHeap(),0,len);
912  WideCharToMultiByte(932,0,input,count,sjis_string,len,NULL,NULL);
913  TRACE("%s\n",debugstr_an(sjis_string,len));
914 
915  rc = ConvertSJIS2JIS(sjis_string, len, NULL);
916  if (out_count >= rc)
917  {
918  ConvertSJIS2JIS(sjis_string, len, output);
919  }
920  HeapFree(GetProcessHeap(),0,sjis_string);
921  return rc;
922 
923 }
924 
925 /*
926  * Dll lifetime tracking declaration
927  */
928 static void LockModule(void)
929 {
931 }
932 
933 static void UnlockModule(void)
934 {
936 }
937 
938 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
939 {
940  switch(fdwReason) {
941  case DLL_PROCESS_ATTACH:
942  instance = hInstDLL;
944  DisableThreadLibraryCalls(hInstDLL);
945  break;
946  case DLL_PROCESS_DETACH:
947  if (lpv) break;
949  break;
950  }
951  return TRUE;
952 }
953 
955  LPDWORD pdwMode,
956  DWORD dwEncoding,
957  LPCSTR pSrcStr,
958  LPINT pcSrcSize,
959  LPWSTR pDstStr,
960  LPINT pcDstSize)
961 {
962  INT src_len = -1;
963 
964  TRACE("%p %d %s %p %p %p\n", pdwMode, dwEncoding,
965  debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
966 
967  if (!pcDstSize)
968  return E_FAIL;
969 
970  if (!pcSrcSize)
971  pcSrcSize = &src_len;
972 
973  if (!*pcSrcSize)
974  {
975  *pcDstSize = 0;
976  return S_OK;
977  }
978 
979  /* forwarding euc-jp to EUC-JP */
980  if (dwEncoding == 51932)
981  dwEncoding = 20932;
982 
983  switch (dwEncoding)
984  {
985  case CP_UNICODE:
986  if (*pcSrcSize == -1)
987  *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
988  *pcDstSize = min(*pcSrcSize, *pcDstSize);
989  *pcSrcSize *= sizeof(WCHAR);
990  if (pDstStr)
991  memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
992  break;
993 
994  case 50220:
995  case 50221:
996  case 50222:
997  *pcDstSize = ConvertJISJapaneseToUnicode(pSrcStr,*pcSrcSize,pDstStr,*pcDstSize);
998  break;
999  case 50932:
1000  *pcDstSize = ConvertUnknownJapaneseToUnicode(pSrcStr,*pcSrcSize,pDstStr,*pcDstSize);
1001  break;
1002 
1003  default:
1004  if (*pcSrcSize == -1)
1005  *pcSrcSize = lstrlenA(pSrcStr);
1006 
1007  if (pDstStr)
1008  *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
1009  else
1010  *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0);
1011  break;
1012  }
1013 
1014  if (!*pcDstSize)
1015  return E_FAIL;
1016 
1017  return S_OK;
1018 }
1019 
1021  LPDWORD pdwMode,
1022  DWORD dwEncoding,
1023  LPCWSTR pSrcStr,
1024  LPINT pcSrcSize,
1025  LPSTR pDstStr,
1026  LPINT pcDstSize)
1027 {
1028  INT destsz, size;
1029  INT src_len = -1;
1030 
1031  TRACE("%p %d %s %p %p %p\n", pdwMode, dwEncoding,
1032  debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
1033 
1034  if (!pcDstSize)
1035  return S_OK;
1036 
1037  if (!pcSrcSize)
1038  pcSrcSize = &src_len;
1039 
1040  destsz = (pDstStr) ? *pcDstSize : 0;
1041  *pcDstSize = 0;
1042 
1043  if (!pSrcStr || !*pcSrcSize)
1044  return S_OK;
1045 
1046  if (*pcSrcSize == -1)
1047  *pcSrcSize = lstrlenW(pSrcStr);
1048 
1049  /* forwarding euc-jp to EUC-JP */
1050  if (dwEncoding == 51932)
1051  dwEncoding = 20932;
1052 
1053  if (dwEncoding == CP_UNICODE)
1054  {
1055  if (*pcSrcSize == -1)
1056  *pcSrcSize = lstrlenW(pSrcStr);
1057 
1058  size = min(*pcSrcSize, destsz) * sizeof(WCHAR);
1059  if (pDstStr)
1060  memmove(pDstStr, pSrcStr, size);
1061 
1062  if (size >= destsz)
1063  goto fail;
1064  }
1065  else if (dwEncoding == 50220 || dwEncoding == 50221 || dwEncoding == 50222)
1066  {
1067  size = ConvertJapaneseUnicodeToJIS(pSrcStr, *pcSrcSize, NULL, 0);
1068  if (!size)
1069  goto fail;
1070 
1071  if (pDstStr)
1072  {
1073  size = ConvertJapaneseUnicodeToJIS(pSrcStr, *pcSrcSize, pDstStr,
1074  destsz);
1075  if (!size)
1076  goto fail;
1077  }
1078 
1079  }
1080  else
1081  {
1082  size = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize,
1083  NULL, 0, NULL, NULL);
1084  if (!size)
1085  goto fail;
1086 
1087  if (pDstStr)
1088  {
1089  size = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize,
1090  pDstStr, destsz, NULL, NULL);
1091  if (!size)
1092  goto fail;
1093  }
1094  }
1095 
1096  *pcDstSize = size;
1097  return S_OK;
1098 
1099 fail:
1100  *pcSrcSize = 0;
1101  *pcDstSize = 0;
1102  return E_FAIL;
1103 }
1104 
1106  LPDWORD pdwMode,
1107  DWORD dwSrcEncoding,
1108  DWORD dwDstEncoding,
1109  LPCSTR pSrcStr,
1110  LPINT pcSrcSize,
1111  LPSTR pDstStr,
1112  LPINT pcDstSize
1113 )
1114 {
1115  TRACE("%p %d %d %s %p %p %p\n", pdwMode, dwSrcEncoding, dwDstEncoding,
1116  debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
1117 
1118  if (dwSrcEncoding == CP_UNICODE)
1119  {
1120  INT cSrcSizeW;
1121  if (pcSrcSize && *pcSrcSize != -1)
1122  {
1123  cSrcSizeW = *pcSrcSize / sizeof(WCHAR);
1124  pcSrcSize = &cSrcSizeW;
1125  }
1126  return ConvertINetUnicodeToMultiByte(pdwMode, dwDstEncoding, (LPCWSTR)pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1127  }
1128  else if (dwDstEncoding == CP_UNICODE)
1129  {
1130  HRESULT hr = ConvertINetMultiByteToUnicode(pdwMode, dwSrcEncoding, pSrcStr, pcSrcSize, (LPWSTR)pDstStr, pcDstSize);
1131  *pcDstSize *= sizeof(WCHAR);
1132  return hr;
1133  }
1134  else
1135  {
1136  INT cDstSizeW;
1137  LPWSTR pDstStrW;
1138  HRESULT hr;
1139 
1140  TRACE("convert %s from %d to %d\n", debugstr_a(pSrcStr), dwSrcEncoding, dwDstEncoding);
1141 
1142  hr = ConvertINetMultiByteToUnicode(pdwMode, dwSrcEncoding, pSrcStr, pcSrcSize, NULL, &cDstSizeW);
1143  if (hr != S_OK)
1144  return hr;
1145 
1146  pDstStrW = HeapAlloc(GetProcessHeap(), 0, cDstSizeW * sizeof(WCHAR));
1147  hr = ConvertINetMultiByteToUnicode(pdwMode, dwSrcEncoding, pSrcStr, pcSrcSize, pDstStrW, &cDstSizeW);
1148  if (hr == S_OK)
1149  hr = ConvertINetUnicodeToMultiByte(pdwMode, dwDstEncoding, pDstStrW, &cDstSizeW, pDstStr, pcDstSize);
1150 
1151  HeapFree(GetProcessHeap(), 0, pDstStrW);
1152  return hr;
1153  }
1154 }
1155 
1157  UINT uiCodePage,
1158  UINT* puiFamilyCodePage)
1159 {
1160  UINT i, n;
1161 
1162  TRACE("%u %p\n", uiCodePage, puiFamilyCodePage);
1163 
1164  if (!puiFamilyCodePage) return S_FALSE;
1165 
1166  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
1167  {
1168  for (n = 0; n < mlang_data[i].number_of_cp; n++)
1169  {
1170  if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
1171  {
1172  *puiFamilyCodePage = mlang_data[i].family_codepage;
1173  return S_OK;
1174  }
1175  }
1176  }
1177 
1178  return S_FALSE;
1179 }
1180 
1182  DWORD dwSrcEncoding,
1183  DWORD dwDstEncoding)
1184 {
1185  UINT src_family, dst_family;
1186 
1187  TRACE("%d %d\n", dwSrcEncoding, dwDstEncoding);
1188 
1189  if (GetFamilyCodePage(dwSrcEncoding, &src_family) != S_OK ||
1190  GetFamilyCodePage(dwDstEncoding, &dst_family) != S_OK)
1191  return S_FALSE;
1192 
1193  if (src_family == dst_family) return S_OK;
1194 
1195  /* we can convert any codepage to/from unicode */
1196  if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
1197 
1198  return S_FALSE;
1199 }
1200 
1201 static inline HRESULT lcid_to_rfc1766A( LCID lcid, LPSTR rfc1766, INT len )
1202 {
1203  CHAR buffer[MAX_RFC1766_NAME];
1204  INT n = GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, buffer, MAX_RFC1766_NAME);
1205  INT i;
1206 
1207  if (n)
1208  {
1209  i = PRIMARYLANGID(lcid);
1210  if ((((i == LANG_ENGLISH) || (i == LANG_CHINESE) || (i == LANG_ARABIC)) &&
1211  (SUBLANGID(lcid) == SUBLANG_DEFAULT)) ||
1212  (SUBLANGID(lcid) > SUBLANG_DEFAULT)) {
1213 
1214  buffer[n - 1] = '-';
1215  i = GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, buffer + n, MAX_RFC1766_NAME - n);
1216  if (!i)
1217  buffer[n - 1] = '\0';
1218  }
1219  else
1220  i = 0;
1221 
1223  return ((n + i) > len) ? E_INVALIDARG : S_OK;
1224  }
1225  return E_FAIL;
1226 }
1227 
1228 static inline HRESULT lcid_to_rfc1766W( LCID lcid, LPWSTR rfc1766, INT len )
1229 {
1230  WCHAR buffer[MAX_RFC1766_NAME];
1231  INT n = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME, buffer, MAX_RFC1766_NAME);
1232  INT i;
1233 
1234  if (n)
1235  {
1236  i = PRIMARYLANGID(lcid);
1237  if ((((i == LANG_ENGLISH) || (i == LANG_CHINESE) || (i == LANG_ARABIC)) &&
1238  (SUBLANGID(lcid) == SUBLANG_DEFAULT)) ||
1239  (SUBLANGID(lcid) > SUBLANG_DEFAULT)) {
1240 
1241  buffer[n - 1] = '-';
1242  i = GetLocaleInfoW(lcid, LOCALE_SISO3166CTRYNAME, buffer + n, MAX_RFC1766_NAME - n);
1243  if (!i)
1244  buffer[n - 1] = '\0';
1245  }
1246  else
1247  i = 0;
1248 
1250  return ((n + i) > len) ? E_INVALIDARG : S_OK;
1251  }
1252  return E_FAIL;
1253 }
1254 
1256  LCID lcid,
1257  LPSTR pszRfc1766,
1258  INT nChar)
1259 {
1260  TRACE("%04x %p %u\n", lcid, pszRfc1766, nChar);
1261  if (!pszRfc1766)
1262  return E_INVALIDARG;
1263 
1264  return lcid_to_rfc1766A(lcid, pszRfc1766, nChar);
1265 }
1266 
1268  LCID lcid,
1269  LPWSTR pszRfc1766,
1270  INT nChar)
1271 {
1272  TRACE("%04x %p %u\n", lcid, pszRfc1766, nChar);
1273  if (!pszRfc1766)
1274  return E_INVALIDARG;
1275 
1276  return lcid_to_rfc1766W(lcid, pszRfc1766, nChar);
1277 }
1278 
1279 static HRESULT lcid_from_rfc1766(IEnumRfc1766 *iface, LCID *lcid, LPCWSTR rfc1766)
1280 {
1281  RFC1766INFO info;
1282  ULONG num;
1283 
1284  while (IEnumRfc1766_Next(iface, 1, &info, &num) == S_OK)
1285  {
1286  if (!strcmpiW(info.wszRfc1766, rfc1766))
1287  {
1288  *lcid = info.lcid;
1289  return S_OK;
1290  }
1291  if (strlenW(rfc1766) == 2 && !memcmp(info.wszRfc1766, rfc1766, 2 * sizeof(WCHAR)))
1292  {
1293  *lcid = PRIMARYLANGID(info.lcid);
1294  return S_OK;
1295  }
1296  }
1297 
1298  return E_FAIL;
1299 }
1300 
1302 {
1303  IEnumRfc1766 *enumrfc1766;
1304  HRESULT hr;
1305 
1306  TRACE("(%p, %s)\n", pLocale, debugstr_w(pszRfc1766));
1307 
1308  if (!pLocale || !pszRfc1766)
1309  return E_INVALIDARG;
1310 
1311  hr = EnumRfc1766_create(0, &enumrfc1766);
1312  if (FAILED(hr))
1313  return hr;
1314 
1315  hr = lcid_from_rfc1766(enumrfc1766, pLocale, pszRfc1766);
1316  IEnumRfc1766_Release(enumrfc1766);
1317 
1318  return hr;
1319 }
1320 
1322 {
1323  WCHAR rfc1766W[MAX_RFC1766_NAME + 1];
1324 
1325  if (!rfc1766A)
1326  return E_INVALIDARG;
1327 
1328  MultiByteToWideChar(CP_ACP, 0, rfc1766A, -1, rfc1766W, MAX_RFC1766_NAME);
1329  rfc1766W[MAX_RFC1766_NAME] = 0;
1330 
1331  return Rfc1766ToLcidW(lcid, rfc1766W);
1332 }
1333 
1334 static HRESULT map_font(HDC hdc, DWORD codepages, HFONT src_font, HFONT *dst_font)
1335 {
1336  struct font_list *font_list_entry;
1337  CHARSETINFO charset_info;
1338  HFONT new_font, old_font;
1339  LOGFONTW font_attr;
1340  DWORD mask, Csb[2];
1341  BOOL found_cached;
1342  UINT charset;
1343  BOOL ret;
1344  UINT i;
1345 
1346  if (hdc == NULL || src_font == NULL) return E_FAIL;
1347 
1348  for (i = 0; i < 32; i++)
1349  {
1350  mask = (DWORD)(1 << i);
1351  if (codepages & mask)
1352  {
1353  Csb[0] = mask;
1354  Csb[1] = 0x0;
1355  ret = TranslateCharsetInfo(Csb, &charset_info, TCI_SRCFONTSIG);
1356  if (!ret) continue;
1357 
1358  /* use cached font if possible */
1359  found_cached = FALSE;
1361  LIST_FOR_EACH_ENTRY(font_list_entry, &font_cache, struct font_list, list_entry)
1362  {
1363  if (font_list_entry->charset == charset_info.ciCharset &&
1364  font_list_entry->base_font == src_font)
1365  {
1366  if (dst_font != NULL)
1367  *dst_font = font_list_entry->font;
1368  found_cached = TRUE;
1369  }
1370  }
1372  if (found_cached) return S_OK;
1373 
1374  GetObjectW(src_font, sizeof(font_attr), &font_attr);
1375  font_attr.lfCharSet = (BYTE)charset_info.ciCharset;
1376  font_attr.lfWidth = 0;
1377  font_attr.lfFaceName[0] = 0;
1378  new_font = CreateFontIndirectW(&font_attr);
1379  if (new_font == NULL) continue;
1380 
1381  old_font = SelectObject(hdc, new_font);
1383  SelectObject(hdc, old_font);
1384  if (charset == charset_info.ciCharset)
1385  {
1386  font_list_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*font_list_entry));
1387  if (font_list_entry == NULL) return E_OUTOFMEMORY;
1388 
1389  font_list_entry->base_font = src_font;
1390  font_list_entry->font = new_font;
1391  font_list_entry->charset = charset;
1392 
1394  list_add_tail(&font_cache, &font_list_entry->list_entry);
1396 
1397  if (dst_font != NULL)
1398  *dst_font = new_font;
1399  return S_OK;
1400  }
1401  }
1402  }
1403 
1404  return E_FAIL;
1405 }
1406 
1408 {
1409  struct font_list *font_list_entry;
1410  HRESULT hr;
1411 
1412  hr = E_FAIL;
1414  LIST_FOR_EACH_ENTRY(font_list_entry, &font_cache, struct font_list, list_entry)
1415  {
1416  if (font_list_entry->font == font)
1417  {
1418  list_remove(&font_list_entry->list_entry);
1419  DeleteObject(font);
1420  HeapFree(GetProcessHeap(), 0, font_list_entry);
1421  hr = S_OK;
1422  break;
1423  }
1424  }
1426 
1427  return hr;
1428 }
1429 
1431 {
1432  struct font_list *font_list_entry;
1433  struct font_list *font_list_entry2;
1434 
1436  LIST_FOR_EACH_ENTRY_SAFE(font_list_entry, font_list_entry2, &font_cache, struct font_list, list_entry)
1437  {
1438  list_remove(&font_list_entry->list_entry);
1439  DeleteObject(font_list_entry->font);
1440  HeapFree(GetProcessHeap(), 0, font_list_entry);
1441  }
1443 
1444  return S_OK;
1445 }
1446 
1447 /******************************************************************************
1448  * MLANG ClassFactory
1449  */
1450 typedef struct {
1451  IClassFactory IClassFactory_iface;
1452  LONG ref;
1453  HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
1455 
1457 {
1458  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
1459 }
1460 
1461 struct object_creation_info
1462 {
1463  const CLSID *clsid;
1465  HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
1466 };
1467 
1468 static const struct object_creation_info object_creation[] =
1469 {
1470  { &CLSID_CMultiLanguage, "CLSID_CMultiLanguage", MultiLanguage_create },
1471  { &CLSID_CMLangConvertCharset, "CLSID_CMLangConvertCharset", MLangConvertCharset_create }
1472 };
1473 
1475 {
1476  TRACE("%s\n", debugstr_guid(riid) );
1477 
1480  {
1481  IClassFactory_AddRef(iface);
1482  *ppobj = iface;
1483  return S_OK;
1484  }
1485 
1486  *ppobj = NULL;
1487  WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
1488  return E_NOINTERFACE;
1489 }
1490 
1492 {
1494  return InterlockedIncrement(&This->ref);
1495 }
1496 
1498 {
1501 
1502  if (ref == 0)
1503  {
1504  TRACE("Destroying %p\n", This);
1505  HeapFree(GetProcessHeap(), 0, This);
1506  }
1507 
1508  return ref;
1509 }
1510 
1512  REFIID riid, void **ppobj)
1513 {
1515  HRESULT hres;
1516  LPUNKNOWN punk;
1517 
1518  TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
1519 
1520  *ppobj = NULL;
1521  hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
1522  if (SUCCEEDED(hres)) {
1523  hres = IUnknown_QueryInterface(punk, riid, ppobj);
1524  IUnknown_Release(punk);
1525  }
1526  TRACE("returning (%p) -> %x\n", *ppobj, hres);
1527  return hres;
1528 }
1529 
1531 {
1532  if (dolock)
1533  LockModule();
1534  else
1535  UnlockModule();
1536 
1537  return S_OK;
1538 }
1539 
1540 static const IClassFactoryVtbl MLANGCF_Vtbl =
1541 {
1547 };
1548 
1549 /******************************************************************
1550  * DllGetClassObject (MLANG.@)
1551  */
1553 {
1554  unsigned int i;
1556 
1557  TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
1558 
1559  if ( !IsEqualGUID( &IID_IClassFactory, iid )
1560  && ! IsEqualGUID( &IID_IUnknown, iid) )
1561  return E_NOINTERFACE;
1562 
1563  for (i = 0; i < ARRAY_SIZE(object_creation); i++)
1564  {
1565  if (IsEqualGUID(object_creation[i].clsid, rclsid))
1566  break;
1567  }
1568 
1569  if (i == ARRAY_SIZE(object_creation))
1570  {
1571  FIXME("%s: no class found.\n", debugstr_guid(rclsid));
1573  }
1574 
1575  TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
1576 
1577  factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
1578  if (factory == NULL) return E_OUTOFMEMORY;
1579 
1581  factory->ref = 1;
1582 
1583  factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
1584 
1586 
1587  TRACE("(%p) <- %p\n", ppv, &factory->IClassFactory_iface);
1588 
1589  return S_OK;
1590 }
1591 
1592 
1593 /******************************************************************************/
1594 
1595 typedef struct tagMLang_impl
1596 {
1597  IMLangFontLink IMLangFontLink_iface;
1598  IMultiLanguage IMultiLanguage_iface;
1599  IMultiLanguage3 IMultiLanguage3_iface;
1600  IMLangFontLink2 IMLangFontLink2_iface;
1601  IMLangLineBreakConsole IMLangLineBreakConsole_iface;
1604 } MLang_impl;
1605 
1606 /******************************************************************************/
1607 
1608 typedef struct tagEnumCodePage_impl
1609 {
1610  IEnumCodePage IEnumCodePage_iface;
1612  MIMECPINFO *cpinfo;
1615 
1616 static inline EnumCodePage_impl *impl_from_IEnumCodePage( IEnumCodePage *iface )
1617 {
1618  return CONTAINING_RECORD( iface, EnumCodePage_impl, IEnumCodePage_iface );
1619 }
1620 
1622  IEnumCodePage* iface,
1623  REFIID riid,
1624  void** ppvObject)
1625 {
1627 
1628  TRACE("%p -> %s\n", This, debugstr_guid(riid) );
1629 
1631  || IsEqualGUID(riid, &IID_IEnumCodePage))
1632  {
1633  IEnumCodePage_AddRef(iface);
1634  TRACE("Returning IID_IEnumCodePage %p ref = %d\n", This, This->ref);
1635  *ppvObject = &This->IEnumCodePage_iface;
1636  return S_OK;
1637  }
1638 
1639  WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
1640  return E_NOINTERFACE;
1641 }
1642 
1644  IEnumCodePage* iface)
1645 {
1647  return InterlockedIncrement(&This->ref);
1648 }
1649 
1651  IEnumCodePage* iface)
1652 {
1655 
1656  TRACE("%p ref = %d\n", This, ref);
1657  if (ref == 0)
1658  {
1659  TRACE("Destroying %p\n", This);
1660  HeapFree(GetProcessHeap(), 0, This->cpinfo);
1661  HeapFree(GetProcessHeap(), 0, This);
1662  }
1663 
1664  return ref;
1665 }
1666 
1668  IEnumCodePage* iface,
1669  IEnumCodePage** ppEnum)
1670 {
1672  FIXME("%p %p\n", This, ppEnum);
1673  return E_NOTIMPL;
1674 }
1675 
1677  IEnumCodePage* iface,
1678  ULONG celt,
1679  PMIMECPINFO rgelt,
1680  ULONG* pceltFetched)
1681 {
1682  ULONG i;
1684 
1685  TRACE("%p %u %p %p\n", This, celt, rgelt, pceltFetched);
1686 
1687  if (!pceltFetched) return S_FALSE;
1688  *pceltFetched = 0;
1689 
1690  if (!rgelt) return S_FALSE;
1691 
1692  if (This->pos + celt > This->total)
1693  celt = This->total - This->pos;
1694 
1695  if (!celt) return S_FALSE;
1696 
1697  memcpy(rgelt, This->cpinfo + This->pos, celt * sizeof(MIMECPINFO));
1698  *pceltFetched = celt;
1699  This->pos += celt;
1700 
1701  for (i = 0; i < celt; i++)
1702  {
1703  TRACE("#%u: %08x %u %u %s %s %s %s %s %s %d\n",
1704  i, rgelt[i].dwFlags, rgelt[i].uiCodePage,
1705  rgelt[i].uiFamilyCodePage,
1706  wine_dbgstr_w(rgelt[i].wszDescription),
1707  wine_dbgstr_w(rgelt[i].wszWebCharset),
1708  wine_dbgstr_w(rgelt[i].wszHeaderCharset),
1709  wine_dbgstr_w(rgelt[i].wszBodyCharset),
1710  wine_dbgstr_w(rgelt[i].wszFixedWidthFont),
1711  wine_dbgstr_w(rgelt[i].wszProportionalFont),
1712  rgelt[i].bGDICharset);
1713  }
1714  return S_OK;
1715 }
1716 
1718  IEnumCodePage* iface)
1719 {
1721 
1722  TRACE("%p\n", This);
1723 
1724  This->pos = 0;
1725  return S_OK;
1726 }
1727 
1729  IEnumCodePage* iface,
1730  ULONG celt)
1731 {
1733 
1734  TRACE("%p %u\n", This, celt);
1735 
1736  if (celt >= This->total) return S_FALSE;
1737 
1738  This->pos += celt;
1739  return S_OK;
1740 }
1741 
1742 static const IEnumCodePageVtbl IEnumCodePage_vtbl =
1743 {
1751 };
1752 
1754  LANGID LangId, IEnumCodePage** ppEnumCodePage )
1755 {
1756  EnumCodePage_impl *ecp;
1757  MIMECPINFO *cpinfo;
1758  UINT i, n;
1759 
1760  TRACE("%p, %08x, %04x, %p\n", mlang, grfFlags, LangId, ppEnumCodePage);
1761 
1762  if (!grfFlags) /* enumerate internal data base of encodings */
1763  grfFlags = MIMECONTF_MIME_LATEST;
1764 
1765  ecp = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl) );
1766  ecp->IEnumCodePage_iface.lpVtbl = &IEnumCodePage_vtbl;
1767  ecp->ref = 1;
1768  ecp->pos = 0;
1769  ecp->total = 0;
1770  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
1771  {
1772  for (n = 0; n < mlang_data[i].number_of_cp; n++)
1773  {
1774  if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
1775  ecp->total++;
1776  }
1777  }
1778 
1779  ecp->cpinfo = HeapAlloc(GetProcessHeap(), 0,
1780  sizeof(MIMECPINFO) * ecp->total);
1781  cpinfo = ecp->cpinfo;
1782 
1783  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
1784  {
1785  for (n = 0; n < mlang_data[i].number_of_cp; n++)
1786  {
1787  if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
1788  fill_cp_info(&mlang_data[i], n, cpinfo++);
1789  }
1790  }
1791 
1792  TRACE("enumerated %d codepages with flags %08x\n", ecp->total, grfFlags);
1793 
1794  *ppEnumCodePage = &ecp->IEnumCodePage_iface;
1795 
1796  return S_OK;
1797 }
1798 
1799 /******************************************************************************/
1800 
1801 typedef struct tagEnumScript_impl
1802 {
1803  IEnumScript IEnumScript_iface;
1805  SCRIPTINFO *script_info;
1807 } EnumScript_impl;
1808 
1809 static inline EnumScript_impl *impl_from_IEnumScript( IEnumScript *iface )
1810 {
1811  return CONTAINING_RECORD( iface, EnumScript_impl, IEnumScript_iface );
1812 }
1813 
1815  IEnumScript* iface,
1816  REFIID riid,
1817  void** ppvObject)
1818 {
1820 
1821  TRACE("%p -> %s\n", This, debugstr_guid(riid) );
1822 
1824  || IsEqualGUID(riid, &IID_IEnumScript))
1825  {
1826  IEnumScript_AddRef(iface);
1827  TRACE("Returning IID_IEnumScript %p ref = %d\n", This, This->ref);
1828  *ppvObject = &This->IEnumScript_iface;
1829  return S_OK;
1830  }
1831 
1832  WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
1833  return E_NOINTERFACE;
1834 }
1835 
1837  IEnumScript* iface)
1838 {
1840  return InterlockedIncrement(&This->ref);
1841 }
1842 
1844  IEnumScript* iface)
1845 {
1848 
1849  TRACE("%p ref = %d\n", This, ref);
1850  if (ref == 0)
1851  {
1852  TRACE("Destroying %p\n", This);
1853  HeapFree(GetProcessHeap(), 0, This->script_info);
1854  HeapFree(GetProcessHeap(), 0, This);
1855  }
1856 
1857  return ref;
1858 }
1859 
1861  IEnumScript* iface,
1862  IEnumScript** ppEnum)
1863 {
1865  FIXME("%p %p: stub!\n", This, ppEnum);
1866  return E_NOTIMPL;
1867 }
1868 
1870  IEnumScript* iface,
1871  ULONG celt,
1872  PSCRIPTINFO rgelt,
1873  ULONG* pceltFetched)
1874 {
1876 
1877  TRACE("%p %u %p %p\n", This, celt, rgelt, pceltFetched);
1878 
1879  if (!pceltFetched || !rgelt) return E_FAIL;
1880 
1881  *pceltFetched = 0;
1882 
1883  if (This->pos + celt > This->total)
1884  celt = This->total - This->pos;
1885 
1886  if (!celt) return S_FALSE;
1887 
1888  memcpy(rgelt, This->script_info + This->pos, celt * sizeof(SCRIPTINFO));
1889  *pceltFetched = celt;
1890  This->pos += celt;
1891 
1892  return S_OK;
1893 }
1894 
1896  IEnumScript* iface)
1897 {
1899 
1900  TRACE("%p\n", This);
1901 
1902  This->pos = 0;
1903  return S_OK;
1904 }
1905 
1907  IEnumScript* iface,
1908  ULONG celt)
1909 {
1911 
1912  TRACE("%p %u\n", This, celt);
1913 
1914  if (celt >= This->total) return S_FALSE;
1915 
1916  This->pos += celt;
1917  return S_OK;
1918 }
1919 
1920 static const IEnumScriptVtbl IEnumScript_vtbl =
1921 {
1929 };
1930 
1932  LANGID LangId, IEnumScript** ppEnumScript )
1933 {
1935  UINT i;
1936 
1937  TRACE("%p, %08x, %04x, %p\n", mlang, dwFlags, LangId, ppEnumScript);
1938 
1939  if (!dwFlags) /* enumerate all available scripts */
1940  dwFlags = SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM;
1941 
1942  es = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl) );
1943  es->IEnumScript_iface.lpVtbl = &IEnumScript_vtbl;
1944  es->ref = 1;
1945  es->pos = 0;
1946  /* do not enumerate unicode flavours */
1947  es->total = ARRAY_SIZE(mlang_data) - 1;
1948  es->script_info = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO) * es->total);
1949 
1950  for (i = 0; i < es->total; i++)
1951  {
1952  es->script_info[i].ScriptId = i;
1953  es->script_info[i].uiCodePage = mlang_data[i].family_codepage;
1955  es->script_info[i].wszDescription, MAX_SCRIPT_NAME);
1956  MultiByteToWideChar(CP_ACP, 0, mlang_data[i].fixed_font, -1,
1957  es->script_info[i].wszFixedWidthFont, MAX_MIMEFACE_NAME);
1958  MultiByteToWideChar(CP_ACP, 0, mlang_data[i].proportional_font, -1,
1959  es->script_info[i].wszProportionalFont, MAX_MIMEFACE_NAME);
1960  }
1961 
1962  TRACE("enumerated %d scripts with flags %08x\n", es->total, dwFlags);
1963 
1964  *ppEnumScript = &es->IEnumScript_iface;
1965 
1966  return S_OK;
1967 }
1968 
1969 /******************************************************************************/
1970 
1971 static inline MLang_impl *impl_from_IMLangFontLink( IMLangFontLink *iface )
1972 {
1973  return CONTAINING_RECORD( iface, MLang_impl, IMLangFontLink_iface );
1974 }
1975 
1977  IMLangFontLink* iface,
1978  REFIID riid,
1979  void** ppvObject)
1980 {
1982  return IMultiLanguage3_QueryInterface( &This->IMultiLanguage3_iface, riid, ppvObject );
1983 }
1984 
1986  IMLangFontLink* iface)
1987 {
1989  return IMultiLanguage3_AddRef( &This->IMultiLanguage3_iface );
1990 }
1991 
1993  IMLangFontLink* iface)
1994 {
1996  return IMultiLanguage3_Release( &This->IMultiLanguage3_iface );
1997 }
1998 
2000  IMLangFontLink* iface,
2001  WCHAR ch_src,
2002  DWORD* codepages)
2003 {
2005  return IMLangFontLink2_GetCharCodePages(&This->IMLangFontLink2_iface, ch_src, codepages);
2006 }
2007 
2009  IMLangFontLink* iface,
2010  const WCHAR* src,
2011  LONG src_len,
2012  DWORD priority_cp,
2013  DWORD* codepages,
2014  LONG* ret_len)
2015 {
2017  return IMLangFontLink2_GetStrCodePages(&This->IMLangFontLink2_iface, src, src_len, priority_cp,
2018  codepages, ret_len);
2019 }
2020 
2022  IMLangFontLink* iface,
2023  UINT codepage,
2024  DWORD* codepages)
2025 {
2027  return IMLangFontLink2_CodePageToCodePages(&This->IMLangFontLink2_iface, codepage, codepages);
2028 }
2029 
2031  IMLangFontLink* iface,
2032  DWORD codepages,
2033  UINT def_codepage,
2034  UINT* codepage)
2035 {
2037  return IMLangFontLink2_CodePagesToCodePage(&This->IMLangFontLink2_iface, codepages,
2038  def_codepage, codepage);
2039 }
2040 
2042  IMLangFontLink* iface,
2043  HDC hdc,
2044  HFONT hfont,
2045  DWORD* codepages)
2046 {
2048  return IMLangFontLink2_GetFontCodePages(&This->IMLangFontLink2_iface, hdc, hfont, codepages);
2049 }
2050 
2052  IMLangFontLink* iface,
2053  HDC hDC,
2054  DWORD dwCodePages,
2055  HFONT hSrcFont,
2056  HFONT* phDestFont)
2057 {
2058  TRACE("(%p)->%p %08x %p %p\n",iface, hDC, dwCodePages, hSrcFont, phDestFont);
2059 
2060  return map_font(hDC, dwCodePages, hSrcFont, phDestFont);
2061 }
2062 
2064  IMLangFontLink* iface,
2065  HFONT hFont)
2066 {
2067  TRACE("(%p)->%p\n",iface, hFont);
2068 
2069  return release_font(hFont);
2070 }
2071 
2073  IMLangFontLink* iface)
2074 {
2075  TRACE("(%p)\n",iface);
2076 
2077  return clear_font_cache();
2078 }
2079 
2080 
2081 static const IMLangFontLinkVtbl IMLangFontLink_vtbl =
2082 {
2094 };
2095 
2096 /******************************************************************************/
2097 
2098 static inline MLang_impl *impl_from_IMultiLanguage( IMultiLanguage *iface )
2099 {
2100  return CONTAINING_RECORD( iface, MLang_impl, IMultiLanguage_iface );
2101 }
2102 
2104  IMultiLanguage* iface,
2105  REFIID riid,
2106  void** obj)
2107 {
2109  return IMultiLanguage3_QueryInterface(&This->IMultiLanguage3_iface, riid, obj);
2110 }
2111 
2112 static ULONG WINAPI fnIMultiLanguage_AddRef( IMultiLanguage* iface )
2113 {
2115  return IMultiLanguage3_AddRef(&This->IMultiLanguage3_iface);
2116 }
2117 
2118 static ULONG WINAPI fnIMultiLanguage_Release( IMultiLanguage* iface )
2119 {
2121  return IMultiLanguage3_Release(&This->IMultiLanguage3_iface);
2122 }
2123 
2125  IMultiLanguage* iface,
2126  UINT* cp)
2127 {
2129  TRACE("(%p, %p)\n", This, cp);
2130  return IMultiLanguage3_GetNumberOfCodePageInfo(&This->IMultiLanguage3_iface, cp);
2131 }
2132 
2134  IMultiLanguage* iface,
2135  UINT uiCodePage,
2136  PMIMECPINFO pCodePageInfo)
2137 {
2138  UINT i, n;
2140 
2141  TRACE("%p, %u, %p\n", This, uiCodePage, pCodePageInfo);
2142 
2143  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
2144  {
2145  for (n = 0; n < mlang_data[i].number_of_cp; n++)
2146  {
2147  if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
2148  {
2149  fill_cp_info(&mlang_data[i], n, pCodePageInfo);
2150  return S_OK;
2151  }
2152  }
2153  }
2154 
2155  return S_FALSE;
2156 }
2157 
2159  IMultiLanguage* iface,
2160  UINT cp,
2161  UINT* family_cp)
2162 {
2164  return IMultiLanguage3_GetFamilyCodePage(&This->IMultiLanguage3_iface, cp, family_cp);
2165 }
2166 
2168  IMultiLanguage* iface,
2169  DWORD grfFlags,
2170  IEnumCodePage** ppEnumCodePage)
2171 {
2173 
2174  TRACE("%p %08x %p\n", This, grfFlags, ppEnumCodePage);
2175 
2176  return EnumCodePage_create( This, grfFlags, 0, ppEnumCodePage );
2177 }
2178 
2180  IMultiLanguage* iface,
2181  BSTR Charset,
2182  PMIMECSETINFO pCharsetInfo)
2183 {
2185  return IMultiLanguage3_GetCharsetInfo( &This->IMultiLanguage3_iface, Charset, pCharsetInfo );
2186 }
2187 
2189  IMultiLanguage* iface,
2190  DWORD src_enc,
2191  DWORD dst_enc)
2192 {
2194  return IMultiLanguage3_IsConvertible(&This->IMultiLanguage3_iface, src_enc, dst_enc);
2195 }
2196 
2198  IMultiLanguage* iface,
2199  DWORD* mode,
2200  DWORD src_enc,
2201  DWORD dst_enc,
2202  BYTE* src,
2203  UINT* src_size,
2204  BYTE* dest,
2205  UINT* dest_size)
2206 {
2208  return IMultiLanguage3_ConvertString(&This->IMultiLanguage3_iface, mode, src_enc,
2209  dst_enc, src, src_size, dest, dest_size);
2210 }
2211 
2213  IMultiLanguage* iface,
2214  DWORD* mode,
2215  DWORD src_enc,
2216  CHAR* src,
2217  UINT* src_size,
2218  WCHAR* dest,
2219  UINT* dest_size)
2220 {
2222  return IMultiLanguage3_ConvertStringToUnicode(&This->IMultiLanguage3_iface,
2223  mode, src_enc, src, src_size, dest, dest_size);
2224 }
2225 
2227  IMultiLanguage* iface,
2228  DWORD* mode,
2229  DWORD encoding,
2230  WCHAR* src,
2231  UINT* src_size,
2232  CHAR* dest,
2233  UINT* dest_size)
2234 {
2236  return IMultiLanguage3_ConvertStringFromUnicode(&This->IMultiLanguage3_iface,
2237  mode, encoding, src, src_size, dest, dest_size);
2238 }
2239 
2241  IMultiLanguage* iface)
2242 {
2244  return IMultiLanguage3_ConvertStringReset(&This->IMultiLanguage3_iface);
2245 }
2246 
2248  IMultiLanguage* iface,
2249  LCID lcid,
2250  BSTR* pbstrRfc1766)
2251 {
2253  return IMultiLanguage3_GetRfc1766FromLcid(&This->IMultiLanguage3_iface, lcid, pbstrRfc1766);
2254 }
2255 
2257  IMultiLanguage* iface,
2258  LCID* locale,
2259  BSTR rfc1766)
2260 {
2262  return IMultiLanguage3_GetLcidFromRfc1766(&This->IMultiLanguage3_iface, locale, rfc1766);
2263 }
2264 
2265 /******************************************************************************/
2266 
2267 typedef struct tagEnumRfc1766_impl
2268 {
2269  IEnumRfc1766 IEnumRfc1766_iface;
2271  RFC1766INFO *info;
2274 
2275 static inline EnumRfc1766_impl *impl_from_IEnumRfc1766( IEnumRfc1766 *iface )
2276 {
2277  return CONTAINING_RECORD( iface, EnumRfc1766_impl, IEnumRfc1766_iface );
2278 }
2279 
2281  IEnumRfc1766 *iface,
2282  REFIID riid,
2283  void** ppvObject)
2284 {
2286 
2287  TRACE("%p -> %s\n", This, debugstr_guid(riid) );
2288 
2290  || IsEqualGUID(riid, &IID_IEnumRfc1766))
2291  {
2292  IEnumRfc1766_AddRef(iface);
2293  TRACE("Returning IID_IEnumRfc1766 %p ref = %d\n", This, This->ref);
2294  *ppvObject = &This->IEnumRfc1766_iface;
2295  return S_OK;
2296  }
2297 
2298  WARN("(%p) -> (%s,%p), not found\n",This,debugstr_guid(riid),ppvObject);
2299  return E_NOINTERFACE;
2300 }
2301 
2303  IEnumRfc1766 *iface)
2304 {
2306  return InterlockedIncrement(&This->ref);
2307 }
2308 
2310  IEnumRfc1766 *iface)
2311 {
2314 
2315  TRACE("%p ref = %d\n", This, ref);
2316  if (ref == 0)
2317  {
2318  TRACE("Destroying %p\n", This);
2319  HeapFree(GetProcessHeap(), 0, This->info);
2320  HeapFree(GetProcessHeap(), 0, This);
2321  }
2322  return ref;
2323 }
2324 
2326  IEnumRfc1766 *iface,
2327  IEnumRfc1766 **ppEnum)
2328 {
2330 
2331  FIXME("%p %p\n", This, ppEnum);
2332  return E_NOTIMPL;
2333 }
2334 
2336  IEnumRfc1766 *iface,
2337  ULONG celt,
2338  PRFC1766INFO rgelt,
2339  ULONG *pceltFetched)
2340 {
2341  ULONG i;
2343 
2344  TRACE("%p %u %p %p\n", This, celt, rgelt, pceltFetched);
2345 
2346  if (!pceltFetched) return S_FALSE;
2347  *pceltFetched = 0;
2348 
2349  if (!rgelt) return S_FALSE;
2350 
2351  if (This->pos + celt > This->total)
2352  celt = This->total - This->pos;
2353 
2354  if (!celt) return S_FALSE;
2355 
2356  memcpy(rgelt, This->info + This->pos, celt * sizeof(RFC1766INFO));
2357  *pceltFetched = celt;
2358  This->pos += celt;
2359 
2360  for (i = 0; i < celt; i++)
2361  {
2362  TRACE("#%u: %08x %s %s\n",
2363  i, rgelt[i].lcid,
2364  wine_dbgstr_w(rgelt[i].wszRfc1766),
2365  wine_dbgstr_w(rgelt[i].wszLocaleName));
2366  }
2367  return S_OK;
2368 }
2369 
2371  IEnumRfc1766 *iface)
2372 {
2374 
2375  TRACE("%p\n", This);
2376 
2377  This->pos = 0;
2378  return S_OK;
2379 }
2380 
2382  IEnumRfc1766 *iface,
2383  ULONG celt)
2384 {
2386 
2387  TRACE("%p %u\n", This, celt);
2388 
2389  if (celt >= This->total) return S_FALSE;
2390 
2391  This->pos += celt;
2392  return S_OK;
2393 }
2394 
2395 static const IEnumRfc1766Vtbl IEnumRfc1766_vtbl =
2396 {
2404 };
2405 
2407 {
2408  RFC1766INFO *info;
2410 };
2411 
2413 {
2414  WCHAR *end;
2416  RFC1766INFO *info;
2417 
2418  TRACE("%s\n", debugstr_w(locale));
2419 
2420  if (data->total >= data->allocated)
2421  {
2422  data->allocated += 32;
2423  data->info = HeapReAlloc(GetProcessHeap(), 0, data->info, data->allocated * sizeof(RFC1766INFO));
2424  if (!data->info) return FALSE;
2425  }
2426 
2427  info = &data->info[data->total];
2428 
2429  info->lcid = strtolW(locale, &end, 16);
2430  if (*end) /* invalid number */
2431  return FALSE;
2432 
2433  info->wszRfc1766[0] = 0;
2434  lcid_to_rfc1766W( info->lcid, info->wszRfc1766, MAX_RFC1766_NAME );
2435 
2436  info->wszLocaleName[0] = 0;
2437  GetLocaleInfoW(info->lcid, LOCALE_SLANGUAGE, info->wszLocaleName, MAX_LOCALE_NAME);
2438  TRACE("ISO639: %s SLANGUAGE: %s\n", wine_dbgstr_w(info->wszRfc1766), wine_dbgstr_w(info->wszLocaleName));
2439 
2440  data->total++;
2441 
2442  return TRUE;
2443 }
2444 
2445 static HRESULT EnumRfc1766_create(LANGID LangId, IEnumRfc1766 **ppEnum)
2446 {
2447  EnumRfc1766_impl *rfc;
2448  struct enum_locales_data data;
2449 
2450  TRACE("%04x, %p\n", LangId, ppEnum);
2451 
2452  rfc = HeapAlloc( GetProcessHeap(), 0, sizeof(EnumRfc1766_impl) );
2453  rfc->IEnumRfc1766_iface.lpVtbl = &IEnumRfc1766_vtbl;
2454  rfc->ref = 1;
2455  rfc->pos = 0;
2456  rfc->total = 0;
2457 
2458  data.total = 0;
2459  data.allocated = 160;
2460  data.info = HeapAlloc(GetProcessHeap(), 0, data.allocated * sizeof(RFC1766INFO));
2461  if (!data.info)
2462  {
2463  HeapFree(GetProcessHeap(), 0, rfc);
2464  return E_OUTOFMEMORY;
2465  }
2466 
2468  EnumSystemLocalesW(enum_locales_proc, 0/*LOCALE_SUPPORTED*/);
2470 
2471  TRACE("enumerated %d rfc1766 structures\n", data.total);
2472 
2473  if (!data.total)
2474  {
2475  HeapFree(GetProcessHeap(), 0, data.info);
2476  HeapFree(GetProcessHeap(), 0, rfc);
2477  return E_FAIL;
2478  }
2479 
2480  rfc->info = data.info;
2481  rfc->total = data.total;
2482 
2483  *ppEnum = &rfc->IEnumRfc1766_iface;
2484  return S_OK;
2485 }
2486 
2488  IMultiLanguage *iface,
2489  IEnumRfc1766 **ppEnumRfc1766)
2490 {
2492 
2493  TRACE("%p %p\n", This, ppEnumRfc1766);
2494 
2495  return EnumRfc1766_create(0, ppEnumRfc1766);
2496 }
2497 
2498 /******************************************************************************/
2499 
2501  IMultiLanguage* iface,
2502  LCID Locale,
2503  PRFC1766INFO pRfc1766Info)
2504 {
2506 
2507  TRACE("(%p, 0x%04x, %p)\n", iface, Locale, pRfc1766Info);
2508 
2509  if (!pRfc1766Info)
2510  return E_INVALIDARG;
2511 
2512  if ((PRIMARYLANGID(Locale) == LANG_ENGLISH) ||
2513  (PRIMARYLANGID(Locale) == LANG_CHINESE) ||
2514  (PRIMARYLANGID(Locale) == LANG_ARABIC)) {
2515 
2516  if (!SUBLANGID(Locale))
2517  type = LOCALE_SENGLANGUAGE; /* suppress country */
2518  }
2519  else
2520  {
2521  if (!SUBLANGID(Locale)) {
2522  TRACE("SUBLANGID missing in 0x%04x\n", Locale);
2523  return E_FAIL;
2524  }
2525  }
2526 
2527  pRfc1766Info->lcid = Locale;
2528  pRfc1766Info->wszRfc1766[0] = 0;
2529  pRfc1766Info->wszLocaleName[0] = 0;
2530 
2531  if ((!lcid_to_rfc1766W(Locale, pRfc1766Info->wszRfc1766, MAX_RFC1766_NAME)) &&
2532  (GetLocaleInfoW(Locale, type, pRfc1766Info->wszLocaleName, MAX_LOCALE_NAME) > 0))
2533  return S_OK;
2534 
2535  /* Locale not supported */
2536  return E_INVALIDARG;
2537 }
2538 
2540  IMultiLanguage* iface,
2541  UINT src_cp,
2542  UINT dst_cp,
2543  DWORD prop,
2544  IMLangConvertCharset** convert_charset)
2545 {
2547  return IMultiLanguage3_CreateConvertCharset(&This->IMultiLanguage3_iface, src_cp, dst_cp, prop, convert_charset);
2548 }
2549 
2550 static const IMultiLanguageVtbl IMultiLanguage_vtbl =
2551 {
2570 };
2571 
2572 
2573 /******************************************************************************/
2574 
2575 static inline MLang_impl *impl_from_IMultiLanguage3( IMultiLanguage3 *iface )
2576 {
2577  return CONTAINING_RECORD( iface, MLang_impl, IMultiLanguage3_iface );
2578 }
2579 
2581  IMultiLanguage3* iface,
2582  REFIID riid,
2583  void** obj)
2584 {
2586 
2587  TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
2588 
2589  if (IsEqualGUID(riid, &IID_IUnknown) ||
2590  IsEqualGUID(riid, &IID_IMultiLanguage))
2591  {
2592  *obj = &This->IMultiLanguage_iface;
2593  }
2594  else if (IsEqualGUID(riid, &IID_IMLangCodePages) ||
2595  IsEqualGUID(riid, &IID_IMLangFontLink))
2596  {
2597  *obj = &This->IMLangFontLink_iface;
2598  }
2599  else if (IsEqualGUID(riid, &IID_IMLangFontLink2))
2600  {
2601  *obj = &This->IMLangFontLink2_iface;
2602  }
2603  else if (IsEqualGUID(riid, &IID_IMultiLanguage2) ||
2604  IsEqualGUID(riid, &IID_IMultiLanguage3))
2605  {
2606  *obj = &This->IMultiLanguage3_iface;
2607  }
2608  else if (IsEqualGUID(riid, &IID_IMLangLineBreakConsole))
2609  {
2610  *obj = &This->IMLangLineBreakConsole_iface;
2611  }
2612  else
2613  {
2614  WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), obj);
2615  *obj = NULL;
2616  return E_NOINTERFACE;
2617  }
2618 
2619  IMultiLanguage3_AddRef(iface);
2620  return S_OK;
2621 }
2622 
2623 static ULONG WINAPI fnIMultiLanguage3_AddRef( IMultiLanguage3* iface )
2624 {
2626  return InterlockedIncrement(&This->ref);
2627 }
2628 
2629 static ULONG WINAPI fnIMultiLanguage3_Release( IMultiLanguage3* iface )
2630 {
2633 
2634  TRACE("(%p)->(%d)\n", This, ref);
2635  if (ref == 0)
2636  {
2637  HeapFree(GetProcessHeap(), 0, This);
2638  UnlockModule();
2639  }
2640 
2641  return ref;
2642 }
2643 
2645  IMultiLanguage3* iface,
2646  UINT* pcCodePage)
2647 {
2649 
2650  TRACE("%p, %p\n", This, pcCodePage);
2651 
2652  if (!pcCodePage) return E_INVALIDARG;
2653 
2654  *pcCodePage = This->total_cp;
2655  return S_OK;
2656 }
2657 
2658 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info)
2659 {
2660  CHARSETINFO csi;
2661 
2662  if (TranslateCharsetInfo((DWORD*)(DWORD_PTR)ml_data->family_codepage, &csi,
2663  TCI_SRCCODEPAGE))
2664  mime_cp_info->bGDICharset = csi.ciCharset;
2665  else
2666  mime_cp_info->bGDICharset = DEFAULT_CHARSET;
2667 
2668  mime_cp_info->dwFlags = ml_data->mime_cp_info[index].flags;
2669  mime_cp_info->uiCodePage = ml_data->mime_cp_info[index].cp;
2670  mime_cp_info->uiFamilyCodePage = ml_data->family_codepage;
2672  mime_cp_info->wszDescription, ARRAY_SIZE(mime_cp_info->wszDescription));
2674  mime_cp_info->wszWebCharset, ARRAY_SIZE(mime_cp_info->wszWebCharset));
2676  mime_cp_info->wszHeaderCharset, ARRAY_SIZE(mime_cp_info->wszHeaderCharset));
2678  mime_cp_info->wszBodyCharset, ARRAY_SIZE(mime_cp_info->wszBodyCharset));
2679 
2680  MultiByteToWideChar(CP_ACP, 0, ml_data->fixed_font, -1,
2681  mime_cp_info->wszFixedWidthFont, ARRAY_SIZE(mime_cp_info->wszFixedWidthFont));
2682  MultiByteToWideChar(CP_ACP, 0, ml_data->proportional_font, -1,
2683  mime_cp_info->wszProportionalFont, ARRAY_SIZE(mime_cp_info->wszProportionalFont));
2684 
2685  TRACE("%08x %u %u %s %s %s %s %s %s %d\n",
2686  mime_cp_info->dwFlags, mime_cp_info->uiCodePage,
2687  mime_cp_info->uiFamilyCodePage,
2688  wine_dbgstr_w(mime_cp_info->wszDescription),
2689  wine_dbgstr_w(mime_cp_info->wszWebCharset),
2690  wine_dbgstr_w(mime_cp_info->wszHeaderCharset),
2691  wine_dbgstr_w(mime_cp_info->wszBodyCharset),
2692  wine_dbgstr_w(mime_cp_info->wszFixedWidthFont),
2693  wine_dbgstr_w(mime_cp_info->wszProportionalFont),
2694  mime_cp_info->bGDICharset);
2695 }
2696 
2698  IMultiLanguage3* iface,
2699  UINT uiCodePage,
2700  LANGID LangId,
2701  PMIMECPINFO pCodePageInfo)
2702 {
2703  UINT i, n;
2705 
2706  TRACE("%p, %u, %04x, %p\n", This, uiCodePage, LangId, pCodePageInfo);
2707 
2708  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
2709  {
2710  for (n = 0; n < mlang_data[i].number_of_cp; n++)
2711  {
2712  if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
2713  {
2714  fill_cp_info(&mlang_data[i], n, pCodePageInfo);
2715  return S_OK;
2716  }
2717  }
2718  }
2719 
2720  return S_FALSE;
2721 }
2722 
2724  IMultiLanguage3* iface,
2725  UINT uiCodePage,
2726  UINT* puiFamilyCodePage)
2727 {
2728  return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
2729 }
2730 
2732  IMultiLanguage3* iface,
2733  DWORD grfFlags,
2734  LANGID LangId,
2735  IEnumCodePage** ppEnumCodePage)
2736 {
2738 
2739  TRACE("%p %08x %04x %p\n", This, grfFlags, LangId, ppEnumCodePage);
2740 
2741  return EnumCodePage_create( This, grfFlags, LangId, ppEnumCodePage );
2742 }
2743 
2745  IMultiLanguage3* iface,
2746  BSTR Charset,
2747  PMIMECSETINFO pCharsetInfo)
2748 {
2749  UINT i, n;
2751 
2752  TRACE("%p %s %p\n", This, debugstr_w(Charset), pCharsetInfo);
2753 
2754  if (!pCharsetInfo) return E_FAIL;
2755 
2756  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
2757  {
2758  for (n = 0; n < mlang_data[i].number_of_cp; n++)
2759  {
2760  WCHAR csetW[MAX_MIMECSET_NAME];
2761 
2762  MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].web_charset, -1, csetW, MAX_MIMECSET_NAME);
2763  if (!lstrcmpiW(Charset, csetW))
2764  {
2765  pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
2766  pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
2767  strcpyW(pCharsetInfo->wszCharset, csetW);
2768  return S_OK;
2769  }
2770  if (mlang_data[i].mime_cp_info[n].alias && !lstrcmpiW(Charset, mlang_data[i].mime_cp_info[n].alias))
2771  {
2772  pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
2773  pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
2774  strcpyW(pCharsetInfo->wszCharset, mlang_data[i].mime_cp_info[n].alias);
2775  return S_OK;
2776  }
2777  }
2778  }
2779 
2780  /* FIXME:
2781  * Since we do not support charsets like iso-2022-jp and do not have
2782  * them in our database as a primary (web_charset) encoding this loop
2783  * does an attempt to 'approximate' charset name by header_charset.
2784  */
2785  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
2786  {
2787  for (n = 0; n < mlang_data[i].number_of_cp; n++)
2788  {
2789  WCHAR csetW[MAX_MIMECSET_NAME];
2790 
2791  MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].header_charset, -1, csetW, MAX_MIMECSET_NAME);
2792  if (!lstrcmpiW(Charset, csetW))
2793  {
2794  pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
2795  pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
2796  strcpyW(pCharsetInfo->wszCharset, csetW);
2797  return S_OK;
2798  }
2799  }
2800  }
2801 
2802  return E_FAIL;
2803 }
2804 
2806  IMultiLanguage3* iface,
2807  DWORD dwSrcEncoding,
2808  DWORD dwDstEncoding)
2809 {
2810  return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
2811 }
2812 
2814  IMultiLanguage3* iface,
2815  DWORD* pdwMode,
2816  DWORD dwSrcEncoding,
2817  DWORD dwDstEncoding,
2818  BYTE* pSrcStr,
2819  UINT* pcSrcSize,
2820  BYTE* pDstStr,
2821  UINT* pcDstSize)
2822 {
2823  return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
2824  (LPCSTR)pSrcStr, (LPINT)pcSrcSize, (LPSTR)pDstStr, (LPINT)pcDstSize);
2825 }
2826 
2828  IMultiLanguage3* iface,
2829  DWORD* pdwMode,
2830  DWORD dwEncoding,
2831  CHAR* pSrcStr,
2832  UINT* pcSrcSize,
2833  WCHAR* pDstStr,
2834  UINT* pcDstSize)
2835 {
2836  return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
2837  pSrcStr, (LPINT)pcSrcSize, pDstStr, (LPINT)pcDstSize);
2838 }
2839 
2841  IMultiLanguage3* iface,
2842  DWORD* pdwMode,
2843  DWORD dwEncoding,
2844  WCHAR* pSrcStr,
2845  UINT* pcSrcSize,
2846  CHAR* pDstStr,
2847  UINT* pcDstSize)
2848 {
2849  return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
2850  pSrcStr, (LPINT)pcSrcSize, pDstStr, (LPINT)pcDstSize);
2851 }
2852 
2854  IMultiLanguage3* iface)
2855 {
2856  FIXME("\n");
2857  return E_NOTIMPL;
2858 }
2859 
2861  IMultiLanguage3* iface,
2862  LCID lcid,
2863  BSTR* pbstrRfc1766)
2864 {
2865  WCHAR buf[MAX_RFC1766_NAME];
2866 
2867  TRACE("%p %04x %p\n", iface, lcid, pbstrRfc1766);
2868  if (!pbstrRfc1766)
2869  return E_INVALIDARG;
2870 
2871  if (!lcid_to_rfc1766W( lcid, buf, MAX_RFC1766_NAME ))
2872  {
2873  *pbstrRfc1766 = SysAllocString( buf );
2874  return S_OK;
2875  }
2876  return E_FAIL;
2877 }
2878 
2880  IMultiLanguage3* iface,
2881  LCID* pLocale,
2882  BSTR bstrRfc1766)
2883 {
2884  HRESULT hr;
2885  IEnumRfc1766 *rfc1766;
2886 
2887  TRACE("%p %p %s\n", iface, pLocale, debugstr_w(bstrRfc1766));
2888 
2889  if (!pLocale || !bstrRfc1766)
2890  return E_INVALIDARG;
2891 
2892  hr = IMultiLanguage3_EnumRfc1766(iface, 0, &rfc1766);
2893  if (FAILED(hr))
2894  return hr;
2895 
2896  hr = lcid_from_rfc1766(rfc1766, pLocale, bstrRfc1766);
2897 
2898  IEnumRfc1766_Release(rfc1766);
2899  return hr;
2900 }
2901 
2903  IMultiLanguage3* iface,
2904  LANGID LangId,
2905  IEnumRfc1766** ppEnumRfc1766)
2906 {
2908 
2909  TRACE("%p %p\n", This, ppEnumRfc1766);
2910 
2911  return EnumRfc1766_create(LangId, ppEnumRfc1766);
2912 }
2913 
2915  IMultiLanguage3* iface,
2916  LCID Locale,
2917  LANGID LangId,
2918  PRFC1766INFO pRfc1766Info)
2919 {
2920  static LANGID last_lang = -1;
2922 
2923  TRACE("(%p, 0x%04x, 0x%04x, %p)\n", iface, Locale, LangId, pRfc1766Info);
2924 
2925  if (!pRfc1766Info)
2926  return E_INVALIDARG;
2927 
2928  if ((PRIMARYLANGID(Locale) == LANG_ENGLISH) ||
2929  (PRIMARYLANGID(Locale) == LANG_CHINESE) ||
2930  (PRIMARYLANGID(Locale) == LANG_ARABIC)) {
2931 
2932  if (!SUBLANGID(Locale))
2933  type = LOCALE_SENGLANGUAGE; /* suppress country */
2934  }
2935  else
2936  {
2937  if (!SUBLANGID(Locale)) {
2938  TRACE("SUBLANGID missing in 0x%04x\n", Locale);
2939  return E_FAIL;
2940  }
2941  }
2942 
2943  pRfc1766Info->lcid = Locale;
2944  pRfc1766Info->wszRfc1766[0] = 0;
2945  pRfc1766Info->wszLocaleName[0] = 0;
2946 
2947  if ((PRIMARYLANGID(LangId) != LANG_ENGLISH) &&
2948  (last_lang != LangId)) {
2949  FIXME("Only English names supported (requested: 0x%04x)\n", LangId);
2950  last_lang = LangId;
2951  }
2952 
2953  if ((!lcid_to_rfc1766W(Locale, pRfc1766Info->wszRfc1766, MAX_RFC1766_NAME)) &&
2954  (GetLocaleInfoW(Locale, type, pRfc1766Info->wszLocaleName, MAX_LOCALE_NAME) > 0))
2955  return S_OK;
2956 
2957  /* Locale not supported */
2958  return E_INVALIDARG;
2959 }
2960 
2962  IMultiLanguage3* iface,
2963  UINT src_cp,
2964  UINT dst_cp,
2965  DWORD prop,
2966  IMLangConvertCharset** convert_charset)
2967 {
2968  HRESULT hr;
2969 
2970  TRACE("(%u %u 0x%08x %p)\n", src_cp, dst_cp, prop, convert_charset);
2971 
2973  if (FAILED(hr)) return hr;
2974 
2975  return IMLangConvertCharset_Initialize(*convert_charset, src_cp, dst_cp, prop);
2976 }
2977 
2979  IMultiLanguage3* iface,
2980  DWORD* pdwMode,
2981  DWORD dwFlag,
2982  WCHAR* lpFallBack,
2983  DWORD dwSrcEncoding,
2984  DWORD dwDstEncoding,
2985  IStream* pstmIn,
2986  IStream* pstmOut)
2987 {
2988  char *src, *dst = NULL;
2989  INT srclen, dstlen;
2990  STATSTG stat;
2991  HRESULT hr;
2992 
2993  TRACE("%p %0x8 %s %u %u %p %p\n",
2994  pdwMode, dwFlag, debugstr_w(lpFallBack), dwSrcEncoding, dwDstEncoding, pstmIn, pstmOut);
2995 
2996  FIXME("dwFlag and lpFallBack not handled\n");
2997 
2998  hr = IStream_Stat(pstmIn, &stat, STATFLAG_NONAME);
2999  if (FAILED(hr)) return hr;
3000 
3001  if (stat.cbSize.QuadPart > MAXLONG) return E_INVALIDARG;
3002  if (!(src = HeapAlloc(GetProcessHeap(), 0, stat.cbSize.QuadPart))) return E_OUTOFMEMORY;
3003 
3004  hr = IStream_Read(pstmIn, src, stat.cbSize.QuadPart, (ULONG *)&srclen);
3005  if (FAILED(hr)) goto exit;
3006 
3007  hr = ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding, src, &srclen, NULL, &dstlen);
3008  if (FAILED(hr)) goto exit;
3009 
3010  if (!(dst = HeapAlloc(GetProcessHeap(), 0, dstlen)))
3011  {
3012  hr = E_OUTOFMEMORY;
3013  goto exit;
3014  }
3015  hr = ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding, src, &srclen, dst, &dstlen);
3016  if (FAILED(hr)) goto exit;
3017 
3018  hr = IStream_Write(pstmOut, dst, dstlen, NULL);
3019 
3020 exit:
3021  HeapFree(GetProcessHeap(), 0, src);
3022  HeapFree(GetProcessHeap(), 0, dst);
3023  return hr;
3024 }
3025 
3027  IMultiLanguage3* iface,
3028  DWORD* pdwMode,
3029  DWORD dwEncoding,
3030  CHAR* pSrcStr,
3031  UINT* pcSrcSize,
3032  WCHAR* pDstStr,
3033  UINT* pcDstSize,
3034  DWORD dwFlag,
3035  WCHAR* lpFallBack)
3036 {
3037  if (dwFlag || lpFallBack)
3038  FIXME("Ignoring dwFlag (0x%x/%d) and lpFallBack (%p)\n",
3039  dwFlag, dwFlag, lpFallBack);
3040 
3041  return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
3042  pSrcStr, (LPINT)pcSrcSize, pDstStr, (LPINT)pcDstSize);
3043 }
3044 
3045 /*****************************************************************************
3046  * MultiLanguage2::ConvertStringToUnicodeEx
3047  *
3048  * Translates the multibyte string from the specified code page to Unicode.
3049  *
3050  * PARAMS
3051  * see ConvertStringToUnicode
3052  * dwFlag
3053  * lpFallBack if dwFlag contains MLCONVCHARF_USEDEFCHAR, lpFallBack string used
3054  * instead unconvertible characters.
3055  *
3056  * RETURNS
3057  * S_OK Success.
3058  * S_FALSE The conversion is not supported.
3059  * E_FAIL Some error has occurred.
3060  *
3061  * TODO: handle dwFlag and lpFallBack
3062 */
3064  IMultiLanguage3* This,
3065  DWORD* pdwMode,
3066  DWORD dwEncoding,
3067  WCHAR* pSrcStr,
3068  UINT* pcSrcSize,
3069  CHAR* pDstStr,
3070  UINT* pcDstSize,
3071  DWORD dwFlag,
3072  WCHAR* lpFallBack)
3073 {
3074  FIXME("\n");
3075  return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
3076  pSrcStr, (LPINT)pcSrcSize, pDstStr, (LPINT)pcDstSize);
3077 }
3078 
3080  IMultiLanguage3* iface,
3081  DWORD dwFlag,
3082  DWORD dwPrefWinCodePage,
3083  IStream* pstmIn,
3084  DetectEncodingInfo* lpEncoding,
3085  INT* pnScores)
3086 {
3087  FIXME("\n");
3088  return E_NOTIMPL;
3089 }
3090 
3092  IMultiLanguage3* iface,
3093  DWORD dwFlag,
3094  DWORD dwPrefWinCodePage,
3095  CHAR* pSrcStr,
3096  INT* pcSrcSize,
3097  DetectEncodingInfo* lpEncoding,
3098  INT* pnScores)
3099 {
3100  FIXME("\n");
3101  return E_NOTIMPL;
3102 }
3103 
3105  IMultiLanguage3* iface,
3106  UINT uiCodePage,
3107  HWND hwnd)
3108 {
3109  return IMultiLanguage3_ValidateCodePageEx(iface,uiCodePage,hwnd,0);
3110 }
3111 
3113  IMultiLanguage3* iface,
3114  UINT uiCodePage,
3115  LCID lcid,
3116  LPWSTR lpWideCharStr,
3117  int cchWideChar)
3118 {
3119  /* Find first instance */
3120  unsigned int i,n;
3121 
3122  TRACE ("%u, %04x, %p, %d\n", uiCodePage, lcid, lpWideCharStr, cchWideChar);
3123  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
3124  {
3125  for (n = 0; n < mlang_data[i].number_of_cp; n++)
3126  {
3127  if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
3128  {
3130  mlang_data[i].mime_cp_info[n].description,
3131  -1, lpWideCharStr, cchWideChar);
3132  return S_OK;
3133  }
3134  }
3135  }
3136 
3137  return S_FALSE;
3138 }
3139 
3141  IMultiLanguage3* iface,
3142  UINT uiCodePage)
3143 {
3144  TRACE("%u\n", uiCodePage);
3145 
3146  /* FIXME: the installable set is usually larger than the set of valid codepages */
3147  return IMultiLanguage3_ValidateCodePageEx(iface, uiCodePage, NULL, CPIOD_PEEK);
3148 }
3149 
3151  IMultiLanguage3* iface,
3152  MIMECONTF dwSource)
3153 {
3154  FIXME("0x%08x\n", dwSource);
3155  return S_OK;
3156 }
3157 
3159  IMultiLanguage3* iface,
3160  UINT* pnScripts)
3161 {
3163 
3164  TRACE("%p %p\n", This, pnScripts);
3165 
3166  if (!pnScripts) return S_FALSE;
3167 
3168  *pnScripts = This->total_scripts;
3169  return S_OK;
3170 }
3171 
3173  IMultiLanguage3* iface,
3174  DWORD dwFlags,
3175  LANGID LangId,
3176  IEnumScript** ppEnumScript)
3177 {
3179 
3180  TRACE("%p %08x %04x %p\n", This, dwFlags, LangId, ppEnumScript);
3181 
3182  return EnumScript_create( This, dwFlags, LangId, ppEnumScript );
3183 }
3184 
3186  IMultiLanguage3* iface,
3187  UINT uiCodePage,
3188  HWND hwnd,
3189  DWORD dwfIODControl)
3190 {
3191  unsigned int i;
3193 
3194  TRACE("%p %u %p %08x\n", This, uiCodePage, hwnd, dwfIODControl);
3195 
3196  /* quick check for kernel32 supported code pages */
3197  if (IsValidCodePage(uiCodePage))
3198  return S_OK;
3199 
3200  /* check for mlang supported code pages */
3201  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
3202  {
3203  UINT n;
3204  for (n = 0; n < mlang_data[i].number_of_cp; n++)
3205  {
3206  if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
3207  return S_OK;
3208  }
3209  }
3210 
3211  if (dwfIODControl != CPIOD_PEEK)
3212  FIXME("Request to install codepage language pack not handled\n");
3213 
3214  return S_FALSE;
3215 }
3216 
3218  IMultiLanguage3 *iface,
3219  DWORD dwFlags,
3220  LPCWSTR lpWideCharStr,
3221  UINT cchWideChar,
3222  UINT *puiPreferredCodePages,
3223  UINT nPreferredCodePages,
3224  UINT *puiDetectedCodePages,
3225  UINT *pnDetectedCodePages,
3226  WCHAR *lpSpecialChar)
3227 {
3229 
3230  FIXME("(%p)->(%08x %s %p %u %p %p(%u) %s)\n", This, dwFlags, debugstr_w(lpWideCharStr),
3231  puiPreferredCodePages, nPreferredCodePages, puiDetectedCodePages,
3232  pnDetectedCodePages, pnDetectedCodePages ? *pnDetectedCodePages : 0,
3233  debugstr_w(lpSpecialChar));
3234 
3235  if (!puiDetectedCodePages || !pnDetectedCodePages || !*pnDetectedCodePages)
3236  return E_INVALIDARG;
3237 
3238  puiDetectedCodePages[0] = CP_UTF8;
3239  *pnDetectedCodePages = 1;
3240  return S_OK;
3241 }
3242 
3244  IMultiLanguage3 *iface,
3245  DWORD dwFlags,
3246  IStream *pStrIn,
3247  UINT *puiPreferredCodePages,
3248  UINT nPreferredCodePages,
3249  UINT *puiDetectedCodePages,
3250  UINT *pnDetectedCodePages,
3251  WCHAR *lpSpecialChar)
3252 {
3254 
3255  FIXME("(%p)->(%08x %p %p %u %p %p(%u) %s)\n", This, dwFlags, pStrIn,
3256  puiPreferredCodePages, nPreferredCodePages, puiDetectedCodePages,
3257  pnDetectedCodePages, pnDetectedCodePages ? *pnDetectedCodePages : 0,
3258  debugstr_w(lpSpecialChar));
3259 
3260  if (!puiDetectedCodePages || !pnDetectedCodePages || !*pnDetectedCodePages)
3261  return E_INVALIDARG;
3262 
3263  puiDetectedCodePages[0] = CP_UTF8;
3264  *pnDetectedCodePages = 1;
3265  return S_OK;
3266 }
3267 
3268 static const IMultiLanguage3Vtbl IMultiLanguage3_vtbl =
3269 {
3302 };
3303 
3304 /******************************************************************************/
3305 
3306 static inline MLang_impl *impl_from_IMLangFontLink2( IMLangFontLink2 *iface )
3307 {
3308  return CONTAINING_RECORD( iface, MLang_impl, IMLangFontLink2_iface );
3309 }
3310 
3312  IMLangFontLink2 * iface,
3313  REFIID riid,
3314  void** ppvObject)
3315 {
3317  return IMultiLanguage3_QueryInterface( &This->IMultiLanguage3_iface, riid, ppvObject );
3318 }
3319 
3320 static ULONG WINAPI fnIMLangFontLink2_AddRef( IMLangFontLink2* iface )
3321 {
3323  return IMultiLanguage3_AddRef( &This->IMultiLanguage3_iface );
3324 }
3325 
3326 static ULONG WINAPI fnIMLangFontLink2_Release( IMLangFontLink2* iface )
3327 {
3329  return IMultiLanguage3_Release( &This->IMultiLanguage3_iface );
3330 }
3331 
3332 static HRESULT WINAPI fnIMLangFontLink2_GetCharCodePages( IMLangFontLink2* iface,
3333  WCHAR ch_src, DWORD *ret_codepages)
3334 {
3336  unsigned int i;
3337 
3338  TRACE("(%p)->(%s %p)\n", This, debugstr_wn(&ch_src, 1), ret_codepages);
3339 
3340  *ret_codepages = 0;
3341 
3342  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
3343  {
3344  BOOL used_dc;
3345  CHAR buf;
3346 
3348  &ch_src, 1, &buf, 1, NULL, &used_dc);
3349 
3350  /* If default char is not used, current codepage include the given symbol */
3351  if (!used_dc)
3352  {
3353  DWORD codepages;
3354 
3355  IMLangFontLink2_CodePageToCodePages(iface,
3356  mlang_data[i].family_codepage, &codepages);
3357  *ret_codepages |= codepages;
3358  }
3359  }
3360  return S_OK;
3361 }
3362 
3363 static HRESULT WINAPI fnIMLangFontLink2_GetStrCodePages( IMLangFontLink2* iface,
3364  const WCHAR *src, LONG src_len, DWORD priority_cp,
3365  DWORD *codepages, LONG *ret_len)
3366 {
3368  LONG i;
3369  DWORD cps = 0;
3370 
3371  TRACE("(%p)->(%s:%d %x %p %p)\n", This, debugstr_wn(src, src_len), src_len, priority_cp,
3372  codepages, ret_len);
3373 
3374  if (codepages) *codepages = 0;
3375  if (ret_len) *ret_len = 0;
3376 
3377  if (!src || !src_len || src_len < 0)
3378  return E_INVALIDARG;
3379 
3380  for (i = 0; i < src_len; i++)
3381  {
3382  DWORD cp;
3383  HRESULT ret;
3384 
3385  ret = IMLangFontLink2_GetCharCodePages(iface, src[i], &cp);
3386  if (ret != S_OK) return E_FAIL;
3387 
3388  if (!cps) cps = cp;
3389  else cps &= cp;
3390 
3391  /* FIXME: not tested */
3392  if (priority_cp & cps) break;
3393  }
3394 
3395  if (codepages) *codepages = cps;
3396  if (ret_len) *ret_len = min( i + 1, src_len );
3397  return S_OK;
3398 }
3399 
3401  UINT codepage,
3402  DWORD *codepages)
3403 {
3405  CHARSETINFO cs;
3406  BOOL rc;
3407 
3408  TRACE("(%p)->(%u %p)\n", This, codepage, codepages);
3409 
3411  if (rc)
3412  {
3413  *codepages = cs.fs.fsCsb[0];
3414  TRACE("resulting codepages 0x%x\n", *codepages);
3415  return S_OK;
3416  }
3417 
3418  TRACE("codepage not found\n");
3419  *codepages = 0;
3420  return E_FAIL;
3421 }
3422 
3424  DWORD codepages, UINT def_codepage, UINT *codepage)
3425 {
3427  DWORD mask = 0;
3428  CHARSETINFO cs;
3429  BOOL rc;
3430  UINT i;
3431 
3432  TRACE("(%p)->(0x%x %u %p)\n", This, codepages, def_codepage, codepage);
3433 
3434  *codepage = 0;
3435 
3436  rc = TranslateCharsetInfo((DWORD*)(DWORD_PTR)def_codepage, &cs, TCI_SRCCODEPAGE);
3437  if (rc && (codepages & cs.fs.fsCsb[0]))
3438  {
3439  TRACE("Found Default Codepage\n");
3440  *codepage = def_codepage;
3441  return S_OK;
3442  }
3443 
3444  for (i = 0; i < 32; i++)
3445  {
3446  mask = 1 << i;
3447  if (codepages & mask)
3448  {
3449  DWORD Csb[2];
3450  Csb[0] = mask;
3451  Csb[1] = 0x0;
3452  rc = TranslateCharsetInfo(Csb, &cs, TCI_SRCFONTSIG);
3453  if (!rc)
3454  continue;
3455 
3456  TRACE("Falling back to least significant found CodePage %u\n",
3457  cs.ciACP);
3458  *codepage = cs.ciACP;
3459  return S_OK;
3460  }
3461  }
3462 
3463  TRACE("no codepage found\n");
3464  return E_FAIL;
3465 }
3466 
3467 static HRESULT WINAPI fnIMLangFontLink2_GetFontCodePages(IMLangFontLink2 *iface,
3468  HDC hdc, HFONT hfont, DWORD *codepages)
3469 {
3471  FONTSIGNATURE fontsig;
3472  HFONT old_font;
3473 
3474  TRACE("(%p)->(%p %p %p)\n", This, hdc, hfont, codepages);
3475 
3476  old_font = SelectObject(hdc, hfont);
3477  GetTextCharsetInfo(hdc, &fontsig, 0);
3478  SelectObject(hdc, old_font);
3479 
3480  *codepages = fontsig.fsCsb[0];
3481  TRACE("ret 0x%x\n", fontsig.fsCsb[0]);
3482 
3483  return S_OK;
3484 }
3485 
3487  HFONT hFont)
3488 {
3489  TRACE("(%p)->%p\n",This, hFont);
3490 
3491  return release_font(hFont);
3492 }
3493 
3495 {
3496  TRACE("(%p)\n",This);
3497 
3498  return clear_font_cache();
3499 }
3500 
3502  HDC hDC, DWORD dwCodePages, WCHAR chSrc, HFONT *pFont)
3503 {
3504  HFONT old_font;
3505 
3506  TRACE("(%p)->%p %08x %04x %p\n",This, hDC, dwCodePages, chSrc, pFont);
3507 
3508  if (!hDC) return E_FAIL;
3509 
3510  if (dwCodePages != 0)
3511  {
3512  old_font = GetCurrentObject(hDC, OBJ_FONT);
3513  return map_font(hDC, dwCodePages, old_font, pFont);
3514  }
3515  else
3516  {
3517  if (pFont == NULL) return E_INVALIDARG;
3518  FIXME("the situation where dwCodepages is set to zero is not implemented\n");
3519  return E_FAIL;
3520  }
3521 }
3522 
3524  HDC hDC, UINT *puiRanges, UNICODERANGE *pUranges)
3525 {
3526  DWORD size;
3527  GLYPHSET *gs;
3528 
3529  TRACE("(%p)->%p %p %p\n", This, hDC, puiRanges, pUranges);
3530 
3531  if (!puiRanges) return E_INVALIDARG;
3532  if (!(size = GetFontUnicodeRanges(hDC, NULL))) return E_FAIL;
3533  if (!(gs = HeapAlloc(GetProcessHeap(), 0, size))) return E_OUTOFMEMORY;
3534 
3535  GetFontUnicodeRanges(hDC, gs);
3536  *puiRanges = gs->cRanges;
3537  if (pUranges)
3538  {
3539  UINT i;
3540  for (i = 0; i < gs->cRanges; i++)
3541  {
3542  if (i >= *puiRanges) break;
3543  pUranges[i].wcFrom = gs->ranges[i].wcLow;
3544  pUranges[i].wcTo = gs->ranges[i].wcLow + gs->ranges[i].cGlyphs;
3545  }
3546  *puiRanges = i;
3547  }
3548  HeapFree(GetProcessHeap(), 0, gs);
3549  return S_OK;
3550 }
3551 
3553  SCRIPT_ID sid, DWORD dwFlags, UINT *puiFonts,
3554  SCRIPTFONTINFO *pScriptFont)
3555 {
3556  UINT i, j;
3557 
3558  TRACE("(%p)->%u %x %p %p\n", This, sid, dwFlags, puiFonts, pScriptFont);
3559 
3560  if (!dwFlags) dwFlags = SCRIPTCONTF_PROPORTIONAL_FONT;
3561 
3562  for (i = 0, j = 0; i < ARRAY_SIZE(mlang_data); i++)
3563  {
3564  if (sid == mlang_data[i].sid)
3565  {
3566  if (pScriptFont)
3567  {
3568  if (j >= *puiFonts) break;
3569 
3570  pScriptFont[j].scripts = 1 << mlang_data[i].sid;
3571  if (dwFlags == SCRIPTCONTF_FIXED_FONT)
3572  {
3573  MultiByteToWideChar(CP_ACP, 0, mlang_data[i].fixed_font, -1,
3574  pScriptFont[j].wszFont, MAX_MIMEFACE_NAME);
3575  }
3576  else if (dwFlags == SCRIPTCONTF_PROPORTIONAL_FONT)
3577  {
3578  MultiByteToWideChar(CP_ACP, 0, mlang_data[i].proportional_font, -1,
3579  pScriptFont[j].wszFont, MAX_MIMEFACE_NAME);
3580  }
3581  }
3582  j++;
3583  }
3584  }
3585  *puiFonts = j;
3586  return S_OK;
3587 }
3588 
3590  UINT uiCodePage, SCRIPT_ID *pSid)
3591 {
3592  UINT i;
3593 
3594  TRACE("(%p)->%i %p\n", This, uiCodePage, pSid);
3595 
3596  if (uiCodePage == CP_UNICODE) return E_FAIL;
3597 
3598  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
3599  {
3600  if (uiCodePage == mlang_data[i].family_codepage)
3601  {
3602  if (pSid) *pSid = mlang_data[i].sid;
3603  return S_OK;
3604  }
3605  }
3606  return E_FAIL;
3607 }
3608 
3609 static const IMLangFontLink2Vtbl IMLangFontLink2_vtbl =
3610 {
3625 };
3626 
3627 /******************************************************************************/
3628 
3629 static inline MLang_impl *impl_from_IMLangLineBreakConsole( IMLangLineBreakConsole *iface )
3630 {
3631  return CONTAINING_RECORD( iface, MLang_impl, IMLangLineBreakConsole_iface );
3632 }
3633 
3635  IMLangLineBreakConsole* iface,
3636  REFIID riid,
3637  void** ppvObject)
3638 {
3640  return IMultiLanguage3_QueryInterface( &This->IMultiLanguage3_iface, riid, ppvObject );
3641 }
3642 
3644  IMLangLineBreakConsole* iface )
3645 {
3647  return IMultiLanguage3_AddRef( &This->IMultiLanguage3_iface );
3648 }
3649 
3651  IMLangLineBreakConsole* iface )
3652 {
3654  return IMultiLanguage3_Release( &This->IMultiLanguage3_iface );
3655 }
3656 
3658  IMLangLineBreakConsole* iface,
3659  IMLangString* pSrcMLStr,
3660  LONG lSrcPos,
3661  LONG lSrcLen,
3662  LONG cMinColumns,
3663  LONG cMaxColumns,
3664  LONG* plLineLen,
3665  LONG* plSkipLen)
3666 {
3667  FIXME("(%p)->%p %i %i %i %i %p %p\n", iface, pSrcMLStr, lSrcPos, lSrcLen, cMinColumns, cMaxColumns, plLineLen, plSkipLen);
3668  return E_NOTIMPL;
3669 }
3670 
3672  IMLangLineBreakConsole* iface,
3673  LCID locale,
3674  const WCHAR* pszSrc,
3675  LONG cchSrc,
3676  LONG cMaxColumns,
3677  LONG* pcchLine,
3678  LONG* pcchSkip )
3679 {
3680  FIXME("(%p)->%i %s %i %i %p %p\n", iface, locale, debugstr_wn(pszSrc,cchSrc), cchSrc, cMaxColumns, pcchLine, pcchSkip);
3681 
3682  *pcchLine = cchSrc;
3683  *pcchSkip = 0;
3684  return S_OK;
3685 }
3686 
3688  IMLangLineBreakConsole* iface,
3689  LCID locale,
3690  UINT uCodePage,
3691  const CHAR* pszSrc,
3692  LONG cchSrc,
3693  LONG cMaxColumns,
3694  LONG* pcchLine,
3695  LONG* pcchSkip)
3696 {
3697  LONG i, line = cchSrc, skip = 0;
3698 
3699  FIXME("(%p)->%i %i %s %i %i %p %p\n", iface, locale, uCodePage, debugstr_an(pszSrc,cchSrc), cchSrc, cMaxColumns, pcchLine, pcchSkip);
3700 
3701  if (uCodePage == CP_USASCII && cchSrc > cMaxColumns)
3702  {
3703  for (line = cMaxColumns, i = cMaxColumns - 1; i >= 0; i--)
3704  {
3705  if (pszSrc[i] == ' ')
3706  {
3707  while (i >= 0 && pszSrc[i] == ' ')
3708  {
3709  i--;
3710  line--;
3711  skip++;
3712  }
3713  break;
3714  }
3715  }
3716  }
3717  *pcchLine = line;
3718  *pcchSkip = skip;
3719  return S_OK;
3720 }
3721 
3722 static const IMLangLineBreakConsoleVtbl IMLangLineBreakConsole_vtbl =
3723 {
3730 };
3731 
3733  IMLangConvertCharset IMLangConvertCharset_iface;
3735 
3738 };
3739 
3740 static inline struct convert_charset *impl_from_IMLangConvertCharset(IMLangConvertCharset *iface)
3741 {
3743 }
3744 
3745 static HRESULT WINAPI MLangConvertCharset_QueryInterface(IMLangConvertCharset *iface, REFIID riid, void **obj)
3746 {
3748 
3749  TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
3750 
3751  if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IMLangConvertCharset))
3752  {
3753  *obj = &This->IMLangConvertCharset_iface;
3754  IMLangConvertCharset_AddRef(iface);
3755  return S_OK;
3756  }
3757 
3758  *obj = NULL;
3759  return E_NOINTERFACE;
3760 }
3761 
3762 static ULONG WINAPI MLangConvertCharset_AddRef(IMLangConvertCharset *iface)
3763 {
3766  TRACE("(%p)->(%u)\n", This, ref);
3767  return ref;
3768 }
3769 
3770 static ULONG WINAPI MLangConvertCharset_Release(IMLangConvertCharset *iface)
3771 {
3774 
3775  TRACE("(%p)->(%u)\n", This, ref);
3776  if (!ref)
3777  {
3778  HeapFree(GetProcessHeap(), 0, This);
3779  UnlockModule();
3780  }
3781 
3782  return ref;
3783 }
3784 
3785 static HRESULT WINAPI MLangConvertCharset_Initialize(IMLangConvertCharset *iface,
3786  UINT src_cp, UINT dst_cp, DWORD prop)
3787 {
3789 
3790  TRACE("(%p)->(%u %u 0x%08x)\n", This, src_cp, dst_cp, prop);
3791 
3792  prop &= ~MLCONVCHARF_USEDEFCHAR;
3793  if (prop)
3794  FIXME("property 0x%08x not supported\n", prop);
3795 
3796  This->src_cp = src_cp;
3797  This->dst_cp = dst_cp;
3798 
3799  return S_OK;
3800 }
3801 
3802 static HRESULT WINAPI MLangConvertCharset_GetSourceCodePage(IMLangConvertCharset *iface, UINT *src_cp)
3803 {
3805 
3806  TRACE("(%p)->(%p)\n", This, src_cp);
3807 
3808  if (!src_cp) return E_INVALIDARG;
3809  *src_cp = This->src_cp;
3810  return S_OK;
3811 }
3812 
3814 {
3816 
3817  TRACE("(%p)->(%p)\n", This, dst_cp);
3818 
3819  if (!dst_cp) return E_INVALIDARG;
3820  *dst_cp = This->dst_cp;
3821  return S_OK;
3822 }
3823 
3824 static HRESULT WINAPI MLangConvertCharset_GetProperty(IMLangConvertCharset *iface, DWORD *prop)
3825 {
3827  FIXME("(%p)->(%p): stub\n", This, prop);
3828  return E_NOTIMPL;
3829 }
3830 
3831 static HRESULT WINAPI MLangConvertCharset_DoConversion(IMLangConvertCharset *iface, BYTE *src,
3832  UINT *src_size, BYTE *dest, UINT *dest_size)
3833 {
3835  FIXME("(%p)->(%p %p %p %p): stub\n", This, src, src_size, dest, dest_size);
3836  return E_NOTIMPL;
3837 }
3838 
3839 static HRESULT WINAPI MLangConvertCharset_DoConversionToUnicode(IMLangConvertCharset *iface, CHAR *src,
3840  UINT *src_size, WCHAR *dest, UINT *dest_size)
3841 {
3843  TRACE("(%p)->(%p %p %p %p)\n", This, src, src_size, dest, dest_size);
3844  return ConvertINetMultiByteToUnicode(NULL, This->src_cp, src, (INT*)src_size, dest, (INT*)dest_size);
3845 }
3846 
3848  WCHAR *src, UINT *src_size, CHAR *dest, UINT *dest_size)
3849 {
3851  TRACE("(%p)->(%p %p %p %p)\n", This, src, src_size, dest, dest_size);
3852  return ConvertINetUnicodeToMultiByte(NULL, This->dst_cp, src, (INT*)src_size, dest, (INT*)dest_size);
3853 }
3854 
3855 static const IMLangConvertCharsetVtbl MLangConvertCharsetVtbl =
3856 {
3867 };
3868 
3869 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj)
3870 {
3871  MLang_impl *mlang;
3872  UINT i;
3873 
3874  TRACE("Creating MultiLanguage object\n");
3875 
3876  if( pUnkOuter )
3877  return CLASS_E_NOAGGREGATION;
3878 
3879  mlang = HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl) );
3880  mlang->IMLangFontLink_iface.lpVtbl = &IMLangFontLink_vtbl;
3881  mlang->IMultiLanguage_iface.lpVtbl = &IMultiLanguage_vtbl;
3882  mlang->IMultiLanguage3_iface.lpVtbl = &IMultiLanguage3_vtbl;
3883  mlang->IMLangFontLink2_iface.lpVtbl = &IMLangFontLink2_vtbl;
3884  mlang->IMLangLineBreakConsole_iface.lpVtbl = &IMLangLineBreakConsole_vtbl;
3885 
3886  mlang->total_cp = 0;
3887  for (i = 0; i < ARRAY_SIZE(mlang_data); i++)
3888  mlang->total_cp += mlang_data[i].number_of_cp;
3889 
3890  /* do not enumerate unicode flavours */
3891  mlang->total_scripts = ARRAY_SIZE(mlang_data) - 1;
3892 
3893  mlang->ref = 1;
3894  *ppObj = &mlang->IMultiLanguage_iface;
3895  TRACE("returning %p\n", mlang);
3896 
3897  LockModule();
3898 
3899  return S_OK;
3900 }
3901 
3903 {
3904  struct convert_charset *convert;
3905 
3906  if (outer)
3907  return CLASS_E_NOAGGREGATION;
3908 
3909  *obj = NULL;
3910 
3911  convert = HeapAlloc(GetProcessHeap(), 0, sizeof(struct convert_charset));
3912  if (!convert) return E_OUTOFMEMORY;
3913 
3914  convert->IMLangConvertCharset_iface.lpVtbl = &MLangConvertCharsetVtbl;
3915  convert->ref = 1;
3916 
3917  *obj = &convert->IMLangConvertCharset_iface;
3918 
3919  LockModule();
3920 
3921  return S_OK;
3922 }
3923 
3924 /******************************************************************************/
3925 
3927 {
3928  return dll_count == 0 ? S_OK : S_FALSE;
3929 }
3930 
3932 {
3933  const struct mlang_data *family;
3934  const MIME_CP_INFO *info;
3935  HKEY db_key, key;
3936  WCHAR buf[32];
3937  LSTATUS status;
3938 
3939  static const WCHAR db_key_nameW[] = {
3940  'M','I','M','E',
3941  '\\','D','a','t','a','b','a','s','e',
3942  '\\','C','o','d','e','p','a','g','e',0};
3943  static const WCHAR familyW[] = {'F','a','m','i','l','y',0};
3944  static const WCHAR formatW[] = {'%','u',0};
3945 
3946  status = RegCreateKeyW(HKEY_CLASSES_ROOT, db_key_nameW, &db_key);
3947  if (status != ERROR_SUCCESS)
3948  return FALSE;
3949 
3950  for (family = mlang_data; family < mlang_data + ARRAY_SIZE(mlang_data); family++)
3951  {
3952  for (info = family->mime_cp_info; info < family->mime_cp_info + family->number_of_cp; info++)
3953  {
3954  sprintfW(buf, formatW, info->cp);
3955  status = RegCreateKeyW(db_key, buf, &key);
3956  if (status != ERROR_SUCCESS)
3957  continue;
3958 
3959  RegSetValueExA(key, "BodyCharset", 0, REG_SZ, (BYTE*)info->body_charset,
3960  strlen(info->body_charset) + 1);
3961 
3962  if (info->cp == family->family_codepage)
3963  {
3964  RegSetValueExA(key, "FixedWidthFont", 0, REG_SZ, (BYTE*)family->fixed_font,
3965  strlen(family->fixed_font) + 1);
3966  RegSetValueExA(key, "ProportionalFont", 0, REG_SZ, (BYTE*)family->proportional_font,
3967  strlen(family->proportional_font) + 1);
3968  }
3969  else
3970  {
3971  RegSetValueExW(key, familyW, 0, REG_DWORD, (BYTE*)&family->family_codepage,
3972  sizeof(family->family_codepage));
3973  }
3974 
3975  RegCloseKey(key);
3976  }
3977  }
3978 
3979  RegCloseKey(db_key);
3980  return TRUE;
3981 }
3982 
3983 /***********************************************************************
3984  * DllRegisterServer (MLANG.@)
3985  */
3987 {
3988  if(!register_codepages())
3989  return E_FAIL;
3991 }
3992 
3993 /***********************************************************************
3994  * DllUnregisterServer (MLANG.@)
3995  */
3997 {
3999 }
4000 
4002 {
4003  if (!unknown) return E_INVALIDARG;
4004 
4005  FIXME("%p: stub\n", unknown);
4006 
4007  return S_FALSE;
4008 }
static const IMLangFontLinkVtbl IMLangFontLink_vtbl
Definition: mlang.c:2081
const char * description
Definition: mlang.c:63
static int enter_shift(LPSTR out, int c)
Definition: mlang.c:732
static HRESULT WINAPI MLangConvertCharset_GetProperty(IMLangConvertCharset *iface, DWORD *prop)
Definition: mlang.c:3824
static ULONG WINAPI fnIEnumRfc1766_AddRef(IEnumRfc1766 *iface)
Definition: mlang.c:2302
static void LockModule(void)
Definition: mlang.c:928
RFC1766INFO * info
Definition: mlang.c:2271
HFONT base_font
Definition: mlang.c:532
static const struct object_creation_info object_creation[]
Definition: mlang.c:1468
static HRESULT EnumCodePage_create(MLang_impl *mlang, DWORD grfFlags, LANGID LangId, IEnumCodePage **ppEnumCodePage)
Definition: mlang.c:1753
#define ISEUC(A)
Definition: mlang.c:556
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static const MIME_CP_INFO turkish_cp[]
Definition: mlang.c:355
static const MIME_CP_INFO cyrillic_cp[]
Definition: mlang.c:196
static HRESULT WINAPI fnIEnumScript_Skip(IEnumScript *iface, ULONG celt)
Definition: mlang.c:1906
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static HRESULT WINAPI fnIMLangLineBreakConsole_QueryInterface(IMLangLineBreakConsole *iface, REFIID riid, void **ppvObject)
Definition: mlang.c:3634
#define REFIID
Definition: guiddef.h:113
#define TRUE
Definition: types.h:120
static BOOL register_codepages(void)
Definition: mlang.c:3931
static HRESULT EnumRfc1766_create(LANGID LangId, IEnumRfc1766 **ppEnum)
Definition: mlang.c:2445
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
static HRESULT WINAPI fnIMultiLanguage3_DetectOutboundCodePage(IMultiLanguage3 *iface, DWORD dwFlags, LPCWSTR lpWideCharStr, UINT cchWideChar, UINT *puiPreferredCodePages, UINT nPreferredCodePages, UINT *puiDetectedCodePages, UINT *pnDetectedCodePages, WCHAR *lpSpecialChar)
Definition: mlang.c:3217
static HRESULT WINAPI fnIMultiLanguage_IsConvertible(IMultiLanguage *iface, DWORD src_enc, DWORD dst_enc)
Definition: mlang.c:2188
#define shift
Definition: input.c:1668
#define E_NOINTERFACE
Definition: winerror.h:2364
static ULONG WINAPI fnIMLangLineBreakConsole_Release(IMLangLineBreakConsole *iface)
Definition: mlang.c:3650
static UINT ConvertJapaneseUnicodeToJIS(LPCWSTR input, DWORD count, LPSTR output, DWORD out_count)
Definition: mlang.c:903
static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info)
Definition: mlang.c:2658
static HRESULT WINAPI fnIMultiLanguage_QueryInterface(IMultiLanguage *iface, REFIID riid, void **obj)
Definition: mlang.c:2103
static const MIME_CP_INFO greek_cp[]
Definition: mlang.c:241
static HRESULT WINAPI fnIEnumRfc1766_Clone(IEnumRfc1766 *iface, IEnumRfc1766 **ppEnum)
Definition: mlang.c:2325
static HRESULT WINAPI fnIMLangFontLink2_GetFontUnicodeRanges(IMLangFontLink2 *This, HDC hDC, UINT *puiRanges, UNICODERANGE *pUranges)
Definition: mlang.c:3523
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
CFF_Charset charset
Definition: cffcmap.c:138
IEnumScript IEnumScript_iface
Definition: mlang.c:1803
static HRESULT WINAPI fnIMLangLineBreakConsole_BreakLineA(IMLangLineBreakConsole *iface, LCID locale, UINT uCodePage, const CHAR *pszSrc, LONG cchSrc, LONG cMaxColumns, LONG *pcchLine, LONG *pcchSkip)
Definition: mlang.c:3687
HRESULT WINAPI ConvertINetString(LPDWORD pdwMode, DWORD dwSrcEncoding, DWORD dwDstEncoding, LPCSTR pSrcStr, LPINT pcSrcSize, LPSTR pDstStr, LPINT pcDstSize)
Definition: mlang.c:1105
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LOCALE_SISO639LANGNAME
Definition: winnls.h:127
#define DWORD_PTR
Definition: treelist.c:76
#define WideCharToMultiByte
Definition: compat.h:101
#define LOCALE_SLANGUAGE
Definition: winnls.h:26
HRESULT hr
Definition: shlfolder.c:183
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
static HRESULT WINAPI fnIMultiLanguage_GetRfc1766Info(IMultiLanguage *iface, LCID Locale, PRFC1766INFO pRfc1766Info)
Definition: mlang.c:2500
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: mlang.c:3869
#define LOCALE_SENGLANGUAGE
Definition: winnls.h:27
#define MAXLONG
Definition: umtypes.h:116
static HRESULT WINAPI MLangConvertCharset_DoConversionToUnicode(IMLangConvertCharset *iface, CHAR *src, UINT *src_size, WCHAR *dest, UINT *dest_size)
Definition: mlang.c:3839
#define TCI_SRCFONTSIG
Definition: wingdi.h:962
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_UTF7
Definition: winnls.h:232
static HRESULT WINAPI fnIMultiLanguage3_DetectOutboundCodePageInIStream(IMultiLanguage3 *iface, DWORD dwFlags, IStream *pStrIn, UINT *puiPreferredCodePages, UINT nPreferredCodePages, UINT *puiDetectedCodePages, UINT *pnDetectedCodePages, WCHAR *lpSpecialChar)
Definition: mlang.c:3243
static const MIME_CP_INFO thai_cp[]
Definition: mlang.c:349
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1199
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: mk_font.cpp:20
#define SJIS1(A)
Definition: mlang.c:558
static HRESULT WINAPI fnIMLangFontLink2_GetCharCodePages(IMLangFontLink2 *iface, WCHAR ch_src, DWORD *ret_codepages)
Definition: mlang.c:3332
REFIID riid
Definition: precomp.h:44
struct list list_entry
Definition: mlang.c:531
#define REFCLSID
Definition: guiddef.h:112
#define CP_ACP
Definition: compat.h:99
INT WINAPI GetLocaleInfoA(LCID lcid, LCTYPE lctype, LPSTR buffer, INT len)
Definition: lang.c:1015
#define LOCALE_USER_DEFAULT
GLuint GLuint GLsizei count
Definition: gl.h:1545
char CHAR
Definition: xmlstorage.h:175
HRESULT WINAPI DllUnregisterServer(void)
Definition: mlang.c:3996
#define SJIS2(A)
Definition: mlang.c:559
#define WARN(fmt,...)
Definition: debug.h:111
#define strtolW(s, e, b)
Definition: unicode.h:33
#define SUBLANG_DEFAULT
Definition: nls.h:168
BYTE lfCharSet
Definition: dimm.idl:67
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
REFIID LPVOID * ppv
Definition: atlbase.h:39
static BOOL CALLBACK enum_locales_proc(LPWSTR locale)
Definition: mlang.c:2412
static HRESULT WINAPI fnIMLangFontLink_ReleaseFont(IMLangFontLink *iface, HFONT hFont)
Definition: mlang.c:2063
GLdouble n
Definition: glext.h:7729
static UINT ConvertSJIS2JIS(LPCSTR input, DWORD count, LPSTR output)
Definition: mlang.c:744
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static HRESULT WINAPI fnIMultiLanguage3_ConvertString(IMultiLanguage3 *iface, DWORD *pdwMode, DWORD dwSrcEncoding, DWORD dwDstEncoding, BYTE *pSrcStr, UINT *pcSrcSize, BYTE *pDstStr, UINT *pcDstSize)
Definition: mlang.c:2813
static HRESULT lcid_from_rfc1766(IEnumRfc1766 *iface, LCID *lcid, LPCWSTR rfc1766)
Definition: mlang.c:1279
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
FT_UInt sid
Definition: cffcmap.c:139
static HRESULT WINAPI fnIMLangFontLink_QueryInterface(IMLangFontLink *iface, REFIID riid, void **ppvObject)
Definition: mlang.c:1976
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLuint buffer
Definition: glext.h:5915
static HRESULT WINAPI fnIMultiLanguage3_EnumScripts(IMultiLanguage3 *iface, DWORD dwFlags, LANGID LangId, IEnumScript **ppEnumScript)
Definition: mlang.c:3172
#define LANG_ARABIC
Definition: nls.h:29
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static DWORD MLANG_tls_index
Definition: mlang.c:54
static HRESULT WINAPI MLangConvertCharset_Initialize(IMLangConvertCharset *iface, UINT src_cp, UINT dst_cp, DWORD prop)
Definition: mlang.c:3785
struct tagEnumCodePage_impl EnumCodePage_impl
DWORD LCID
Definition: nls.h:13
static HRESULT WINAPI fnIMLangFontLink2_CodePageToScriptID(IMLangFontLink2 *This, UINT uiCodePage, SCRIPT_ID *pSid)
Definition: mlang.c:3589
GLuint GLuint end
Definition: gl.h:1545
WORD LANGID
Definition: typedefs.h:79
OLECHAR * BSTR
Definition: compat.h:1927
IMultiLanguage IMultiLanguage_iface
Definition: mlang.c:1598
static DWORD
Definition: mlang.c:45
DWORD allocated
Definition: mlang.c:2409
static HRESULT WINAPI fnIMultiLanguage3_ConvertStringInIStream(IMultiLanguage3 *iface, DWORD *pdwMode, DWORD dwFlag, WCHAR *lpFallBack, DWORD dwSrcEncoding, DWORD dwDstEncoding, IStream *pstmIn, IStream *pstmOut)
Definition: mlang.c:2978
UINT number_of_cp
Definition: mlang.c:490
const char * description
Definition: directx.c:2502
static UINT ConvertJIS2SJIS(LPCSTR input, DWORD count, LPSTR output)
Definition: mlang.c:676
static HRESULT lcid_to_rfc1766W(LCID lcid, LPWSTR rfc1766, INT len)
Definition: mlang.c:1228
static ULONG WINAPI fnIEnumScript_Release(IEnumScript *iface)
Definition: mlang.c:1843
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
char * LPSTR
Definition: xmlstorage.h:182
HRESULT WINAPI GetGlobalFontLinkObject(void **unknown)
Definition: mlang.c:4001
const MIME_CP_INFO * mime_cp_info
Definition: mlang.c:491
#define DEFAULT_CHARSET
Definition: wingdi.h:383
const CLSID * clsid
Definition: main.c:70
#define lstrlenW
Definition: compat.h:407
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT WINAPI fnIMLangFontLink_CodePagesToCodePage(IMLangFontLink *iface, DWORD codepages, UINT def_codepage, UINT *codepage)
Definition: mlang.c:2030
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
int32_t INT
Definition: typedefs.h:56
static HRESULT WINAPI fnIMultiLanguage3_GetCodePageDescription(IMultiLanguage3 *iface, UINT uiCodePage, LCID lcid, LPWSTR lpWideCharStr, int cchWideChar)
Definition: mlang.c:3112
Definition: send.c:47
static ULONG WINAPI MLangConvertCharset_Release(IMLangConvertCharset *iface)
Definition: mlang.c:3770
static void sjis2jis(unsigned char *p1, unsigned char *p2)
Definition: mlang.c:619
HFONT hFont
Definition: main.c:53
static HRESULT WINAPI fnIMultiLanguage_GetFamilyCodePage(IMultiLanguage *iface, UINT cp, UINT *family_cp)
Definition: mlang.c:2158
static HRESULT WINAPI fnIEnumCodePage_Next(IEnumCodePage *iface, ULONG celt, PMIMECPINFO rgelt, ULONG *pceltFetched)
Definition: mlang.c:1676
HFONT font
Definition: mlang.c:533
static ULONG WINAPI fnIMultiLanguage_AddRef(IMultiLanguage *iface)
Definition: mlang.c:2112
static const MIME_CP_INFO korean_cp[]
Definition: mlang.c:340
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define HANKATA(A)
Definition: mlang.c:555
static ULONG WINAPI MLANGCF_Release(IClassFactory *iface)
Definition: mlang.c:1497
struct _test_info info[]
Definition: SetCursorPos.c:19
static HRESULT WINAPI fnIEnumCodePage_Reset(IEnumCodePage *iface)
Definition: mlang.c:1717
MIMECPINFO * cpinfo
Definition: mlang.c:1612
static HINSTANCE instance
Definition: mlang.c:53
struct tagIClassFactoryImpl IClassFactoryImpl
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1095
HRESULT(* pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: main.c:71
static HRESULT WINAPI fnIMultiLanguage3_ConvertStringFromUnicodeEx(IMultiLanguage3 *This, DWORD *pdwMode, DWORD dwEncoding, WCHAR *pSrcStr, UINT *pcSrcSize, CHAR *pDstStr, UINT *pcDstSize, DWORD dwFlag, WCHAR *lpFallBack)
Definition: mlang.c:3063
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
uint32_t cs
Definition: isohybrid.c:75
DWORD LCTYPE
Definition: winnls.h:514
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static HRESULT MLangConvertCharset_create(IUnknown *outer, void **obj)
Definition: mlang.c:3902
static HRESULT WINAPI fnIMultiLanguage_ConvertStringReset(IMultiLanguage *iface)
Definition: mlang.c:2240
GLenum GLint GLuint mask
Definition: glext.h:6028
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
static HRESULT WINAPI fnIMultiLanguage_GetRfc1766FromLcid(IMultiLanguage *iface, LCID lcid, BSTR *pbstrRfc1766)
Definition: mlang.c:2247
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static ULONG WINAPI fnIMLangFontLink_AddRef(IMLangFontLink *iface)
Definition: mlang.c:1985
#define CP_UTF8
Definition: nls.h:20
static ULONG WINAPI fnIMultiLanguage_Release(IMultiLanguage *iface)
Definition: mlang.c:2118
static HRESULT WINAPI fnIEnumCodePage_Skip(IEnumCodePage *iface, ULONG celt)
Definition: mlang.c:1728
static HRESULT WINAPI fnIMultiLanguage3_SetMimeDBSource(IMultiLanguage3 *iface, MIMECONTF dwSource)
Definition: mlang.c:3150
Definition: _locale.h:75
static const WCHAR asciiW[]
Definition: mlang.c:397
static HRESULT WINAPI fnIMultiLanguage_EnumRfc1766(IMultiLanguage *iface, IEnumRfc1766 **ppEnumRfc1766)
Definition: mlang.c:2487
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: main.c:440
const char * fixed_font
Definition: mlang.c:492
static UINT ConvertUnknownJapaneseToUnicode(LPCSTR input, DWORD count, LPWSTR output, DWORD out_count)
Definition: mlang.c:855
static HRESULT WINAPI fnIMLangFontLink2_GetStrCodePages(IMLangFontLink2 *iface, const WCHAR *src, LONG src_len, DWORD priority_cp, DWORD *codepages, LONG *ret_len)
Definition: mlang.c:3363
static LPUNKNOWN
Definition: ndr_ole.c:49
static HRESULT WINAPI MLANGCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: mlang.c:1511
#define ISMARU(A)
Definition: mlang.c:560
#define debugstr_w
Definition: kernel32.h:32
INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen)
Definition: lang.c:2018
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
static HRESULT WINAPI fnIMultiLanguage_EnumCodePages(IMultiLanguage *iface, DWORD grfFlags, IEnumCodePage **ppEnumCodePage)
Definition: mlang.c:2167
static ULONG WINAPI fnIEnumCodePage_AddRef(IEnumCodePage *iface)
Definition: mlang.c:1643
static EnumRfc1766_impl * impl_from_IEnumRfc1766(IEnumRfc1766 *iface)
Definition: mlang.c:2275
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: CString.cpp:62
static HRESULT WINAPI fnIMultiLanguage3_ConvertStringReset(IMultiLanguage3 *iface)
Definition: mlang.c:2853
int codepage
Definition: win_iconv.c:156
#define LCMAP_LOWERCASE
Definition: winnls.h:181
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
UINT ciCharset
Definition: wingdi.h:1524
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: mlang.c:1456
static HRESULT(WINAPI *pConvertINetMultiByteToUnicode)(LPDWORD
LONG lfWidth
Definition: dimm.idl:60
static HRESULT WINAPI fnIMultiLanguage3_ValidateCodePage(IMultiLanguage3 *iface, UINT uiCodePage, HWND hwnd)
Definition: mlang.c:3104
static HRESULT WINAPI fnIMultiLanguage_ConvertStringFromUnicode(IMultiLanguage *iface, DWORD *mode, DWORD encoding, WCHAR *src, UINT *src_size, CHAR *dest, UINT *dest_size)
Definition: mlang.c:2226
smooth NULL
Definition: ftsmooth.c:416
static HRESULT WINAPI fnIMLangFontLink2_QueryInterface(IMLangFontLink2 *iface, REFIID riid, void **ppvObject)
Definition: mlang.c:3311
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
static HRESULT WINAPI fnIMultiLanguage3_ConvertStringToUnicodeEx(IMultiLanguage3 *iface, DWORD *pdwMode, DWORD dwEncoding, CHAR *pSrcStr, UINT *pcSrcSize, WCHAR *pDstStr, UINT *pcDstSize, DWORD dwFlag, WCHAR *lpFallBack)
Definition: mlang.c:3026
static const MIME_CP_INFO unicode_cp[]
Definition: mlang.c:465
#define gs
Definition: i386-dis.c:436
int WINAPI GetTextCharsetInfo(_In_ HDC, _Out_opt_ LPFONTSIGNATURE, _In_ DWORD)
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
Definition: parser.c:48
static HRESULT WINAPI fnIMultiLanguage_ConvertStringToUnicode(IMultiLanguage *iface, DWORD *mode, DWORD src_enc, CHAR *src, UINT *src_size, WCHAR *dest, UINT *dest_size)
Definition: mlang.c:2212
IEnumRfc1766 IEnumRfc1766_iface
Definition: mlang.c:2269
GLuint index
Definition: glext.h:6031
static int exit_shift(LPSTR out, int c)
Definition: mlang.c:721
const char * LPCSTR
Definition: xmlstorage.h:183
static struct convert_charset * impl_from_IMLangConvertCharset(IMLangConvertCharset *iface)
Definition: mlang.c:3740
IEnumCodePage IEnumCodePage_iface
Definition: mlang.c:1610
BOOL WINAPI EnumSystemLocalesW(LOCALE_ENUMPROCW lpfnLocaleEnum, DWORD dwFlags)
Definition: lang.c:1601
#define debugstr_guid
Definition: kernel32.h:35
static HRESULT WINAPI fnIMultiLanguage_GetNumberOfCodePageInfo(IMultiLanguage *iface, UINT *cp)
Definition: mlang.c:2124
IMultiLanguage3 IMultiLanguage3_iface
Definition: mlang.c:1599
UINT charset
Definition: mlang.c:534
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static HRESULT WINAPI fnIMLangFontLink2_GetFontCodePages(IMLangFontLink2 *iface, HDC hdc, HFONT hfont, DWORD *codepages)
Definition: mlang.c:3467
IMLangFontLink IMLangFontLink_iface
Definition: mlang.c:1597
static HFONT hfont
static const MIME_CP_INFO western_cp[]
Definition: mlang.c:399
#define DLL_PROCESS_DETACH
Definition: compat.h:119
static ULONG WINAPI fnIEnumScript_AddRef(IEnumScript *iface)
Definition: mlang.c:1836
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static void UnlockModule(void)
Definition: mlang.c:933
static HRESULT WINAPI MLangConvertCharset_DoConversion(IMLangConvertCharset *iface, BYTE *src, UINT *src_size, BYTE *dest, UINT *dest_size)
Definition: mlang.c:3831
DWORD flags
Definition: mlang.c:65
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
static ULONG WINAPI fnIMultiLanguage3_Release(IMultiLanguage3 *iface)
Definition: mlang.c:2629
static HRESULT WINAPI fnIEnumScript_Clone(IEnumScript *iface, IEnumScript **ppEnum)
Definition: mlang.c:1860
static HRESULT WINAPI fnIMultiLanguage3_GetNumberOfScripts(IMultiLanguage3 *iface, UINT *pnScripts)
Definition: mlang.c:3158
BOOL WINAPI TranslateCharsetInfo(_Inout_ PDWORD, _Out_ LPCHARSETINFO, _In_ DWORD)
static HRESULT WINAPI MLangConvertCharset_GetDestinationCodePage(IMLangConvertCharset *iface, UINT *dst_cp)
Definition: mlang.c:3813
#define TRACE(s)
Definition: solgame.cpp:4
static const IMultiLanguage3Vtbl IMultiLanguage3_vtbl
Definition: mlang.c:3268
static const WCHAR szClassName[]
Definition: clipbrd.c:11
static HRESULT lcid_to_rfc1766A(LCID lcid, LPSTR rfc1766, INT len)
Definition: mlang.c:1201
HRESULT WINAPI Rfc1766ToLcidA(LCID *lcid, LPCSTR rfc1766A)
Definition: mlang.c:1321
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
const char * body_charset
Definition: mlang.c:68
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int convert
Definition: msacm.c:1362
static HRESULT WINAPI fnIMultiLanguage3_GetNumberOfCodePageInfo(IMultiLanguage3 *iface, UINT *pcCodePage)
Definition: mlang.c:2644
#define CP_UNICODE
Definition: mlang.c:39
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1089
#define LIST_INIT(head)
Definition: queue.h:197
static const MIME_CP_INFO chinese_simplified_cp[]
Definition: mlang.c:120
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HRESULT WINAPI fnIMultiLanguage3_IsCodePageInstallable(IMultiLanguage3 *iface, UINT uiCodePage)
Definition: mlang.c:3140
#define debugstr_a
Definition: kernel32.h:31
LONG HRESULT
Definition: typedefs.h:77
static HRESULT WINAPI fnIEnumRfc1766_QueryInterface(IEnumRfc1766 *iface, REFIID riid, void **ppvObject)
Definition: mlang.c:2280
LONG ref
Definition: mlang.c:1602
const GUID IID_IUnknown
HRESULT WINAPI ConvertINetMultiByteToUnicode(LPDWORD pdwMode, DWORD dwEncoding, LPCSTR pSrcStr, LPINT pcSrcSize, LPWSTR pDstStr, LPINT pcDstSize)
Definition: mlang.c:954
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:51
static MLang_impl * impl_from_IMLangLineBreakConsole(IMLangLineBreakConsole *iface)
Definition: mlang.c:3629
#define WINAPI
Definition: msvc.h:8
static const IEnumRfc1766Vtbl IEnumRfc1766_vtbl
Definition: mlang.c:2395
const GLubyte * c
Definition: glext.h:8905
static const IClassFactoryVtbl MLANGCF_Vtbl
Definition: mlang.c:1540
static FILE * out
Definition: regtests2xml.c:44
static const IEnumScriptVtbl IEnumScript_vtbl
Definition: mlang.c:1920
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
static HRESULT WINAPI fnIMLangLineBreakConsole_BreakLineW(IMLangLineBreakConsole *iface, LCID locale, const WCHAR *pszSrc, LONG cchSrc, LONG cMaxColumns, LONG *pcchLine, LONG *pcchSkip)
Definition: mlang.c:3671
Definition: id3.c:18
#define OBJ_FONT
Definition: objidl.idl:1414
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
static JOBOBJECTINFOCLASS LPVOID DWORD LPDWORD ret_len
Definition: process.c:79
RFC1766INFO * info
Definition: mlang.c:2408
GLbitfield flags
Definition: glext.h:7161
static HRESULT WINAPI fnIEnumRfc1766_Reset(IEnumRfc1766 *iface)
Definition: mlang.c:2370
#define WC_NO_BEST_FIT_CHARS
Definition: unicode.h:46
UINT family_codepage
Definition: mlang.c:489
#define LANG_ENGLISH
Definition: nls.h:52
static MLang_impl * impl_from_IMultiLanguage3(IMultiLanguage3 *iface)
Definition: mlang.c:2575
static LONG dll_count
Definition: mlang.c:549
UINT cp
Definition: mlang.c:64
static const IMLangFontLink2Vtbl IMLangFontLink2_vtbl
Definition: mlang.c:3609
IMLangFontLink2 IMLangFontLink2_iface
Definition: mlang.c:1600
SCRIPT_ID sid
Definition: mlang.c:494
int ret
static HRESULT WINAPI fnIMultiLanguage3_GetFamilyCodePage(IMultiLanguage3 *iface, UINT uiCodePage, UINT *puiFamilyCodePage)
Definition: mlang.c:2723
char line[200]
Definition: main.c:97
REFCLSID clsid
Definition: msctf.c:84
static HRESULT WINAPI fnIMLangFontLink2_CodePageToCodePages(IMLangFontLink2 *iface, UINT codepage, DWORD *codepages)
Definition: mlang.c:3400
#define index(s, c)
Definition: various.h:29
static HRESULT WINAPI fnIMLangFontLink_MapFont(IMLangFontLink *iface, HDC hDC, DWORD dwCodePages, HFONT hSrcFont, HFONT *phDestFont)
Definition: mlang.c:2051
static HRESULT WINAPI fnIEnumCodePage_QueryInterface(IEnumCodePage *iface, REFIID riid, void **ppvObject)
Definition: mlang.c:1621
DWORD total_cp
Definition: mlang.c:1603
#define InterlockedDecrement
Definition: armddk.h:52
HDC hdc
Definition: main.c:9