1 | /* $Id: string_odin.cpp,v 1.1 2000-08-24 09:32:44 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 |
|
---|
69 | ODINDEBUGCHANNEL(SHLWAPI-STRING)
|
---|
70 |
|
---|
71 |
|
---|
72 | /*****************************************************************************
|
---|
73 | * Name : ChrCmpIA
|
---|
74 | * Purpose :
|
---|
75 | * Parameters:
|
---|
76 | * Variables :
|
---|
77 | * Result :
|
---|
78 | * Remark :
|
---|
79 | * Status : PARTIALLY IMPLEMENTED UNTESTED
|
---|
80 | *
|
---|
81 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
82 | *****************************************************************************/
|
---|
83 |
|
---|
84 | ODINFUNCTION2(INT, ChrCmpIA,
|
---|
85 | INT, ch1,
|
---|
86 | INT, ch2)
|
---|
87 | {
|
---|
88 | // Note: IsDBCSLeadByte ignored !
|
---|
89 |
|
---|
90 | if ( (ch1 >= 'A') && (ch1 <= 'Z') ) ch1 |= 0x20;
|
---|
91 | if ( (ch2 >= 'A') && (ch2 <= 'Z') ) ch2 |= 0x20;
|
---|
92 |
|
---|
93 | return ch1 - ch2;
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | /*************************************************************************
|
---|
98 | * OleStrToStrN [SHELL32.78]
|
---|
99 | */
|
---|
100 | BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
---|
101 | {
|
---|
102 | TRACE("%p %x %s %x\n", lpStr, nStr, debugstr_w(lpOle), nOle);
|
---|
103 | return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
---|
104 | }
|
---|
105 |
|
---|
106 | BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
---|
107 | {
|
---|
108 | TRACE("%p %x %s %x\n", lpwStr, nwStr, debugstr_w(lpOle), nOle);
|
---|
109 |
|
---|
110 | if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
---|
111 | { return lstrlenW (lpwStr);
|
---|
112 | }
|
---|
113 | return 0;
|
---|
114 | }
|
---|
115 |
|
---|
116 | BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
---|
117 | {
|
---|
118 | if (VERSION_OsIsUnicode())
|
---|
119 | return OleStrToStrNW ((LPWSTR)lpOut, nOut, (LPCWSTR)lpIn, nIn);
|
---|
120 | return OleStrToStrNA ((LPSTR)lpOut, nOut, (LPCWSTR)lpIn, nIn);
|
---|
121 | }
|
---|
122 |
|
---|
123 | /*************************************************************************
|
---|
124 | * StrToOleStrN [SHELL32.79]
|
---|
125 | * lpMulti, nMulti, nWide [IN]
|
---|
126 | * lpWide [OUT]
|
---|
127 | */
|
---|
128 | BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
---|
129 | {
|
---|
130 | TRACE("%p %x %s %x\n", lpWide, nWide, lpStrA, nStr);
|
---|
131 | return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
|
---|
132 | }
|
---|
133 | BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
---|
134 | {
|
---|
135 | TRACE("%p %x %s %x\n", lpWide, nWide, debugstr_w(lpStrW), nStr);
|
---|
136 |
|
---|
137 | if (lstrcpynW (lpWide, lpStrW, nWide))
|
---|
138 | { return lstrlenW (lpWide);
|
---|
139 | }
|
---|
140 | return 0;
|
---|
141 | }
|
---|
142 |
|
---|
143 | BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
---|
144 | {
|
---|
145 | if (VERSION_OsIsUnicode())
|
---|
146 | return StrToOleStrNW (lpWide, nWide, (LPWSTR)lpStr, nStr);
|
---|
147 | return StrToOleStrNA (lpWide, nWide, (LPSTR)lpStr, nStr);
|
---|
148 | }
|
---|
149 |
|
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 | /************************************************************************
|
---|
154 | * StrToOleStr [SHELL32.163]
|
---|
155 | *
|
---|
156 | */
|
---|
157 | int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
---|
158 | {
|
---|
159 | TRACE("%p %p(%s)\n",
|
---|
160 | lpWideCharStr, lpMultiByteString, lpMultiByteString);
|
---|
161 |
|
---|
162 | return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
---|
163 |
|
---|
164 | }
|
---|
165 | int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
---|
166 | {
|
---|
167 | TRACE("%p %p(%s)\n",
|
---|
168 | lpWideCharStr, lpWString, debugstr_w(lpWString));
|
---|
169 |
|
---|
170 | if (lstrcpyW (lpWideCharStr, lpWString ))
|
---|
171 | { return lstrlenW (lpWideCharStr);
|
---|
172 | }
|
---|
173 | return 0;
|
---|
174 | }
|
---|
175 |
|
---|
176 | BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
---|
177 | {
|
---|
178 | if (VERSION_OsIsUnicode())
|
---|
179 | return StrToOleStrW (lpWideCharStr, (LPCWSTR)lpString);
|
---|
180 | return StrToOleStrA (lpWideCharStr, (LPCSTR)lpString);
|
---|
181 | }
|
---|
182 |
|
---|
183 |
|
---|
184 |
|
---|
185 | /*****************************************************************************
|
---|
186 | * Name : StrChrIA
|
---|
187 | * Purpose : Searches a string for the first occurrence of a character that
|
---|
188 | * matches the specified character. The comparison is not case sensitive.
|
---|
189 | * Parameters: LPCSTR lpStart Address of the string to be searched.
|
---|
190 | * TCHAR wMatch Character to be used for comparison.
|
---|
191 | * Variables :
|
---|
192 | * Result : Returns the address of the first occurrence of the character in
|
---|
193 | * the string if successful, or NULL otherwise.
|
---|
194 | * Remark : SHELL32.
|
---|
195 | * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
|
---|
196 | *
|
---|
197 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
198 | *****************************************************************************/
|
---|
199 |
|
---|
200 | ODINFUNCTION2(LPSTR, StrChrIA,
|
---|
201 | LPCSTR, lpStart,
|
---|
202 | CHAR, wMatch)
|
---|
203 | {
|
---|
204 | LPSTR lpRes;
|
---|
205 |
|
---|
206 | wMatch = tolower(wMatch);
|
---|
207 | lpRes = strchr(lpStart, wMatch); // lower case comparsion
|
---|
208 | if (NULL == lpRes)
|
---|
209 | {
|
---|
210 | wMatch = toupper(wMatch);
|
---|
211 | lpRes = strchr(lpStart, wMatch); // upper case comparsion
|
---|
212 | }
|
---|
213 |
|
---|
214 | return lpRes;
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 | /*****************************************************************************
|
---|
219 | * Name : StrChrIW
|
---|
220 | * Purpose : Searches a string for the first occurrence of a character that
|
---|
221 | * matches the specified character. The comparison is not case sensitive.
|
---|
222 | * Parameters: LPCSTR lpStart Address of the string to be searched.
|
---|
223 | * TCHAR wMatch Character to be used for comparison.
|
---|
224 | * Variables :
|
---|
225 | * Result : Returns the address of the first occurrence of the character in
|
---|
226 | * the string if successful, or NULL otherwise.
|
---|
227 | * Remark : SHELL32.
|
---|
228 | * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
|
---|
229 | *
|
---|
230 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
231 | *****************************************************************************/
|
---|
232 |
|
---|
233 | ODINFUNCTION2(LPWSTR, StrChrIW,
|
---|
234 | LPCWSTR, lpStart,
|
---|
235 | WCHAR, wMatch)
|
---|
236 | {
|
---|
237 | LPWSTR lpRes;
|
---|
238 |
|
---|
239 | wMatch = towlower(wMatch);
|
---|
240 | lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // lower case comparsion
|
---|
241 | if (NULL == lpRes)
|
---|
242 | {
|
---|
243 | wMatch = towupper(wMatch);
|
---|
244 | lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // upper case comparsion
|
---|
245 | }
|
---|
246 |
|
---|
247 | return lpRes;
|
---|
248 | }
|
---|
249 |
|
---|
250 |
|
---|
251 | /*****************************************************************************
|
---|
252 | * Name : StrStrIA
|
---|
253 | * Purpose : Finds the first occurrence of a substring within a string. The
|
---|
254 | * comparison is not case sensitive.
|
---|
255 | * Parameters: LPCSTR lpFirst
|
---|
256 | * LPCSTR lpSrch
|
---|
257 | * Variables :
|
---|
258 | * Result : Returns the address of the first occurrence of the matching
|
---|
259 | * substring if successful, or NULL otherwise.
|
---|
260 | * Remark : SHELL32.
|
---|
261 | * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
|
---|
262 | *
|
---|
263 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
264 | *****************************************************************************/
|
---|
265 |
|
---|
266 | ODINFUNCTION2(LPSTR, StrStrIA,
|
---|
267 | LPCSTR, lpFirst,
|
---|
268 | LPCSTR, lpSrch)
|
---|
269 | {
|
---|
270 | char ch = lpSrch[0]; // look for 1st character
|
---|
271 | LONG lLen = lstrlenA(lpSrch); // length of search string
|
---|
272 | int iRes; // comparsion result
|
---|
273 |
|
---|
274 | do
|
---|
275 | {
|
---|
276 | lpFirst = StrChrIA(lpFirst, // find first matching character
|
---|
277 | ch);
|
---|
278 | if (NULL == lpFirst) // not found
|
---|
279 | return NULL;
|
---|
280 |
|
---|
281 | iRes = StrCmpNIA((LPSTR)lpFirst, // compare search string
|
---|
282 | (LPSTR)lpSrch,
|
---|
283 | lLen);
|
---|
284 |
|
---|
285 | if (0 == iRes) // Found!
|
---|
286 | return (LPSTR)lpFirst;
|
---|
287 |
|
---|
288 | lpFirst = CharNextA(lpFirst); // skip to next character
|
---|
289 | }
|
---|
290 | while (*lpFirst != 0); // safe termination
|
---|
291 |
|
---|
292 | return NULL; // default result
|
---|
293 | }
|
---|
294 |
|
---|
295 |
|
---|
296 |
|
---|
297 | /*****************************************************************************
|
---|
298 | * Name : StrStrIW
|
---|
299 | * Purpose : Finds the first occurrence of a substring within a string. The
|
---|
300 | * comparison is not case sensitive.
|
---|
301 | * Parameters: LPCWSTR lpFirst
|
---|
302 | * LPCWSTR lpSrch
|
---|
303 | * Variables :
|
---|
304 | * Result : Returns the address of the first occurrence of the matching
|
---|
305 | * substring if successful, or NULL otherwise.
|
---|
306 | * Remark : SHELL32.
|
---|
307 | * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
|
---|
308 | *
|
---|
309 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
310 | *****************************************************************************/
|
---|
311 |
|
---|
312 | ODINFUNCTION2(LPWSTR, StrStrIW,
|
---|
313 | LPCWSTR, lpFirst,
|
---|
314 | LPCWSTR, lpSrch)
|
---|
315 | {
|
---|
316 | WCHAR ch = lpSrch[0]; // look for 1st character
|
---|
317 | LONG lLen = lstrlenW(lpSrch); // length of search string
|
---|
318 | int iRes; // comparsion result
|
---|
319 |
|
---|
320 | do
|
---|
321 | {
|
---|
322 | lpFirst = StrChrIW(lpFirst, // find first matching character
|
---|
323 | ch);
|
---|
324 | if (NULL == lpFirst) // not found
|
---|
325 | return NULL;
|
---|
326 |
|
---|
327 | iRes = StrCmpNIW((LPWSTR)lpFirst, // compare search string
|
---|
328 | (LPWSTR)lpSrch,
|
---|
329 | lLen);
|
---|
330 |
|
---|
331 | if (0 == iRes) // Found!
|
---|
332 | return (LPWSTR)lpFirst;
|
---|
333 |
|
---|
334 | lpFirst = CharNextW(lpFirst); // skip to next character
|
---|
335 | }
|
---|
336 | while (*lpFirst != 0); // safe termination
|
---|
337 |
|
---|
338 | return NULL; // default result
|
---|
339 | }
|
---|
340 |
|
---|
341 |
|
---|
342 |
|
---|
343 |
|
---|
344 |
|
---|
345 |
|
---|
346 | /*****************************************************************************
|
---|
347 | * Name : StrCpyA
|
---|
348 | * Purpose : copy a string
|
---|
349 | * Parameters:
|
---|
350 | * Variables :
|
---|
351 | * Result :
|
---|
352 | * Remark : not exported ?
|
---|
353 | * Status : UNTESTED
|
---|
354 | *
|
---|
355 | * Author :
|
---|
356 | *****************************************************************************/
|
---|
357 |
|
---|
358 | ODINFUNCTIONNODBG2(LPSTR, StrCpyA,
|
---|
359 | LPSTR, lpDest,
|
---|
360 | LPCSTR, lpSource)
|
---|
361 | {
|
---|
362 | return lstrcpyA(lpDest,
|
---|
363 | lpSource);
|
---|
364 | }
|
---|
365 |
|
---|
366 |
|
---|
367 |
|
---|
368 |
|
---|