[SHLWAPI]

* Sync with Wine 1.5.26.

svn path=/trunk/; revision=58600
This commit is contained in:
Amine Khaldi 2013-03-24 12:35:51 +00:00
parent 66fc8a9d5a
commit aa6e6ab600
10 changed files with 193 additions and 75 deletions

View file

@ -531,7 +531,7 @@ HRESULT WINAPI SHCreateStreamOnFileA(LPCSTR lpszPath, DWORD dwMode,
if (!lpszPath)
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
MultiByteToWideChar(0, 0, lpszPath, -1, szPath, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, szPath, MAX_PATH);
return SHCreateStreamOnFileW(szPath, dwMode, lppStream);
}

View file

@ -641,25 +641,6 @@ INT WINAPI SHStringFromGUIDW(REFGUID guid, LPWSTR lpszDest, INT cchMax)
return iLen;
}
/*************************************************************************
* @ [SHLWAPI.29]
*
* Determine if a Unicode character is a space.
*
* PARAMS
* wc [I] Character to check.
*
* RETURNS
* TRUE, if wc is a space,
* FALSE otherwise.
*/
BOOL WINAPI IsCharSpaceW(WCHAR wc)
{
WORD CharType;
return GetStringTypeW(CT_CTYPE1, &wc, 1, &CharType) && (CharType & C1_SPACE);
}
/*************************************************************************
* @ [SHLWAPI.30]
*
@ -2680,7 +2661,7 @@ DWORD WINAPI SHGetRestriction(LPCWSTR lpSubKey, LPCWSTR lpSubName, LPCWSTR lpVal
lpSubKey = strRegistryPolicyW;
retval = RegOpenKeyW(HKEY_LOCAL_MACHINE, lpSubKey, &hKey);
if (retval != ERROR_SUCCESS)
if (retval != ERROR_SUCCESS)
retval = RegOpenKeyW(HKEY_CURRENT_USER, lpSubKey, &hKey);
if (retval != ERROR_SUCCESS)
return 0;
@ -2728,7 +2709,7 @@ DWORD WINAPI SHRestrictionLookup(
/* we have a known policy */
/* check if this policy has been cached */
if (*polArr == SHELL_NO_POLICY)
if (*polArr == SHELL_NO_POLICY)
*polArr = SHGetRestriction(initial, polTable->appstr, polTable->keystr);
return *polArr;
}

View file

