source: trunk/src/kernel32/lang.cpp@ 224

Last change on this file since 224 was 224, checked in by sandervl, 26 years ago

KERNEL32/lang.cpp: Bugfix for GetLocaleInfoA

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