mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:02:58 +00:00
[SHELL32]
* Rename shellstring.cpp to shellstring.c and update it against Wine 1.7.27. CORE-8540 svn path=/trunk/; revision=65147
This commit is contained in:
parent
8a1d7dd1c0
commit
80d683ac8d
4 changed files with 100 additions and 349 deletions
|
@ -42,7 +42,6 @@ list(APPEND SOURCE
|
||||||
shellord.cpp
|
shellord.cpp
|
||||||
shellpath.cpp
|
shellpath.cpp
|
||||||
shellreg.cpp
|
shellreg.cpp
|
||||||
shellstring.cpp
|
|
||||||
folders/desktop.cpp
|
folders/desktop.cpp
|
||||||
folders/fs.cpp
|
folders/fs.cpp
|
||||||
folders/mycomp.cpp
|
folders/mycomp.cpp
|
||||||
|
@ -76,6 +75,7 @@ list(APPEND SOURCE
|
||||||
|
|
||||||
add_library(shell32 SHARED
|
add_library(shell32 SHARED
|
||||||
${SOURCE}
|
${SOURCE}
|
||||||
|
shellstring.c
|
||||||
vista.c
|
vista.c
|
||||||
shell32.rc
|
shell32.rc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/shell32_stubs.c
|
${CMAKE_CURRENT_BINARY_DIR}/shell32_stubs.c
|
||||||
|
|
|
@ -30,7 +30,7 @@ extern HINSTANCE shell32_hInstance;
|
||||||
extern HIMAGELIST ShellSmallIconList;
|
extern HIMAGELIST ShellSmallIconList;
|
||||||
extern HIMAGELIST ShellBigIconList;
|
extern HIMAGELIST ShellBigIconList;
|
||||||
|
|
||||||
extern "C" BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
|
BOOL WINAPI Shell_GetImageLists(HIMAGELIST * lpBigList, HIMAGELIST * lpSmallList);
|
||||||
|
|
||||||
/* Iconcache */
|
/* Iconcache */
|
||||||
#define INVALID_INDEX -1
|
#define INVALID_INDEX -1
|
||||||
|
@ -128,7 +128,7 @@ BOOL SHELL_ConfirmYesNoW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir);
|
||||||
void WINAPI _InsertMenuItemW (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
|
void WINAPI _InsertMenuItemW (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
|
||||||
UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState);
|
UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState);
|
||||||
|
|
||||||
static BOOL __inline SHELL_OsIsUnicode(void)
|
static __inline BOOL SHELL_OsIsUnicode(void)
|
||||||
{
|
{
|
||||||
/* if high-bit of version is 0, we are emulating NT */
|
/* if high-bit of version is 0, we are emulating NT */
|
||||||
return !(GetVersion() & 0x80000000);
|
return !(GetVersion() & 0x80000000);
|
||||||
|
@ -139,26 +139,26 @@ static BOOL __inline SHELL_OsIsUnicode(void)
|
||||||
SHFree(*ptr); \
|
SHFree(*ptr); \
|
||||||
*ptr = NULL; \
|
*ptr = NULL; \
|
||||||
};
|
};
|
||||||
static void __inline __SHCloneStrA(char **target, const char *source)
|
static __inline void __SHCloneStrA(char **target, const char *source)
|
||||||
{
|
{
|
||||||
*target = (char *)SHAlloc(strlen(source) + 1);
|
*target = (char *)SHAlloc(strlen(source) + 1);
|
||||||
strcpy(*target, source);
|
strcpy(*target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __inline __SHCloneStrWtoA(char **target, const WCHAR *source)
|
static __inline void __SHCloneStrWtoA(char **target, const WCHAR *source)
|
||||||
{
|
{
|
||||||
int len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
|
int len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
|
||||||
*target = (char *)SHAlloc(len);
|
*target = (char *)SHAlloc(len);
|
||||||
WideCharToMultiByte(CP_ACP, 0, source, -1, *target, len, NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, source, -1, *target, len, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __inline __SHCloneStrW(WCHAR **target, const WCHAR *source)
|
static __inline void __SHCloneStrW(WCHAR **target, const WCHAR *source)
|
||||||
{
|
{
|
||||||
*target = (WCHAR *)SHAlloc((lstrlenW(source) + 1) * sizeof(WCHAR) );
|
*target = (WCHAR *)SHAlloc((lstrlenW(source) + 1) * sizeof(WCHAR) );
|
||||||
lstrcpyW(*target, source);
|
lstrcpyW(*target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LPWSTR __inline __SHCloneStrAtoW(WCHAR **target, const char *source)
|
static __inline LPWSTR __SHCloneStrAtoW(WCHAR **target, const char *source)
|
||||||
{
|
{
|
||||||
int len = MultiByteToWideChar(CP_ACP, 0, source, -1, NULL, 0);
|
int len = MultiByteToWideChar(CP_ACP, 0, source, -1, NULL, 0);
|
||||||
*target = (WCHAR *)SHAlloc(len * sizeof(WCHAR));
|
*target = (WCHAR *)SHAlloc(len * sizeof(WCHAR));
|
||||||
|
|
|
@ -16,20 +16,43 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <precomp.h>
|
#define WIN32_NO_STATUS
|
||||||
|
#define _INC_WINDOWS
|
||||||
|
#define NONAMELESSUNION
|
||||||
|
#define NONAMELESSSTRUCT
|
||||||
|
|
||||||
|
#include <windef.h>
|
||||||
|
#include <winbase.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <shlwapi.h>
|
||||||
|
#include <wine/unicode.h>
|
||||||
|
#include <wine/debug.h>
|
||||||
|
|
||||||
|
#include "shell32_main.h"
|
||||||
|
#include "undocshell.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||||
|
|
||||||
/************************* STRRET functions ****************************/
|
/************************* STRRET functions ****************************/
|
||||||
|
|
||||||
|
static const char *debugstr_strret(STRRET *s)
|
||||||
|
{
|
||||||
|
switch (s->uType)
|
||||||
|
{
|
||||||
|
case STRRET_WSTR:
|
||||||
|
return "STRRET_WSTR";
|
||||||
|
case STRRET_CSTR:
|
||||||
|
return "STRRET_CSTR";
|
||||||
|
case STRRET_OFFSET:
|
||||||
|
return "STRRET_OFFSET";
|
||||||
|
default:
|
||||||
|
return "STRRET_???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOL WINAPI StrRetToStrNA(LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
BOOL WINAPI StrRetToStrNA(LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
||||||
{
|
{
|
||||||
TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n",
|
TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n", dest, len, src, debugstr_strret(src), pidl);
|
||||||
dest,len,src,
|
|
||||||
(src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
|
|
||||||
(src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
|
|
||||||
(src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
|
|
||||||
pidl);
|
|
||||||
|
|
||||||
if (!dest)
|
if (!dest)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -40,18 +63,16 @@ BOOL WINAPI StrRetToStrNA(LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST
|
||||||
WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, dest, len, NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, dest, len, NULL, NULL);
|
||||||
CoTaskMemFree(src->u.pOleStr);
|
CoTaskMemFree(src->u.pOleStr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STRRET_CSTR:
|
case STRRET_CSTR:
|
||||||
lstrcpynA(dest, src->u.cStr, len);
|
lstrcpynA(dest, src->u.cStr, len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STRRET_OFFSET:
|
case STRRET_OFFSET:
|
||||||
lstrcpynA(dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
lstrcpynA(dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FIXME("unknown type!\n");
|
FIXME("unknown type %u!\n", src->uType);
|
||||||
if (len) *dest = '\0';
|
if (len)
|
||||||
|
*dest = '\0';
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
TRACE("-- %s\n", debugstr_a(dest) );
|
TRACE("-- %s\n", debugstr_a(dest) );
|
||||||
|
@ -62,12 +83,7 @@ BOOL WINAPI StrRetToStrNA(LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST
|
||||||
|
|
||||||
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
||||||
{
|
{
|
||||||
TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n",
|
TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n", dest, len, src, debugstr_strret(src), pidl);
|
||||||
dest,len,src,
|
|
||||||
(src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
|
|
||||||
(src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
|
|
||||||
(src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
|
|
||||||
pidl);
|
|
||||||
|
|
||||||
if (!dest)
|
if (!dest)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -78,20 +94,19 @@ BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST
|
||||||
lstrcpynW(dest, src->u.pOleStr, len);
|
lstrcpynW(dest, src->u.pOleStr, len);
|
||||||
CoTaskMemFree(src->u.pOleStr);
|
CoTaskMemFree(src->u.pOleStr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STRRET_CSTR:
|
case STRRET_CSTR:
|
||||||
if (!MultiByteToWideChar(CP_ACP, 0, src->u.cStr, -1, dest, len) && len)
|
if (!MultiByteToWideChar(CP_ACP, 0, src->u.cStr, -1, dest, len) && len)
|
||||||
dest[len-1] = 0;
|
dest[len-1] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STRRET_OFFSET:
|
case STRRET_OFFSET:
|
||||||
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len ) && len)
|
if (!MultiByteToWideChar(CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len)
|
||||||
|
&& len)
|
||||||
dest[len-1] = 0;
|
dest[len-1] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FIXME("unknown type!\n");
|
FIXME("unknown type %u!\n", src->uType);
|
||||||
if (len) *dest = '\0';
|
if (len)
|
||||||
|
*dest = '\0';
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -120,21 +135,21 @@ BOOL WINAPI StrRetToStrNAW(LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIS
|
||||||
* StrToOleStr [SHELL32.163]
|
* StrToOleStr [SHELL32.163]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
static int StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
||||||
{
|
{
|
||||||
TRACE("(%p, %p %s)\n",
|
TRACE("(%p, %p %s)\n",
|
||||||
lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
|
lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
|
||||||
|
|
||||||
return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
return MultiByteToWideChar(CP_ACP, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
||||||
|
|
||||||
}
|
}
|
||||||
int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
static int StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
||||||
{
|
{
|
||||||
TRACE("(%p, %p %s)\n",
|
TRACE("(%p, %p %s)\n",
|
||||||
lpWideCharStr, lpWString, debugstr_w(lpWString));
|
lpWideCharStr, lpWString, debugstr_w(lpWString));
|
||||||
|
|
||||||
wcscpy (lpWideCharStr, lpWString );
|
strcpyW (lpWideCharStr, lpWString );
|
||||||
return wcslen(lpWideCharStr);
|
return strlenW(lpWideCharStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
||||||
|
@ -149,19 +164,19 @@ BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
||||||
* lpMulti, nMulti, nWide [IN]
|
* lpMulti, nMulti, nWide [IN]
|
||||||
* lpWide [OUT]
|
* lpWide [OUT]
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
static BOOL StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
||||||
{
|
{
|
||||||
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
|
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
|
||||||
return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
|
return MultiByteToWideChar (CP_ACP, 0, lpStrA, nStr, lpWide, nWide);
|
||||||
}
|
}
|
||||||
BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
static BOOL StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
||||||
{
|
{
|
||||||
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
|
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
|
||||||
|
|
||||||
if (lstrcpynW (lpWide, lpStrW, nWide))
|
if (lstrcpynW (lpWide, lpStrW, nWide))
|
||||||
{ return wcslen (lpWide);
|
{ return lstrlenW (lpWide);
|
||||||
}
|
}
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
||||||
|
@ -174,20 +189,20 @@ BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* OleStrToStrN [SHELL32.78]
|
* OleStrToStrN [SHELL32.78]
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
static BOOL OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
||||||
{
|
{
|
||||||
TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
|
TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
|
||||||
return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
return WideCharToMultiByte (CP_ACP, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
static BOOL OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
||||||
{
|
{
|
||||||
TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
|
TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
|
||||||
|
|
||||||
if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
||||||
{ return wcslen (lpwStr);
|
{ return lstrlenW (lpwStr);
|
||||||
}
|
}
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
||||||
|
@ -222,7 +237,7 @@ DWORD WINAPI CheckEscapesA(
|
||||||
DWORD ret = 0;
|
DWORD ret = 0;
|
||||||
|
|
||||||
TRACE("(%s %d)\n", debugstr_a(string), len);
|
TRACE("(%s %d)\n", debugstr_a(string), len);
|
||||||
wString = (LPWSTR)LocalAlloc(LPTR, len * sizeof(WCHAR));
|
wString = LocalAlloc(LPTR, len * sizeof(WCHAR));
|
||||||
if (wString)
|
if (wString)
|
||||||
{
|
{
|
||||||
MultiByteToWideChar(CP_ACP, 0, string, len, wString, len);
|
MultiByteToWideChar(CP_ACP, 0, string, len, wString, len);
|
||||||
|
@ -244,7 +259,7 @@ DWORD WINAPI CheckEscapesW(
|
||||||
LPWSTR string,
|
LPWSTR string,
|
||||||
DWORD len)
|
DWORD len)
|
||||||
{
|
{
|
||||||
DWORD size = wcslen(string);
|
DWORD size = lstrlenW(string);
|
||||||
LPWSTR s, d;
|
LPWSTR s, d;
|
||||||
|
|
||||||
TRACE("(%s %d) stub\n", debugstr_w(string), len);
|
TRACE("(%s %d) stub\n", debugstr_w(string), len);
|
||||||
|
|
|
@ -1,264 +0,0 @@
|
||||||
/*
|
|
||||||
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "precomp.h"
|
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|
||||||
|
|
||||||
/************************* STRRET functions ****************************/
|
|
||||||
|
|
||||||
BOOL WINAPI StrRetToStrNA(LPSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
|
||||||
{
|
|
||||||
TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n",
|
|
||||||
dest,len,src,
|
|
||||||
(src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
|
|
||||||
(src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
|
|
||||||
(src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
|
|
||||||
pidl);
|
|
||||||
|
|
||||||
if (!dest)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
switch (src->uType)
|
|
||||||
{
|
|
||||||
case STRRET_WSTR:
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, src->pOleStr, -1, dest, len, NULL, NULL);
|
|
||||||
CoTaskMemFree(src->pOleStr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STRRET_CSTR:
|
|
||||||
lstrcpynA(dest, src->cStr, len);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STRRET_OFFSET:
|
|
||||||
lstrcpynA(dest, ((LPCSTR)&pidl->mkid)+src->uOffset, len);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
FIXME("unknown type!\n");
|
|
||||||
if (len) *dest = '\0';
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
TRACE("-- %s\n", debugstr_a(dest) );
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
|
||||||
{
|
|
||||||
TRACE("dest=%p len=0x%x strret=%p(%s) pidl=%p\n",
|
|
||||||
dest,len,src,
|
|
||||||
(src->uType == STRRET_WSTR) ? "STRRET_WSTR" :
|
|
||||||
(src->uType == STRRET_CSTR) ? "STRRET_CSTR" :
|
|
||||||
(src->uType == STRRET_OFFSET) ? "STRRET_OFFSET" : "STRRET_???",
|
|
||||||
pidl);
|
|
||||||
|
|
||||||
if (!dest)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
switch (src->uType)
|
|
||||||
{
|
|
||||||
case STRRET_WSTR:
|
|
||||||
lstrcpynW(dest, src->pOleStr, len);
|
|
||||||
CoTaskMemFree(src->pOleStr);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STRRET_CSTR:
|
|
||||||
if (!MultiByteToWideChar( CP_ACP, 0, src->cStr, -1, dest, len ) && len)
|
|
||||||
dest[len-1] = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STRRET_OFFSET:
|
|
||||||
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->uOffset, -1, dest, len ) && len)
|
|
||||||
dest[len-1] = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
FIXME("unknown type!\n");
|
|
||||||
if (len) *dest = '\0';
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* StrRetToStrN [SHELL32.96]
|
|
||||||
*
|
|
||||||
* converts a STRRET to a normal string
|
|
||||||
*
|
|
||||||
* NOTES
|
|
||||||
* the pidl is for STRRET OFFSET
|
|
||||||
*/
|
|
||||||
EXTERN_C BOOL WINAPI StrRetToStrNAW(LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
|
||||||
{
|
|
||||||
if(SHELL_OsIsUnicode())
|
|
||||||
return StrRetToStrNW((LPWSTR)dest, len, src, pidl);
|
|
||||||
else
|
|
||||||
return StrRetToStrNA((LPSTR)dest, len, src, pidl);
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************* OLESTR functions ****************************/
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* StrToOleStr [SHELL32.163]
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static int StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
|
||||||
{
|
|
||||||
TRACE("(%p, %p %s)\n",
|
|
||||||
lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
|
|
||||||
|
|
||||||
return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
|
||||||
|
|
||||||
}
|
|
||||||
static int StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
|
||||||
{
|
|
||||||
TRACE("(%p, %p %s)\n",
|
|
||||||
lpWideCharStr, lpWString, debugstr_w(lpWString));
|
|
||||||
|
|
||||||
wcscpy (lpWideCharStr, lpWString );
|
|
||||||
return wcslen(lpWideCharStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
EXTERN_C BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
|
||||||
{
|
|
||||||
if (SHELL_OsIsUnicode())
|
|
||||||
return StrToOleStrW (lpWideCharStr, (LPCWSTR)lpString);
|
|
||||||
return StrToOleStrA (lpWideCharStr, (LPCSTR)lpString);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* StrToOleStrN [SHELL32.79]
|
|
||||||
* lpMulti, nMulti, nWide [IN]
|
|
||||||
* lpWide [OUT]
|
|
||||||
*/
|
|
||||||
static BOOL StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
|
||||||
{
|
|
||||||
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
|
|
||||||
return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
|
|
||||||
}
|
|
||||||
static BOOL StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
|
||||||
{
|
|
||||||
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
|
|
||||||
|
|
||||||
if (lstrcpynW (lpWide, lpStrW, nWide))
|
|
||||||
{ return wcslen (lpWide);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
EXTERN_C BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
|
||||||
{
|
|
||||||
if (SHELL_OsIsUnicode())
|
|
||||||
return StrToOleStrNW (lpWide, nWide, (LPCWSTR)lpStr, nStr);
|
|
||||||
return StrToOleStrNA (lpWide, nWide, (LPCSTR)lpStr, nStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* OleStrToStrN [SHELL32.78]
|
|
||||||
*/
|
|
||||||
static BOOL OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
|
||||||
{
|
|
||||||
TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
|
|
||||||
return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
|
||||||
{
|
|
||||||
TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
|
|
||||||
|
|
||||||
if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
|
||||||
{ return wcslen (lpwStr);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
EXTERN_C BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
|
||||||
{
|
|
||||||
if (SHELL_OsIsUnicode())
|
|
||||||
return OleStrToStrNW ((LPWSTR)lpOut, nOut, (LPCWSTR)lpIn, nIn);
|
|
||||||
return OleStrToStrNA ((LPSTR)lpOut, nOut, (LPCWSTR)lpIn, nIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* CheckEscapesA [SHELL32.@]
|
|
||||||
*
|
|
||||||
* Checks a string for special characters which are not allowed in a path
|
|
||||||
* and encloses it in quotes if that is the case.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* string [I/O] string to check and on return eventually quoted
|
|
||||||
* len [I] length of string
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* length of actual string
|
|
||||||
*
|
|
||||||
* NOTES
|
|
||||||
* Not really sure if this function returns actually a value at all.
|
|
||||||
*/
|
|
||||||
DWORD WINAPI CheckEscapesA(
|
|
||||||
LPSTR string, /* [I/O] string to check ??*/
|
|
||||||
DWORD len) /* [I] is 0 */
|
|
||||||
{
|
|
||||||
LPWSTR wString;
|
|
||||||
DWORD ret = 0;
|
|
||||||
|
|
||||||
TRACE("(%s %d)\n", debugstr_a(string), len);
|
|
||||||
wString = (LPWSTR)LocalAlloc(LPTR, len * sizeof(WCHAR));
|
|
||||||
if (wString)
|
|
||||||
{
|
|
||||||
MultiByteToWideChar(CP_ACP, 0, string, len, wString, len);
|
|
||||||
ret = CheckEscapesW(wString, len);
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, wString, len, string, len, NULL, NULL);
|
|
||||||
LocalFree(wString);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const WCHAR strEscapedChars[] = {' ','"',',',';','^',0};
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* CheckEscapesW [SHELL32.@]
|
|
||||||
*
|
|
||||||
* See CheckEscapesA.
|
|
||||||
*/
|
|
||||||
DWORD WINAPI CheckEscapesW(
|
|
||||||
LPWSTR string,
|
|
||||||
DWORD len)
|
|
||||||
{
|
|
||||||
DWORD size = wcslen(string);
|
|
||||||
LPWSTR s, d;
|
|
||||||
|
|
||||||
TRACE("(%s %d) stub\n", debugstr_w(string), len);
|
|
||||||
|
|
||||||
if (StrPBrkW(string, strEscapedChars) && size + 2 <= len)
|
|
||||||
{
|
|
||||||
s = &string[size - 1];
|
|
||||||
d = &string[size + 2];
|
|
||||||
*d-- = 0;
|
|
||||||
*d-- = '"';
|
|
||||||
for (;d > string;)
|
|
||||||
*d-- = *s--;
|
|
||||||
*d = '"';
|
|
||||||
return size + 2;
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue