| 1 | /* $Id: char.cpp,v 1.3 1999-09-15 23:20:37 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Win32 character API functions for OS/2 | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1998 Sander van Leeuwen | 
|---|
| 7 | * Copyright 1998 Patrick Haller | 
|---|
| 8 | * Copyright 1998 Peter Fitzsimmons | 
|---|
| 9 | * | 
|---|
| 10 | * | 
|---|
| 11 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 12 | * | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | #include "user32.h" | 
|---|
| 16 |  | 
|---|
| 17 | #include <wctype.h> /* towupper, towlower support */ | 
|---|
| 18 |  | 
|---|
| 19 |  | 
|---|
| 20 | //****************************************************************************** | 
|---|
| 21 | //****************************************************************************** | 
|---|
| 22 | LPSTR WIN32API CharLowerA( LPSTR arg1) | 
|---|
| 23 | { | 
|---|
| 24 | dprintf(("USER32:  OS2CharLowerA\n")); | 
|---|
| 25 | return O32_CharLower(arg1); | 
|---|
| 26 | } | 
|---|
| 27 | //****************************************************************************** | 
|---|
| 28 | //****************************************************************************** | 
|---|
| 29 | DWORD WIN32API CharLowerBuffA( LPSTR arg1, DWORD  arg2) | 
|---|
| 30 | { | 
|---|
| 31 | dprintf(("USER32:  OS2CharLowerBuffA\n")); | 
|---|
| 32 | return O32_CharLowerBuff(arg1, arg2); | 
|---|
| 33 | } | 
|---|
| 34 | //****************************************************************************** | 
|---|
| 35 | //****************************************************************************** | 
|---|
| 36 | DWORD WIN32API CharLowerBuffW(LPWSTR x,DWORD buflen) | 
|---|
| 37 | { | 
|---|
| 38 | DWORD done=0; | 
|---|
| 39 |  | 
|---|
| 40 | dprintf(("USER32: CharLowerBuffW(%08xh,%08xh)\n", | 
|---|
| 41 | x, | 
|---|
| 42 | buflen)); | 
|---|
| 43 |  | 
|---|
| 44 | if (!x) | 
|---|
| 45 | return 0; /* YES */ | 
|---|
| 46 |  | 
|---|
| 47 | while (*x && (buflen--)) | 
|---|
| 48 | { | 
|---|
| 49 | *x=towlower(*x); | 
|---|
| 50 | x++; | 
|---|
| 51 | done++; | 
|---|
| 52 | } | 
|---|
| 53 |  | 
|---|
| 54 | return done; | 
|---|
| 55 | } | 
|---|
| 56 | //****************************************************************************** | 
|---|
| 57 | //****************************************************************************** | 
|---|
| 58 | LPWSTR WIN32API CharLowerW( LPWSTR x) | 
|---|
| 59 | { | 
|---|
| 60 | dprintf(("USER32: CharLowerW(%08xh)\n", | 
|---|
| 61 | x)); | 
|---|
| 62 |  | 
|---|
| 63 | if (HIWORD(x)) | 
|---|
| 64 | { | 
|---|
| 65 | LPWSTR s = x; | 
|---|
| 66 | while (*s) | 
|---|
| 67 | { | 
|---|
| 68 | *s=towlower(*s); | 
|---|
| 69 | s++; | 
|---|
| 70 | } | 
|---|
| 71 | return x; | 
|---|
| 72 | } | 
|---|
| 73 | else | 
|---|
| 74 | return (LPWSTR)((UINT)towlower(LOWORD(x))); | 
|---|
| 75 | } | 
|---|
| 76 | //****************************************************************************** | 
|---|
| 77 | //****************************************************************************** | 
|---|
| 78 | LPSTR WIN32API CharNextA( LPCSTR arg1) | 
|---|
| 79 | { | 
|---|
| 80 | dprintf(("USER32: OS2CharNextA(%08xh)\n", | 
|---|
| 81 | arg1)); | 
|---|
| 82 |  | 
|---|
| 83 | return O32_CharNext(arg1); | 
|---|
| 84 | } | 
|---|
| 85 | //****************************************************************************** | 
|---|
| 86 | //****************************************************************************** | 
|---|
| 87 | LPWSTR WIN32API CharNextW(LPCWSTR x) | 
|---|
| 88 | { | 
|---|
| 89 | dprintf(("USER32: OS2CharNextW(%08xh)\n", | 
|---|
| 90 | x)); | 
|---|
| 91 |  | 
|---|
| 92 | if (*x) | 
|---|
| 93 | return (LPWSTR)(x+1); | 
|---|
| 94 | else | 
|---|
| 95 | return (LPWSTR)x; | 
|---|
| 96 | } | 
|---|
| 97 | //****************************************************************************** | 
|---|
| 98 | //****************************************************************************** | 
|---|
| 99 | LPSTR WIN32API CharPrevA( LPCSTR arg1, LPCSTR  arg2) | 
|---|
| 100 | { | 
|---|
| 101 | dprintf(("USER32:  OS2CharPrevA\n")); | 
|---|
| 102 | return O32_CharPrev(arg1, arg2); | 
|---|
| 103 | } | 
|---|
| 104 | //****************************************************************************** | 
|---|
| 105 | //****************************************************************************** | 
|---|
| 106 | LPWSTR WIN32API CharPrevW(LPCWSTR x, | 
|---|
| 107 | LPCWSTR start) | 
|---|
| 108 | { | 
|---|
| 109 | dprintf(("USER32: OS2CharPrevW(%08xh,%08xh)\n", | 
|---|
| 110 | x, | 
|---|
| 111 | start)); | 
|---|
| 112 |  | 
|---|
| 113 | /* FIXME: add DBCS / codepage stuff */ | 
|---|
| 114 | if (x>start) | 
|---|
| 115 | return (LPWSTR)(x-1); | 
|---|
| 116 | else | 
|---|
| 117 | return (LPWSTR)x; | 
|---|
| 118 | } | 
|---|
| 119 | //****************************************************************************** | 
|---|
| 120 | //****************************************************************************** | 
|---|
| 121 | BOOL WIN32API CharToOemA( LPCSTR arg1, LPSTR  arg2) | 
|---|
| 122 | { | 
|---|
| 123 | dprintf(("USER32:  OS2CharToOemA\n")); | 
|---|
| 124 | return O32_CharToOem(arg1, arg2); | 
|---|
| 125 | } | 
|---|
| 126 | //****************************************************************************** | 
|---|
| 127 | //****************************************************************************** | 
|---|
| 128 | BOOL WIN32API CharToOemBuffA( LPCSTR arg1, LPSTR arg2, DWORD  arg3) | 
|---|
| 129 | { | 
|---|
| 130 | dprintf(("USER32:  OS2CharToOemBuffA\n")); | 
|---|
| 131 | return O32_CharToOemBuff(arg1, arg2, arg3); | 
|---|
| 132 | } | 
|---|
| 133 | //****************************************************************************** | 
|---|
| 134 | //****************************************************************************** | 
|---|
| 135 | BOOL WIN32API CharToOemBuffW( LPCWSTR arg1, LPSTR arg2, DWORD  arg3) | 
|---|
| 136 | { | 
|---|
| 137 | dprintf(("USER32:  OS2CharToOemBuffW DOESN'T WORK\n")); | 
|---|
| 138 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 139 | return 0; | 
|---|
| 140 | //    return O32_CharToOemBuff(arg1, arg2, arg3); | 
|---|
| 141 | } | 
|---|
| 142 | //****************************************************************************** | 
|---|
| 143 | //****************************************************************************** | 
|---|
| 144 | BOOL WIN32API CharToOemW( LPCWSTR arg1, LPSTR  arg2) | 
|---|
| 145 | { | 
|---|
| 146 | dprintf(("USER32:  OS2CharToOemW DOESN'T WORK\n")); | 
|---|
| 147 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 148 | return 0; | 
|---|
| 149 | //    return O32_CharToOem(arg1, arg2); | 
|---|
| 150 | } | 
|---|
| 151 | //****************************************************************************** | 
|---|
| 152 | //****************************************************************************** | 
|---|
| 153 | LPSTR WIN32API CharUpperA( LPSTR arg1) | 
|---|
| 154 | { | 
|---|
| 155 | LPSTR rc; | 
|---|
| 156 |  | 
|---|
| 157 | if((int)arg1 >> 16 != 0) { | 
|---|
| 158 | dprintf(("USER32:  OS2CharUpperA %s\n", arg1)); | 
|---|
| 159 | } | 
|---|
| 160 | else { | 
|---|
| 161 | dprintf(("USER32:  OS2CharUpperA %X\n", arg1)); | 
|---|
| 162 | } | 
|---|
| 163 |  | 
|---|
| 164 | rc = O32_CharUpper(arg1); | 
|---|
| 165 |  | 
|---|
| 166 | if((int)rc >> 16 != 0) { | 
|---|
| 167 | dprintf(("USER32:  OS2CharUpperA %s\n", rc)); | 
|---|
| 168 | } | 
|---|
| 169 | else { | 
|---|
| 170 | dprintf(("USER32:  OS2CharUpperA %X\n", rc)); | 
|---|
| 171 | } | 
|---|
| 172 |  | 
|---|
| 173 | return(rc); | 
|---|
| 174 | } | 
|---|
| 175 | //****************************************************************************** | 
|---|
| 176 | //****************************************************************************** | 
|---|
| 177 | DWORD WIN32API CharUpperBuffA( LPSTR arg1, DWORD  arg2) | 
|---|
| 178 | { | 
|---|
| 179 | dprintf(("USER32:  OS2CharUpperBuffA\n")); | 
|---|
| 180 | return O32_CharUpperBuff(arg1, arg2); | 
|---|
| 181 | } | 
|---|
| 182 | //****************************************************************************** | 
|---|
| 183 | //****************************************************************************** | 
|---|
| 184 | DWORD WIN32API CharUpperBuffW(LPWSTR x, DWORD buflen) | 
|---|
| 185 | { | 
|---|
| 186 | DWORD done=0; | 
|---|
| 187 |  | 
|---|
| 188 | dprintf(("USER32: OS2CharUpperBuffW(%08xh,%08xh)\n", | 
|---|
| 189 | x, | 
|---|
| 190 | buflen)); | 
|---|
| 191 |  | 
|---|
| 192 | if (!x) | 
|---|
| 193 | return 0; /* YES */ | 
|---|
| 194 |  | 
|---|
| 195 | while (*x && (buflen--)) | 
|---|
| 196 | { | 
|---|
| 197 | *x=towupper(*x); | 
|---|
| 198 | x++; | 
|---|
| 199 | done++; | 
|---|
| 200 | } | 
|---|
| 201 |  | 
|---|
| 202 | return done; | 
|---|
| 203 | } | 
|---|
| 204 | //****************************************************************************** | 
|---|
| 205 | //****************************************************************************** | 
|---|
| 206 | LPWSTR WIN32API CharUpperW( LPWSTR x) | 
|---|
| 207 | { | 
|---|
| 208 | dprintf(("USER32: OS2CharUpperW(%08xh)\n", | 
|---|
| 209 | x)); | 
|---|
| 210 |  | 
|---|
| 211 | if (HIWORD(x)) | 
|---|
| 212 | { | 
|---|
| 213 | LPWSTR s = x; | 
|---|
| 214 |  | 
|---|
| 215 | while (*s) | 
|---|
| 216 | { | 
|---|
| 217 | *s=towupper(*s); | 
|---|
| 218 | s++; | 
|---|
| 219 | } | 
|---|
| 220 | return x; | 
|---|
| 221 | } | 
|---|
| 222 | else | 
|---|
| 223 | return (LPWSTR)((UINT)towupper(LOWORD(x))); | 
|---|
| 224 | } | 
|---|
| 225 | //****************************************************************************** | 
|---|
| 226 | //****************************************************************************** | 
|---|
| 227 | LPSTR WIN32API CharNextExA( WORD codepage, LPCSTR ptr, DWORD flags ) | 
|---|
| 228 | { | 
|---|
| 229 | if (!*ptr) return (LPSTR)ptr; | 
|---|
| 230 | //    if (O32_IsDBCSLeadByteEx( codepage, *ptr )) return (LPSTR)(ptr + 2); | 
|---|
| 231 | return (LPSTR)(ptr + 1); | 
|---|
| 232 | } | 
|---|
| 233 | //****************************************************************************** | 
|---|
| 234 | //****************************************************************************** | 
|---|
| 235 | LPSTR WIN32API CharPrevExA(WORD codepage, LPCSTR start, LPCSTR ptr, DWORD flags) | 
|---|
| 236 | { | 
|---|
| 237 | while (*start && (start < ptr)) | 
|---|
| 238 | { | 
|---|
| 239 | LPCSTR next = CharNextExA(codepage, start, flags); | 
|---|
| 240 | if (next > ptr) break; | 
|---|
| 241 | start = next; | 
|---|
| 242 | } | 
|---|
| 243 | return (LPSTR)start; | 
|---|
| 244 | } | 
|---|
| 245 | /***************************************************************************** | 
|---|
| 246 | * Name      : LPSTR WIN32API CharNextExW | 
|---|
| 247 | * Purpose   : The CharNextExA function retrieves the address of the next | 
|---|
| 248 | *             character in a string. This function can handle strings | 
|---|
| 249 | *             consisting of either single- or multi-byte characters. | 
|---|
| 250 | * Parameters: | 
|---|
| 251 | * Variables : | 
|---|
| 252 | * Result    : If the function succeeds, the return value is a pointer to the | 
|---|
| 253 | *             next character in the string, or to the terminating null character | 
|---|
| 254 | *             if at the end of the string. | 
|---|
| 255 | *             If lpCurrentChar points to the terminating null character, the | 
|---|
| 256 | *             return value is equal to lpCurrentChar. | 
|---|
| 257 | * Remark    : | 
|---|
| 258 | * Status    : UNTESTED STUB | 
|---|
| 259 | * | 
|---|
| 260 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 261 | *****************************************************************************/ | 
|---|
| 262 |  | 
|---|
| 263 | LPWSTR WIN32API CharNextExW(WORD   CodePage, | 
|---|
| 264 | LPCWSTR lpCurrentChar, | 
|---|
| 265 | DWORD  dwFlags) | 
|---|
| 266 | { | 
|---|
| 267 | dprintf(("USER32:CharNextExW(%u,%08xh,%08x) not implemented.\n", | 
|---|
| 268 | CodePage, | 
|---|
| 269 | lpCurrentChar, | 
|---|
| 270 | dwFlags)); | 
|---|
| 271 |  | 
|---|
| 272 | return (NULL); | 
|---|
| 273 | } | 
|---|
| 274 |  | 
|---|
| 275 |  | 
|---|
| 276 | /***************************************************************************** | 
|---|
| 277 | * Name      : LPSTR WIN32API CharPrevExW | 
|---|
| 278 | * Purpose   : The CharPrevExA function retrieves the address of the preceding | 
|---|
| 279 | *             character in a string. This function can handle strings | 
|---|
| 280 | *             consisting of either single- or multi-byte characters. | 
|---|
| 281 | * Parameters: | 
|---|
| 282 | * Variables : | 
|---|
| 283 | * Result    : If the function succeeds, the return value is a pointer to the | 
|---|
| 284 | *             preceding character in the string, or to the first character in | 
|---|
| 285 | *             the string if the lpCurrentChar parameter equals the lpStart parameter. | 
|---|
| 286 | * Remark    : | 
|---|
| 287 | * Status    : UNTESTED STUB | 
|---|
| 288 | * | 
|---|
| 289 | * Author    : Patrick Haller [Thu, 1998/02/26 11:55] | 
|---|
| 290 | *****************************************************************************/ | 
|---|
| 291 |  | 
|---|
| 292 | LPWSTR WIN32API CharPrevExW(WORD CodePage, | 
|---|
| 293 | LPCWSTR lpStart, | 
|---|
| 294 | LPCWSTR lpCurrentChar, | 
|---|
| 295 | DWORD  dwFlags) | 
|---|
| 296 | { | 
|---|
| 297 | dprintf(("USER32:CharPrevExW(%u,%08xh,%08xh,%08x) not implemented.\n", | 
|---|
| 298 | CodePage, | 
|---|
| 299 | lpStart, | 
|---|
| 300 | lpCurrentChar, | 
|---|
| 301 | dwFlags)); | 
|---|
| 302 |  | 
|---|
| 303 | return (NULL); | 
|---|
| 304 | } | 
|---|
| 305 | //****************************************************************************** | 
|---|
| 306 | //****************************************************************************** | 
|---|
| 307 | BOOL WIN32API IsCharAlphaA( CHAR arg1) | 
|---|
| 308 | { | 
|---|
| 309 | #ifdef DEBUG | 
|---|
| 310 | WriteLog("USER32:  OS2IsCharAlphaA\n"); | 
|---|
| 311 | #endif | 
|---|
| 312 | return O32_IsCharAlpha(arg1); | 
|---|
| 313 | } | 
|---|
| 314 | //****************************************************************************** | 
|---|
| 315 | //****************************************************************************** | 
|---|
| 316 | BOOL WIN32API IsCharAlphaNumericA( CHAR arg1) | 
|---|
| 317 | { | 
|---|
| 318 | #ifdef DEBUG | 
|---|
| 319 | WriteLog("USER32:  OS2IsCharAlphaNumericA\n"); | 
|---|
| 320 | #endif | 
|---|
| 321 | return O32_IsCharAlphaNumeric(arg1); | 
|---|
| 322 | } | 
|---|
| 323 | //****************************************************************************** | 
|---|
| 324 | //****************************************************************************** | 
|---|
| 325 | BOOL WIN32API IsCharAlphaNumericW( WCHAR arg1) | 
|---|
| 326 | { | 
|---|
| 327 | #ifdef DEBUG | 
|---|
| 328 | WriteLog("USER32:  OS2IsCharAlphaNumericW\n"); | 
|---|
| 329 | #endif | 
|---|
| 330 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 331 | return O32_IsCharAlphaNumeric((CHAR)arg1); | 
|---|
| 332 | } | 
|---|
| 333 | //****************************************************************************** | 
|---|
| 334 | //****************************************************************************** | 
|---|
| 335 | BOOL WIN32API IsCharAlphaW( WCHAR arg1) | 
|---|
| 336 | { | 
|---|
| 337 | #ifdef DEBUG | 
|---|
| 338 | WriteLog("USER32:  OS2IsCharAlphaW\n"); | 
|---|
| 339 | #endif | 
|---|
| 340 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 341 | return O32_IsCharAlpha((CHAR)arg1); | 
|---|
| 342 | } | 
|---|
| 343 | //****************************************************************************** | 
|---|
| 344 | //****************************************************************************** | 
|---|
| 345 | BOOL WIN32API IsCharLowerA( CHAR arg1) | 
|---|
| 346 | { | 
|---|
| 347 | #ifdef DEBUG | 
|---|
| 348 | WriteLog("USER32:  OS2IsCharLowerA\n"); | 
|---|
| 349 | #endif | 
|---|
| 350 | return O32_IsCharLower(arg1); | 
|---|
| 351 | } | 
|---|
| 352 | //****************************************************************************** | 
|---|
| 353 | //****************************************************************************** | 
|---|
| 354 | BOOL WIN32API IsCharLowerW( WCHAR arg1) | 
|---|
| 355 | { | 
|---|
| 356 | #ifdef DEBUG | 
|---|
| 357 | WriteLog("USER32:  OS2IsCharLowerW\n"); | 
|---|
| 358 | #endif | 
|---|
| 359 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 360 | return O32_IsCharLower((CHAR)arg1); | 
|---|
| 361 | } | 
|---|
| 362 | //****************************************************************************** | 
|---|
| 363 | //****************************************************************************** | 
|---|
| 364 | BOOL WIN32API IsCharUpperA( CHAR arg1) | 
|---|
| 365 | { | 
|---|
| 366 | #ifdef DEBUG | 
|---|
| 367 | WriteLog("USER32:  OS2IsCharUpperA\n"); | 
|---|
| 368 | #endif | 
|---|
| 369 | return O32_IsCharUpper(arg1); | 
|---|
| 370 | } | 
|---|
| 371 | //****************************************************************************** | 
|---|
| 372 | //****************************************************************************** | 
|---|
| 373 | BOOL WIN32API IsCharUpperW( WCHAR arg1) | 
|---|
| 374 | { | 
|---|
| 375 | #ifdef DEBUG | 
|---|
| 376 | WriteLog("USER32:  OS2IsCharUpperW\n"); | 
|---|
| 377 | #endif | 
|---|
| 378 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 379 | return O32_IsCharUpper((CHAR)arg1); | 
|---|
| 380 | } | 
|---|
| 381 | //****************************************************************************** | 
|---|
| 382 | //****************************************************************************** | 
|---|
| 383 | BOOL WIN32API OemToCharA( LPCSTR arg1, LPSTR  arg2) | 
|---|
| 384 | { | 
|---|
| 385 | #ifdef DEBUG | 
|---|
| 386 | WriteLog("USER32:  OS2OemToCharA\n"); | 
|---|
| 387 | #endif | 
|---|
| 388 | return O32_OemToChar(arg1, arg2); | 
|---|
| 389 | } | 
|---|
| 390 | //****************************************************************************** | 
|---|
| 391 | //****************************************************************************** | 
|---|
| 392 | BOOL WIN32API OemToCharBuffA( LPCSTR arg1, LPSTR arg2, DWORD  arg3) | 
|---|
| 393 | { | 
|---|
| 394 | #ifdef DEBUG | 
|---|
| 395 | WriteLog("USER32:  OS2OemToCharBuffA\n"); | 
|---|
| 396 | #endif | 
|---|
| 397 | return O32_OemToCharBuff(arg1, arg2, arg3); | 
|---|
| 398 | } | 
|---|
| 399 | //****************************************************************************** | 
|---|
| 400 | //****************************************************************************** | 
|---|
| 401 | BOOL WIN32API OemToCharBuffW(LPCSTR arg1, LPWSTR arg2, DWORD  arg3) | 
|---|
| 402 | { | 
|---|
| 403 | #ifdef DEBUG | 
|---|
| 404 | WriteLog("USER32: OemToCharBuffW DOESN'T WORK \n"); | 
|---|
| 405 | #endif | 
|---|
| 406 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 407 | return 0; | 
|---|
| 408 | //    return O32_OemToCharBuff(arg1, arg2, arg3); | 
|---|
| 409 | } | 
|---|
| 410 | //****************************************************************************** | 
|---|
| 411 | //****************************************************************************** | 
|---|
| 412 | BOOL WIN32API OemToCharW( LPCSTR arg1, LPWSTR  arg2) | 
|---|
| 413 | { | 
|---|
| 414 | #ifdef DEBUG | 
|---|
| 415 | WriteLog("USER32:  OS2OemToCharW DOESN'T WORK\n"); | 
|---|
| 416 | #endif | 
|---|
| 417 | // NOTE: This will not work as is (needs UNICODE support) | 
|---|
| 418 | return 0; | 
|---|
| 419 | //    return O32_OemToChar(arg1, arg2); | 
|---|
| 420 | } | 
|---|