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=%p(%s) pidl=%p\n",
52 (src
->uType
== STRRET_WSTR
) ? "STRRET_WSTR" :
53 (src
->uType
== STRRET_CSTR
) ? "STRRET_CSTR" :
54 (src
->uType
== STRRET_OFFSET
) ? "STRRET_OFFSET" : "STRRET_???",
60 WideCharToMultiByte(CP_ACP
, 0, src
->u
.pOleStr
, -1, (LPSTR
)dest
, len
, NULL
, NULL
);
61 CoTaskMemFree(src
->u
.pOleStr
);
65 lstrcpynA((LPSTR
)dest
, src
->u
.cStr
, len
);
69 lstrcpynA((LPSTR
)dest
, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
, len
);
73 FIXME("unknown type!\n");
74 if (len
) *(LPSTR
)dest
= '\0';
77 TRACE("-- %s\n", debugstr_a(dest
) );
81 /************************************************************************/
83 HRESULT WINAPI
StrRetToStrNW (LPVOID dest
, DWORD len
, LPSTRRET src
, const ITEMIDLIST
*pidl
)
85 TRACE("dest=0x%p len=0x%lx strret=%p(%s) pidl=%p\n",
87 (src
->uType
== STRRET_WSTR
) ? "STRRET_WSTR" :
88 (src
->uType
== STRRET_CSTR
) ? "STRRET_CSTR" :
89 (src
->uType
== STRRET_OFFSET
) ? "STRRET_OFFSET" : "STRRET_???",
95 lstrcpynW((LPWSTR
)dest
, src
->u
.pOleStr
, len
);
96 CoTaskMemFree(src
->u
.pOleStr
);
100 if (!MultiByteToWideChar( CP_ACP
, 0, src
->u
.cStr
, -1, dest
, len
) && len
)
101 ((LPWSTR
)dest
)[len
-1] = 0;
105 if (!MultiByteToWideChar( CP_ACP
, 0, ((LPCSTR
)&pidl
->mkid
)+src
->u
.uOffset
, -1, dest
, len
) && len
)
106 ((LPWSTR
)dest
)[len
-1] = 0;
110 FIXME("unknown type!\n");
111 if (len
) *(LPWSTR
)dest
= '\0';
118 /*************************************************************************
119 * StrRetToStrN [SHELL32.96]
121 * converts a STRRET to a normal string
124 * the pidl is for STRRET OFFSET
126 HRESULT WINAPI
StrRetToStrNAW (LPVOID dest
, DWORD len
, LPSTRRET src
, const ITEMIDLIST
*pidl
)
128 if(SHELL_OsIsUnicode())
129 return StrRetToStrNW (dest
, len
, src
, pidl
);
130 return StrRetToStrNA (dest
, len
, src
, pidl
);
133 /************************* OLESTR functions ****************************/
135 /************************************************************************
136 * StrToOleStr [SHELL32.163]
139 int WINAPI
StrToOleStrA (LPWSTR lpWideCharStr
, LPCSTR lpMultiByteString
)
141 TRACE("(%p, %p %s)\n",
142 lpWideCharStr
, lpMultiByteString
, debugstr_a(lpMultiByteString
));
144 return MultiByteToWideChar(0, 0, lpMultiByteString
, -1, lpWideCharStr
, MAX_PATH
);
147 int WINAPI
StrToOleStrW (LPWSTR lpWideCharStr
, LPCWSTR lpWString
)
149 TRACE("(%p, %p %s)\n",
150 lpWideCharStr
, lpWString
, debugstr_w(lpWString
));
152 strcpyW (lpWideCharStr
, lpWString
);
153 return strlenW(lpWideCharStr
);
156 BOOL WINAPI
StrToOleStrAW (LPWSTR lpWideCharStr
, LPCVOID lpString
)
158 if (SHELL_OsIsUnicode())
159 return StrToOleStrW (lpWideCharStr
, lpString
);
160 return StrToOleStrA (lpWideCharStr
, lpString
);
163 /*************************************************************************
164 * StrToOleStrN [SHELL32.79]
165 * lpMulti, nMulti, nWide [IN]
168 BOOL WINAPI
StrToOleStrNA (LPWSTR lpWide
, INT nWide
, LPCSTR lpStrA
, INT nStr
)
170 TRACE("(%p, %x, %s, %x)\n", lpWide
, nWide
, debugstr_an(lpStrA
,nStr
), nStr
);
171 return MultiByteToWideChar (0, 0, lpStrA
, nStr
, lpWide
, nWide
);
173 BOOL WINAPI
StrToOleStrNW (LPWSTR lpWide
, INT nWide
, LPCWSTR lpStrW
, INT nStr
)
175 TRACE("(%p, %x, %s, %x)\n", lpWide
, nWide
, debugstr_wn(lpStrW
, nStr
), nStr
);
177 if (lstrcpynW (lpWide
, lpStrW
, nWide
))
178 { return lstrlenW (lpWide
);
183 BOOL WINAPI
StrToOleStrNAW (LPWSTR lpWide
, INT nWide
, LPCVOID lpStr
, INT nStr
)
185 if (SHELL_OsIsUnicode())
186 return StrToOleStrNW (lpWide
, nWide
, lpStr
, nStr
);
187 return StrToOleStrNA (lpWide
, nWide
, lpStr
, nStr
);
190 /*************************************************************************
191 * OleStrToStrN [SHELL32.78]
193 BOOL WINAPI
OleStrToStrNA (LPSTR lpStr
, INT nStr
, LPCWSTR lpOle
, INT nOle
)
195 TRACE("(%p, %x, %s, %x)\n", lpStr
, nStr
, debugstr_wn(lpOle
,nOle
), nOle
);
196 return WideCharToMultiByte (0, 0, lpOle
, nOle
, lpStr
, nStr
, NULL
, NULL
);
199 BOOL WINAPI
OleStrToStrNW (LPWSTR lpwStr
, INT nwStr
, LPCWSTR lpOle
, INT nOle
)
201 TRACE("(%p, %x, %s, %x)\n", lpwStr
, nwStr
, debugstr_wn(lpOle
,nOle
), nOle
);
203 if (lstrcpynW ( lpwStr
, lpOle
, nwStr
))
204 { return lstrlenW (lpwStr
);
209 BOOL WINAPI
OleStrToStrNAW (LPVOID lpOut
, INT nOut
, LPCVOID lpIn
, INT nIn
)
211 if (SHELL_OsIsUnicode())
212 return OleStrToStrNW (lpOut
, nOut
, lpIn
, nIn
);
213 return OleStrToStrNA (lpOut
, nOut
, lpIn
, nIn
);
217 /*************************************************************************
218 * CheckEscapes [SHELL32]
220 DWORD WINAPI
CheckEscapesA(
221 LPSTR string
, /* [in] string to check ??*/
222 DWORD b
, /* [???] is 0 */
223 DWORD c
, /* [???] is 0 */
224 LPDWORD d
, /* [???] is address */
225 LPDWORD e
, /* [???] is address */
226 DWORD handle
) /* [in] looks like handle but not */
228 FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
229 string
, debugstr_a(string
),
232 d
, (d
) ? *d
: 0xabbacddc,
233 e
, (e
) ? *e
: 0xabbacddd,
238 DWORD WINAPI
CheckEscapesW(
239 LPWSTR string
, /* [in] string to check ??*/
240 DWORD b
, /* [???] is 0 */
241 DWORD c
, /* [???] is 0 */
242 LPDWORD d
, /* [???] is address */
243 LPDWORD e
, /* [???] is address */
244 DWORD handle
) /* [in] looks like handle but not */
246 FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
247 string
, debugstr_w(string
),
250 d
, (d
) ? *d
: 0xabbacddc,
251 e
, (e
) ? *e
: 0xabbacddd,