2 * Copyright 2000 Juergen Schmied
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "shell32_main.h"
31 #include "undocshell.h"
32 #include "wine/unicode.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
37 /************************* STRRET functions ****************************/
41 * These routines are identical to StrRetToBuf[AW] in dlls/shlwapi/string.c.
42 * They were duplicated here because not every version of Shlwapi.dll exports
43 * StrRetToBuf[AW]. If you change one routine, change them both. YOU HAVE BEEN
48 HRESULT WINAPI
StrRetToStrNA (LPVOID dest
, DWORD len
, LPSTRRET src
, const ITEMIDLIST
*pidl
)
50 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest
,len
,src
,pidl
);
55 WideCharToMultiByte(CP_ACP
, 0, src
->u
.pOleStr
, -1, (LPSTR
)dest
, len
, NULL
, NULL
);
56 /* SHFree(src->u.pOleStr); FIXME: is this right? */
60 lstrcpynA((LPSTR
)dest
, src
->u
.cStr
, len
);
64 lstrcpynA((LPSTR
)dest
, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
, len
);
68 FIXME("unknown type!\n");
78 /************************************************************************/
80 HRESULT WINAPI
StrRetToStrNW (LPVOID dest1
, DWORD len
, LPSTRRET src
, const ITEMIDLIST
*pidl
)
82 LPWSTR dest
= (LPWSTR
) dest1
;
83 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest
,len
,src
,pidl
);
88 lstrcpynW((LPWSTR
)dest
, src
->u
.pOleStr
, len
);
89 /* SHFree(src->u.pOleStr); FIXME: is this right? */
93 if (!MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, dest
, len
) && len
)
100 if (!MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
, -1,
107 FIXME("unknown type!\n");
109 { *(LPSTR
)dest
= '\0';
117 /*************************************************************************
118 * StrRetToStrN [SHELL32.96]
120 * converts a STRRET to a normal string
123 * the pidl is for STRRET OFFSET
125 HRESULT WINAPI
StrRetToStrNAW (LPVOID dest
, DWORD len
, LPSTRRET src
, const ITEMIDLIST
*pidl
)
127 if(SHELL_OsIsUnicode())
128 return StrRetToStrNW (dest
, len
, src
, pidl
);
129 return StrRetToStrNA (dest
, len
, src
, pidl
);
132 /************************* OLESTR functions ****************************/
134 /************************************************************************
135 * StrToOleStr [SHELL32.163]
138 int WINAPI
StrToOleStrA (LPWSTR lpWideCharStr
, LPCSTR lpMultiByteString
)
140 TRACE("(%p, %p %s)\n",
141 lpWideCharStr
, lpMultiByteString
, debugstr_a(lpMultiByteString
));
143 return MultiByteToWideChar(0, 0, lpMultiByteString
, -1, lpWideCharStr
, MAX_PATH
);
146 int WINAPI
StrToOleStrW (LPWSTR lpWideCharStr
, LPCWSTR lpWString
)
148 TRACE("(%p, %p %s)\n",
149 lpWideCharStr
, lpWString
, debugstr_w(lpWString
));
151 strcpyW (lpWideCharStr
, lpWString
);
152 return strlenW(lpWideCharStr
);
155 BOOL WINAPI
StrToOleStrAW (LPWSTR lpWideCharStr
, LPCVOID lpString
)
157 if (SHELL_OsIsUnicode())
158 return StrToOleStrW (lpWideCharStr
, lpString
);
159 return StrToOleStrA (lpWideCharStr
, lpString
);
162 /*************************************************************************
163 * StrToOleStrN [SHELL32.79]
164 * lpMulti, nMulti, nWide [IN]
167 BOOL WINAPI
StrToOleStrNA (LPWSTR lpWide
, INT nWide
, LPCSTR lpStrA
, INT nStr
)
169 TRACE("(%p, %x, %s, %x)\n", lpWide
, nWide
, debugstr_an(lpStrA
,nStr
), nStr
);
170 return MultiByteToWideChar (0, 0, lpStrA
, nStr
, lpWide
, nWide
);
172 BOOL WINAPI
StrToOleStrNW (LPWSTR lpWide
, INT nWide
, LPCWSTR lpStrW
, INT nStr
)
174 TRACE("(%p, %x, %s, %x)\n", lpWide
, nWide
, debugstr_wn(lpStrW
, nStr
), nStr
);
176 if (lstrcpynW (lpWide
, lpStrW
, nWide
))
177 { return lstrlenW (lpWide
);
182 BOOL WINAPI
StrToOleStrNAW (LPWSTR lpWide
, INT nWide
, LPCVOID lpStr
, INT nStr
)
184 if (SHELL_OsIsUnicode())
185 return StrToOleStrNW (lpWide
, nWide
, lpStr
, nStr
);
186 return StrToOleStrNA (lpWide
, nWide
, lpStr
, nStr
);
189 /*************************************************************************
190 * OleStrToStrN [SHELL32.78]
192 BOOL WINAPI
OleStrToStrNA (LPSTR lpStr
, INT nStr
, LPCWSTR lpOle
, INT nOle
)
194 TRACE("(%p, %x, %s, %x)\n", lpStr
, nStr
, debugstr_wn(lpOle
,nOle
), nOle
);
195 return WideCharToMultiByte (0, 0, lpOle
, nOle
, lpStr
, nStr
, NULL
, NULL
);
198 BOOL WINAPI
OleStrToStrNW (LPWSTR lpwStr
, INT nwStr
, LPCWSTR lpOle
, INT nOle
)
200 TRACE("(%p, %x, %s, %x)\n", lpwStr
, nwStr
, debugstr_wn(lpOle
,nOle
), nOle
);
202 if (lstrcpynW ( lpwStr
, lpOle
, nwStr
))
203 { return lstrlenW (lpwStr
);
208 BOOL WINAPI
OleStrToStrNAW (LPVOID lpOut
, INT nOut
, LPCVOID lpIn
, INT nIn
)
210 if (SHELL_OsIsUnicode())
211 return OleStrToStrNW (lpOut
, nOut
, lpIn
, nIn
);
212 return OleStrToStrNA (lpOut
, nOut
, lpIn
, nIn
);
216 /*************************************************************************
217 * CheckEscapes [SHELL32]
219 DWORD WINAPI
CheckEscapesA(
220 LPSTR string
, /* [in] string to check ??*/
221 DWORD b
, /* [???] is 0 */
222 DWORD c
, /* [???] is 0 */
223 LPDWORD d
, /* [???] is address */
224 LPDWORD e
, /* [???] is address */
225 DWORD handle
) /* [in] looks like handle but not */
227 FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
228 string
, debugstr_a(string
),
231 d
, (d
) ? *d
: 0xabbacddc,
232 e
, (e
) ? *e
: 0xabbacddd,
237 DWORD WINAPI
CheckEscapesW(
238 LPWSTR string
, /* [in] string to check ??*/
239 DWORD b
, /* [???] is 0 */
240 DWORD c
, /* [???] is 0 */
241 LPDWORD d
, /* [???] is address */
242 LPDWORD e
, /* [???] is address */
243 DWORD handle
) /* [in] looks like handle but not */
245 FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
246 string
, debugstr_w(string
),
249 d
, (d
) ? *d
: 0xabbacddc,
250 e
, (e
) ? *e
: 0xabbacddd,