1 | /* $Id: string_odin.cpp,v 1.3 2001-07-20 15:37:53 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 | #if 0
|
---|
98 | /*************************************************************************
|
---|
99 | * OleStrToStrN [SHELL32.78]
|
---|
100 | */
|
---|
101 | BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
---|
102 | {
|
---|
103 | TRACE("%p %x %s %x\n", lpStr, nStr, debugstr_w(lpOle), nOle);
|
---|
104 | return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
---|
105 | }
|
---|
106 |
|
---|
107 | BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
---|
108 | {
|
---|
109 | TRACE("%p %x %s %x\n", lpwStr, nwStr, debugstr_w(lpOle), nOle);
|
---|
110 |
|
---|
111 | if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
---|
112 | { return lstrlenW (lpwStr);
|
---|
113 | }
|
---|
114 | return 0;
|
---|
115 | }
|
---|
116 |
|
---|
117 | BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
---|
118 | {
|
---|
119 | if (VERSION_OsIsUnicode())
|
---|
120 | return OleStrToStrNW ((LPWSTR)lpOut, nOut, (LPCWSTR)lpIn, nIn);
|
---|
121 | return OleStrToStrNA ((LPSTR)lpOut, nOut, (LPCWSTR)lpIn, nIn);
|
---|
122 | }
|
---|
123 |
|
---|
124 | /*************************************************************************
|
---|
125 | * StrToOleStrN [SHELL32.79]
|
---|
126 | * lpMulti, nMulti, nWide [IN]
|
---|
127 | * lpWide [OUT]
|
---|
128 | */
|
---|
129 | BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
---|
130 | {
|
---|
131 | TRACE("%p %x %s %x\n", lpWide, nWide, lpStrA, nStr);
|
---|
132 | return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
|
---|
133 | }
|
---|
134 | BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
---|
135 | {
|
---|
136 | TRACE("%p %x %s %x\n", lpWide, nWide, debugstr_w(lpStrW), nStr);
|
---|
137 |
|
---|
138 | if (lstrcpynW (lpWide, lpStrW, nWide))
|
---|
139 | { return lstrlenW (lpWide);
|
---|
140 | }
|
---|
141 | return 0;
|
---|
142 | }
|
---|
143 |
|
---|
144 | BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
---|
145 | {
|
---|
146 | if (VERSION_OsIsUnicode())
|
---|
147 | return StrToOleStrNW (lpWide, nWide, (LPWSTR)lpStr, nStr);
|
---|
148 | return StrToOleStrNA (lpWide, nWide, (LPSTR)lpStr, nStr);
|
---|
149 | }
|
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 | /************************************************************************
|
---|
155 | * StrToOleStr [SHELL32.163]
|
---|
156 | *
|
---|
157 | */
|
---|
158 | int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
---|
159 | {
|
---|
160 | TRACE("%p %p(%s)\n",
|
---|
161 | lpWideCharStr, lpMultiByteString, lpMultiByteString);
|
---|
162 |
|
---|
163 | return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
---|
164 |
|
---|
165 | }
|
---|
166 | int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
---|
167 | {
|
---|
168 | TRACE("%p %p(%s)\n",
|
---|
169 | lpWideCharStr, lpWString, debugstr_w(lpWString));
|
---|
170 |
|
---|
171 | if (lstrcpyW (lpWideCharStr, lpWString ))
|
---|
172 | { return lstrlenW (lpWideCharStr);
|
---|
173 | }
|
---|
174 | return 0;
|
---|
175 | }
|
---|
176 |
|
---|
177 | BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
---|
178 | {
|
---|
179 | if (VERSION_OsIsUnicode())
|
---|
180 | return StrToOleStrW (lpWideCharStr, (LPCWSTR)lpString);
|
---|
181 | return StrToOleStrA (lpWideCharStr, (LPCSTR)lpString);
|
---|
182 | }
|
---|
183 | #endif
|
---|
184 |
|
---|
185 |
|
---|
186 | /*****************************************************************************
|
---|
187 | * Name : StrChrIA
|
---|
188 | * Purpose : Searches a string for the first occurrence of a character that
|
---|
189 | * matches the specified character. The comparison is not case sensitive.
|
---|
190 | * Parameters: LPCSTR lpStart Address of the string to be searched.
|
---|
191 | * TCHAR wMatch Character to be used for comparison.
|
---|
192 | * Variables :
|
---|
193 | * Result : Returns the address of the first occurrence of the character in
|
---|
194 | * the string if successful, or NULL otherwise.
|
---|
195 | * Remark : SHELL32.
|
---|
196 | * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
|
---|
197 | *
|
---|
198 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
199 | *****************************************************************************/
|
---|
200 |
|
---|
201 | ODINFUNCTION2(LPSTR, StrChrIA,
|
---|
202 | LPCSTR, lpStart,
|
---|
203 | WORD, wMatch)
|
---|
204 | {
|
---|
205 | LPSTR lpRes;
|
---|
206 |
|
---|
207 | wMatch = tolower(wMatch);
|
---|
208 | lpRes = strchr(lpStart, wMatch); // lower case comparsion
|
---|
209 | if (NULL == lpRes)
|
---|
210 | {
|
---|
211 | wMatch = toupper(wMatch);
|
---|
212 | lpRes = strchr(lpStart, wMatch); // upper case comparsion
|
---|
213 | }
|
---|
214 |
|
---|
215 | return lpRes;
|
---|
216 | }
|
---|
217 |
|
---|
218 |
|
---|
219 | /*****************************************************************************
|
---|
220 | * Name : StrChrIW
|
---|
221 | * Purpose : Searches a string for the first occurrence of a character that
|
---|
222 | * matches the specified character. The comparison is not case sensitive.
|
---|
223 | * Parameters: LPCSTR lpStart Address of the string to be searched.
|
---|
224 | * TCHAR wMatch Character to be used for comparison.
|
---|
225 | * Variables :
|
---|
226 | * Result : Returns the address of the first occurrence of the character in
|
---|
227 | * the string if successful, or NULL otherwise.
|
---|
228 | * Remark : SHELL32.
|
---|
229 | * Status : COMPLETELY IMPLEMENTED UNTESTED UNKNOWN
|
---|
230 | *
|
---|
231 | * Author : Patrick Haller [Wed, 1999/12/29 09:00]
|
---|
232 | *****************************************************************************/
|
---|
233 |
|
---|
234 | ODINFUNCTION2(LPWSTR, StrChrIW,
|
---|
235 | LPCWSTR, lpStart,
|
---|
236 | WCHAR, wMatch)
|
---|
237 | {
|
---|
238 | LPWSTR lpRes;
|
---|
239 |
|
---|
240 | wMatch = towlower(wMatch);
|
---|
241 | lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // lower case comparsion
|
---|
242 | if (NULL == lpRes)
|
---|
243 | {
|
---|
244 | wMatch = towupper(wMatch);
|
---|
245 | lpRes = (WCHAR*)wcschr((const wchar_t*)lpStart, wMatch); // upper case comparsion
|
---|
246 | }
|
---|
247 |
|
---|
248 | return lpRes;
|
---|
249 | }
|
---|
250 |
|
---|
251 |
|
---|
252 | /*****************************************************************************
|
---|
253 | * Name : StrCpyA
|
---|
254 | * Purpose : copy a string
|
---|
255 | * Parameters:
|
---|
256 | * Variables :
|
---|
257 | * Result :
|
---|
258 | * Remark : not exported ?
|
---|
259 | * Status : UNTESTED
|
---|
260 | *
|
---|
261 | * Author :
|
---|
262 | *****************************************************************************/
|
---|
263 |
|
---|
264 | ODINFUNCTIONNODBG2(LPSTR, StrCpyA,
|
---|
265 | LPSTR, lpDest,
|
---|
266 | LPCSTR, lpSource)
|
---|
267 | {
|
---|
268 | return lstrcpyA(lpDest,
|
---|
269 | lpSource);
|
---|
270 | }
|
---|
271 |
|
---|
272 |
|
---|
273 |
|
---|
274 |
|
---|