1 | /* $Id: lang.cpp,v 1.7 1999-06-28 16:15:47 phaller Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 language API functions for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen
|
---|
7 | * Copyright 1998 Patrick Haller
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
11 | *
|
---|
12 | */
|
---|
13 | #include <os2win.h>
|
---|
14 | #include <winnls.h>
|
---|
15 | #include <stdlib.h>
|
---|
16 | #include <string.h>
|
---|
17 | #include <winos2def.h>
|
---|
18 | #include "unicode.h"
|
---|
19 |
|
---|
20 |
|
---|
21 | //******************************************************************************
|
---|
22 | //******************************************************************************
|
---|
23 | BOOL WIN32API IsValidCodePage(UINT CodePage)
|
---|
24 | {
|
---|
25 | dprintf(("KERNEL32: IsValidCodePage not implemented\n"));
|
---|
26 | return(TRUE);
|
---|
27 | }
|
---|
28 | //******************************************************************************
|
---|
29 | //******************************************************************************
|
---|
30 | LCID WIN32API GetUserDefaultLCID(void)
|
---|
31 | {
|
---|
32 | dprintf(("KERNEL32: OS2GetUserDefaultLCID: always retuns US English!\n"));
|
---|
33 | return(0x409); //US English
|
---|
34 | }
|
---|
35 | //******************************************************************************
|
---|
36 | //******************************************************************************
|
---|
37 | LCID WIN32API GetSystemDefaultLCID(void)
|
---|
38 | {
|
---|
39 | dprintf(("KERNEL32: OS2GetSystemDefaultLCID: always retuns US English!\n"));
|
---|
40 | return(0x409); //US English
|
---|
41 | }
|
---|
42 | //******************************************************************************
|
---|
43 | //******************************************************************************
|
---|
44 | LANGID WIN32API GetUserDefaultLangID()
|
---|
45 | {
|
---|
46 | dprintf(("KERNEL32: OS2GetUserDefaultLangID, always returns US English\n"));
|
---|
47 | return(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
---|
48 | }
|
---|
49 | //******************************************************************************
|
---|
50 | //******************************************************************************
|
---|
51 | LANGID WIN32API GetSystemDefaultLangID(void)
|
---|
52 | {
|
---|
53 | dprintf(("KERNEL32: OS2GetSystemDefaultLangID, always returns US English\n"));
|
---|
54 | return(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
---|
55 | }
|
---|
56 | //******************************************************************************
|
---|
57 | //******************************************************************************
|
---|
58 | int WIN32API GetLocaleInfoA(LCID lcid, LCTYPE LCType, LPSTR buf, int len)
|
---|
59 | {
|
---|
60 | COUNTRYCODE Country = {0};
|
---|
61 | COUNTRYINFO CtryInfo = {0};
|
---|
62 | ULONG ulInfoLen = 0;
|
---|
63 |
|
---|
64 | dprintf(("KERNEL32: OS2GetLocaleInfoA: Not complete!\n"));
|
---|
65 | if (len && (! buf) )
|
---|
66 | {
|
---|
67 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
---|
68 | return 0;
|
---|
69 | }
|
---|
70 |
|
---|
71 | if(!buf) // @@@PH: which result does make sense without a buffer ?
|
---|
72 | return 0; // nevertheless, OPERA.EXE calls it with NULL ?!
|
---|
73 |
|
---|
74 | // Only standard. TODO: Use os2.ini PM_National section
|
---|
75 | DosQueryCtryInfo(sizeof(CtryInfo), &Country, &CtryInfo, &ulInfoLen);
|
---|
76 |
|
---|
77 | LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP);
|
---|
78 |
|
---|
79 | switch(LCType)
|
---|
80 | {
|
---|
81 | case LOCALE_SDECIMAL:
|
---|
82 | if(buf) *buf = CtryInfo.szDecimal[0];
|
---|
83 | return 1;
|
---|
84 | case LOCALE_SDATE:
|
---|
85 | if(buf) *buf = CtryInfo.szDateSeparator[0];
|
---|
86 | return 1;
|
---|
87 | case LOCALE_STIME:
|
---|
88 | if(buf) *buf = CtryInfo.szTimeSeparator[0];
|
---|
89 | return 1;
|
---|
90 | case LOCALE_STHOUSAND:
|
---|
91 | if(buf) *buf = CtryInfo.szThousandsSeparator[0];
|
---|
92 | return 1;
|
---|
93 | case LOCALE_SCURRENCY:
|
---|
94 | if(len > strlen(CtryInfo.szCurrency))
|
---|
95 | {
|
---|
96 | strcpy(buf, CtryInfo.szCurrency);
|
---|
97 | return (strlen(buf) + 1);
|
---|
98 | }
|
---|
99 | else
|
---|
100 | break;
|
---|
101 | case LOCALE_SSHORTDATE:
|
---|
102 | if(CtryInfo.fsDateFmt == 0)
|
---|
103 | {
|
---|
104 | if(len > 8)
|
---|
105 | {
|
---|
106 | strcpy(buf, "MMXddXyy");
|
---|
107 | buf[2] = buf[5] = CtryInfo.szDateSeparator[0];
|
---|
108 | return 9;
|
---|
109 | }
|
---|
110 | else
|
---|
111 | break;
|
---|
112 | }
|
---|
113 | else if(CtryInfo.fsDateFmt == 1)
|
---|
114 | {
|
---|
115 | if(len > 8)
|
---|
116 | {
|
---|
117 | strcpy(buf, "ddXMMXyy");
|
---|
118 | buf[2] = buf[5] = CtryInfo.szDateSeparator[0];
|
---|
119 | return 9;
|
---|
120 | }
|
---|
121 | else
|
---|
122 | break;
|
---|
123 | }
|
---|
124 | else /* if(CtryInfo.fsDateFmt == 2) */
|
---|
125 | {
|
---|
126 | if(len > 8)
|
---|
127 | {
|
---|
128 | strcpy(buf, "yyXMMXdd");
|
---|
129 | buf[2] = buf[5] = CtryInfo.szDateSeparator[0];
|
---|
130 | return 9;
|
---|
131 | }
|
---|
132 | else
|
---|
133 | break;
|
---|
134 | }
|
---|
135 | case LOCALE_STIMEFORMAT:
|
---|
136 | if(CtryInfo.fsTimeFmt == 0)
|
---|
137 | {
|
---|
138 | if(len > 8)
|
---|
139 | {
|
---|
140 | strcpy(buf, "HHXmmXss");
|
---|
141 | buf[2] = buf[5] = CtryInfo.szTimeSeparator[0];
|
---|
142 | return 9;
|
---|
143 | }
|
---|
144 | else
|
---|
145 | break;
|
---|
146 | }
|
---|
147 | else /* if(CtryInfo.fsTimeFmt == 1) */
|
---|
148 | {
|
---|
149 | if(len > 8)
|
---|
150 | {
|
---|
151 | strcpy(buf, "HHXmmXss");
|
---|
152 | buf[2] = buf[5] = CtryInfo.szTimeSeparator[0];
|
---|
153 | return 9;
|
---|
154 | }
|
---|
155 | else
|
---|
156 | break;
|
---|
157 | }
|
---|
158 | case LOCALE_S1159:
|
---|
159 | if(CtryInfo.fsTimeFmt == 0)
|
---|
160 | {
|
---|
161 | if(len > 2)
|
---|
162 | {
|
---|
163 | strcpy(buf, "AM");
|
---|
164 | return 3;
|
---|
165 | }
|
---|
166 | else
|
---|
167 | break;
|
---|
168 | }
|
---|
169 | *buf = 0;
|
---|
170 | return 1;
|
---|
171 | case LOCALE_S2359:
|
---|
172 | if(CtryInfo.fsTimeFmt == 0)
|
---|
173 | {
|
---|
174 | if(len > 2)
|
---|
175 | {
|
---|
176 | strcpy(buf, "PM");
|
---|
177 | return 3;
|
---|
178 | }
|
---|
179 | else
|
---|
180 | break;
|
---|
181 | }
|
---|
182 | if(buf) *buf = 0;
|
---|
183 | return 1;
|
---|
184 | /***
|
---|
185 | LOCALE_SABBREVMONTHNAME11:
|
---|
186 | LOCALE_SABBREVMONTHNAME12:
|
---|
187 | LOCALE_SABBREVMONTHNAME13:
|
---|
188 | LOCALE_SPOSITIVESIGN:
|
---|
189 | LOCALE_SNEGATIVESIGN:
|
---|
190 | LOCALE_IPOSSIGNPOSN:
|
---|
191 | LOCALE_INEGSIGNPOSN:
|
---|
192 | LOCALE_IPOSSYMPRECEDES:
|
---|
193 | LOCALE_IPOSSEPBYSPACE:
|
---|
194 | LOCALE_INEGSYMPRECEDES:
|
---|
195 | LOCALE_INEGSEPBYSPACE:
|
---|
196 | LOCALE_FONTSIGNATURE:
|
---|
197 | LOCALE_SISO639LANGNAME:
|
---|
198 | LOCALE_SISO3166CTRYNAME:
|
---|
199 | ***/
|
---|
200 | default:
|
---|
201 | dprintf(("KERNEL32: OS2GetLocaleInfoA: LCType %d not yet supported\n", LCType));
|
---|
202 | if(buf) *buf = '1';
|
---|
203 | return(1);
|
---|
204 | }
|
---|
205 |
|
---|
206 | // a 'break' in 'switch(LCType)': buffer too small
|
---|
207 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
---|
208 | return 0;
|
---|
209 |
|
---|
210 | }
|
---|
211 | //******************************************************************************
|
---|
212 | //******************************************************************************
|
---|
213 | int WIN32API GetLocaleInfoW(LCID lcid, LCTYPE LCType, LPWSTR wbuf, int len)
|
---|
214 | {
|
---|
215 | WORD wlen;
|
---|
216 | char *abuf;
|
---|
217 |
|
---|
218 | dprintf(("KERNEL32: OS2GetLocaleInfoW\n"));
|
---|
219 | if (len && (! wbuf) )
|
---|
220 | {
|
---|
221 | SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
---|
222 | return 0;
|
---|
223 | }
|
---|
224 | abuf = (char *) malloc(len);
|
---|
225 | wlen = GetLocaleInfoA(lcid, LCType, abuf, len);
|
---|
226 |
|
---|
227 | if (wlen && len) // no check of wbuf length !!
|
---|
228 | AsciiToUnicodeN(abuf, wbuf, wlen);
|
---|
229 |
|
---|
230 | free(abuf);
|
---|
231 | return wlen;
|
---|
232 | }
|
---|
233 | //******************************************************************************
|
---|
234 | //******************************************************************************
|
---|
235 | BOOL WIN32API IsValidLocale(LCID Locale, DWORD dwFlags)
|
---|
236 | {
|
---|
237 | dprintf(("KERNEL32: OS2IsValidLocale, always returns TRUE\n"));
|
---|
238 | return(TRUE);
|
---|
239 | }
|
---|
240 | //******************************************************************************
|
---|
241 | //******************************************************************************
|
---|
242 | LCID WIN32API GetThreadLocale()
|
---|
243 | {
|
---|
244 | dprintf(("KERNEL32: OS2GetThreadLocale always return US English!\n"));
|
---|
245 | return(0x409); //US English
|
---|
246 | }
|
---|
247 | //******************************************************************************
|
---|
248 | //******************************************************************************
|
---|
249 | //******************************************************************************
|
---|
250 | BOOL WIN32API SetThreadLocale( LCID locale )
|
---|
251 | {
|
---|
252 | dprintf(("KERNEL32: OS2SetThreadLocale not implemented!\n"));
|
---|
253 | return(TRUE);
|
---|
254 | }
|
---|
255 | //******************************************************************************
|
---|
256 | //******************************************************************************
|
---|
257 | BOOL WIN32API EnumSystemLocalesA(LOCALE_ENUMPROCA lpLocaleEnumProc,
|
---|
258 | DWORD dwFlags)
|
---|
259 | {
|
---|
260 | dprintf(("EnumSystemLocalesA %X %X\n", lpLocaleEnumProc, dwFlags));
|
---|
261 | if(lpLocaleEnumProc == NULL || ((dwFlags & LCID_INSTALLED) && (dwFlags & LCID_SUPPORTED))) {
|
---|
262 | dprintf(("Invalid parameter\n"));
|
---|
263 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
264 | return(FALSE);
|
---|
265 | }
|
---|
266 | lpLocaleEnumProc("OS/2 US English");
|
---|
267 | return(TRUE);
|
---|
268 | }
|
---|
269 | //******************************************************************************
|
---|
270 | //******************************************************************************
|
---|
271 | BOOL WIN32API EnumSystemLocalesW(LOCALE_ENUMPROCW lpLocaleEnumProc,
|
---|
272 | DWORD dwFlags)
|
---|
273 | {
|
---|
274 | WCHAR locStr[32];
|
---|
275 |
|
---|
276 | dprintf(("EnumSystemLocalesW %X %X\n", lpLocaleEnumProc, dwFlags));
|
---|
277 | if(lpLocaleEnumProc == NULL || ((dwFlags & LCID_INSTALLED) && (dwFlags & LCID_SUPPORTED))) {
|
---|
278 | dprintf(("Invalid parameter\n"));
|
---|
279 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
280 | return(FALSE);
|
---|
281 | }
|
---|
282 | AsciiToUnicode("OS/2 US English", locStr);
|
---|
283 | lpLocaleEnumProc(locStr);
|
---|
284 | return(TRUE);
|
---|
285 | }
|
---|
286 | //******************************************************************************
|
---|
287 | //******************************************************************************
|
---|
288 |
|
---|
289 |
|
---|
290 | /*****************************************************************************
|
---|
291 | * Name : BOOL SetLocaleInfoA
|
---|
292 | * Purpose : The SetLocaleInfoA function sets an item of locale information.
|
---|
293 | * It does so by making an entry in the process portion of the
|
---|
294 | * locale table. This setting only affects the user override portion
|
---|
295 | * of the locale settings; it does not set the system defaults.
|
---|
296 | * Only certain types of locale information, or LCTYPE values, can
|
---|
297 | * be set by this function. See the following Remarks section for a
|
---|
298 | * list of valid LCTYPE values.
|
---|
299 | * The locale information is always passed in as a null-terminated
|
---|
300 | * Unicode string in the Unicode (W) version of the function, and as
|
---|
301 | * a null-terminated ANSI string in the ANSI (A) version. No integers
|
---|
302 | * are allowed by this function; any numeric values must be specified
|
---|
303 | * as Unicode or ANSI text. Each LCTYPE has a particular format, as
|
---|
304 | * noted in Locale Identifiers.
|
---|
305 | * Parameters: LCID Locale locale identifier
|
---|
306 | * LCTYPE LCType type of information to set
|
---|
307 | * LPCTSTR lpLCData pointer to information to set
|
---|
308 | * Variables :
|
---|
309 | * Result : TRUE / FALSE
|
---|
310 | * Remark :
|
---|
311 | * Status : UNTESTED STUB
|
---|
312 | *
|
---|
313 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
314 | *****************************************************************************/
|
---|
315 |
|
---|
316 | BOOL WIN32API SetLocaleInfoA(LCID Locale,
|
---|
317 | LCTYPE LCType,
|
---|
318 | LPCSTR lpLCData)
|
---|
319 | {
|
---|
320 | dprintf(("KERNEL32: SetLocaleInfoA(%08xh,%08xh,%08xh) not implemented.\n",
|
---|
321 | Locale,
|
---|
322 | LCType,
|
---|
323 | lpLCData));
|
---|
324 |
|
---|
325 | return (FALSE);
|
---|
326 | }
|
---|
327 |
|
---|
328 |
|
---|
329 | /*****************************************************************************
|
---|
330 | * Name : BOOL SetLocaleInfoW
|
---|
331 | * Purpose : The SetLocaleInfoW function sets an item of locale information.
|
---|
332 | * It does so by making an entry in the process portion of the
|
---|
333 | * locale table. This setting only affects the user override portion
|
---|
334 | * of the locale settings; it does not set the system defaults.
|
---|
335 | * Only certain types of locale information, or LCTYPE values, can
|
---|
336 | * be set by this function. See the following Remarks section for a
|
---|
337 | * list of valid LCTYPE values.
|
---|
338 | * The locale information is always passed in as a null-terminated
|
---|
339 | * Unicode string in the Unicode (W) version of the function, and as
|
---|
340 | * a null-terminated ANSI string in the ANSI (A) version. No integers
|
---|
341 | * are allowed by this function; any numeric values must be specified
|
---|
342 | * as Unicode or ANSI text. Each LCTYPE has a particular format, as
|
---|
343 | * noted in Locale Identifiers.
|
---|
344 | * Parameters: LCID Locale locale identifier
|
---|
345 | * LCTYPE LCType type of information to set
|
---|
346 | * LPCTSTR lpLCData pointer to information to set
|
---|
347 | * Variables :
|
---|
348 | * Result : TRUE / FALSE
|
---|
349 | * Remark :
|
---|
350 | * Status : UNTESTED STUB
|
---|
351 | *
|
---|
352 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
353 | *****************************************************************************/
|
---|
354 |
|
---|
355 | BOOL WIN32API SetLocaleInfoW(LCID Locale,
|
---|
356 | LCTYPE LCType,
|
---|
357 | LPCWSTR lpLCData)
|
---|
358 | {
|
---|
359 | dprintf(("KERNEL32: SetLocaleInfoW(%08xh,%08xh,%08xh) not implemented.\n",
|
---|
360 | Locale,
|
---|
361 | LCType,
|
---|
362 | lpLCData));
|
---|
363 |
|
---|
364 | return (FALSE);
|
---|
365 | }
|
---|
366 |
|
---|
367 |
|
---|
368 | /*****************************************************************************
|
---|
369 | * Name : DWORD VerLanguageNameA
|
---|
370 | * Purpose : The VerLanguageNameA function converts the specified binary
|
---|
371 | * Microsoft language identifier into a text representation of the language.
|
---|
372 | * Parameters: DWORD idLang Microsoft language identifier
|
---|
373 | * LPTSTR lpszLang address of buffer for language string
|
---|
374 | * DWORD cbLang size of buffer
|
---|
375 | * Variables :
|
---|
376 | * Result : size of target buffer
|
---|
377 | * Remark :
|
---|
378 | * Status : UNTESTED STUB
|
---|
379 | *
|
---|
380 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
381 | *****************************************************************************/
|
---|
382 |
|
---|
383 | DWORD WIN32API VerLanguageNameA(UINT idLang,
|
---|
384 | LPSTR lpszLang,
|
---|
385 | UINT cbLang)
|
---|
386 | {
|
---|
387 | dprintf(("KERNEL32: VerLanguageNameA(%08x,%08x,%08x) not implemented.\n",
|
---|
388 | idLang,
|
---|
389 | lpszLang,
|
---|
390 | cbLang));
|
---|
391 |
|
---|
392 | return (0);
|
---|
393 | }
|
---|
394 |
|
---|
395 |
|
---|
396 | /*****************************************************************************
|
---|
397 | * Name : DWORD VerLanguageNameW
|
---|
398 | * Purpose : The VerLanguageNameW function converts the specified binary
|
---|
399 | * Microsoft language identifier into a text representation of the language.
|
---|
400 | * Parameters: DWORD idLang Microsoft language identifier
|
---|
401 | * LPTSTR lpszLang address of buffer for language string
|
---|
402 | * DWORD cbLang size of buffer
|
---|
403 | * Variables :
|
---|
404 | * Result : size of target buffer
|
---|
405 | * Remark :
|
---|
406 | * Status : UNTESTED STUB
|
---|
407 | *
|
---|
408 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
409 | *****************************************************************************/
|
---|
410 |
|
---|
411 | DWORD WIN32API VerLanguageNameW(UINT idLang,
|
---|
412 | LPWSTR lpszLang,
|
---|
413 | UINT cbLang)
|
---|
414 | {
|
---|
415 | dprintf(("KERNEL32: VerLanguageNameW(%08x,%08x,%08x) not implemented.\n",
|
---|
416 | idLang,
|
---|
417 | lpszLang,
|
---|
418 | cbLang));
|
---|
419 |
|
---|
420 | return (0);
|
---|
421 | }
|
---|
422 |
|
---|
423 |
|
---|