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