source: trunk/src/user32/char.cpp@ 2804

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

Added new logging feature

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