2002-03-10 00:29:33 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2000 Juergen Schmied
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2000-06-02 01:25:44 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
2002-06-01 01:06:46 +02:00
|
|
|
#include <stdlib.h>
|
2000-06-02 01:25:44 +02:00
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2000-06-02 01:25:44 +02:00
|
|
|
#include "winnls.h"
|
|
|
|
#include "winerror.h"
|
2001-11-06 23:31:19 +01:00
|
|
|
#include "winreg.h"
|
2000-06-02 01:25:44 +02:00
|
|
|
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "shlobj.h"
|
2000-06-02 01:25:44 +02:00
|
|
|
#include "shellapi.h"
|
2000-08-14 16:35:01 +02:00
|
|
|
#include "shell32_main.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2000-06-13 03:10:29 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-06-02 01:25:44 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2000-06-02 01:25:44 +02:00
|
|
|
|
|
|
|
/************************* STRRET functions ****************************/
|
|
|
|
|
2002-01-18 19:57:43 +01:00
|
|
|
/*
|
2001-11-06 00:55:36 +01:00
|
|
|
* ***** NOTE *****
|
2002-01-18 19:57:43 +01:00
|
|
|
* These routines are identical to StrRetToBuf[AW] in dlls/shlwapi/string.c.
|
|
|
|
* They were duplicated here because not every version of Shlwapi.dll exports
|
|
|
|
* StrRetToBuf[AW]. If you change one routine, change them both. YOU HAVE BEEN
|
2001-11-06 00:55:36 +01:00
|
|
|
* WARNED.
|
|
|
|
* ***** NOTE *****
|
2000-06-02 01:25:44 +02:00
|
|
|
*/
|
2002-01-18 19:57:43 +01:00
|
|
|
|
2000-09-26 02:00:55 +02:00
|
|
|
HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
2002-10-25 05:50:14 +02:00
|
|
|
TRACE("dest=%p len=0x%lx strret=%p(%s) pidl=%p\n",
|
2002-07-24 03:56:03 +02:00
|
|
|
dest,len,src,
|
|
|
|
(src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
|
|
|
|
(src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
|
|
|
|
(src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
|
|
|
|
pidl);
|
2001-09-07 17:24:25 +02:00
|
|
|
|
|
|
|
switch (src->uType)
|
|
|
|
{
|
|
|
|
case STRRET_WSTR:
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
|
2002-07-02 04:05:17 +02:00
|
|
|
CoTaskMemFree(src->u.pOleStr);
|
2001-09-07 17:24:25 +02:00
|
|
|
break;
|
|
|
|
|
2002-07-02 04:05:17 +02:00
|
|
|
case STRRET_CSTR:
|
2001-09-07 17:24:25 +02:00
|
|
|
lstrcpynA((LPSTR)dest, src->u.cStr, len);
|
|
|
|
break;
|
|
|
|
|
2002-07-02 04:05:17 +02:00
|
|
|
case STRRET_OFFSET:
|
2001-09-07 17:24:25 +02:00
|
|
|
lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unknown type!\n");
|
2002-07-24 03:56:03 +02:00
|
|
|
if (len) *(LPSTR)dest = '\0';
|
2001-09-07 17:24:25 +02:00
|
|
|
return(FALSE);
|
|
|
|
}
|
2002-07-24 03:56:03 +02:00
|
|
|
TRACE("-- %s\n", debugstr_a(dest) );
|
2001-09-07 17:24:25 +02:00
|
|
|
return S_OK;
|
2000-06-02 01:25:44 +02:00
|
|
|
}
|
|
|
|
|
2002-01-18 19:57:43 +01:00
|
|
|
/************************************************************************/
|
2001-09-11 01:16:31 +02:00
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
HRESULT WINAPI StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
2002-10-25 05:50:14 +02:00
|
|
|
TRACE("dest=%p len=0x%lx strret=%p(%s) pidl=%p\n",
|
2002-07-24 03:56:03 +02:00
|
|
|
dest,len,src,
|
|
|
|
(src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
|
|
|
|
(src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
|
|
|
|
(src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
|
|
|
|
pidl);
|
2001-09-07 17:24:25 +02:00
|
|
|
|
|
|
|
switch (src->uType)
|
|
|
|
{
|
|
|
|
case STRRET_WSTR:
|
|
|
|
lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
|
2002-07-02 04:05:17 +02:00
|
|
|
CoTaskMemFree(src->u.pOleStr);
|
2001-09-07 17:24:25 +02:00
|
|
|
break;
|
|
|
|
|
2002-07-02 04:05:17 +02:00
|
|
|
case STRRET_CSTR:
|
2002-07-24 03:56:03 +02:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
|
|
|
|
((LPWSTR)dest)[len-1] = 0;
|
2001-09-07 17:24:25 +02:00
|
|
|
break;
|
|
|
|
|
2002-07-02 04:05:17 +02:00
|
|
|
case STRRET_OFFSET:
|
2002-07-24 03:56:03 +02:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len ) && len)
|
|
|
|
((LPWSTR)dest)[len-1] = 0;
|
2001-09-07 17:24:25 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unknown type!\n");
|
2002-07-24 03:56:03 +02:00
|
|
|
if (len) *(LPWSTR)dest = '\0';
|
2001-09-07 17:24:25 +02:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2000-06-02 01:25:44 +02:00
|
|
|
}
|
2000-07-26 19:51:32 +02:00
|
|
|
|
2001-09-11 01:16:31 +02:00
|
|
|
|
2002-01-18 19:57:43 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* StrRetToStrN [SHELL32.96]
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2002-01-18 19:57:43 +01:00
|
|
|
* converts a STRRET to a normal string
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* the pidl is for STRRET OFFSET
|
|
|
|
*/
|
2000-09-26 02:00:55 +02:00
|
|
|
HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if(SHELL_OsIsUnicode())
|
2000-06-02 01:25:44 +02:00
|
|
|
return StrRetToStrNW (dest, len, src, pidl);
|
|
|
|
return StrRetToStrNA (dest, len, src, pidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************* OLESTR functions ****************************/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* StrToOleStr [SHELL32.163]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p %s)\n",
|
|
|
|
lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
|
|
|
|
|
|
|
|
return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
|
|
|
|
|
|
|
}
|
|
|
|
int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p %s)\n",
|
|
|
|
lpWideCharStr, lpWString, debugstr_w(lpWString));
|
|
|
|
|
2000-08-14 16:35:01 +02:00
|
|
|
strcpyW (lpWideCharStr, lpWString );
|
|
|
|
return strlenW(lpWideCharStr);
|
2000-06-02 01:25:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if (SHELL_OsIsUnicode())
|
2000-06-02 01:25:44 +02:00
|
|
|
return StrToOleStrW (lpWideCharStr, lpString);
|
|
|
|
return StrToOleStrA (lpWideCharStr, lpString);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrToOleStrN [SHELL32.79]
|
|
|
|
* lpMulti, nMulti, nWide [IN]
|
|
|
|
* lpWide [OUT]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
|
|
|
|
return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
|
|
|
|
|
|
|
|
if (lstrcpynW (lpWide, lpStrW, nWide))
|
|
|
|
{ return lstrlenW (lpWide);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if (SHELL_OsIsUnicode())
|
2000-06-02 01:25:44 +02:00
|
|
|
return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
|
|
|
|
return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* OleStrToStrN [SHELL32.78]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
|
|
|
|
return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
|
|
|
|
|
|
|
|
if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
|
|
|
{ return lstrlenW (lpwStr);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if (SHELL_OsIsUnicode())
|
2000-06-02 01:25:44 +02:00
|
|
|
return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
|
|
|
|
return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
|
|
|
|
}
|
2002-01-29 19:21:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* CheckEscapes [SHELL32]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI CheckEscapesA(
|
|
|
|
LPSTR string, /* [in] string to check ??*/
|
|
|
|
DWORD b, /* [???] is 0 */
|
|
|
|
DWORD c, /* [???] is 0 */
|
|
|
|
LPDWORD d, /* [???] is address */
|
|
|
|
LPDWORD e, /* [???] is address */
|
|
|
|
DWORD handle ) /* [in] looks like handle but not */
|
|
|
|
{
|
|
|
|
FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
|
|
|
|
string, debugstr_a(string),
|
|
|
|
b,
|
|
|
|
c,
|
|
|
|
d, (d) ? *d : 0xabbacddc,
|
|
|
|
e, (e) ? *e : 0xabbacddd,
|
|
|
|
handle);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI CheckEscapesW(
|
|
|
|
LPWSTR string, /* [in] string to check ??*/
|
|
|
|
DWORD b, /* [???] is 0 */
|
|
|
|
DWORD c, /* [???] is 0 */
|
|
|
|
LPDWORD d, /* [???] is address */
|
|
|
|
LPDWORD e, /* [???] is address */
|
|
|
|
DWORD handle ) /* [in] looks like handle but not */
|
|
|
|
{
|
|
|
|
FIXME("(%p<%s> %ld %ld %p<%ld> %p<%ld> 0x%08lx) stub\n",
|
|
|
|
string, debugstr_w(string),
|
|
|
|
b,
|
|
|
|
c,
|
|
|
|
d, (d) ? *d : 0xabbacddc,
|
|
|
|
e, (e) ? *e : 0xabbacddd,
|
|
|
|
handle);
|
|
|
|
return 0;
|
|
|
|
}
|