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

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

resync with latest wine

File size: 7.7 KB
Line 
1 /* $Id: string_odin.cpp,v 1.2 2001-04-28 13:32:21 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 * 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
84ODINFUNCTION2(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 */
100BOOL 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
106BOOL 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
116BOOL 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 */
128BOOL 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}
133BOOL 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
143BOOL 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 */
157int 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}
165int 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
176BOOL 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
200ODINFUNCTION2(LPSTR, StrChrIA,
201 LPCSTR, lpStart,
202 WORD, 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
233ODINFUNCTION2(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 : StrCpyA
253 * Purpose : copy a string
254 * Parameters:
255 * Variables :
256 * Result :
257 * Remark : not exported ?
258 * Status : UNTESTED
259 *
260 * Author :
261 *****************************************************************************/
262
263ODINFUNCTIONNODBG2(LPSTR, StrCpyA,
264 LPSTR, lpDest,
265 LPCSTR, lpSource)
266{
267 return lstrcpyA(lpDest,
268 lpSource);
269}
270
271
272
273
Note: See TracBrowser for help on using the repository browser.