@ -3246,6 +3246,9 @@ HRESULT WINAPI PathCreateFromUrlA(LPCSTR pszUrl, LPSTR pszPath,
HRESULT ret;
DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
return E_INVALIDARG;
if(!RtlCreateUnicodeStringFromAsciiz(&urlW, pszUrl))
return E_INVALIDARG;
if((ret = PathCreateFromUrlW(urlW.Buffer, pathW, &lenW, dwReserved)) == E_POINTER) {
@ -3287,61 +3290,156 @@ HRESULT WINAPI PathCreateFromUrlW(LPCWSTR pszUrl, LPWSTR pszPath,
LPDWORD pcchPath, DWORD dwReserved)
{
static const WCHAR file_colon[] = { 'f','i','l','e',':',0 };
HRESULT hr;
DWORD nslashes = 0;
WCHAR *ptr;
static const WCHAR localhost[] = { 'l','o','c','a','l','h','o','s','t',0 };
DWORD nslashes, unescape, len;
const WCHAR *src;
WCHAR *tpath, *dst;
HRESULT ret;
TRACE("(%s,%p,%p,0x%08x)\n", debugstr_w(pszUrl), pszPath, pcchPath, dwReserved);
if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
return E_INVALIDARG;
if (strncmpW(pszUrl, file_colon, 5))
if (CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pszUrl, 5,
file_colon, 5) != CSTR_EQUAL)
return E_INVALIDARG;
pszUrl += 5;
ret = S_OK;
while(*pszUrl == '/' || *pszUrl == '\\') {
src = pszUrl;
nslashes = 0;
while (*src == '/' || *src == '\\') {
nslashes++;
pszUrl++;
src++;
}
if(isalphaW(*pszUrl) && (pszUrl[1] == ':' || pszUrl[1] == '|') && (pszUrl[2] == '/' || pszUrl[2] == '\\'))
nslashes = 0;
/* We need a temporary buffer so we can compute what size to ask for.
* We know that the final string won't be longer than the current pszUrl
* plus at most two backslashes. All the other transformations make it
* shorter.
*/
len = 2 + lstrlenW(pszUrl) + 1;
if (*pcchPath < len)
tpath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
else
tpath = pszPath;
switch(nslashes) {
case 2:
pszUrl -= 2;
break;
len = 0;
dst = tpath;
unescape = 1;
switch (nslashes)
{
case 0:
/* 'file:' + escaped DOS path */
break;
case 1:
/* 'file:/' + escaped DOS path */
/* fall through */
case 3:
/* 'file:///' (implied localhost) + escaped DOS path */
if (!isalphaW(*src) || (src[1] != ':' && src[1] != '|'))
src -= 1;
break;
case 2:
if (CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, src, 9,
localhost, 9) == CSTR_EQUAL &&
(src[9] == '/' || src[9] == '\\'))
{
/* 'file://localhost/' + escaped DOS path */
src += 10;
}
else if (isalphaW(*src) && (src[1] == ':' || src[1] == '|'))
{
/* 'file://' + unescaped DOS path */
unescape = 0;
}
else
{
/* 'file://hostname:port/path' (where path is escaped)
* or 'file:' + escaped UNC path (\\server\share\path)
* The second form is clearly specific to Windows and it might
* even be doing a network lookup to try to figure it out.
*/
while (*src && *src != '/' && *src != '\\')
src++;
len = src - pszUrl;
StrCpyNW(dst, pszUrl, len + 1);
dst += len;
if (isalphaW(src[1]) && (src[2] == ':' || src[2] == '|'))
{
/* 'Forget' to add a trailing '/', just like Windows */
src++;
}
}
break;
case 4:
/* 'file://' + unescaped UNC path (\\server\share\path) */
unescape = 0;
if (isalphaW(*src) && (src[1] == ':' || src[1] == '|'))
break;
/* fall through */
default:
pszUrl -= 1;
break;
/* 'file:/...' + escaped UNC path (\\server\share\path) */
src -= 2;
}
hr = UrlUnescapeW((LPWSTR)pszUrl, pszPath, pcchPath, 0);
if(hr != S_OK) return hr;
/* Copy the remainder of the path */
len += lstrlenW(src);
StrCpyW(dst, src);
for(ptr = pszPath; *ptr; ptr++)
if(*ptr == '/') *ptr = '\\';
/* First do the Windows-specific path conversions */
for (dst = tpath; *dst; dst++)
if (*dst == '/') *dst = '\\';
if (isalphaW(*tpath) && tpath[1] == '|')
tpath[1] = ':'; /* c| -> c: */
while(*pszPath == '\\')
pszPath++;
if(isalphaW(*pszPath) && pszPath[1] == '|' && pszPath[2] == '\\') /* c|\ -> c:\ */
pszPath[1] = ':';
if(nslashes == 2 && (ptr = strchrW(pszPath, '\\'))) { /* \\host\c:\ -> \\hostc:\ */
ptr++;
if(isalphaW(*ptr) && (ptr[1] == ':' || ptr[1] == '|') && ptr[2] == '\\') {
memmove(ptr - 1, ptr, (strlenW(ptr) + 1) * sizeof(WCHAR));
(*pcchPath)--;
/* And only then unescape the path (i.e. escaped slashes are left as is) */
if (unescape)
{
ret = UrlUnescapeW(tpath, NULL, &len, URL_UNESCAPE_INPLACE);
if (ret == S_OK)
{
/* When working in-place UrlUnescapeW() does not set len */
len = lstrlenW(tpath);
}
}
TRACE("Returning %s\n",debugstr_w(pszPath));
if (*pcchPath < len + 1)
{
ret = E_POINTER;
*pcchPath = len + 1;
}
else
{
*pcchPath = len;
if (tpath != pszPath)
StrCpyW(pszPath, tpath);
}
if (tpath != pszPath)
HeapFree(GetProcessHeap(), 0, tpath);
TRACE("Returning (%u) %s\n", *pcchPath, debugstr_w(pszPath));
return ret;
}
/*************************************************************************
* PathCreateFromUrlAlloc [SHLWAPI.@]
*/
HRESULT WINAPI PathCreateFromUrlAlloc(LPCWSTR pszUrl, LPWSTR *pszPath,
DWORD dwReserved)
{
WCHAR pathW[MAX_PATH];
DWORD size;
HRESULT hr;
size = MAX_PATH;
hr = PathCreateFromUrlW(pszUrl, pathW, &size, dwReserved);
if (SUCCEEDED(hr))
{
/* Yes, this is supposed to crash if pszPath is NULL */
*pszPath = StrDupW(pathW);
}
return hr;
}

View file

@ -2232,7 +2232,7 @@ DWORD WINAPI SHCopyKeyA(HKEY hKeySrc, LPCSTR lpszSrcSubKey, HKEY hKeyDst, DWORD
TRACE("(hkey=%p,%s,%p08x,%d)\n", hKeySrc, debugstr_a(lpszSrcSubKey), hKeyDst, dwReserved);
if (lpszSrcSubKey)
MultiByteToWideChar(0, 0, lpszSrcSubKey, -1, szSubKeyW, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, lpszSrcSubKey, -1, szSubKeyW, MAX_PATH);
return SHCopyKeyW(hKeySrc, lpszSrcSubKey ? szSubKeyW : NULL, hKeyDst, dwReserved);
}

View file

@ -1,5 +1,5 @@
/*
* Top level resource file for shlwapi
* Resources for shlwapi
*
* Copyright 2004 Jon Griffiths
*

View file

@ -566,6 +566,8 @@
@ stdcall HashData (ptr long ptr long)
@ stdcall IntlStrEqWorkerA(long str str long) StrIsIntlEqualA
@ stdcall IntlStrEqWorkerW(long wstr wstr long) StrIsIntlEqualW
@ stdcall IsCharSpaceA(long)
@ stdcall IsInternetESCEnabled()
@ stdcall PathAddBackslashA (str)
@ stdcall PathAddBackslashW (wstr)
@ stdcall PathAddExtensionA (str str)
@ -586,6 +588,7 @@
@ stdcall PathCompactPathW(long wstr long)
@ stdcall PathCreateFromUrlA(str ptr ptr long)
@ stdcall PathCreateFromUrlW(wstr ptr ptr long)
@ stdcall PathCreateFromUrlAlloc(wstr ptr long)
@ stdcall PathFileExistsA (str)
@ stdcall PathFileExistsW (wstr)
@ stdcall PathFindExtensionA (str)

View file

@ -1891,7 +1891,7 @@ HRESULT WINAPI SHStrDupA(LPCSTR lpszStr, LPWSTR * lppszDest)
if (lpszStr)
{
len = MultiByteToWideChar(0, 0, lpszStr, -1, 0, 0) * sizeof(WCHAR);
len = MultiByteToWideChar(CP_ACP, 0, lpszStr, -1, NULL, 0) * sizeof(WCHAR);
*lppszDest = CoTaskMemAlloc(len);
}
else
@ -1899,7 +1899,7 @@ HRESULT WINAPI SHStrDupA(LPCSTR lpszStr, LPWSTR * lppszDest)
if (*lppszDest)
{
MultiByteToWideChar(0, 0, lpszStr, -1, *lppszDest, len/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpszStr, -1, *lppszDest, len/sizeof(WCHAR));
hRet = S_OK;
}
else
@ -2828,3 +2828,28 @@ end:
HeapFree(GetProcessHeap(), 0, dllname);
return hr;
}
BOOL WINAPI IsCharSpaceA(CHAR c)
{
WORD CharType;
return GetStringTypeA(GetSystemDefaultLCID(), CT_CTYPE1, &c, 1, &CharType) && (CharType & C1_SPACE);
}
/*************************************************************************
* @ [SHLWAPI.29]
*
* Determine if a Unicode character is a space.
*
* PARAMS
* wc [I] Character to check.
*
* RETURNS
* TRUE, if wc is a space,
* FALSE otherwise.
*/
BOOL WINAPI IsCharSpaceW(WCHAR wc)
{
WORD CharType;
return GetStringTypeW(CT_CTYPE1, &wc, 1, &CharType) && (CharType & C1_SPACE);
}

View file

@ -534,7 +534,7 @@ HANDLE WINAPI SHGlobalCounterCreateNamedA(LPCSTR lpszName, DWORD iInitial)
TRACE("(%s,%d)\n", debugstr_a(lpszName), iInitial);
if (lpszName)
MultiByteToWideChar(0, 0, lpszName, -1, szBuff, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, lpszName, -1, szBuff, MAX_PATH);
return SHGlobalCounterCreateNamedW(lpszName ? szBuff : NULL, iInitial);
}

View file

@ -270,8 +270,8 @@ HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
ret = UrlCanonicalizeW(url, canonical, pcchCanonicalized, dwFlags);
if(ret == S_OK)
WideCharToMultiByte(0, 0, canonical, -1, pszCanonicalized,
*pcchCanonicalized+1, 0, 0);
WideCharToMultiByte(CP_ACP, 0, canonical, -1, pszCanonicalized,
*pcchCanonicalized+1, NULL, NULL);
HeapFree(GetProcessHeap(), 0, url);
HeapFree(GetProcessHeap(), 0, canonical);
@ -631,8 +631,8 @@ HRESULT WINAPI UrlCombineA(LPCSTR pszBase, LPCSTR pszRelative,
relative = base + INTERNET_MAX_URL_LENGTH;
combined = relative + INTERNET_MAX_URL_LENGTH;
MultiByteToWideChar(0, 0, pszBase, -1, base, INTERNET_MAX_URL_LENGTH);
MultiByteToWideChar(0, 0, pszRelative, -1, relative, INTERNET_MAX_URL_LENGTH);
MultiByteToWideChar(CP_ACP, 0, pszBase, -1, base, INTERNET_MAX_URL_LENGTH);
MultiByteToWideChar(CP_ACP, 0, pszRelative, -1, relative, INTERNET_MAX_URL_LENGTH);
len = *pcchCombined;
ret = UrlCombineW(base, relative, pszCombined?combined:NULL, &len, dwFlags);
@ -642,14 +642,14 @@ HRESULT WINAPI UrlCombineA(LPCSTR pszBase, LPCSTR pszRelative,
return ret;
}
len2 = WideCharToMultiByte(0, 0, combined, len, 0, 0, 0, 0);
len2 = WideCharToMultiByte(CP_ACP, 0, combined, len, NULL, 0, NULL, NULL);
if (len2 > *pcchCombined) {
*pcchCombined = len2;
HeapFree(GetProcessHeap(), 0, base);
return E_POINTER;
}
WideCharToMultiByte(0, 0, combined, len+1, pszCombined, (*pcchCombined)+1,
0, 0);
WideCharToMultiByte(CP_ACP, 0, combined, len+1, pszCombined, (*pcchCombined)+1,
NULL, NULL);
*pcchCombined = len2;
HeapFree(GetProcessHeap(), 0, base);
return S_OK;
@ -1601,7 +1601,7 @@ HRESULT WINAPI UrlHashW(LPCWSTR pszUrl, unsigned char *lpDest, DWORD nDestLen)
/* Win32 hashes the data as an ASCII string, presumably so that both A+W
* return the same digests for the same URL.
*/
WideCharToMultiByte(0, 0, pszUrl, -1, szUrl, MAX_PATH, 0, 0);
WideCharToMultiByte(CP_ACP, 0, pszUrl, -1, szUrl, MAX_PATH, NULL, NULL);
HashData((const BYTE*)szUrl, (int)strlen(szUrl), lpDest, nDestLen);
return S_OK;
}
@ -1670,7 +1670,7 @@ static HRESULT URL_GuessScheme(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut)
WCHAR value[MAX_PATH], data[MAX_PATH];
WCHAR Wxx, Wyy;
MultiByteToWideChar(0, 0,
MultiByteToWideChar(CP_ACP, 0,
"Software\\Microsoft\\Windows\\CurrentVersion\\URL\\Prefixes",
-1, reg_path, MAX_PATH);
RegOpenKeyExW(HKEY_LOCAL_MACHINE, reg_path, 0, 1, &newkey);
@ -1868,7 +1868,8 @@ BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis)
return FALSE;
case URLIS_FILEURL:
return !StrCmpNA("file:", pszUrl, 5);
return (CompareStringA(LOCALE_INVARIANT, NORM_IGNORECASE, pszUrl, 5,
"file:", 5) == CSTR_EQUAL);
case URLIS_DIRECTORY:
last = pszUrl + strlen(pszUrl) - 1;
@ -1893,7 +1894,7 @@ BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis)
*/
BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis)
{
static const WCHAR stemp[] = { 'f','i','l','e',':',0 };
static const WCHAR file_colon[] = { 'f','i','l','e',':',0 };
PARSEDURLW base;
DWORD res1;
LPCWSTR last;
@ -1921,7 +1922,8 @@ BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis)
return FALSE;
case URLIS_FILEURL:
return !strncmpW(stemp, pszUrl, 5);
return (CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pszUrl, 5,
file_colon, 5) == CSTR_EQUAL);
case URLIS_DIRECTORY:
last = pszUrl + strlenW(pszUrl) - 1;
@ -2199,7 +2201,7 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut,
(2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
out = in + INTERNET_MAX_URL_LENGTH;
MultiByteToWideChar(0, 0, pszIn, -1, in, INTERNET_MAX_URL_LENGTH);
MultiByteToWideChar(CP_ACP, 0, pszIn, -1, in, INTERNET_MAX_URL_LENGTH);
len = INTERNET_MAX_URL_LENGTH;
ret = UrlGetPartW(in, out, &len, dwPart, dwFlags);
@ -2209,13 +2211,13 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut,
return ret;
}
len2 = WideCharToMultiByte(0, 0, out, len, 0, 0, 0, 0);
len2 = WideCharToMultiByte(CP_ACP, 0, out, len, NULL, 0, NULL, NULL);
if (len2 > *pcchOut) {
*pcchOut = len2+1;
HeapFree(GetProcessHeap(), 0, in);
return E_POINTER;
}
len2 = WideCharToMultiByte(0, 0, out, len+1, pszOut, *pcchOut, 0, 0);
len2 = WideCharToMultiByte(CP_ACP, 0, out, len+1, pszOut, *pcchOut, NULL, NULL);
*pcchOut = len2-1;
HeapFree(GetProcessHeap(), 0, in);
return ret;
@ -2529,7 +2531,7 @@ HRESULT WINAPI MLBuildResURLA(LPCSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
hRet = MLBuildResURLW(lpszLibName ? szLibName : NULL, hMod, dwFlags,
lpszRes ? szRes : NULL, lpszDest ? szDest : NULL, dwDestLen);
if (SUCCEEDED(hRet) && lpszDest)
WideCharToMultiByte(CP_ACP, 0, szDest, -1, lpszDest, dwDestLen, 0, 0);
WideCharToMultiByte(CP_ACP, 0, szDest, -1, lpszDest, dwDestLen, NULL, NULL);
return hRet;
}
@ -2623,3 +2625,12 @@ HRESULT WINAPI UrlFixupW(LPCWSTR url, LPWSTR translatedUrl, DWORD maxChars)
return S_OK;
}
/*************************************************************************
* IsInternetESCEnabled [SHLWAPI.@]
*/
BOOL WINAPI IsInternetESCEnabled(void)
{
FIXME(": stub\n");
return FALSE;
}

View file

@ -164,7 +164,7 @@ reactos/dll/win32/shdoclc # Synced to Wine-1.5.19
reactos/dll/win32/shdocvw # Autosync
reactos/dll/win32/shell32 # Forked at Wine-20071011
reactos/dll/win32/shfolder # Autosync
reactos/dll/win32/shlwapi # Synced to Wine-1.5.13
reactos/dll/win32/shlwapi # Synced to Wine-1.5.26
reactos/dll/win32/slbcsp # Synced to Wine-1.5.19
reactos/dll/win32/snmpapi # Synced to Wine-1.5.19
reactos/dll/win32/softpub # Synced to Wine-1.5.19