1 | /* $Id: string.cpp,v 1.1 2000-05-15 02:43:17 phaller 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.h"
|
---|
63 |
|
---|
64 | /*****************************************************************************
|
---|
65 | * Local Variables *
|
---|
66 | *****************************************************************************/
|
---|
67 |
|
---|
68 | ODINDEBUGCHANNEL(SHLWAPI-STRING)
|
---|
69 |
|
---|
70 |
|
---|
71 |
|
---|
72 | /*************************************************************************
|
---|
73 | * OleStrToStrN [SHELL32.78]
|
---|
74 | */
|
---|
75 | BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
---|
76 | {
|
---|
77 | TRACE("%p %x %s %x\n", lpStr, nStr, debugstr_w(lpOle), nOle);
|
---|
78 | return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
---|
79 | }
|
---|
80 |
|
---|
81 | BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
---|
82 | {
|
---|
83 | TRACE("%p %x %s %x\n", lpwStr, nwStr, debugstr_w(lpOle), nOle);
|
---|
84 |
|
---|
85 | if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
---|
86 | { return lstrlenW (lpwStr);
|
---|
87 | }
|
---|
88 | return 0;
|
---|
89 | }
|
---|
90 |
|
---|
91 | BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
---|
92 | {
|
---|
93 | if (VERSION_OsIsUnicode())
|
---|
94 | return OleStrToStrNW ((LPWSTR)lpOut, nOut, (LPCWSTR)lpIn, nIn);
|
---|
95 | return OleStrToStrNA ((LPSTR)lpOut, nOut, (LPCWSTR)lpIn, nIn);
|
---|
96 | }
|
---|
97 |
|
---|
98 | /*************************************************************************
|
---|
99 | * StrToOleStrN [SHELL32.79]
|
---|
100 | * lpMulti, nMulti, nWide [IN]
|
---|
101 | * lpWide [OUT]
|
---|
102 | */
|
---|
103 | BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
---|
104 | {
|
---|
105 | TRACE("%p %x %s %x\n", lpWide, nWide, lpStrA, nStr);
|
---|
106 | return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
|
---|
107 | }
|
---|
108 | BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
---|
109 | {
|
---|
110 | TRACE("%p %x %s %x\n", lpWide, nWide, debugstr_w(lpStrW), nStr);
|
---|
111 |
|
---|
112 | if (lstrcpynW (lpWide, lpStrW, nWide))
|
---|
113 | { return lstrlenW (lpWide);
|
---|
114 | }
|
---|
115 | return 0;
|
---|
116 | }
|
---|
117 |
|
---|
118 | BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
---|
119 | {
|
---|
120 | if (VERSION_OsIsUnicode())
|
---|
121 | return StrToOleStrNW (lpWide, nWide, (LPWSTR)lpStr, nStr);
|
---|
122 | return StrToOleStrNA (lpWide, nWide, (LPSTR)lpStr, nStr);
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|
126 | /*************************************************************************
|
---|
127 | * StrRetToStrN [SHELL32.96]
|
---|
128 | *
|
---|
129 | * converts a STRRET to a normal string
|
---|
130 | *
|
---|
131 | * NOTES
|
---|
132 | * the pidl is for STRRET OFFSET
|
---|
133 | */
|
---|
134 | HRESULT WINAPI StrRetToBufA (LPSTRRET src, LPITEMIDLIST pidl, LPSTR dest, DWORD len)
|
---|
135 | {
|
---|
136 | return StrRetToStrNA(dest, len, src, pidl);
|
---|
137 | }
|
---|
138 |
|
---|
139 | HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
|
---|
140 | {
|
---|
141 | TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
|
---|
142 |
|
---|
143 | switch (src->uType)
|
---|
144 | {
|
---|
145 | case STRRET_WSTR:
|
---|
146 | WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
|
---|
147 | SHFree(src->u.pOleStr);
|
---|
148 | break;
|
---|
149 |
|
---|
150 | case STRRET_CSTRA:
|
---|
151 | lstrcpynA((LPSTR)dest, src->u.cStr, len);
|
---|
152 | break;
|
---|
153 |
|
---|
154 | case STRRET_OFFSETA:
|
---|
155 | lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
---|
156 | break;
|
---|
157 |
|
---|
158 | default:
|
---|
159 | FIXME("unknown type!\n");
|
---|
160 | if (len)
|
---|
161 | {
|
---|
162 | *(LPSTR)dest = '\0';
|
---|
163 | }
|
---|
164 | return(FALSE);
|
---|
165 | }
|
---|
166 | return S_OK;
|
---|
167 | }
|
---|
168 |
|
---|
169 | HRESULT WINAPI StrRetToBufW (LPSTRRET src, LPITEMIDLIST pidl, LPWSTR dest, DWORD len)
|
---|
170 | {
|
---|
171 | return StrRetToStrNW(dest, len, src, pidl);
|
---|
172 | }
|
---|
173 |
|
---|
174 | HRESULT WINAPI StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
|
---|
175 | {
|
---|
176 | TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
|
---|
177 |
|
---|
178 | switch (src->uType)
|
---|
179 | {
|
---|
180 | case STRRET_WSTR:
|
---|
181 | lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
|
---|
182 | SHFree(src->u.pOleStr);
|
---|
183 | break;
|
---|
184 |
|
---|
185 | case STRRET_CSTRA:
|
---|
186 | lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
|
---|
187 | break;
|
---|
188 |
|
---|
189 | case STRRET_OFFSETA:
|
---|
190 | if (pidl)
|
---|
191 | {
|
---|
192 | lstrcpynAtoW((LPWSTR)dest, ((LPSTR)&pidl->mkid)+src->u.uOffset, len);
|
---|
193 | }
|
---|
194 | break;
|
---|
195 |
|
---|
196 | default:
|
---|
197 | FIXME("unknown type!\n");
|
---|
198 | if (len)
|
---|
199 | { *(LPSTR)dest = '\0';
|
---|
200 | }
|
---|
201 | return(FALSE);
|
---|
202 | }
|
---|
203 | return S_OK;
|
---|
204 | }
|
---|
205 | HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
|
---|
206 | {
|
---|
207 | if(VERSION_OsIsUnicode())
|
---|
208 | return StrRetToStrNW (dest, len, src, pidl);
|
---|
209 | return StrRetToStrNA (dest, len, src, pidl);
|
---|
210 | }
|
---|
211 |
|
---|
212 | /*************************************************************************
|
---|
213 | * StrChrA [NT 4.0:SHELL32.651]
|
---|
214 | *
|
---|
215 | */
|
---|
216 | LPSTR WINAPI StrChrA (LPSTR str, CHAR x )
|
---|
217 | { LPSTR ptr=str;
|
---|
218 |
|
---|
219 | do
|
---|
220 | { if (*ptr==x)
|
---|
221 | { return ptr;
|
---|
222 | }
|
---|
223 | ptr++;
|
---|
224 | } while (*ptr);
|
---|
225 | return NULL;
|
---|
226 | }
|
---|
227 |
|
---|
228 | /*************************************************************************
|
---|
229 | * StrChrW [NT 4.0:SHELL32.651]
|
---|
230 | *
|
---|
231 | */
|
---|
232 | LPWSTR WINAPI StrChrW (LPWSTR str, WCHAR x )
|
---|
233 | { LPWSTR ptr=str;
|
---|
234 |
|
---|
235 | TRACE("%s 0x%04x\n",debugstr_w(str),x);
|
---|
236 | do
|
---|
237 | { if (*ptr==x)
|
---|
238 | { return ptr;
|
---|
239 | }
|
---|
240 | ptr++;
|
---|
241 | } while (*ptr);
|
---|
242 | return NULL;
|
---|
243 | }
|
---|
244 |
|
---|
245 | /*************************************************************************
|
---|
246 | * StrCmpNIW [NT 4.0:SHELL32.*]
|
---|
247 | *
|
---|
248 | */
|
---|
249 | INT WINAPI StrCmpNIW ( LPWSTR wstr1, LPWSTR wstr2, INT len)
|
---|
250 | { FIXME("%s %s %i stub\n", debugstr_w(wstr1),debugstr_w(wstr2),len);
|
---|
251 | return 0;
|
---|
252 | }
|
---|
253 |
|
---|
254 | /*************************************************************************
|
---|
255 | * StrCmpNIA [NT 4.0:SHELL32.*]
|
---|
256 | *
|
---|
257 | */
|
---|
258 | INT WINAPI StrCmpNIA ( LPSTR wstr1, LPSTR wstr2, INT len)
|
---|
259 | { FIXME("%s %s %i stub\n", wstr1,wstr2,len);
|
---|
260 | return 0;
|
---|
261 | }
|
---|
262 |
|
---|
263 |
|
---|
264 | /*************************************************************************
|
---|
265 | * StrRChrA [SHELL32.346]
|
---|
266 | *
|
---|
267 | */
|
---|
268 | LPSTR WINAPI StrRChrA(LPCSTR lpStart, LPCSTR lpEnd, DWORD wMatch)
|
---|
269 | {
|
---|
270 | if (!lpStart)
|
---|
271 | return NULL;
|
---|
272 |
|
---|
273 | /* if the end not given, search*/
|
---|
274 | if (!lpEnd)
|
---|
275 | { lpEnd=lpStart;
|
---|
276 | while (*lpEnd)
|
---|
277 | lpEnd++;
|
---|
278 | }
|
---|
279 |
|
---|
280 | for (--lpEnd;lpStart <= lpEnd; lpEnd--)
|
---|
281 | if (*lpEnd==(char)wMatch)
|
---|
282 | return (LPSTR)lpEnd;
|
---|
283 |
|
---|
284 | return NULL;
|
---|
285 | }
|
---|
286 | /*************************************************************************
|
---|
287 | * StrRChrW [SHELL32.320]
|
---|
288 | *
|
---|
289 | */
|
---|
290 | LPWSTR WINAPI StrRChrW(LPWSTR lpStart, LPWSTR lpEnd, DWORD wMatch)
|
---|
291 | { LPWSTR wptr=NULL;
|
---|
292 | TRACE("%s %s 0x%04x\n",debugstr_w(lpStart),debugstr_w(lpEnd), (WCHAR)wMatch );
|
---|
293 |
|
---|
294 | /* if the end not given, search*/
|
---|
295 | if (!lpEnd)
|
---|
296 | { lpEnd=lpStart;
|
---|
297 | while (*lpEnd)
|
---|
298 | lpEnd++;
|
---|
299 | }
|
---|
300 |
|
---|
301 | do
|
---|
302 | { if (*lpStart==(WCHAR)wMatch)
|
---|
303 | wptr = lpStart;
|
---|
304 | lpStart++;
|
---|
305 | } while ( lpStart<=lpEnd );
|
---|
306 | return wptr;
|
---|
307 | }
|
---|
308 |
|
---|
309 | /*************************************************************************
|
---|
310 | * StrFormatByteSize [SHLWAPI]
|
---|
311 | */
|
---|
312 | LPSTR WINAPI StrFormatByteSizeA ( DWORD dw, LPSTR pszBuf, UINT cchBuf )
|
---|
313 | { char buf[64];
|
---|
314 | TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
|
---|
315 | if ( dw<1024L )
|
---|
316 | { sprintf (buf,"%3.0f bytes", (FLOAT)dw);
|
---|
317 | }
|
---|
318 | else if ( dw<1048576L)
|
---|
319 | { sprintf (buf,"%3.2f KB", (FLOAT)dw/1024);
|
---|
320 | }
|
---|
321 | else if ( dw < 1073741824L)
|
---|
322 | { sprintf (buf,"%3.2f MB", (FLOAT)dw/1048576L);
|
---|
323 | }
|
---|
324 | else
|
---|
325 | { sprintf (buf,"%3.2f GB", (FLOAT)dw/1073741824L);
|
---|
326 | }
|
---|
327 | lstrcpynA (pszBuf, buf, cchBuf);
|
---|
328 | return pszBuf;
|
---|
329 | }
|
---|
330 | LPWSTR WINAPI StrFormatByteSizeW ( DWORD dw, LPWSTR pszBuf, UINT cchBuf )
|
---|
331 | { char buf[64];
|
---|
332 | TRACE("%lx %p %i\n", dw, pszBuf, cchBuf);
|
---|
333 | if ( dw<1024L )
|
---|
334 | { sprintf (buf,"%3.0f bytes", (FLOAT)dw);
|
---|
335 | }
|
---|
336 | else if ( dw<1048576L)
|
---|
337 | { sprintf (buf,"%3.2f KB", (FLOAT)dw/1024);
|
---|
338 | }
|
---|
339 | else if ( dw < 1073741824L)
|
---|
340 | { sprintf (buf,"%3.2f MB", (FLOAT)dw/1048576L);
|
---|
341 | }
|
---|
342 | else
|
---|
343 | { sprintf (buf,"%3.2f GB", (FLOAT)dw/1073741824L);
|
---|
344 | }
|
---|
345 | lstrcpynAtoW (pszBuf, buf, cchBuf);
|
---|
346 | return pszBuf;
|
---|
347 | }
|
---|
348 |
|
---|
349 |
|
---|
350 | /************************************************************************
|
---|
351 | * StrToOleStr [SHELL32.163]
|
---|
352 | *
|
---|
353 | */
|
---|
354 | int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
---|
355 | {
|
---|
356 | TRACE("%p %p(%s)\n",
|
---|
357 | lpWideCharStr, lpMultiByteString, lpMultiByteString);
|
---|
358 |
|
---|
359 | return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
---|
360 |
|
---|
361 | }
|
---|
362 | int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
---|
363 | {
|
---|
364 | TRACE("%p %p(%s)\n",
|
---|
365 | lpWideCharStr, lpWString, debugstr_w(lpWString));
|
---|
366 |
|
---|
367 | if (lstrcpyW (lpWideCharStr, lpWString ))
|
---|
368 | { return lstrlenW (lpWideCharStr);
|
---|
369 | }
|
---|
370 | return 0;
|
---|
371 | }
|
---|
372 |
|
---|
373 | BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
---|
374 | {
|
---|
375 | if (VERSION_OsIsUnicode())
|
---|
376 | return StrToOleStrW (lpWideCharStr, (LPCWSTR)lpString);
|
---|
377 | return StrToOleStrA (lpWideCharStr, (LPCSTR)lpString);
|
---|
378 | }
|
---|
379 |
|
---|
380 |
|
---|
381 |
|
---|
382 | /*****************************************************************************
|
---|
383 | * Name : StrChrIA
|
---|
384 | * Purpose : Searches a string for the first occurrence of a character that
|
---|
385 | * matches the specified character. The comparison is not case sensitive.
|
---|
386 | * Parameters: LPCSTR lpStart Address of the string to be searched.
|
---|
387 | * TCHAR wMatch Character to be used for comparison.
|
---|
388 | * Variables :
|
---|
389 | * Result : Returns the address of the first occurrence of the character in
|
---|
390 | * the string if successful, or NULL otherwise.
|
---|
391 | * Remark : SHELL32.
|
---|
392 | * Status : UNTESTED UNKNOWN
|
---|
393 | *
|
---|
394 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
395 | *****************************************************************************/
|
---|
396 |
|
---|
397 | ODINFUNCTION2(LPSTR, StrChrIA,
|
---|
398 | LPCSTR, lpStart,
|
---|
399 | CHAR, wMatch)
|
---|
400 | {
|
---|
401 | LPSTR lpRes;
|
---|
402 |
|
---|
403 | wMatch = tolower(wMatch);
|
---|
404 | lpRes = strchr(lpStart, wMatch); // lower case comparsion
|
---|
405 | if (NULL == lpRes)
|
---|
406 | {
|
---|
407 | wMatch = toupper(wMatch);
|
---|
408 | lpRes = strchr(lpStart, wMatch); // upper case comparsion
|
---|
409 | }
|
---|
410 |
|
---|
411 | return lpRes;
|
---|
412 | }
|
---|
413 |
|
---|
414 |
|
---|
415 | /*****************************************************************************
|
---|
416 | * Name : StrChrIW
|
---|
417 | * Purpose : Searches a string for the first occurrence of a character that
|
---|
418 | * matches the specified character. The comparison is not case sensitive.
|
---|
419 | * Parameters: LPCSTR lpStart Address of the string to be searched.
|
---|
420 | * TCHAR wMatch Character to be used for comparison.
|
---|
421 | * Variables :
|
---|
422 | * Result : Returns the address of the first occurrence of the character in
|
---|
423 | * the string if successful, or NULL otherwise.
|
---|
424 | * Remark : SHELL32.
|
---|
425 | * Status : UNTESTED UNKNOWN
|
---|
426 | *
|
---|
427 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
428 | *****************************************************************************/
|
---|
429 |
|
---|
430 | ODINFUNCTION2(LPWSTR, StrChrIW,
|
---|
431 | LPCWSTR, lpStart,
|
---|
432 | WCHAR, wMatch)
|
---|
433 | {
|
---|
434 | LPWSTR lpRes;
|
---|
435 |
|
---|
436 | wMatch = towlower(wMatch);
|
---|
437 | lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // lower case comparsion
|
---|
438 | if (NULL == lpRes)
|
---|
439 | {
|
---|
440 | wMatch = towupper(wMatch);
|
---|
441 | lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // upper case comparsion
|
---|
442 | }
|
---|
443 |
|
---|
444 | return lpRes;
|
---|
445 | }
|
---|
446 |
|
---|
447 |
|
---|
448 | /*****************************************************************************
|
---|
449 | * Name : StrStrIA
|
---|
450 | * Purpose : Finds the first occurrence of a substring within a string. The
|
---|
451 | * comparison is not case sensitive.
|
---|
452 | * Parameters: LPCSTR lpFirst
|
---|
453 | * LPCSTR lpSrch
|
---|
454 | * Variables :
|
---|
455 | * Result : Returns the address of the first occurrence of the matching
|
---|
456 | * substring if successful, or NULL otherwise.
|
---|
457 | * Remark : SHELL32.
|
---|
458 | * Status : UNTESTED UNKNOWN
|
---|
459 | *
|
---|
460 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
461 | *****************************************************************************/
|
---|
462 |
|
---|
463 | ODINFUNCTION2(LPSTR, StrStrIA,
|
---|
464 | LPCSTR, lpFirst,
|
---|
465 | LPCSTR, lpSrch)
|
---|
466 | {
|
---|
467 | char ch = lpSrch[0]; // look for 1st character
|
---|
468 | LONG lLen = lstrlenA(lpSrch); // length of search string
|
---|
469 | int iRes; // comparsion result
|
---|
470 |
|
---|
471 | do
|
---|
472 | {
|
---|
473 | lpFirst = StrChrIA(lpFirst, // find first matching character
|
---|
474 | ch);
|
---|
475 | if (NULL == lpFirst) // not found
|
---|
476 | return NULL;
|
---|
477 |
|
---|
478 | iRes = StrCmpNIA((LPSTR)lpFirst, // compare search string
|
---|
479 | (LPSTR)lpSrch,
|
---|
480 | lLen);
|
---|
481 |
|
---|
482 | if (0 == iRes) // Found!
|
---|
483 | return (LPSTR)lpFirst;
|
---|
484 |
|
---|
485 | lpFirst = CharNextA(lpFirst); // skip to next character
|
---|
486 | }
|
---|
487 | while (*lpFirst != 0); // safe termination
|
---|
488 |
|
---|
489 | return NULL; // default result
|
---|
490 | }
|
---|
491 |
|
---|
492 |
|
---|
493 |
|
---|
494 | /*****************************************************************************
|
---|
495 | * Name : StrStrIW
|
---|
496 | * Purpose : Finds the first occurrence of a substring within a string. The
|
---|
497 | * comparison is not case sensitive.
|
---|
498 | * Parameters: LPCWSTR lpFirst
|
---|
499 | * LPCWSTR lpSrch
|
---|
500 | * Variables :
|
---|
501 | * Result : Returns the address of the first occurrence of the matching
|
---|
502 | * substring if successful, or NULL otherwise.
|
---|
503 | * Remark : SHELL32.
|
---|
504 | * Status : UNTESTED UNKNOWN
|
---|
505 | *
|
---|
506 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
507 | *****************************************************************************/
|
---|
508 |
|
---|
509 | ODINFUNCTION2(LPWSTR, StrStrIW,
|
---|
510 | LPCWSTR, lpFirst,
|
---|
511 | LPCWSTR, lpSrch)
|
---|
512 | {
|
---|
513 | WCHAR ch = lpSrch[0]; // look for 1st character
|
---|
514 | LONG lLen = lstrlenW(lpSrch); // length of search string
|
---|
515 | int iRes; // comparsion result
|
---|
516 |
|
---|
517 | do
|
---|
518 | {
|
---|
519 | lpFirst = StrChrIW(lpFirst, // find first matching character
|
---|
520 | ch);
|
---|
521 | if (NULL == lpFirst) // not found
|
---|
522 | return NULL;
|
---|
523 |
|
---|
524 | iRes = StrCmpNIW((LPWSTR)lpFirst, // compare search string
|
---|
525 | (LPWSTR)lpSrch,
|
---|
526 | lLen);
|
---|
527 |
|
---|
528 | if (0 == iRes) // Found!
|
---|
529 | return (LPWSTR)lpFirst;
|
---|
530 |
|
---|
531 | lpFirst = CharNextW(lpFirst); // skip to next character
|
---|
532 | }
|
---|
533 | while (*lpFirst != 0); // safe termination
|
---|
534 |
|
---|
535 | return NULL; // default result
|
---|
536 | }
|
---|
537 |
|
---|
538 |
|
---|
539 |
|
---|
540 | /*****************************************************************************
|
---|
541 | * Name : StrToIntA
|
---|
542 | * Purpose : convert string to integer (used by explorer.exe)
|
---|
543 | * Parameters: Unknown (wrong)
|
---|
544 | * Variables :
|
---|
545 | * Result : Unknown
|
---|
546 | * Remark :
|
---|
547 | * Status : UNTESTED STUB
|
---|
548 | *
|
---|
549 | * Author : Christoph Bratschi [Wed, 2000/03/29 19:47]
|
---|
550 | *****************************************************************************/
|
---|
551 |
|
---|
552 | ODINFUNCTION1(INT,StrToIntA,LPSTR,pszPath)
|
---|
553 | {
|
---|
554 | dprintf(("not implemented"));
|
---|
555 |
|
---|
556 | return NULL;
|
---|
557 | }
|
---|