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
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
32 #include "shell32_main.h"
33 #include "undocshell.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(shell);
39 /************************* STRRET functions ****************************/
43 * These routines are identical to StrRetToBuf[AW] in dlls/shlwapi/string.c.
44 * They were duplicated here because not every version of Shlwapi.dll exports
45 * StrRetToBuf[AW]. If you change one routine, change them both. YOU HAVE BEEN
50 HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
52 TRACE("dest=%p len=0x%lx strret=%p(%s) pidl=%p\n",
54 (src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
55 (src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
56 (src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
62 WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
63 CoTaskMemFree(src->u.pOleStr);
67 lstrcpynA((LPSTR)dest, src->u.cStr, len);
71 lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
75 FIXME("unknown type!\n");
76 if (len) *(LPSTR)dest = '\0';
79 TRACE("-- %s\n", debugstr_a(dest) );
83 /************************************************************************/
85 HRESULT WINAPI StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
87 TRACE("dest=%p len=0x%lx strret=%p(%s) pidl=%p\n",
89 (src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
90 (src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
91 (src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
97 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
98 CoTaskMemFree(src->u.pOleStr);
102 if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
103 ((LPWSTR)dest)[len-1] = 0;
107 if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len ) && len)
108 ((LPWSTR)dest)[len-1] = 0;
112 FIXME("unknown type!\n");
113 if (len) *(LPWSTR)dest = '\0';
120 /*************************************************************************
121 * StrRetToStrN [SHELL32.96]
123 * converts a STRRET to a normal string
126 * the pidl is for STRRET OFFSET
128 HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
130 if(SHELL_OsIsUnicode())
131 return StrRetToStrNW (dest, len, src, pidl);
132 return StrRetToStrNA (dest, len, src, pidl);
135 /************************* OLESTR functions ****************************/
137 /************************************************************************
138 * StrToOleStr [SHELL32.163]
141 int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
143 TRACE("(%p, %p %s)\n",
144 lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
146 return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
149 int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
151 TRACE("(%p, %p %s)\n",
152 lpWideCharStr, lpWString, debugstr_w(lpWString));
154 strcpyW (lpWideCharStr, lpWString );
155 return strlenW(lpWideCharStr);
158 BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
160 if (SHELL_OsIsUnicode())
161 return StrToOleStrW (lpWideCharStr, lpString);
162 return StrToOleStrA (lpWideCharStr, lpString);
165 /*************************************************************************
166 * StrToOleStrN [SHELL32.79]
167 * lpMulti, nMulti, nWide [IN]
170 BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
172 TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
173 return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
175 BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
177 TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
179 if (lstrcpynW (lpWide, lpStrW, nWide))
180 { return lstrlenW (lpWide);
185 BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
187 if (SHELL_OsIsUnicode())
188 return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
189 return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
192 /*************************************************************************
193 * OleStrToStrN [SHELL32.78]
195 BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
197 TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
198 return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
201 BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
203 TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
205 if (lstrcpynW ( lpwStr, lpOle, nwStr))
206 { return lstrlenW (lpwStr);
211 BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
213 if (SHELL_OsIsUnicode())
214 return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
215 return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
219 /*************************************************************************
220 * CheckEscapes [SHELL32]
222 DWORD WINAPI CheckEscapesA(
223 LPSTR string, /* [in] string to check ??*/
224 DWORD b, /* [???] is 0 */
225 DWORD c, /* [???] is 0 */
226 LPDWORD d, /* [???] is address */
227 LPDWORD e, /* [???] is address */
228 DWORD handle ) /* [in] looks like handle but not */
230 FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
231 string, debugstr_a(string),
234 d, (d) ? *d : 0xabbacddc,
235 e, (e) ? *e : 0xabbacddd,
240 DWORD WINAPI CheckEscapesW(
241 LPWSTR string, /* [in] string to check ??*/
242 DWORD b, /* [???] is 0 */
243 DWORD c, /* [???] is 0 */
244 LPDWORD d, /* [???] is address */
245 LPDWORD e, /* [???] is address */
246 DWORD handle ) /* [in] looks like handle but not */
248 FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
249 string, debugstr_w(string),
252 d, (d) ? *d : 0xabbacddc,
253 e, (e) ? *e : 0xabbacddd,