source: trunk/src/shlwapi/string_odin.cpp@ 7838

Last change on this file since 7838 was 7838, checked in by sandervl, 24 years ago

update

File size: 9.0 KB
Line 
1 /* $Id: string_odin.cpp,v 1.7 2002-02-08 10:23:35 sandervl Exp $ */
2
3/*
4 * Win32 Lightweight SHELL32 for OS/2
5 *
6 * Copyright 1997 Marcus Meissner
7 * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 * Path Functions
11 *
12 * Many of this functions are in SHLWAPI.DLL also
13 *
14 * Corel WINE 20000324 level (without CRTDLL_* calls)
15 */
16
17/*****************************************************************************
18 * Remark *
19 *****************************************************************************
20
21 */
22
23
24/*****************************************************************************
25 * Includes *
26 *****************************************************************************/
27
28#include <odin.h>
29#include <odinwrap.h>
30#include <os2sel.h>
31
32#include <string.h>
33#include <ctype.h>
34#include <wctype.h>
35#include <wcstr.h>
36#define HAVE_WCTYPE_H
37
38#include "debugtools.h"
39
40#include <winreg.h>
41
42#include <heapstring.h>
43#include <misc.h>
44#include <win\shell.h>
45#include <win\winerror.h>
46#include <winversion.h>
47#include <winuser.h>
48
49
50#define ICOM_CINTERFACE 1
51#define CINTERFACE 1
52
53#include "winerror.h"
54#include "winnls.h"
55#include "winversion.h"
56#include "heap.h"
57
58#include "shellapi.h"
59#include "shlobj.h"
60#include "wine/undocshell.h"
61
62#include "shlwapi_odin.h"
63#include "shlwapi.h"
64
65/*****************************************************************************
66 * Local Variables *
67 *****************************************************************************/
68
69ODINDEBUGCHANNEL(SHLWAPI-STRING)
70
71
72
73
74/*****************************************************************************
75 * Name : StrChrIA
76 * Purpose : Searches a string for the first occurrence of a character that
77 * matches the specified character. The comparison is not case sensitive.
78 * Parameters: LPCSTR lpStart Address of the string to be searched.
79 * TCHAR wMatch Character to be used for comparison.
80 * Variables :
81 * Result : Returns the address of the first occurrence of the character in
82 * the string if successful, or NULL otherwise.
83 * Remark : SHELL32.
84 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
85 *
86 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
87 *****************************************************************************/
88
89ODINFUNCTION2(LPSTR, StrChrIA,
90 LPCSTR, lpStart,
91 char, cMatch)
92{
93 LPSTR lpRes;
94
95 cMatch = tolower(cMatch);
96 lpRes = strchr(lpStart, cMatch); // lower case comparsion
97 if (NULL == lpRes)
98 {
99 cMatch = toupper(cMatch);
100 lpRes = strchr(lpStart, cMatch); // upper case comparsion
101 }
102
103 return lpRes;
104}
105
106
107/*****************************************************************************
108 * Name : StrChrIW
109 * Purpose : Searches a string for the first occurrence of a character that
110 * matches the specified character. The comparison is not case sensitive.
111 * Parameters: LPCSTR lpStart Address of the string to be searched.
112 * TCHAR wMatch Character to be used for comparison.
113 * Variables :
114 * Result : Returns the address of the first occurrence of the character in
115 * the string if successful, or NULL otherwise.
116 * Remark : SHELL32.
117 * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
118 *
119 * Author : Patrick Haller [Wed, 1999/12/29 09:00]
120 *****************************************************************************/
121
122ODINFUNCTION2(LPWSTR, StrChrIW,
123 LPCWSTR, lpStart,
124 WCHAR, wMatch)
125{
126 LPWSTR lpRes;
127
128 wMatch = towlower(wMatch);
129 lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // lower case comparsion
130 if (NULL == lpRes)
131 {
132 wMatch = towupper(wMatch);
133 lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // upper case comparsion
134 }
135
136 return lpRes;
137}
138
139#if 0
140/*****************************************************************************
141 * Name : StrCpyA
142 * Purpose : copy a string
143 * Parameters:
144 * Variables :
145 * Result :
146 * Remark : not exported ?
147 * Status : UNTESTED
148 *
149 * Author :
150 *****************************************************************************/
151
152ODINFUNCTIONNODBG2(LPSTR, StrCpyA,
153 LPSTR, lpDest,
154 LPCSTR, lpSource)
155{
156 return lstrcpyA(lpDest,
157 lpSource);
158}
159#endif
160
161/*****************************************************************************
162 * Name : StrSpnA
163 * Purpose : find the first occurence of a character in string1
164 * that is not contained in the set of characters specified by
165 * string2.
166 * Parameters:
167 * Variables :
168 * Result :
169 * Remark : COMCTL32undoc.StrSpnW, CRTDLL.strspn
170 * Status : UNTESTED
171 *
172 * Author :
173 *****************************************************************************/
174
175ODINFUNCTION2(INT, StrSpnA,
176 LPCSTR, lpString1,
177 LPCSTR, lpString2)
178{
179 // 2001-08-30 PH
180 // copied from implementation in COMCTL32
181 if ( (lpString1 == NULL) ||
182 (lpString2 == NULL) )
183 return 0;
184
185 LPSTR lpLoop = (LPSTR)lpString1;
186
187 for (; (*lpLoop != 0); lpLoop++ )
188 if ( StrChrA( lpString2, *lpLoop ) )
189 return (INT) (lpLoop - lpString1);
190
191 return (INT) (lpLoop - lpString1);
192}
193
194
195/*****************************************************************************
196 * Name : StrSpnW
197 * Purpose : find the first occurence of a character in string1
198 * that is not contained in the set of characters specified by
199 * string2.
200 * Parameters:
201 * Variables :
202 * Result :
203 * Remark : COMCTL32undoc.StrSpnW, CRTDLL.strspn
204 * Status : UNTESTED
205 *
206 * Author :
207 *****************************************************************************/
208
209ODINFUNCTION2(INT, StrSpnW,
210 LPCWSTR, lpString1,
211 LPCWSTR, lpString2)
212{
213 // 2001-08-30 PH
214 // copied from implementation in COMCTL32
215 if ( (lpString1 == NULL) ||
216 (lpString2 == NULL) )
217 return 0;
218
219 LPWSTR lpLoop = (LPWSTR)lpString1;
220
221 for (; (*lpLoop != 0); lpLoop++ )
222 if ( StrChrW( lpString2, *lpLoop ) )
223 return (INT) (lpLoop - lpString1);
224
225 return (INT) (lpLoop - lpString1);
226}
227
228
229/*****************************************************************************
230 * Name : StrPBrkA
231 * Purpose : find the first occurence in string1 of any character from string2
232 * Parameters:
233 * Variables :
234 * Result :
235 * Remark :
236 * Status : UNTESTED
237 *
238 * Author :
239 *****************************************************************************/
240
241ODINFUNCTION2(LPSTR, StrPBrkA,
242 LPCSTR, lpString1,
243 LPCSTR, lpString2)
244{
245 register LPSTR s1;
246
247 while (*lpString1)
248 {
249 for (s1 = (LPSTR)lpString2;
250 *s1 && *s1 != *lpString1;
251 s1++)
252 /* empty */
253 ;
254
255 if (*s1)
256 return (LPSTR)lpString1;
257
258 lpString1++;
259 }
260
261 return (LPSTR)NULL;
262}
263
264
265/*****************************************************************************
266 * Name : StrPBrkW
267 * Purpose : find the first occurence in string1 of any character from string2
268 * Parameters:
269 * Variables :
270 * Result :
271 * Remark :
272 * Status : UNTESTED
273 *
274 * Author :
275 *****************************************************************************/
276
277ODINFUNCTION2(LPWSTR, StrPBrkW,
278 LPCWSTR, lpString1,
279 LPCWSTR, lpString2)
280{
281 register LPWSTR s1;
282
283 while (*lpString1)
284 {
285 for (s1 = (LPWSTR)lpString2;
286 *s1 && *s1 != *lpString1;
287 s1++)
288 /* empty */
289 ;
290
291 if (*s1)
292 return (LPWSTR)lpString1;
293
294 lpString1++;
295 }
296
297 return (LPWSTR)NULL;
298}
299
300
301/*************************************************************************
302 * StrRStrIA [SHLWAPI]
303 */
304LPSTR WINAPI StrRStrIA(LPCSTR lpFirst, LPCSTR lpSrch, LPCSTR unknown)
305{
306 INT iLen = lstrlenA(lpFirst) - lstrlenA(lpSrch);
307
308 dprintf(("StrRStrIA %x %x %x NOT IMPLEMENTED correctly", lpFirst, lpSrch, unknown));
309
310 // lpSrch cannot fit into lpFirst
311 if (iLen < 0)
312 return (LPSTR)NULL;
313
314 LPSTR lpThis = (LPSTR)lpFirst + iLen;
315
316 while (lpThis >= lpFirst)
317 {
318 LPCSTR p1 = lpThis, p2 = lpSrch;
319 while (*p1 && *p2 && toupper(*p1) == toupper(*p2)) { p1++; p2++; }
320 if (!*p2) return (LPSTR)lpThis;
321 lpThis--;
322 }
323
324 return NULL;
325}
326
327
328/*************************************************************************
329 * StrRStrIW [SHLWAPI]
330 */
331LPWSTR WINAPI StrRStrIW(LPCWSTR lpFirst, LPCWSTR lpSrch, LPCWSTR unknown)
332{
333 INT iLen = lstrlenW(lpFirst) - lstrlenW(lpSrch);
334
335 dprintf(("StrRStrIA %x %x %x NOT IMPLEMENTED correctly", lpFirst, lpSrch, unknown));
336
337 // lpSrch cannot fit into lpFirst
338 if (iLen < 0)
339 return (LPWSTR)NULL;
340
341 LPWSTR lpThis = (LPWSTR)lpFirst + iLen;
342
343 while (lpThis >= lpFirst)
344 {
345 LPCWSTR p1 = lpThis, p2 = lpSrch;
346 while (*p1 && *p2 && toupperW(*p1) == toupperW(*p2)) { p1++; p2++; }
347 if (!*p2) return (LPWSTR)lpThis;
348 lpThis--;
349 }
350
351 return NULL;
352}
Note: See TracBrowser for help on using the repository browser.