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