Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/kernelbase/kernelbase.spec | 12 +- dlls/kernelbase/registry.c | 210 +++++++++++++++++++++++++++++++- 2 files changed, 212 insertions(+), 10 deletions(-)
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index 24d7b1772b..0a68928953 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -1367,16 +1367,16 @@ @ stdcall SHRegEnumUSKeyW(long long wstr ptr long) @ stdcall SHRegEnumUSValueA(long long ptr ptr ptr ptr ptr long) @ stdcall SHRegEnumUSValueW(long long ptr ptr ptr ptr ptr long) -@ stdcall SHRegGetBoolUSValueA(str str long long) shlwapi.SHRegGetBoolUSValueA -@ stdcall SHRegGetBoolUSValueW(wstr wstr long long) shlwapi.SHRegGetBoolUSValueW -@ stdcall SHRegGetUSValueA( str str ptr ptr ptr long ptr long ) shlwapi.SHRegGetUSValueA -@ stdcall SHRegGetUSValueW( wstr wstr ptr ptr ptr long ptr long ) shlwapi.SHRegGetUSValueW +@ stdcall SHRegGetBoolUSValueA(str str long long) +@ stdcall SHRegGetBoolUSValueW(wstr wstr long long) +@ stdcall SHRegGetUSValueA(str str ptr ptr ptr long ptr long) +@ stdcall SHRegGetUSValueW(wstr wstr ptr ptr ptr long ptr long) @ stdcall SHRegOpenUSKeyA(str long long long long) @ stdcall SHRegOpenUSKeyW(wstr long long long long) @ stdcall SHRegQueryInfoUSKeyA(long ptr ptr ptr ptr long) @ stdcall SHRegQueryInfoUSKeyW(long ptr ptr ptr ptr long) -@ stdcall SHRegQueryUSValueA( long str ptr ptr ptr long ptr long ) shlwapi.SHRegQueryUSValueA -@ stdcall SHRegQueryUSValueW( long wstr ptr ptr ptr long ptr long ) shlwapi.SHRegQueryUSValueW +@ stdcall SHRegQueryUSValueA(long str ptr ptr ptr long ptr long) +@ stdcall SHRegQueryUSValueW(long wstr ptr ptr ptr long ptr long) @ stdcall SHRegSetUSValueA(str str long ptr long long) @ stdcall SHRegSetUSValueW(wstr wstr long ptr long long) @ stdcall SHRegWriteUSValueA(long str long ptr long long) diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index bfc7f10942..0bf6b44aea 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -430,8 +430,8 @@ LONG WINAPI SHRegSetUSValueW(const WCHAR *subkey, const WCHAR *value, DWORD type return ret; }
-LONG WINAPI SHRegQueryInfoUSKeyA(HUSKEY hUSKey, DWORD *subkeys, DWORD *max_subkey_len, DWORD *values, DWORD *max_value_name_len, - SHREGENUM_FLAGS flags) +LONG WINAPI SHRegQueryInfoUSKeyA(HUSKEY hUSKey, DWORD *subkeys, DWORD *max_subkey_len, DWORD *values, + DWORD *max_value_name_len, SHREGENUM_FLAGS flags) { HKEY dokey; LONG ret; @@ -453,8 +453,8 @@ LONG WINAPI SHRegQueryInfoUSKeyA(HUSKEY hUSKey, DWORD *subkeys, DWORD *max_subke return ERROR_INVALID_FUNCTION; }
-LONG WINAPI SHRegQueryInfoUSKeyW(HUSKEY hUSKey, DWORD *subkeys, DWORD *max_subkey_len, DWORD *values, DWORD *max_value_name_len, - SHREGENUM_FLAGS flags) +LONG WINAPI SHRegQueryInfoUSKeyW(HUSKEY hUSKey, DWORD *subkeys, DWORD *max_subkey_len, DWORD *values, + DWORD *max_value_name_len, SHREGENUM_FLAGS flags) { HKEY dokey; LONG ret; @@ -475,3 +475,205 @@ LONG WINAPI SHRegQueryInfoUSKeyW(HUSKEY hUSKey, DWORD *subkeys, DWORD *max_subke
return ERROR_INVALID_FUNCTION; } + +LONG WINAPI SHRegQueryUSValueA(HUSKEY hUSKey, const char *value, DWORD *type, void *data, DWORD *data_len, + BOOL ignore_hkcu, void *default_data, DWORD default_data_len) +{ + LONG ret = ~ERROR_SUCCESS; + DWORD move_len; + HKEY dokey; + + /* If user wants HKCU, and it exists, then try it */ + if (!ignore_hkcu && (dokey = reg_get_hkey_from_huskey(hUSKey, TRUE))) + { + ret = RegQueryValueExA(dokey, value, 0, type, data, data_len); + TRACE("HKCU RegQueryValue returned %d\n", ret); + } + + /* If HKCU did not work and HKLM exists, then try it */ + if ((ret != ERROR_SUCCESS) && (dokey = reg_get_hkey_from_huskey(hUSKey, FALSE))) + { + ret = RegQueryValueExA(dokey, value, 0, type, data, data_len); + TRACE("HKLM RegQueryValue returned %d\n", ret); + } + + /* If neither worked, and default data exists, then use it */ + if (ret != ERROR_SUCCESS) + { + if (default_data && default_data_len) + { + move_len = default_data_len >= *data_len ? *data_len : default_data_len; + memmove(data, default_data, move_len); + *data_len = move_len; + TRACE("setting default data\n"); + ret = ERROR_SUCCESS; + } + } + + return ret; +} + +LONG WINAPI SHRegQueryUSValueW(HUSKEY hUSKey, const WCHAR *value, DWORD *type, void *data, DWORD *data_len, + BOOL ignore_hkcu, void *default_data, DWORD default_data_len) +{ + LONG ret = ~ERROR_SUCCESS; + DWORD move_len; + HKEY dokey; + + /* If user wants HKCU, and it exists, then try it */ + if (!ignore_hkcu && (dokey = reg_get_hkey_from_huskey(hUSKey, TRUE))) + { + ret = RegQueryValueExW(dokey, value, 0, type, data, data_len); + TRACE("HKCU RegQueryValue returned %d\n", ret); + } + + /* If HKCU did not work and HKLM exists, then try it */ + if ((ret != ERROR_SUCCESS) && (dokey = reg_get_hkey_from_huskey(hUSKey, FALSE))) + { + ret = RegQueryValueExW(dokey, value, 0, type, data, data_len); + TRACE("HKLM RegQueryValue returned %d\n", ret); + } + + /* If neither worked, and default data exists, then use it */ + if (ret != ERROR_SUCCESS) + { + if (default_data && default_data_len) + { + move_len = default_data_len >= *data_len ? *data_len : default_data_len; + memmove(data, default_data, move_len); + *data_len = move_len; + TRACE("setting default data\n"); + ret = ERROR_SUCCESS; + } + } + + return ret; +} + +LONG WINAPI SHRegGetUSValueA(const char *subkey, const char *value, DWORD *type, void *data, DWORD *data_len, + BOOL ignore_hkcu, void *default_data, DWORD default_data_len) +{ + HUSKEY myhuskey; + LONG ret; + + if (!data || !data_len) + return ERROR_INVALID_FUNCTION; /* FIXME:wrong*/ + + TRACE("%s, %s, %d\n", debugstr_a(subkey), debugstr_a(value), *data_len); + + ret = SHRegOpenUSKeyA(subkey, KEY_QUERY_VALUE, 0, &myhuskey, ignore_hkcu); + if (!ret) + { + ret = SHRegQueryUSValueA(myhuskey, value, type, data, data_len, ignore_hkcu, default_data, default_data_len); + SHRegCloseUSKey(myhuskey); + } + + return ret; +} + +LONG WINAPI SHRegGetUSValueW(const WCHAR *subkey, const WCHAR *value, DWORD *type, void *data, DWORD *data_len, + BOOL ignore_hkcu, void *default_data, DWORD default_data_len) +{ + HUSKEY myhuskey; + LONG ret; + + if (!data || !data_len) + return ERROR_INVALID_FUNCTION; /* FIXME:wrong*/ + + TRACE("%s, %s, %d\n", debugstr_w(subkey), debugstr_w(value), *data_len); + + ret = SHRegOpenUSKeyW(subkey, KEY_QUERY_VALUE, 0, &myhuskey, ignore_hkcu); + if (!ret) + { + ret = SHRegQueryUSValueW(myhuskey, value, type, data, data_len, ignore_hkcu, default_data, default_data_len); + SHRegCloseUSKey(myhuskey); + } + + return ret; +} + +BOOL WINAPI SHRegGetBoolUSValueA(const char *subkey, const char *value, BOOL ignore_hkcu, BOOL default_value) +{ + BOOL ret = default_value; + DWORD type, datalen; + char data[10]; + + TRACE("%s, %s, %d\n", debugstr_a(subkey), debugstr_a(value), ignore_hkcu); + + datalen = ARRAY_SIZE(data) - 1; + if (!SHRegGetUSValueA(subkey, value, &type, data, &datalen, ignore_hkcu, 0, 0)) + { + switch (type) + { + case REG_SZ: + data[9] = '\0'; + if (!lstrcmpiA(data, "YES") || !lstrcmpiA(data, "TRUE")) + ret = TRUE; + else if (!lstrcmpiA(data, "NO") || !lstrcmpiA(data, "FALSE")) + ret = FALSE; + break; + case REG_DWORD: + ret = *(DWORD *)data != 0; + break; + case REG_BINARY: + if (datalen == 1) + { + ret = !!data[0]; + break; + } + default: + FIXME("Unsupported registry data type %d\n", type); + ret = FALSE; + } + TRACE("got value (type=%d), returning %d\n", type, ret); + } + else + TRACE("returning default value %d\n", ret); + + return ret; +} + +BOOL WINAPI SHRegGetBoolUSValueW(const WCHAR *subkey, const WCHAR *value, BOOL ignore_hkcu, BOOL default_value) +{ + static const WCHAR yesW[]= {'Y','E','S',0}; + static const WCHAR trueW[] = {'T','R','U','E',0}; + static const WCHAR noW[] = {'N','O',0}; + static const WCHAR falseW[] = {'F','A','L','S','E',0}; + BOOL ret = default_value; + DWORD type, datalen; + WCHAR data[10]; + + TRACE("%s, %s, %d\n", debugstr_w(subkey), debugstr_w(value), ignore_hkcu); + + datalen = (ARRAY_SIZE(data) - 1) * sizeof(WCHAR); + if (!SHRegGetUSValueW(subkey, value, &type, data, &datalen, ignore_hkcu, 0, 0)) + { + switch (type) + { + case REG_SZ: + data[9] = '\0'; + if (!lstrcmpiW(data, yesW) || !lstrcmpiW(data, trueW)) + ret = TRUE; + else if (!lstrcmpiW(data, noW) || !lstrcmpiW(data, falseW)) + ret = FALSE; + break; + case REG_DWORD: + ret = *(DWORD *)data != 0; + break; + case REG_BINARY: + if (datalen == 1) + { + ret = !!data[0]; + break; + } + default: + FIXME("Unsupported registry data type %d\n", type); + ret = FALSE; + } + TRACE("got value (type=%d), returning %d\n", type, ret); + } + else + TRACE("returning default value %d\n", ret); + + return ret; +}
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/shlwapi/ordinal.c | 95 --- dlls/shlwapi/shlwapi.spec | 90 +-- dlls/shlwapi/string.c | 1179 +++---------------------------------- 3 files changed, 120 insertions(+), 1244 deletions(-)
diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c index 657c33fffa..16096614f9 100644 --- a/dlls/shlwapi/ordinal.c +++ b/dlls/shlwapi/ordinal.c @@ -731,35 +731,6 @@ BOOL WINAPI GetStringType3ExW(LPWSTR src, INT count, LPWORD type) return GetStringTypeW(CT_CTYPE3, src, count, type); }
-/************************************************************************* - * @ [SHLWAPI.151] - * - * Compare two Ascii strings up to a given length. - * - * PARAMS - * lpszSrc [I] Source string - * lpszCmp [I] String to compare to lpszSrc - * len [I] Maximum length - * - * RETURNS - * A number greater than, less than or equal to 0 depending on whether - * lpszSrc is greater than, less than or equal to lpszCmp. - */ -DWORD WINAPI StrCmpNCA(LPCSTR lpszSrc, LPCSTR lpszCmp, INT len) -{ - return StrCmpNA(lpszSrc, lpszCmp, len); -} - -/************************************************************************* - * @ [SHLWAPI.152] - * - * Unicode version of StrCmpNCA. - */ -DWORD WINAPI StrCmpNCW(LPCWSTR lpszSrc, LPCWSTR lpszCmp, INT len) -{ - return StrCmpNW(lpszSrc, lpszCmp, len); -} - /************************************************************************* * @ [SHLWAPI.153] * @@ -779,72 +750,6 @@ DWORD WINAPI StrCmpNICA(LPCSTR lpszSrc, LPCSTR lpszCmp, DWORD len) return StrCmpNIA(lpszSrc, lpszCmp, len); }
-/************************************************************************* - * @ [SHLWAPI.154] - * - * Unicode version of StrCmpNICA. - */ -DWORD WINAPI StrCmpNICW(LPCWSTR lpszSrc, LPCWSTR lpszCmp, DWORD len) -{ - return StrCmpNIW(lpszSrc, lpszCmp, len); -} - -/************************************************************************* - * @ [SHLWAPI.155] - * - * Compare two Ascii strings. - * - * PARAMS - * lpszSrc [I] Source string - * lpszCmp [I] String to compare to lpszSrc - * - * RETURNS - * A number greater than, less than or equal to 0 depending on whether - * lpszSrc is greater than, less than or equal to lpszCmp. - */ -DWORD WINAPI StrCmpCA(LPCSTR lpszSrc, LPCSTR lpszCmp) -{ - return lstrcmpA(lpszSrc, lpszCmp); -} - -/************************************************************************* - * @ [SHLWAPI.156] - * - * Unicode version of StrCmpCA. - */ -DWORD WINAPI StrCmpCW(LPCWSTR lpszSrc, LPCWSTR lpszCmp) -{ - return lstrcmpW(lpszSrc, lpszCmp); -} - -/************************************************************************* - * @ [SHLWAPI.157] - * - * Compare two Ascii strings, ignoring case. - * - * PARAMS - * lpszSrc [I] Source string - * lpszCmp [I] String to compare to lpszSrc - * - * RETURNS - * A number greater than, less than or equal to 0 depending on whether - * lpszSrc is greater than, less than or equal to lpszCmp. - */ -DWORD WINAPI StrCmpICA(LPCSTR lpszSrc, LPCSTR lpszCmp) -{ - return lstrcmpiA(lpszSrc, lpszCmp); -} - -/************************************************************************* - * @ [SHLWAPI.158] - * - * Unicode version of StrCmpICA. - */ -DWORD WINAPI StrCmpICW(LPCWSTR lpszSrc, LPCWSTR lpszCmp) -{ - return lstrcmpiW(lpszSrc, lpszCmp); -} - /************************************************************************* * @ [SHLWAPI.160] * diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec index 060daccf24..3bc0da8fb0 100644 --- a/dlls/shlwapi/shlwapi.spec +++ b/dlls/shlwapi/shlwapi.spec @@ -148,14 +148,14 @@ 148 stdcall -noname VkKeyScanWrapW(long) user32.VkKeyScanW 149 stdcall -noname WinHelpWrapW(long wstr long long) user32.WinHelpW 150 stdcall -noname wvsprintfWrapW(ptr wstr ptr) user32.wvsprintfW -151 stdcall -ordinal StrCmpNCA(str ptr long) -152 stdcall -ordinal StrCmpNCW(wstr wstr long) +151 stdcall -ordinal StrCmpNCA(str ptr long) kernelbase.StrCmpNCA +152 stdcall -ordinal StrCmpNCW(wstr wstr long) kernelbase.StrCmpNCW 153 stdcall -ordinal StrCmpNICA(long long long) -154 stdcall -ordinal StrCmpNICW(wstr wstr long) -155 stdcall -ordinal StrCmpCA(str str) -156 stdcall -ordinal StrCmpCW(wstr wstr) -157 stdcall -ordinal StrCmpICA(str str) -158 stdcall -ordinal StrCmpICW(wstr wstr) +154 stdcall -ordinal StrCmpNICW(wstr wstr long) kernelbase.StrCmpNICW +155 stdcall -ordinal StrCmpCA(str str) kernelbase.StrCmpCA +156 stdcall -ordinal StrCmpCW(wstr wstr) kernelbase.StrCmpCW +157 stdcall -ordinal StrCmpICA(str str) kernelbase.StrCmpICA +158 stdcall -ordinal StrCmpICW(wstr wstr) kernelbase.StrCmpICW 159 stdcall -noname CompareStringAltW(long long wstr long wstr long) kernel32.CompareStringW 160 stdcall -noname SHAboutInfoA(ptr long) 161 stdcall -noname SHAboutInfoW(ptr long) @@ -396,8 +396,8 @@ 396 stub -noname MLHtmlHelpA 397 stub -noname MLWinHelpW 398 stub -noname MLHtmlHelpW -399 stdcall -noname StrCpyNXA(ptr str long) -400 stdcall -noname StrCpyNXW(ptr wstr long) +399 stdcall -noname StrCpyNXA(ptr str long) kernelbase.StrCpyNXA +400 stdcall -noname StrCpyNXW(ptr wstr long) kernelbase.StrCpyNXW 401 stdcall -noname PageSetupDlgWrapW(ptr) 402 stdcall -noname PrintDlgWrapW(ptr) 403 stdcall -noname GetOpenFileNameWrapW(ptr) @@ -564,8 +564,8 @@ @ stdcall -private DllGetVersion(ptr) @ stdcall GetMenuPosFromID(ptr long) @ stdcall HashData (ptr long ptr long) -@ stdcall IntlStrEqWorkerA(long str str long) StrIsIntlEqualA -@ stdcall IntlStrEqWorkerW(long wstr wstr long) StrIsIntlEqualW +@ stdcall IntlStrEqWorkerA(long str str long) kernelbase.StrIsIntlEqualA +@ stdcall IntlStrEqWorkerW(long wstr wstr long) kernelbase.StrIsIntlEqualW @ stdcall IsCharSpaceA(long) @ stdcall IsInternetESCEnabled() @ stdcall PathAddBackslashA (str) @@ -753,29 +753,29 @@ @ stdcall SHSkipJunction(ptr ptr) @ stdcall SHStrDupA (str ptr) @ stdcall SHStrDupW (wstr ptr) -@ stdcall StrCSpnA (str str) -@ stdcall StrCSpnIA (str str) -@ stdcall StrCSpnIW (wstr wstr) -@ stdcall StrCSpnW (wstr wstr) -@ stdcall StrCatBuffA (str str long) +@ stdcall StrCSpnA(str str) kernelbase.StrCSpnA +@ stdcall StrCSpnIA(str str) kernelbase.StrCSpnIA +@ stdcall StrCSpnIW(wstr wstr) kernelbase.StrCSpnIW +@ stdcall StrCSpnW(wstr wstr) kernelbase.StrCSpnW +@ stdcall StrCatBuffA(str str long) kernelbase.StrCatBuffA @ stdcall StrCatBuffW (wstr wstr long) -@ stdcall StrCatChainW (ptr long long wstr) +@ stdcall StrCatChainW(ptr long long wstr) kernelbase.StrCatChainW @ stdcall StrCatW (ptr wstr) @ stdcall StrChrA (str long) -@ stdcall StrChrIA (str long) -@ stdcall StrChrIW (wstr long) +@ stdcall StrChrIA(str long) kernelbase.StrChrIA +@ stdcall StrChrIW(wstr long) kernelbase.StrChrIW @ stdcall StrChrNW(wstr long long) @ stdcall StrChrW (wstr long) -@ stdcall StrCmpIW (wstr wstr) -@ stdcall StrCmpLogicalW(wstr wstr) +@ stdcall StrCmpIW(wstr wstr) kernelbase.StrCmpIW +@ stdcall StrCmpLogicalW(wstr wstr) kernelbase.StrCmpLogicalW @ stdcall StrCmpNA (str str long) @ stdcall StrCmpNIA (str str long) -@ stdcall StrCmpNIW (wstr wstr long) -@ stdcall StrCmpNW (wstr wstr long) -@ stdcall StrCmpW (wstr wstr) +@ stdcall StrCmpNIW(wstr wstr long) kernelbase.StrCmpNIW +@ stdcall StrCmpNW(wstr wstr long) kernelbase.StrCmpNW +@ stdcall StrCmpW(wstr wstr) kernelbase.StrCmpW @ stdcall StrCpyNW (ptr wstr long) @ stdcall StrCpyW (ptr wstr) -@ stdcall StrDupA (str) +@ stdcall StrDupA(str) kernelbase.StrDupA @ stdcall StrDupW (wstr) @ stdcall StrFormatByteSize64A(int64 ptr long) @ stdcall StrFormatByteSizeA(long ptr long) @@ -784,39 +784,39 @@ @ stdcall StrFormatKBSizeW(int64 wstr long) @ stdcall StrFromTimeIntervalA(ptr long long long) @ stdcall StrFromTimeIntervalW(ptr long long long) -@ stdcall StrIsIntlEqualA(long str str long) -@ stdcall StrIsIntlEqualW(long wstr wstr long) +@ stdcall StrIsIntlEqualA(long str str long) kernelbase.StrIsIntlEqualA +@ stdcall StrIsIntlEqualW(long wstr wstr long) kernelbase.StrIsIntlEqualW @ stdcall StrNCatA(str str long) @ stdcall StrNCatW(wstr wstr long) -@ stdcall StrPBrkA(str str) -@ stdcall StrPBrkW(wstr wstr) -@ stdcall StrRChrA (str str long) -@ stdcall StrRChrIA (str str long) -@ stdcall StrRChrIW (wstr wstr long) -@ stdcall StrRChrW (wstr wstr long) -@ stdcall StrRStrIA (str str str) -@ stdcall StrRStrIW (wstr wstr wstr) +@ stdcall StrPBrkA(str str) kernelbase.StrPBrkA +@ stdcall StrPBrkW(wstr wstr) kernelbase.StrPBrkW +@ stdcall StrRChrA(str str long) kernelbase.StrRChrA +@ stdcall StrRChrIA(str str long) kernelbase.StrRChrIA +@ stdcall StrRChrIW(wstr wstr long) kernelbase.StrRChrIW +@ stdcall StrRChrW(wstr wstr long) kernelbase.StrRChrW +@ stdcall StrRStrIA(str str str) kernelbase.StrRStrIA +@ stdcall StrRStrIW(wstr wstr wstr) kernelbase.StrRStrIW @ stdcall StrRetToBSTR(ptr ptr ptr) @ stdcall StrRetToBufA(ptr ptr ptr long) @ stdcall StrRetToBufW(ptr ptr ptr long) @ stdcall StrRetToStrA(ptr ptr ptr) @ stdcall StrRetToStrW(ptr ptr ptr) -@ stdcall StrSpnA (str str) -@ stdcall StrSpnW (wstr wstr) -@ stdcall StrStrA(str str) -@ stdcall StrStrIA(str str) -@ stdcall StrStrIW(wstr wstr) -@ stdcall StrStrNW(wstr wstr long) -@ stdcall StrStrNIW(wstr wstr long) -@ stdcall StrStrW(wstr wstr) +@ stdcall StrSpnA(str str) kernelbase.StrSpnA +@ stdcall StrSpnW(wstr wstr) kernelbase.StrSpnW +@ stdcall StrStrA(str str) kernelbase.StrStrA +@ stdcall StrStrIA(str str) kernelbase.StrStrIA +@ stdcall StrStrIW(wstr wstr) kernelbase.StrStrIW +@ stdcall StrStrNW(wstr wstr long) kernelbase.StrStrNW +@ stdcall StrStrNIW(wstr wstr long) kernelbase.StrStrNIW +@ stdcall StrStrW(wstr wstr) kernelbase.StrStrW @ stdcall StrToInt64ExA(str long ptr) @ stdcall StrToInt64ExW(wstr long ptr) @ stdcall StrToIntA(str) @ stdcall StrToIntExA(str long ptr) @ stdcall StrToIntExW(wstr long ptr) @ stdcall StrToIntW(wstr) -@ stdcall StrTrimA(str str) -@ stdcall StrTrimW(wstr wstr) +@ stdcall StrTrimA(str str) kernelbase.StrTrimA +@ stdcall StrTrimW(wstr wstr) kernelbase.StrTrimW @ stdcall UrlApplySchemeA(str ptr ptr long) @ stdcall UrlApplySchemeW(wstr ptr ptr long) @ stdcall UrlCanonicalizeA(str ptr ptr long) diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c index 7b8473a379..816638b65f 100644 --- a/dlls/shlwapi/string.c +++ b/dlls/shlwapi/string.c @@ -263,59 +263,6 @@ LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch) return lpszRet; }
-/************************************************************************* - * StrChrIA [SHLWAPI.@] - * - * Find a given character in a string, ignoring case. - * - * PARAMS - * lpszStr [I] String to search in. - * ch [I] Character to search for. - * - * RETURNS - * Success: A pointer to the first occurrence of ch in lpszStr, or NULL if - * not found. - * Failure: NULL, if any arguments are invalid. - */ -LPSTR WINAPI StrChrIA(LPCSTR lpszStr, WORD ch) -{ - TRACE("(%s,%i)\n", debugstr_a(lpszStr), ch); - - if (lpszStr) - { - while (*lpszStr) - { - if (!ChrCmpIA(*lpszStr, ch)) - return (LPSTR)lpszStr; - lpszStr = CharNextA(lpszStr); - } - } - return NULL; -} - -/************************************************************************* - * StrChrIW [SHLWAPI.@] - * - * See StrChrA. - */ -LPWSTR WINAPI StrChrIW(LPCWSTR lpszStr, WCHAR ch) -{ - TRACE("(%s,%i)\n", debugstr_w(lpszStr), ch); - - if (lpszStr) - { - ch = toupperW(ch); - while (*lpszStr) - { - if (toupperW(*lpszStr) == ch) - return (LPWSTR)lpszStr; - lpszStr++; - } - lpszStr = NULL; - } - return (LPWSTR)lpszStr; -} - /************************************************************************* * StrChrNW [SHLWAPI.@] */ @@ -335,25 +282,6 @@ LPWSTR WINAPI StrChrNW(LPCWSTR lpszStr, WCHAR ch, UINT cchMax) return NULL; }
-/************************************************************************* - * StrCmpIW [SHLWAPI.@] - * - * Compare two strings, ignoring case. - * - * PARAMS - * lpszStr [I] First string to compare - * lpszComp [I] Second string to compare - * - * RETURNS - * An integer less than, equal to or greater than 0, indicating that - * lpszStr is less than, the same, or greater than lpszComp. - */ -int WINAPI StrCmpIW(LPCWSTR lpszStr, LPCWSTR lpszComp) -{ - TRACE("(%s,%s)\n", debugstr_w(lpszStr),debugstr_w(lpszComp)); - return CompareStringW(GetThreadLocale(), NORM_IGNORECASE, lpszStr, -1, lpszComp, -1) - CSTR_EQUAL; -} - /************************************************************************* * StrCmpNA [SHLWAPI.@] * @@ -374,17 +302,6 @@ INT WINAPI StrCmpNA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen) return CompareStringA(GetThreadLocale(), 0, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL; }
-/************************************************************************* - * StrCmpNW [SHLWAPI.@] - * - * See StrCmpNA. - */ -INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen) -{ - TRACE("(%s,%s,%i)\n", debugstr_w(lpszStr), debugstr_w(lpszComp), iLen); - return CompareStringW(GetThreadLocale(), 0, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL; -} - /************************************************************************* * StrCmpNIA [SHLWAPI.@] * @@ -405,36 +322,6 @@ int WINAPI StrCmpNIA(LPCSTR lpszStr, LPCSTR lpszComp, int iLen) return CompareStringA(GetThreadLocale(), NORM_IGNORECASE, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL; }
-/************************************************************************* - * StrCmpNIW [SHLWAPI.@] - * - * See StrCmpNIA. - */ -INT WINAPI StrCmpNIW(LPCWSTR lpszStr, LPCWSTR lpszComp, int iLen) -{ - TRACE("(%s,%s,%i)\n", debugstr_w(lpszStr), debugstr_w(lpszComp), iLen); - return CompareStringW(GetThreadLocale(), NORM_IGNORECASE, lpszStr, iLen, lpszComp, iLen) - CSTR_EQUAL; -} - -/************************************************************************* - * StrCmpW [SHLWAPI.@] - * - * Compare two strings. - * - * PARAMS - * lpszStr [I] First string to compare - * lpszComp [I] Second string to compare - * - * RETURNS - * An integer less than, equal to or greater than 0, indicating that - * lpszStr is less than, the same, or greater than lpszComp. - */ -int WINAPI StrCmpW(LPCWSTR lpszStr, LPCWSTR lpszComp) -{ - TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszComp)); - return CompareStringW(GetThreadLocale(), 0, lpszStr, -1, lpszComp, -1) - CSTR_EQUAL; -} - /************************************************************************* * StrCatW [SHLWAPI.@] * @@ -456,47 +343,6 @@ LPWSTR WINAPI StrCatW(LPWSTR lpszStr, LPCWSTR lpszSrc) return lpszStr; }
-/************************************************************************* - * StrCatChainW [SHLWAPI.@] - * - * Concatenates two unicode strings. - * - * PARAMS - * lpszStr [O] Initial string - * cchMax [I] Length of destination buffer - * ichAt [I] Offset from the destination buffer to begin concatenation - * lpszCat [I] String to concatenate - * - * RETURNS - * The offset from the beginning of pszDst to the terminating NULL. - */ -DWORD WINAPI StrCatChainW(LPWSTR lpszStr, DWORD cchMax, DWORD ichAt, LPCWSTR lpszCat) -{ - TRACE("(%s,%u,%d,%s)\n", debugstr_w(lpszStr), cchMax, ichAt, debugstr_w(lpszCat)); - - if (ichAt == -1) - ichAt = strlenW(lpszStr); - - if (!cchMax) - return ichAt; - - if (ichAt == cchMax) - ichAt--; - - if (lpszCat && ichAt < cchMax) - { - lpszStr += ichAt; - while (ichAt < cchMax - 1 && *lpszCat) - { - *lpszStr++ = *lpszCat++; - ichAt++; - } - *lpszStr = 0; - } - - return ichAt; -} - /************************************************************************* * StrCpyW [SHLWAPI.@] * @@ -551,261 +397,6 @@ LPWSTR WINAPI StrCpyNW(LPWSTR dst, LPCWSTR src, int count) return dst; }
-/************************************************************************* - * SHLWAPI_StrStrHelperA - * - * Internal implementation of StrStrA/StrStrIA - */ -static LPSTR SHLWAPI_StrStrHelperA(LPCSTR lpszStr, LPCSTR lpszSearch, - INT (WINAPI *pStrCmpFn)(LPCSTR,LPCSTR,INT)) -{ - size_t iLen; - LPCSTR end; - - if (!lpszStr || !lpszSearch || !*lpszSearch) - return NULL; - - iLen = strlen(lpszSearch); - end = lpszStr + strlen(lpszStr); - - while (lpszStr + iLen <= end) - { - if (!pStrCmpFn(lpszStr, lpszSearch, iLen)) - return (LPSTR)lpszStr; - lpszStr = CharNextA(lpszStr); - } - return NULL; -} - -/************************************************************************* - * StrStrA [SHLWAPI.@] - * - * Find a substring within a string. - * - * PARAMS - * lpszStr [I] String to search in - * lpszSearch [I] String to look for - * - * RETURNS - * The start of lpszSearch within lpszStr, or NULL if not found. - */ -LPSTR WINAPI StrStrA(LPCSTR lpszStr, LPCSTR lpszSearch) -{ - TRACE("(%s,%s)\n", debugstr_a(lpszStr), debugstr_a(lpszSearch)); - - return SHLWAPI_StrStrHelperA(lpszStr, lpszSearch, StrCmpNA); -} - -/************************************************************************* - * StrStrW [SHLWAPI.@] - * - * See StrStrA. - */ -LPWSTR WINAPI StrStrW(LPCWSTR lpszStr, LPCWSTR lpszSearch) -{ - TRACE("(%s, %s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch)); - - if (!lpszStr || !lpszSearch || !*lpszSearch) return NULL; - return strstrW( lpszStr, lpszSearch ); -} - -/************************************************************************* - * StrRStrIA [SHLWAPI.@] - * - * Find the last occurrence of a substring within a string. - * - * PARAMS - * lpszStr [I] String to search in - * lpszEnd [I] End of lpszStr - * lpszSearch [I] String to look for - * - * RETURNS - * The last occurrence lpszSearch within lpszStr, or NULL if not found. - */ -LPSTR WINAPI StrRStrIA(LPCSTR lpszStr, LPCSTR lpszEnd, LPCSTR lpszSearch) -{ - LPSTR lpszRet = NULL; - WORD ch1, ch2; - INT iLen; - - TRACE("(%s,%s)\n", debugstr_a(lpszStr), debugstr_a(lpszSearch)); - - if (!lpszStr || !lpszSearch || !*lpszSearch) - return NULL; - - if (IsDBCSLeadByte(*lpszSearch)) - ch1 = *lpszSearch << 8 | (UCHAR)lpszSearch[1]; - else - ch1 = *lpszSearch; - iLen = lstrlenA(lpszSearch); - - if (!lpszEnd) - lpszEnd = lpszStr + lstrlenA(lpszStr); - else /* reproduce the broken behaviour on Windows */ - lpszEnd += min(iLen - 1, lstrlenA(lpszEnd)); - - while (lpszStr + iLen <= lpszEnd && *lpszStr) - { - ch2 = IsDBCSLeadByte(*lpszStr)? *lpszStr << 8 | (UCHAR)lpszStr[1] : *lpszStr; - if (!ChrCmpIA(ch1, ch2)) - { - if (!StrCmpNIA(lpszStr, lpszSearch, iLen)) - lpszRet = (LPSTR)lpszStr; - } - lpszStr = CharNextA(lpszStr); - } - return lpszRet; -} - -/************************************************************************* - * StrRStrIW [SHLWAPI.@] - * - * See StrRStrIA. - */ -LPWSTR WINAPI StrRStrIW(LPCWSTR lpszStr, LPCWSTR lpszEnd, LPCWSTR lpszSearch) -{ - LPWSTR lpszRet = NULL; - INT iLen; - - TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch)); - - if (!lpszStr || !lpszSearch || !*lpszSearch) - return NULL; - - iLen = strlenW(lpszSearch); - - if (!lpszEnd) - lpszEnd = lpszStr + strlenW(lpszStr); - else /* reproduce the broken behaviour on Windows */ - lpszEnd += min(iLen - 1, lstrlenW(lpszEnd)); - - while (lpszStr + iLen <= lpszEnd && *lpszStr) - { - if (!ChrCmpIW(*lpszSearch, *lpszStr)) - { - if (!StrCmpNIW(lpszStr, lpszSearch, iLen)) - lpszRet = (LPWSTR)lpszStr; - } - lpszStr++; - } - return lpszRet; -} - -/************************************************************************* - * StrStrIA [SHLWAPI.@] - * - * Find a substring within a string, ignoring case. - * - * PARAMS - * lpszStr [I] String to search in - * lpszSearch [I] String to look for - * - * RETURNS - * The start of lpszSearch within lpszStr, or NULL if not found. - */ -LPSTR WINAPI StrStrIA(LPCSTR lpszStr, LPCSTR lpszSearch) -{ - TRACE("(%s,%s)\n", debugstr_a(lpszStr), debugstr_a(lpszSearch)); - - return SHLWAPI_StrStrHelperA(lpszStr, lpszSearch, StrCmpNIA); -} - -/************************************************************************* - * StrStrIW [SHLWAPI.@] - * - * See StrStrIA. - */ -LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch) -{ - int iLen; - LPCWSTR end; - - TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch)); - - if (!lpszStr || !lpszSearch || !*lpszSearch) - return NULL; - - iLen = strlenW(lpszSearch); - end = lpszStr + strlenW(lpszStr); - - while (lpszStr + iLen <= end) - { - if (!StrCmpNIW(lpszStr, lpszSearch, iLen)) - return (LPWSTR)lpszStr; - lpszStr++; - } - return NULL; -} - -/************************************************************************* - * StrStrNW [SHLWAPI.@] - * - * Find a substring within a string up to a given number of initial characters. - * - * PARAMS - * lpFirst [I] String to search in - * lpSrch [I] String to look for - * cchMax [I] Maximum number of initial search characters - * - * RETURNS - * The start of lpFirst within lpSrch, or NULL if not found. - */ -LPWSTR WINAPI StrStrNW(LPCWSTR lpFirst, LPCWSTR lpSrch, UINT cchMax) -{ - UINT i; - int len; - - TRACE("(%s, %s, %u)\n", debugstr_w(lpFirst), debugstr_w(lpSrch), cchMax); - - if (!lpFirst || !lpSrch || !*lpSrch || !cchMax) - return NULL; - - len = strlenW(lpSrch); - - for (i = cchMax; *lpFirst && (i > 0); i--, lpFirst++) - { - if (!strncmpW(lpFirst, lpSrch, len)) - return (LPWSTR)lpFirst; - } - - return NULL; -} - -/************************************************************************* - * StrStrNIW [SHLWAPI.@] - * - * Find a substring within a string up to a given number of initial characters, - * ignoring case. - * - * PARAMS - * lpFirst [I] String to search in - * lpSrch [I] String to look for - * cchMax [I] Maximum number of initial search characters - * - * RETURNS - * The start of lpFirst within lpSrch, or NULL if not found. - */ -LPWSTR WINAPI StrStrNIW(LPCWSTR lpFirst, LPCWSTR lpSrch, UINT cchMax) -{ - UINT i; - int len; - - TRACE("(%s, %s, %u)\n", debugstr_w(lpFirst), debugstr_w(lpSrch), cchMax); - - if (!lpFirst || !lpSrch || !*lpSrch || !cchMax) - return NULL; - - len = strlenW(lpSrch); - - for (i = cchMax; *lpFirst && (i > 0); i--, lpFirst++) - { - if (!strncmpiW(lpFirst, lpSrch, len)) - return (LPWSTR)lpFirst; - } - - return NULL; -} - /************************************************************************* * StrToIntA [SHLWAPI.@] * @@ -956,480 +547,118 @@ BOOL WINAPI StrToInt64ExA(LPCSTR lpszStr, DWORD dwFlags, LONGLONG *lpiRet) iRet += (*lpszStr - '0'); lpszStr++; } - *lpiRet = bNegative ? -iRet : iRet; - return TRUE; -} - -/************************************************************************* - * StrToIntExW [SHLWAPI.@] - * - * See StrToIntExA. - */ -BOOL WINAPI StrToIntExW(LPCWSTR lpszStr, DWORD dwFlags, LPINT lpiRet) -{ - LONGLONG li; - BOOL bRes; - - TRACE("(%s,%08X,%p)\n", debugstr_w(lpszStr), dwFlags, lpiRet); - - bRes = StrToInt64ExW(lpszStr, dwFlags, &li); - if (bRes) *lpiRet = li; - return bRes; -} - -/************************************************************************* - * StrToInt64ExW [SHLWAPI.@] - * - * See StrToIntExA. - */ -BOOL WINAPI StrToInt64ExW(LPCWSTR lpszStr, DWORD dwFlags, LONGLONG *lpiRet) -{ - BOOL bNegative = FALSE; - LONGLONG iRet = 0; - - TRACE("(%s,%08X,%p)\n", debugstr_w(lpszStr), dwFlags, lpiRet); - - if (!lpszStr || !lpiRet) - { - WARN("Invalid parameter would crash under Win32!\n"); - return FALSE; - } - if (dwFlags > STIF_SUPPORT_HEX) WARN("Unknown flags %08x\n", dwFlags); - - /* Skip leading space, '+', '-' */ - while (isspaceW(*lpszStr)) lpszStr++; - - if (*lpszStr == '-') - { - bNegative = TRUE; - lpszStr++; - } - else if (*lpszStr == '+') - lpszStr++; - - if (dwFlags & STIF_SUPPORT_HEX && - *lpszStr == '0' && tolowerW(lpszStr[1]) == 'x') - { - /* Read hex number */ - lpszStr += 2; - - if (!isxdigitW(*lpszStr)) - return FALSE; - - while (isxdigitW(*lpszStr)) - { - iRet = iRet * 16; - if (isdigitW(*lpszStr)) - iRet += (*lpszStr - '0'); - else - iRet += 10 + (tolowerW(*lpszStr) - 'a'); - lpszStr++; - } - *lpiRet = iRet; - return TRUE; - } - - /* Read decimal number */ - if (!isdigitW(*lpszStr)) - return FALSE; - - while (isdigitW(*lpszStr)) - { - iRet = iRet * 10; - iRet += (*lpszStr - '0'); - lpszStr++; - } - *lpiRet = bNegative ? -iRet : iRet; - return TRUE; -} - -/************************************************************************* - * StrDupA [SHLWAPI.@] - * - * Duplicate a string. - * - * PARAMS - * lpszStr [I] String to duplicate. - * - * RETURNS - * Success: A pointer to a new string containing the contents of lpszStr - * Failure: NULL, if memory cannot be allocated - * - * NOTES - * The string memory is allocated with LocalAlloc(), and so should be released - * by calling LocalFree(). - */ -LPSTR WINAPI StrDupA(LPCSTR lpszStr) -{ - int iLen; - LPSTR lpszRet; - - TRACE("(%s)\n",debugstr_a(lpszStr)); - - iLen = lpszStr ? strlen(lpszStr) + 1 : 1; - lpszRet = LocalAlloc(LMEM_FIXED, iLen); - - if (lpszRet) - { - if (lpszStr) - memcpy(lpszRet, lpszStr, iLen); - else - *lpszRet = '\0'; - } - return lpszRet; -} - -/************************************************************************* - * StrDupW [SHLWAPI.@] - * - * See StrDupA. - */ -LPWSTR WINAPI StrDupW(LPCWSTR lpszStr) -{ - int iLen; - LPWSTR lpszRet; - - TRACE("(%s)\n",debugstr_w(lpszStr)); - - iLen = (lpszStr ? strlenW(lpszStr) + 1 : 1) * sizeof(WCHAR); - lpszRet = LocalAlloc(LMEM_FIXED, iLen); - - if (lpszRet) - { - if (lpszStr) - memcpy(lpszRet, lpszStr, iLen); - else - *lpszRet = '\0'; - } - return lpszRet; -} - -/************************************************************************* - * SHLWAPI_StrSpnHelperA - * - * Internal implementation of StrSpnA/StrCSpnA/StrCSpnIA - */ -static int SHLWAPI_StrSpnHelperA(LPCSTR lpszStr, LPCSTR lpszMatch, - LPSTR (WINAPI *pStrChrFn)(LPCSTR,WORD), - BOOL bInvert) -{ - LPCSTR lpszRead = lpszStr; - if (lpszStr && *lpszStr && lpszMatch) - { - while (*lpszRead) - { - LPCSTR lpszTest = pStrChrFn(lpszMatch, *lpszRead); - - if (!bInvert && !lpszTest) - break; - if (bInvert && lpszTest) - break; - lpszRead = CharNextA(lpszRead); - }; - } - return lpszRead - lpszStr; -} - -/************************************************************************* - * StrSpnA [SHLWAPI.@] - * - * Find the length of the start of a string that contains only certain - * characters. - * - * PARAMS - * lpszStr [I] String to search - * lpszMatch [I] Characters that can be in the substring - * - * RETURNS - * The length of the part of lpszStr containing only chars from lpszMatch, - * or 0 if any parameter is invalid. - */ -int WINAPI StrSpnA(LPCSTR lpszStr, LPCSTR lpszMatch) -{ - TRACE("(%s,%s)\n",debugstr_a(lpszStr), debugstr_a(lpszMatch)); - - return SHLWAPI_StrSpnHelperA(lpszStr, lpszMatch, StrChrA, FALSE); -} - -/************************************************************************* - * StrSpnW [SHLWAPI.@] - * - * See StrSpnA. - */ -int WINAPI StrSpnW(LPCWSTR lpszStr, LPCWSTR lpszMatch) -{ - if (!lpszStr || !lpszMatch) return 0; - return strspnW( lpszStr, lpszMatch ); -} - -/************************************************************************* - * StrCSpnA [SHLWAPI.@] - * - * Find the length of the start of a string that does not contain certain - * characters. - * - * PARAMS - * lpszStr [I] String to search - * lpszMatch [I] Characters that cannot be in the substring - * - * RETURNS - * The length of the part of lpszStr containing only chars not in lpszMatch, - * or 0 if any parameter is invalid. - */ -int WINAPI StrCSpnA(LPCSTR lpszStr, LPCSTR lpszMatch) -{ - TRACE("(%s,%s)\n",debugstr_a(lpszStr), debugstr_a(lpszMatch)); - - return SHLWAPI_StrSpnHelperA(lpszStr, lpszMatch, StrChrA, TRUE); -} - -/************************************************************************* - * StrCSpnW [SHLWAPI.@] - * - * See StrCSpnA. - */ -int WINAPI StrCSpnW(LPCWSTR lpszStr, LPCWSTR lpszMatch) -{ - if (!lpszStr || !lpszMatch) return 0; - return strcspnW( lpszStr, lpszMatch ); -} - -/************************************************************************* - * StrCSpnIA [SHLWAPI.@] - * - * Find the length of the start of a string that does not contain certain - * characters, ignoring case. - * - * PARAMS - * lpszStr [I] String to search - * lpszMatch [I] Characters that cannot be in the substring - * - * RETURNS - * The length of the part of lpszStr containing only chars not in lpszMatch, - * or 0 if any parameter is invalid. - */ -int WINAPI StrCSpnIA(LPCSTR lpszStr, LPCSTR lpszMatch) -{ - TRACE("(%s,%s)\n",debugstr_a(lpszStr), debugstr_a(lpszMatch)); - - return SHLWAPI_StrSpnHelperA(lpszStr, lpszMatch, StrChrIA, TRUE); -} - -/************************************************************************* - * StrCSpnIW [SHLWAPI.@] - * - * See StrCSpnIA. - */ -int WINAPI StrCSpnIW(LPCWSTR lpszStr, LPCWSTR lpszMatch) -{ - LPCWSTR lpszRead = lpszStr; - - TRACE("(%s,%s)\n",debugstr_w(lpszStr), debugstr_w(lpszMatch)); - - if (lpszStr && *lpszStr && lpszMatch) - { - while (*lpszRead) - { - if (StrChrIW(lpszMatch, *lpszRead)) break; - lpszRead++; - } - } - return lpszRead - lpszStr; -} - -/************************************************************************* - * StrPBrkA [SHLWAPI.@] - * - * Search a string for any of a group of characters. - * - * PARAMS - * lpszStr [I] String to search - * lpszMatch [I] Characters to match - * - * RETURNS - * A pointer to the first matching character in lpszStr, or NULL if no - * match was found. - */ -LPSTR WINAPI StrPBrkA(LPCSTR lpszStr, LPCSTR lpszMatch) -{ - TRACE("(%s,%s)\n",debugstr_a(lpszStr), debugstr_a(lpszMatch)); - - if (lpszStr && lpszMatch && *lpszMatch) - { - while (*lpszStr) - { - if (StrChrA(lpszMatch, *lpszStr)) - return (LPSTR)lpszStr; - lpszStr = CharNextA(lpszStr); - } - } - return NULL; + *lpiRet = bNegative ? -iRet : iRet; + return TRUE; }
/************************************************************************* - * StrPBrkW [SHLWAPI.@] + * StrToIntExW [SHLWAPI.@] * - * See StrPBrkA. + * See StrToIntExA. */ -LPWSTR WINAPI StrPBrkW(LPCWSTR lpszStr, LPCWSTR lpszMatch) +BOOL WINAPI StrToIntExW(LPCWSTR lpszStr, DWORD dwFlags, LPINT lpiRet) { - if (!lpszStr || !lpszMatch) return NULL; - return strpbrkW( lpszStr, lpszMatch ); + LONGLONG li; + BOOL bRes; + + TRACE("(%s,%08X,%p)\n", debugstr_w(lpszStr), dwFlags, lpiRet); + + bRes = StrToInt64ExW(lpszStr, dwFlags, &li); + if (bRes) *lpiRet = li; + return bRes; }
/************************************************************************* - * SHLWAPI_StrRChrHelperA + * StrToInt64ExW [SHLWAPI.@] * - * Internal implementation of StrRChrA/StrRChrIA. + * See StrToIntExA. */ -static LPSTR SHLWAPI_StrRChrHelperA(LPCSTR lpszStr, - LPCSTR lpszEnd, WORD ch, - BOOL (WINAPI *pChrCmpFn)(WORD,WORD)) +BOOL WINAPI StrToInt64ExW(LPCWSTR lpszStr, DWORD dwFlags, LONGLONG *lpiRet) { - LPCSTR lpszRet = NULL; + BOOL bNegative = FALSE; + LONGLONG iRet = 0;
- if (lpszStr) - { - WORD ch2; + TRACE("(%s,%08X,%p)\n", debugstr_w(lpszStr), dwFlags, lpiRet);
- if (!lpszEnd) - lpszEnd = lpszStr + lstrlenA(lpszStr); + if (!lpszStr || !lpiRet) + { + WARN("Invalid parameter would crash under Win32!\n"); + return FALSE; + } + if (dwFlags > STIF_SUPPORT_HEX) WARN("Unknown flags %08x\n", dwFlags);
- while (*lpszStr && lpszStr <= lpszEnd) - { - ch2 = IsDBCSLeadByte(*lpszStr)? *lpszStr << 8 | lpszStr[1] : *lpszStr; + /* Skip leading space, '+', '-' */ + while (isspaceW(*lpszStr)) lpszStr++;
- if (!pChrCmpFn(ch, ch2)) - lpszRet = lpszStr; - lpszStr = CharNextA(lpszStr); - } + if (*lpszStr == '-') + { + bNegative = TRUE; + lpszStr++; } - return (LPSTR)lpszRet; -} - -/************************************************************************** - * StrRChrA [SHLWAPI.@] - * - * Find the last occurrence of a character in string. - * - * PARAMS - * lpszStr [I] String to search in - * lpszEnd [I] Place to end search, or NULL to search until the end of lpszStr - * ch [I] Character to search for. - * - * RETURNS - * Success: A pointer to the last occurrence of ch in lpszStr before lpszEnd, - * or NULL if not found. - * Failure: NULL, if any arguments are invalid. - */ -LPSTR WINAPI StrRChrA(LPCSTR lpszStr, LPCSTR lpszEnd, WORD ch) -{ - TRACE("(%s,%s,%x)\n", debugstr_a(lpszStr), debugstr_a(lpszEnd), ch); + else if (*lpszStr == '+') + lpszStr++;
- return SHLWAPI_StrRChrHelperA(lpszStr, lpszEnd, ch, SHLWAPI_ChrCmpA); -} + if (dwFlags & STIF_SUPPORT_HEX && + *lpszStr == '0' && tolowerW(lpszStr[1]) == 'x') + { + /* Read hex number */ + lpszStr += 2;
-/************************************************************************** - * StrRChrW [SHLWAPI.@] - * - * See StrRChrA. - */ -LPWSTR WINAPI StrRChrW(LPCWSTR str, LPCWSTR end, WORD ch) -{ - WCHAR *ret = NULL; + if (!isxdigitW(*lpszStr)) + return FALSE;
- if (!str) return NULL; - if (!end) end = str + strlenW(str); - while (str < end) + while (isxdigitW(*lpszStr)) { - if (*str == ch) ret = (WCHAR *)str; - str++; + iRet = iRet * 16; + if (isdigitW(*lpszStr)) + iRet += (*lpszStr - '0'); + else + iRet += 10 + (tolowerW(*lpszStr) - 'a'); + lpszStr++; } - return ret; -} - -/************************************************************************** - * StrRChrIA [SHLWAPI.@] - * - * Find the last occurrence of a character in string, ignoring case. - * - * PARAMS - * lpszStr [I] String to search in - * lpszEnd [I] Place to end search, or NULL to search until the end of lpszStr - * ch [I] Character to search for. - * - * RETURNS - * Success: A pointer to the last occurrence of ch in lpszStr before lpszEnd, - * or NULL if not found. - * Failure: NULL, if any arguments are invalid. - */ -LPSTR WINAPI StrRChrIA(LPCSTR lpszStr, LPCSTR lpszEnd, WORD ch) -{ - TRACE("(%s,%s,%x)\n", debugstr_a(lpszStr), debugstr_a(lpszEnd), ch); - - return SHLWAPI_StrRChrHelperA(lpszStr, lpszEnd, ch, ChrCmpIA); -} + *lpiRet = iRet; + return TRUE; + }
-/************************************************************************** - * StrRChrIW [SHLWAPI.@] - * - * See StrRChrIA. - */ -LPWSTR WINAPI StrRChrIW(LPCWSTR str, LPCWSTR end, WORD ch) -{ - WCHAR *ret = NULL; + /* Read decimal number */ + if (!isdigitW(*lpszStr)) + return FALSE;
- if (!str) return NULL; - if (!end) end = str + strlenW(str); - while (str < end) - { - if (!ChrCmpIW(*str, ch)) ret = (WCHAR *)str; - str++; - } - return ret; + while (isdigitW(*lpszStr)) + { + iRet = iRet * 10; + iRet += (*lpszStr - '0'); + lpszStr++; + } + *lpiRet = bNegative ? -iRet : iRet; + return TRUE; }
/************************************************************************* - * StrCatBuffA [SHLWAPI.@] - * - * Concatenate two strings together. - * - * PARAMS - * lpszStr [O] String to concatenate to - * lpszCat [I] String to add to lpszCat - * cchMax [I] Maximum number of characters for the whole string - * - * RETURNS - * lpszStr. - * - * NOTES - * cchMax determines the number of characters in the final length of the - * string, not the number appended to lpszStr from lpszCat. + * StrDupW [SHLWAPI.@] */ -LPSTR WINAPI StrCatBuffA(LPSTR lpszStr, LPCSTR lpszCat, INT cchMax) +LPWSTR WINAPI StrDupW(LPCWSTR lpszStr) { - INT iLen; + int iLen; + LPWSTR lpszRet; + + TRACE("(%s)\n",debugstr_w(lpszStr));
- TRACE("(%p,%s,%d)\n", lpszStr, debugstr_a(lpszCat), cchMax); + iLen = (lpszStr ? strlenW(lpszStr) + 1 : 1) * sizeof(WCHAR); + lpszRet = LocalAlloc(LMEM_FIXED, iLen);
- if (!lpszStr) + if (lpszRet) { - WARN("Invalid lpszStr would crash under Win32!\n"); - return NULL; + if (lpszStr) + memcpy(lpszRet, lpszStr, iLen); + else + *lpszRet = '\0'; } - - iLen = strlen(lpszStr); - cchMax -= iLen; - - if (cchMax > 0) - StrCpyNA(lpszStr + iLen, lpszCat, cchMax); - return lpszStr; + return lpszRet; }
/************************************************************************* * StrCatBuffW [SHLWAPI.@] - * - * See StrCatBuffA. */ LPWSTR WINAPI StrCatBuffW(LPWSTR lpszStr, LPCWSTR lpszCat, INT cchMax) { @@ -1809,95 +1038,6 @@ LPWSTR WINAPI StrNCatW(LPWSTR lpszStr, LPCWSTR lpszCat, INT cchMax) return lpszRet; }
-/************************************************************************* - * StrTrimA [SHLWAPI.@] - * - * Remove characters from the start and end of a string. - * - * PARAMS - * lpszStr [O] String to remove characters from - * lpszTrim [I] Characters to remove from lpszStr - * - * RETURNS - * TRUE If lpszStr was valid and modified - * FALSE Otherwise - */ -BOOL WINAPI StrTrimA(LPSTR lpszStr, LPCSTR lpszTrim) -{ - DWORD dwLen; - LPSTR lpszRead = lpszStr; - BOOL bRet = FALSE; - - TRACE("(%s,%s)\n", debugstr_a(lpszStr), debugstr_a(lpszTrim)); - - if (lpszRead && *lpszRead) - { - while (*lpszRead && StrChrA(lpszTrim, *lpszRead)) - lpszRead = CharNextA(lpszRead); /* Skip leading matches */ - - dwLen = strlen(lpszRead); - - if (lpszRead != lpszStr) - { - memmove(lpszStr, lpszRead, dwLen + 1); - bRet = TRUE; - } - if (dwLen > 0) - { - lpszRead = lpszStr + dwLen; - while (StrChrA(lpszTrim, lpszRead[-1])) - lpszRead = CharPrevA(lpszStr, lpszRead); /* Skip trailing matches */ - - if (lpszRead != lpszStr + dwLen) - { - *lpszRead = '\0'; - bRet = TRUE; - } - } - } - return bRet; -} - -/************************************************************************* - * StrTrimW [SHLWAPI.@] - * - * See StrTrimA. - */ -BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim) -{ - DWORD dwLen; - LPWSTR lpszRead = lpszStr; - BOOL bRet = FALSE; - - TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszTrim)); - - if (lpszRead && *lpszRead) - { - while (*lpszRead && StrChrW(lpszTrim, *lpszRead)) lpszRead++; - - dwLen = strlenW(lpszRead); - - if (lpszRead != lpszStr) - { - memmove(lpszStr, lpszRead, (dwLen + 1) * sizeof(WCHAR)); - bRet = TRUE; - } - if (dwLen > 0) - { - lpszRead = lpszStr + dwLen; - while (StrChrW(lpszTrim, lpszRead[-1])) - lpszRead--; /* Skip trailing matches */ - - if (lpszRead != lpszStr + dwLen) - { - *lpszRead = '\0'; - bRet = TRUE; - } - } - } - return bRet; -} - /************************************************************************* * _SHStrDupAA [INTERNAL] * @@ -2175,175 +1315,6 @@ INT WINAPI StrFromTimeIntervalW(LPWSTR lpszStr, UINT cchMax, DWORD dwMS, return iRet; }
-/************************************************************************* - * StrIsIntlEqualA [SHLWAPI.@] - * - * Compare two strings. - * - * PARAMS - * bCase [I] Whether to compare case sensitively - * lpszStr [I] First string to compare - * lpszComp [I] Second string to compare - * iLen [I] Length to compare - * - * RETURNS - * TRUE If the strings are equal. - * FALSE Otherwise. - */ -BOOL WINAPI StrIsIntlEqualA(BOOL bCase, LPCSTR lpszStr, LPCSTR lpszComp, - int iLen) -{ - DWORD dwFlags; - - TRACE("(%d,%s,%s,%d)\n", bCase, - debugstr_a(lpszStr), debugstr_a(lpszComp), iLen); - - /* FIXME: This flag is undocumented and unknown by our CompareString. - * We need a define for it. - */ - dwFlags = 0x10000000; - if (!bCase) dwFlags |= NORM_IGNORECASE; - - return (CompareStringA(GetThreadLocale(), dwFlags, lpszStr, iLen, lpszComp, iLen) == CSTR_EQUAL); -} - -/************************************************************************* - * StrIsIntlEqualW [SHLWAPI.@] - * - * See StrIsIntlEqualA. - */ -BOOL WINAPI StrIsIntlEqualW(BOOL bCase, LPCWSTR lpszStr, LPCWSTR lpszComp, - int iLen) -{ - DWORD dwFlags; - - TRACE("(%d,%s,%s,%d)\n", bCase, - debugstr_w(lpszStr),debugstr_w(lpszComp), iLen); - - /* FIXME: This flag is undocumented and unknown by our CompareString. - * We need a define for it. - */ - dwFlags = 0x10000000; - if (!bCase) dwFlags |= NORM_IGNORECASE; - - return (CompareStringW(GetThreadLocale(), dwFlags, lpszStr, iLen, lpszComp, iLen) == CSTR_EQUAL); -} - -/************************************************************************* - * @ [SHLWAPI.399] - * - * Copy a string to another string, up to a maximum number of characters. - * - * PARAMS - * lpszDest [O] Destination string - * lpszSrc [I] Source string - * iLen [I] Maximum number of chars to copy - * - * RETURNS - * Success: A pointer to the last character written to lpszDest. - * Failure: lpszDest, if any arguments are invalid. - */ -LPSTR WINAPI StrCpyNXA(LPSTR lpszDest, LPCSTR lpszSrc, int iLen) -{ - TRACE("(%p,%s,%i)\n", lpszDest, debugstr_a(lpszSrc), iLen); - - if (lpszDest && lpszSrc && iLen > 0) - { - while ((iLen-- > 1) && *lpszSrc) - *lpszDest++ = *lpszSrc++; - if (iLen >= 0) - *lpszDest = '\0'; - } - return lpszDest; -} - -/************************************************************************* - * @ [SHLWAPI.400] - * - * Unicode version of StrCpyNXA. - */ -LPWSTR WINAPI StrCpyNXW(LPWSTR lpszDest, LPCWSTR lpszSrc, int iLen) -{ - TRACE("(%p,%s,%i)\n", lpszDest, debugstr_w(lpszSrc), iLen); - - if (lpszDest && lpszSrc && iLen > 0) - { - while ((iLen-- > 1) && *lpszSrc) - *lpszDest++ = *lpszSrc++; - if (iLen >= 0) - *lpszDest = '\0'; - } - return lpszDest; -} - -/************************************************************************* - * StrCmpLogicalW [SHLWAPI.@] - * - * Compare two strings, ignoring case and comparing digits as numbers. - * - * PARAMS - * lpszStr [I] First string to compare - * lpszComp [I] Second string to compare - * iLen [I] Length to compare - * - * RETURNS - * TRUE If the strings are equal. - * FALSE Otherwise. - */ -INT WINAPI StrCmpLogicalW(LPCWSTR lpszStr, LPCWSTR lpszComp) -{ - INT iDiff; - - TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszComp)); - - if (lpszStr && lpszComp) - { - while (*lpszStr) - { - if (!*lpszComp) - return 1; - else if (isdigitW(*lpszStr)) - { - int iStr, iComp; - - if (!isdigitW(*lpszComp)) - return -1; - - /* Compare the numbers */ - StrToIntExW(lpszStr, 0, &iStr); - StrToIntExW(lpszComp, 0, &iComp); - - if (iStr < iComp) - return -1; - else if (iStr > iComp) - return 1; - - /* Skip */ - while (isdigitW(*lpszStr)) - lpszStr++; - while (isdigitW(*lpszComp)) - lpszComp++; - } - else if (isdigitW(*lpszComp)) - return 1; - else - { - iDiff = ChrCmpIW(*lpszStr,*lpszComp); - if (iDiff > 0) - return 1; - else if (iDiff < 0) - return -1; - - lpszStr++; - lpszComp++; - } - } - if (*lpszComp) - return -1; - } - return 0; -} - /* Structure for formatting byte strings */ typedef struct tagSHLWAPI_BYTEFORMATS {
Nikolay Sivov nsivov@codeweavers.com writes:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/shlwapi/ordinal.c | 95 --- dlls/shlwapi/shlwapi.spec | 90 +-- dlls/shlwapi/string.c | 1179 +++---------------------------------- 3 files changed, 120 insertions(+), 1244 deletions(-)
This doesn't work here:
$ ./wine notepad 000d:err:seh:setup_exception_record stack overflow 848 bytes in thread 000d eip f7b7abc9 esp 00230fe0 stack 0x230000-0x231000-0x330000 000b:err:seh:setup_exception_record stack overflow 1424 bytes in thread 000b eip f7bd682d esp 00230da0 stack 0x230000-0x231000-0x330000 0009:err:seh:setup_exception_record stack overflow 832 bytes in thread 0009 eip f7c515bc esp 004a0ff0 stack 0x4a0000-0x4a1000-0x6a0000 $
On 5/28/19 12:40 PM, Alexandre Julliard wrote:
Nikolay Sivov nsivov@codeweavers.com writes:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/shlwapi/ordinal.c | 95 --- dlls/shlwapi/shlwapi.spec | 90 +-- dlls/shlwapi/string.c | 1179 +++---------------------------------- 3 files changed, 120 insertions(+), 1244 deletions(-)
This doesn't work here:
$ ./wine notepad 000d:err:seh:setup_exception_record stack overflow 848 bytes in thread 000d eip f7b7abc9 esp 00230fe0 stack 0x230000-0x231000-0x330000 000b:err:seh:setup_exception_record stack overflow 1424 bytes in thread 000b eip f7bd682d esp 00230da0 stack 0x230000-0x231000-0x330000 0009:err:seh:setup_exception_record stack overflow 832 bytes in thread 0009 eip f7c515bc esp 004a0ff0 stack 0x4a0000-0x4a1000-0x6a0000 $
Strange, works fine for me.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/shlwapi/shlwapi.spec | 38 +- dlls/shlwapi/url.c | 906 -------------------------------------- 2 files changed, 19 insertions(+), 925 deletions(-)
diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec index 3bc0da8fb0..10970dc60e 100644 --- a/dlls/shlwapi/shlwapi.spec +++ b/dlls/shlwapi/shlwapi.spec @@ -459,7 +459,7 @@ 459 stdcall -noname SHExpandEnvironmentStringsA(str ptr long) kernel32.ExpandEnvironmentStringsA 460 stdcall -noname SHExpandEnvironmentStringsW(wstr ptr long) kernel32.ExpandEnvironmentStringsW 461 stdcall -noname SHGetAppCompatFlags(long) -462 stdcall -ordinal UrlFixupW(wstr wstr long) +462 stdcall -ordinal UrlFixupW(wstr wstr long) kernelbase.UrlFixupW 463 stdcall -noname SHExpandEnvironmentStringsForUserA(ptr str ptr long) userenv.ExpandEnvironmentStringsForUserA 464 stdcall -noname SHExpandEnvironmentStringsForUserW(ptr wstr ptr long) userenv.ExpandEnvironmentStringsForUserW 465 stub -noname PathUnExpandEnvStringsForUserA @@ -563,11 +563,11 @@ @ stdcall DelayLoadFailureHook(str str) kernel32.DelayLoadFailureHook @ stdcall -private DllGetVersion(ptr) @ stdcall GetMenuPosFromID(ptr long) -@ stdcall HashData (ptr long ptr long) +@ stdcall HashData(ptr long ptr long) kernelbase.HashData @ stdcall IntlStrEqWorkerA(long str str long) kernelbase.StrIsIntlEqualA @ stdcall IntlStrEqWorkerW(long wstr wstr long) kernelbase.StrIsIntlEqualW @ stdcall IsCharSpaceA(long) -@ stdcall IsInternetESCEnabled() +@ stdcall IsInternetESCEnabled() kernelbase.IsInternetESCEnabled @ stdcall PathAddBackslashA (str) @ stdcall PathAddBackslashW (wstr) @ stdcall PathAddExtensionA (str str) @@ -823,24 +823,24 @@ @ stdcall UrlCanonicalizeW(wstr ptr ptr long) @ stdcall UrlCombineA(str str ptr ptr long) @ stdcall UrlCombineW(wstr wstr ptr ptr long) -@ stdcall UrlCompareA(str str long) -@ stdcall UrlCompareW(wstr wstr long) -@ stdcall UrlCreateFromPathA(str ptr ptr long) -@ stdcall UrlCreateFromPathW(wstr ptr ptr long) +@ stdcall UrlCompareA(str str long) kernelbase.UrlCompareA +@ stdcall UrlCompareW(wstr wstr long) kernelbase.UrlCompareW +@ stdcall UrlCreateFromPathA(str ptr ptr long) kernelbase.UrlCreateFromPathA +@ stdcall UrlCreateFromPathW(wstr ptr ptr long) kernelbase.UrlCreateFromPathW @ stdcall UrlEscapeA(str ptr ptr long) @ stdcall UrlEscapeW(wstr ptr ptr long) -@ stdcall UrlGetLocationA(str) -@ stdcall UrlGetLocationW(wstr) -@ stdcall UrlGetPartA(str ptr ptr long long) -@ stdcall UrlGetPartW(wstr ptr ptr long long) -@ stdcall UrlHashA(str ptr long) -@ stdcall UrlHashW(wstr ptr long) -@ stdcall UrlIsA(str long) -@ stdcall UrlIsNoHistoryA(str) -@ stdcall UrlIsNoHistoryW(wstr) -@ stdcall UrlIsOpaqueA(str) -@ stdcall UrlIsOpaqueW(wstr) -@ stdcall UrlIsW(wstr long) +@ stdcall UrlGetLocationA(str) kernelbase.UrlGetLocationA +@ stdcall UrlGetLocationW(wstr) kernelbase.UrlGetLocationW +@ stdcall UrlGetPartA(str ptr ptr long long) kernelbase.UrlGetPartA +@ stdcall UrlGetPartW(wstr ptr ptr long long) kernelbase.UrlGetPartW +@ stdcall UrlHashA(str ptr long) kernelbase.UrlHashA +@ stdcall UrlHashW(wstr ptr long) kernelbase.UrlHashW +@ stdcall UrlIsA(str long) kernelbase.UrlIsA +@ stdcall UrlIsNoHistoryA(str) kernelbase.UrlIsNoHistoryA +@ stdcall UrlIsNoHistoryW(wstr) kernelbase.UrlIsNoHistoryW +@ stdcall UrlIsOpaqueA(str) kernelbase.UrlIsOpaqueA +@ stdcall UrlIsOpaqueW(wstr) kernelbase.UrlIsOpaqueW +@ stdcall UrlIsW(wstr long) kernelbase.UrlIsW @ stdcall UrlUnescapeA(str ptr ptr long) @ stdcall UrlUnescapeW(wstr ptr ptr long) @ stdcall _SHGetInstanceExplorer(ptr) diff --git a/dlls/shlwapi/url.c b/dlls/shlwapi/url.c index 72cc4616a0..8a93052afa 100644 --- a/dlls/shlwapi/url.c +++ b/dlls/shlwapi/url.c @@ -84,54 +84,8 @@ static const struct { {URL_SCHEME_RES, {'r','e','s',0}}, };
-typedef struct { - LPCWSTR pScheme; /* [out] start of scheme */ - DWORD szScheme; /* [out] size of scheme (until colon) */ - LPCWSTR pUserName; /* [out] start of Username */ - DWORD szUserName; /* [out] size of Username (until ":" or "@") */ - LPCWSTR pPassword; /* [out] start of Password */ - DWORD szPassword; /* [out] size of Password (until "@") */ - LPCWSTR pHostName; /* [out] start of Hostname */ - DWORD szHostName; /* [out] size of Hostname (until ":" or "/") */ - LPCWSTR pPort; /* [out] start of Port */ - DWORD szPort; /* [out] size of Port (until "/" or eos) */ - LPCWSTR pQuery; /* [out] start of Query */ - DWORD szQuery; /* [out] size of Query (until eos) */ -} WINE_PARSE_URL; - -typedef enum { - SCHEME, - HOST, - PORT, - USERPASS, -} WINE_URL_SCAN_TYPE; - static const CHAR hexDigits[] = "0123456789ABCDEF";
-static const WCHAR fileW[] = {'f','i','l','e','\0'}; - -static const unsigned char HashDataLookup[256] = { - 0x01, 0x0E, 0x6E, 0x19, 0x61, 0xAE, 0x84, 0x77, 0x8A, 0xAA, 0x7D, 0x76, 0x1B, - 0xE9, 0x8C, 0x33, 0x57, 0xC5, 0xB1, 0x6B, 0xEA, 0xA9, 0x38, 0x44, 0x1E, 0x07, - 0xAD, 0x49, 0xBC, 0x28, 0x24, 0x41, 0x31, 0xD5, 0x68, 0xBE, 0x39, 0xD3, 0x94, - 0xDF, 0x30, 0x73, 0x0F, 0x02, 0x43, 0xBA, 0xD2, 0x1C, 0x0C, 0xB5, 0x67, 0x46, - 0x16, 0x3A, 0x4B, 0x4E, 0xB7, 0xA7, 0xEE, 0x9D, 0x7C, 0x93, 0xAC, 0x90, 0xB0, - 0xA1, 0x8D, 0x56, 0x3C, 0x42, 0x80, 0x53, 0x9C, 0xF1, 0x4F, 0x2E, 0xA8, 0xC6, - 0x29, 0xFE, 0xB2, 0x55, 0xFD, 0xED, 0xFA, 0x9A, 0x85, 0x58, 0x23, 0xCE, 0x5F, - 0x74, 0xFC, 0xC0, 0x36, 0xDD, 0x66, 0xDA, 0xFF, 0xF0, 0x52, 0x6A, 0x9E, 0xC9, - 0x3D, 0x03, 0x59, 0x09, 0x2A, 0x9B, 0x9F, 0x5D, 0xA6, 0x50, 0x32, 0x22, 0xAF, - 0xC3, 0x64, 0x63, 0x1A, 0x96, 0x10, 0x91, 0x04, 0x21, 0x08, 0xBD, 0x79, 0x40, - 0x4D, 0x48, 0xD0, 0xF5, 0x82, 0x7A, 0x8F, 0x37, 0x69, 0x86, 0x1D, 0xA4, 0xB9, - 0xC2, 0xC1, 0xEF, 0x65, 0xF2, 0x05, 0xAB, 0x7E, 0x0B, 0x4A, 0x3B, 0x89, 0xE4, - 0x6C, 0xBF, 0xE8, 0x8B, 0x06, 0x18, 0x51, 0x14, 0x7F, 0x11, 0x5B, 0x5C, 0xFB, - 0x97, 0xE1, 0xCF, 0x15, 0x62, 0x71, 0x70, 0x54, 0xE2, 0x12, 0xD6, 0xC7, 0xBB, - 0x0D, 0x20, 0x5E, 0xDC, 0xE0, 0xD4, 0xF7, 0xCC, 0xC4, 0x2B, 0xF9, 0xEC, 0x2D, - 0xF4, 0x6F, 0xB6, 0x99, 0x88, 0x81, 0x5A, 0xD9, 0xCA, 0x13, 0xA5, 0xE7, 0x47, - 0xE6, 0x8E, 0x60, 0xE3, 0x3E, 0xB3, 0xF6, 0x72, 0xA2, 0x35, 0xA0, 0xD7, 0xCD, - 0xB4, 0x2F, 0x6D, 0x2C, 0x26, 0x1F, 0x95, 0x87, 0x00, 0xD8, 0x34, 0x3F, 0x17, - 0x25, 0x45, 0x27, 0x75, 0x92, 0xB8, 0xA3, 0xC8, 0xDE, 0xEB, 0xF8, 0xF3, 0xDB, - 0x0A, 0x98, 0x83, 0x7B, 0xE5, 0xCB, 0x4C, 0x78, 0xD1 }; - static DWORD get_scheme_code(LPCWSTR scheme, DWORD scheme_len) { unsigned int i; @@ -1412,222 +1366,6 @@ HRESULT WINAPI UrlUnescapeW( return ret; }
-/************************************************************************* - * UrlGetLocationA [SHLWAPI.@] - * - * Get the location from a Url. - * - * PARAMS - * pszUrl [I] Url to get the location from - * - * RETURNS - * A pointer to the start of the location in pszUrl, or NULL if there is - * no location. - * - * NOTES - * - MSDN erroneously states that "The location is the segment of the Url - * starting with a '?' or '#' character". Neither V4 nor V5 of shlwapi.dll - * stop at '?' and always return a NULL in this case. - * - MSDN also erroneously states that "If a file URL has a query string, - * the returned string is the query string". In all tested cases, if the - * Url starts with "fi" then a NULL is returned. V5 gives the following results: - *| Result Url - *| ------ --- - *| NULL file://aa/b/cd#hohoh - *| #hohoh http://aa/b/cd#hohoh - *| NULL fi://aa/b/cd#hohoh - *| #hohoh ff://aa/b/cd#hohoh - */ -LPCSTR WINAPI UrlGetLocationA( - LPCSTR pszUrl) -{ - PARSEDURLA base; - DWORD res1; - - base.cbSize = sizeof(base); - res1 = ParseURLA(pszUrl, &base); - if (res1) return NULL; /* invalid scheme */ - - /* if scheme is file: then never return pointer */ - if (strncmp(base.pszProtocol, "file", min(4,base.cchProtocol)) == 0) return NULL; - - /* Look for '#' and return its addr */ - return strchr(base.pszSuffix, '#'); -} - -/************************************************************************* - * UrlGetLocationW [SHLWAPI.@] - * - * See UrlGetLocationA. - */ -LPCWSTR WINAPI UrlGetLocationW( - LPCWSTR pszUrl) -{ - PARSEDURLW base; - DWORD res1; - - base.cbSize = sizeof(base); - res1 = ParseURLW(pszUrl, &base); - if (res1) return NULL; /* invalid scheme */ - - /* if scheme is file: then never return pointer */ - if (strncmpW(base.pszProtocol, fileW, min(4,base.cchProtocol)) == 0) return NULL; - - /* Look for '#' and return its addr */ - return strchrW(base.pszSuffix, '#'); -} - -/************************************************************************* - * UrlCompareA [SHLWAPI.@] - * - * Compare two Urls. - * - * PARAMS - * pszUrl1 [I] First Url to compare - * pszUrl2 [I] Url to compare to pszUrl1 - * fIgnoreSlash [I] TRUE = compare only up to a final slash - * - * RETURNS - * less than zero, zero, or greater than zero indicating pszUrl2 is greater - * than, equal to, or less than pszUrl1 respectively. - */ -INT WINAPI UrlCompareA( - LPCSTR pszUrl1, - LPCSTR pszUrl2, - BOOL fIgnoreSlash) -{ - INT ret, len, len1, len2; - - if (!fIgnoreSlash) - return strcmp(pszUrl1, pszUrl2); - len1 = strlen(pszUrl1); - if (pszUrl1[len1-1] == '/') len1--; - len2 = strlen(pszUrl2); - if (pszUrl2[len2-1] == '/') len2--; - if (len1 == len2) - return strncmp(pszUrl1, pszUrl2, len1); - len = min(len1, len2); - ret = strncmp(pszUrl1, pszUrl2, len); - if (ret) return ret; - if (len1 > len2) return 1; - return -1; -} - -/************************************************************************* - * UrlCompareW [SHLWAPI.@] - * - * See UrlCompareA. - */ -INT WINAPI UrlCompareW( - LPCWSTR pszUrl1, - LPCWSTR pszUrl2, - BOOL fIgnoreSlash) -{ - INT ret; - size_t len, len1, len2; - - if (!fIgnoreSlash) - return strcmpW(pszUrl1, pszUrl2); - len1 = strlenW(pszUrl1); - if (pszUrl1[len1-1] == '/') len1--; - len2 = strlenW(pszUrl2); - if (pszUrl2[len2-1] == '/') len2--; - if (len1 == len2) - return strncmpW(pszUrl1, pszUrl2, len1); - len = min(len1, len2); - ret = strncmpW(pszUrl1, pszUrl2, len); - if (ret) return ret; - if (len1 > len2) return 1; - return -1; -} - -/************************************************************************* - * HashData [SHLWAPI.@] - * - * Hash an input block into a variable sized digest. - * - * PARAMS - * lpSrc [I] Input block - * nSrcLen [I] Length of lpSrc - * lpDest [I] Output for hash digest - * nDestLen [I] Length of lpDest - * - * RETURNS - * Success: TRUE. lpDest is filled with the computed hash value. - * Failure: FALSE, if any argument is invalid. - */ -HRESULT WINAPI HashData(const unsigned char *lpSrc, DWORD nSrcLen, - unsigned char *lpDest, DWORD nDestLen) -{ - INT srcCount = nSrcLen - 1, destCount = nDestLen - 1; - - if (!lpSrc || !lpDest) - return E_INVALIDARG; - - while (destCount >= 0) - { - lpDest[destCount] = (destCount & 0xff); - destCount--; - } - - while (srcCount >= 0) - { - destCount = nDestLen - 1; - while (destCount >= 0) - { - lpDest[destCount] = HashDataLookup[lpSrc[srcCount] ^ lpDest[destCount]]; - destCount--; - } - srcCount--; - } - return S_OK; -} - -/************************************************************************* - * UrlHashA [SHLWAPI.@] - * - * Produce a Hash from a Url. - * - * PARAMS - * pszUrl [I] Url to hash - * lpDest [O] Destinationh for hash - * nDestLen [I] Length of lpDest - * - * RETURNS - * Success: S_OK. lpDest is filled with the computed hash value. - * Failure: E_INVALIDARG, if any argument is invalid. - */ -HRESULT WINAPI UrlHashA(LPCSTR pszUrl, unsigned char *lpDest, DWORD nDestLen) -{ - if (IsBadStringPtrA(pszUrl, -1) || IsBadWritePtr(lpDest, nDestLen)) - return E_INVALIDARG; - - HashData((const BYTE*)pszUrl, (int)strlen(pszUrl), lpDest, nDestLen); - return S_OK; -} - -/************************************************************************* - * UrlHashW [SHLWAPI.@] - * - * See UrlHashA. - */ -HRESULT WINAPI UrlHashW(LPCWSTR pszUrl, unsigned char *lpDest, DWORD nDestLen) -{ - char szUrl[MAX_PATH]; - - TRACE("(%s,%p,%d)\n",debugstr_w(pszUrl), lpDest, nDestLen); - - if (IsBadStringPtrW(pszUrl, -1) || IsBadWritePtr(lpDest, nDestLen)) - return E_INVALIDARG; - - /* Win32 hashes the data as an ASCII string, presumably so that both A+W - * return the same digests for the same URL. - */ - WideCharToMultiByte(CP_ACP, 0, pszUrl, -1, szUrl, MAX_PATH, NULL, NULL); - HashData((const BYTE*)szUrl, (int)strlen(szUrl), lpDest, nDestLen); - return S_OK; -} - /************************************************************************* * UrlApplySchemeA [SHLWAPI.@] * @@ -1848,539 +1586,6 @@ HRESULT WINAPI UrlApplySchemeW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, DW return S_FALSE; }
-/************************************************************************* - * UrlIsA [SHLWAPI.@] - * - * Determine if a Url is of a certain class. - * - * PARAMS - * pszUrl [I] Url to check - * Urlis [I] URLIS_ constant from "shlwapi.h" - * - * RETURNS - * TRUE if pszUrl belongs to the class type in Urlis. - * FALSE Otherwise. - */ -BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis) -{ - PARSEDURLA base; - DWORD res1; - LPCSTR last; - - TRACE("(%s %d)\n", debugstr_a(pszUrl), Urlis); - - if(!pszUrl) - return FALSE; - - switch (Urlis) { - - case URLIS_OPAQUE: - base.cbSize = sizeof(base); - res1 = ParseURLA(pszUrl, &base); - if (res1) return FALSE; /* invalid scheme */ - switch (base.nScheme) - { - case URL_SCHEME_MAILTO: - case URL_SCHEME_SHELL: - case URL_SCHEME_JAVASCRIPT: - case URL_SCHEME_VBSCRIPT: - case URL_SCHEME_ABOUT: - return TRUE; - } - return FALSE; - - case URLIS_FILEURL: - return (CompareStringA(LOCALE_INVARIANT, NORM_IGNORECASE, pszUrl, 5, - "file:", 5) == CSTR_EQUAL); - - case URLIS_DIRECTORY: - last = pszUrl + strlen(pszUrl) - 1; - return (last >= pszUrl && (*last == '/' || *last == '\' )); - - case URLIS_URL: - return PathIsURLA(pszUrl); - - case URLIS_NOHISTORY: - case URLIS_APPLIABLE: - case URLIS_HASQUERY: - default: - FIXME("(%s %d): stub\n", debugstr_a(pszUrl), Urlis); - } - return FALSE; -} - -/************************************************************************* - * UrlIsW [SHLWAPI.@] - * - * See UrlIsA. - */ -BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis) -{ - static const WCHAR file_colon[] = { 'f','i','l','e',':',0 }; - PARSEDURLW base; - DWORD res1; - LPCWSTR last; - - TRACE("(%s %d)\n", debugstr_w(pszUrl), Urlis); - - if(!pszUrl) - return FALSE; - - switch (Urlis) { - - case URLIS_OPAQUE: - base.cbSize = sizeof(base); - res1 = ParseURLW(pszUrl, &base); - if (res1) return FALSE; /* invalid scheme */ - switch (base.nScheme) - { - case URL_SCHEME_MAILTO: - case URL_SCHEME_SHELL: - case URL_SCHEME_JAVASCRIPT: - case URL_SCHEME_VBSCRIPT: - case URL_SCHEME_ABOUT: - return TRUE; - } - return FALSE; - - case URLIS_FILEURL: - return (CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pszUrl, 5, - file_colon, 5) == CSTR_EQUAL); - - case URLIS_DIRECTORY: - last = pszUrl + strlenW(pszUrl) - 1; - return (last >= pszUrl && (*last == '/' || *last == '\')); - - case URLIS_URL: - return PathIsURLW(pszUrl); - - case URLIS_NOHISTORY: - case URLIS_APPLIABLE: - case URLIS_HASQUERY: - default: - FIXME("(%s %d): stub\n", debugstr_w(pszUrl), Urlis); - } - return FALSE; -} - -/************************************************************************* - * UrlIsNoHistoryA [SHLWAPI.@] - * - * Determine if a Url should not be stored in the users history list. - * - * PARAMS - * pszUrl [I] Url to check - * - * RETURNS - * TRUE, if pszUrl should be excluded from the history list, - * FALSE otherwise. - */ -BOOL WINAPI UrlIsNoHistoryA(LPCSTR pszUrl) -{ - return UrlIsA(pszUrl, URLIS_NOHISTORY); -} - -/************************************************************************* - * UrlIsNoHistoryW [SHLWAPI.@] - * - * See UrlIsNoHistoryA. - */ -BOOL WINAPI UrlIsNoHistoryW(LPCWSTR pszUrl) -{ - return UrlIsW(pszUrl, URLIS_NOHISTORY); -} - -/************************************************************************* - * UrlIsOpaqueA [SHLWAPI.@] - * - * Determine if a Url is opaque. - * - * PARAMS - * pszUrl [I] Url to check - * - * RETURNS - * TRUE if pszUrl is opaque, - * FALSE Otherwise. - * - * NOTES - * An opaque Url is one that does not start with "<protocol>://". - */ -BOOL WINAPI UrlIsOpaqueA(LPCSTR pszUrl) -{ - return UrlIsA(pszUrl, URLIS_OPAQUE); -} - -/************************************************************************* - * UrlIsOpaqueW [SHLWAPI.@] - * - * See UrlIsOpaqueA. - */ -BOOL WINAPI UrlIsOpaqueW(LPCWSTR pszUrl) -{ - return UrlIsW(pszUrl, URLIS_OPAQUE); -} - -/************************************************************************* - * Scans for characters of type "type" and when not matching found, - * returns pointer to it and length in size. - * - * Characters tested based on RFC 1738 - */ -static LPCWSTR URL_ScanID(LPCWSTR start, LPDWORD size, WINE_URL_SCAN_TYPE type) -{ - static DWORD alwayszero = 0; - BOOL cont = TRUE; - - *size = 0; - - switch(type){ - - case SCHEME: - while (cont) { - if ( (islowerW(*start) && isalphaW(*start)) || - isdigitW(*start) || - (*start == '+') || - (*start == '-') || - (*start == '.')) { - start++; - (*size)++; - } - else - cont = FALSE; - } - - if(*start != ':') - *size = 0; - - break; - - case USERPASS: - while (cont) { - if ( isalphaW(*start) || - isdigitW(*start) || - /* user/password only characters */ - (*start == ';') || - (*start == '?') || - (*start == '&') || - (*start == '=') || - /* *extra* characters */ - (*start == '!') || - (*start == '*') || - (*start == ''') || - (*start == '(') || - (*start == ')') || - (*start == ',') || - /* *safe* characters */ - (*start == '$') || - (*start == '_') || - (*start == '+') || - (*start == '-') || - (*start == '.') || - (*start == ' ')) { - start++; - (*size)++; - } else if (*start == '%') { - if (isxdigitW(*(start+1)) && - isxdigitW(*(start+2))) { - start += 3; - *size += 3; - } else - cont = FALSE; - } else - cont = FALSE; - } - break; - - case PORT: - while (cont) { - if (isdigitW(*start)) { - start++; - (*size)++; - } - else - cont = FALSE; - } - break; - - case HOST: - while (cont) { - if (isalnumW(*start) || - (*start == '-') || - (*start == '.') || - (*start == ' ') || - (*start == '*') ) { - start++; - (*size)++; - } - else - cont = FALSE; - } - break; - default: - FIXME("unknown type %d\n", type); - return (LPWSTR)&alwayszero; - } - /* TRACE("scanned %d characters next char %p<%c>\n", - *size, start, *start); */ - return start; -} - -/************************************************************************* - * Attempt to parse URL into pieces. - */ -static LONG URL_ParseUrl(LPCWSTR pszUrl, WINE_PARSE_URL *pl) -{ - LPCWSTR work; - - memset(pl, 0, sizeof(WINE_PARSE_URL)); - pl->pScheme = pszUrl; - work = URL_ScanID(pl->pScheme, &pl->szScheme, SCHEME); - if (!*work || (*work != ':')) goto ErrorExit; - work++; - if ((*work != '/') || (*(work+1) != '/')) goto SuccessExit; - pl->pUserName = work + 2; - work = URL_ScanID(pl->pUserName, &pl->szUserName, USERPASS); - if (*work == ':' ) { - /* parse password */ - work++; - pl->pPassword = work; - work = URL_ScanID(pl->pPassword, &pl->szPassword, USERPASS); - if (*work != '@') { - /* what we just parsed must be the hostname and port - * so reset pointers and clear then let it parse */ - pl->szUserName = pl->szPassword = 0; - work = pl->pUserName - 1; - pl->pUserName = pl->pPassword = 0; - } - } else if (*work == '@') { - /* no password */ - pl->szPassword = 0; - pl->pPassword = 0; - } else if (!*work || (*work == '/') || (*work == '.')) { - /* what was parsed was hostname, so reset pointers and let it parse */ - pl->szUserName = pl->szPassword = 0; - work = pl->pUserName - 1; - pl->pUserName = pl->pPassword = 0; - } else goto ErrorExit; - - /* now start parsing hostname or hostnumber */ - work++; - pl->pHostName = work; - work = URL_ScanID(pl->pHostName, &pl->szHostName, HOST); - if (*work == ':') { - /* parse port */ - work++; - pl->pPort = work; - work = URL_ScanID(pl->pPort, &pl->szPort, PORT); - } - if (*work == '/') { - /* see if query string */ - pl->pQuery = strchrW(work, '?'); - if (pl->pQuery) pl->szQuery = strlenW(pl->pQuery); - } - SuccessExit: - TRACE("parse successful: scheme=%p(%d), user=%p(%d), pass=%p(%d), host=%p(%d), port=%p(%d), query=%p(%d)\n", - pl->pScheme, pl->szScheme, - pl->pUserName, pl->szUserName, - pl->pPassword, pl->szPassword, - pl->pHostName, pl->szHostName, - pl->pPort, pl->szPort, - pl->pQuery, pl->szQuery); - return S_OK; - ErrorExit: - FIXME("failed to parse %s\n", debugstr_w(pszUrl)); - return E_INVALIDARG; -} - -/************************************************************************* - * UrlGetPartA [SHLWAPI.@] - * - * Retrieve part of a Url. - * - * PARAMS - * pszIn [I] Url to parse - * pszOut [O] Destination for part of pszIn requested - * pcchOut [I] Size of pszOut - * [O] length of pszOut string EXCLUDING '\0' if S_OK, otherwise - * needed size of pszOut INCLUDING '\0'. - * dwPart [I] URL_PART_ enum from "shlwapi.h" - * dwFlags [I] URL_ flags from "shlwapi.h" - * - * RETURNS - * Success: S_OK. pszOut contains the part requested, pcchOut contains its length. - * Failure: An HRESULT error code describing the error. - */ -HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut, - DWORD dwPart, DWORD dwFlags) -{ - LPWSTR in, out; - DWORD ret, len, len2; - - if(!pszIn || !pszOut || !pcchOut || *pcchOut <= 0) - return E_INVALIDARG; - - in = HeapAlloc(GetProcessHeap(), 0, - (2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR)); - out = 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); - - if (FAILED(ret)) { - HeapFree(GetProcessHeap(), 0, in); - return ret; - } - - 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(CP_ACP, 0, out, len+1, pszOut, *pcchOut, NULL, NULL); - *pcchOut = len2-1; - HeapFree(GetProcessHeap(), 0, in); - return ret; -} - -/************************************************************************* - * UrlGetPartW [SHLWAPI.@] - * - * See UrlGetPartA. - */ -HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, - DWORD dwPart, DWORD dwFlags) -{ - WINE_PARSE_URL pl; - HRESULT ret; - DWORD scheme, size, schsize; - LPCWSTR addr, schaddr; - - TRACE("(%s %p %p(%d) %08x %08x)\n", - debugstr_w(pszIn), pszOut, pcchOut, *pcchOut, dwPart, dwFlags); - - if(!pszIn || !pszOut || !pcchOut || *pcchOut <= 0) - return E_INVALIDARG; - - *pszOut = '\0'; - - addr = strchrW(pszIn, ':'); - if(!addr) - scheme = URL_SCHEME_UNKNOWN; - else - scheme = get_scheme_code(pszIn, addr-pszIn); - - ret = URL_ParseUrl(pszIn, &pl); - - switch (dwPart) { - case URL_PART_SCHEME: - if (!pl.szScheme) { - *pcchOut = 0; - return S_FALSE; - } - addr = pl.pScheme; - size = pl.szScheme; - break; - - case URL_PART_HOSTNAME: - switch(scheme) { - case URL_SCHEME_FTP: - case URL_SCHEME_HTTP: - case URL_SCHEME_GOPHER: - case URL_SCHEME_TELNET: - case URL_SCHEME_FILE: - case URL_SCHEME_HTTPS: - break; - default: - *pcchOut = 0; - return E_FAIL; - } - - if(scheme==URL_SCHEME_FILE && (!pl.szHostName || - (pl.szHostName==1 && *(pl.pHostName+1)==':'))) { - *pcchOut = 0; - return S_FALSE; - } - - if (!pl.szHostName) { - *pcchOut = 0; - return S_FALSE; - } - addr = pl.pHostName; - size = pl.szHostName; - break; - - case URL_PART_USERNAME: - if (!pl.szUserName) { - *pcchOut = 0; - return S_FALSE; - } - addr = pl.pUserName; - size = pl.szUserName; - break; - - case URL_PART_PASSWORD: - if (!pl.szPassword) { - *pcchOut = 0; - return S_FALSE; - } - addr = pl.pPassword; - size = pl.szPassword; - break; - - case URL_PART_PORT: - if (!pl.szPort) { - *pcchOut = 0; - return S_FALSE; - } - addr = pl.pPort; - size = pl.szPort; - break; - - case URL_PART_QUERY: - if (!pl.szQuery) { - *pcchOut = 0; - return S_FALSE; - } - addr = pl.pQuery; - size = pl.szQuery; - break; - - default: - *pcchOut = 0; - return E_INVALIDARG; - } - - if (dwFlags == URL_PARTFLAG_KEEPSCHEME) { - if(!pl.pScheme || !pl.szScheme) { - *pcchOut = 0; - return E_FAIL; - } - schaddr = pl.pScheme; - schsize = pl.szScheme; - if (*pcchOut < schsize + size + 2) { - *pcchOut = schsize + size + 2; - return E_POINTER; - } - memcpy(pszOut, schaddr, schsize*sizeof(WCHAR)); - pszOut[schsize] = ':'; - memcpy(pszOut+schsize+1, addr, size*sizeof(WCHAR)); - pszOut[schsize+1+size] = 0; - *pcchOut = schsize + 1 + size; - } - else { - if (*pcchOut < size + 1) {*pcchOut = size+1; return E_POINTER;} - memcpy(pszOut, addr, size*sizeof(WCHAR)); - pszOut[size] = 0; - *pcchOut = size; - } - TRACE("len=%d %s\n", *pcchOut, debugstr_w(pszOut)); - - return ret; -} - /************************************************************************* * PathIsURLA [SHLWAPI.@] * @@ -2428,76 +1633,6 @@ BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath) return hres == S_OK && (base.nScheme != URL_SCHEME_INVALID); }
-/************************************************************************* - * UrlCreateFromPathA [SHLWAPI.@] - * - * See UrlCreateFromPathW - */ -HRESULT WINAPI UrlCreateFromPathA(LPCSTR pszPath, LPSTR pszUrl, LPDWORD pcchUrl, DWORD dwReserved) -{ - WCHAR bufW[INTERNET_MAX_URL_LENGTH]; - WCHAR *urlW = bufW; - UNICODE_STRING pathW; - HRESULT ret; - DWORD lenW = ARRAY_SIZE(bufW), lenA; - - if(!RtlCreateUnicodeStringFromAsciiz(&pathW, pszPath)) - return E_INVALIDARG; - if((ret = UrlCreateFromPathW(pathW.Buffer, urlW, &lenW, dwReserved)) == E_POINTER) { - urlW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR)); - ret = UrlCreateFromPathW(pathW.Buffer, urlW, &lenW, dwReserved); - } - if(ret == S_OK || ret == S_FALSE) { - RtlUnicodeToMultiByteSize(&lenA, urlW, lenW * sizeof(WCHAR)); - if(*pcchUrl > lenA) { - RtlUnicodeToMultiByteN(pszUrl, *pcchUrl - 1, &lenA, urlW, lenW * sizeof(WCHAR)); - pszUrl[lenA] = 0; - *pcchUrl = lenA; - } else { - *pcchUrl = lenA + 1; - ret = E_POINTER; - } - } - if(urlW != bufW) HeapFree(GetProcessHeap(), 0, urlW); - RtlFreeUnicodeString(&pathW); - return ret; -} - -/************************************************************************* - * UrlCreateFromPathW [SHLWAPI.@] - * - * Create a Url from a file path. - * - * PARAMS - * pszPath [I] Path to convert - * pszUrl [O] Destination for the converted Url - * pcchUrl [I/O] Length of pszUrl - * dwReserved [I] Reserved, must be 0 - * - * RETURNS - * Success: S_OK pszUrl contains the converted path, S_FALSE if the path is already a Url - * Failure: An HRESULT error code. - */ -HRESULT WINAPI UrlCreateFromPathW(LPCWSTR pszPath, LPWSTR pszUrl, LPDWORD pcchUrl, DWORD dwReserved) -{ - HRESULT ret; - - TRACE("(%s, %p, %p, 0x%08x)\n", debugstr_w(pszPath), pszUrl, pcchUrl, dwReserved); - - /* Validate arguments */ - if (dwReserved != 0) - return E_INVALIDARG; - if (!pszUrl || !pcchUrl) - return E_INVALIDARG; - - ret = URL_CreateFromPath(pszPath, pszUrl, pcchUrl); - - if (S_FALSE == ret) - strcpyW(pszUrl, pszPath); - - return ret; -} - /************************************************************************* * SHAutoComplete [SHLWAPI.@] * @@ -2615,44 +1750,3 @@ HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags, } return hRet; } - -/*********************************************************************** - * UrlFixupW [SHLWAPI.462] - * - * Checks the scheme part of a URL and attempts to correct misspellings. - * - * PARAMS - * lpszUrl [I] Pointer to the URL to be corrected - * lpszTranslatedUrl [O] Pointer to a buffer to store corrected URL - * dwMaxChars [I] Maximum size of corrected URL - * - * RETURNS - * success: S_OK if URL corrected or already correct - * failure: S_FALSE if unable to correct / COM error code if other error - * - */ -HRESULT WINAPI UrlFixupW(LPCWSTR url, LPWSTR translatedUrl, DWORD maxChars) -{ - DWORD srcLen; - - FIXME("(%s,%p,%d) STUB\n", debugstr_w(url), translatedUrl, maxChars); - - if (!url) - return E_FAIL; - - srcLen = lstrlenW(url) + 1; - - /* For now just copy the URL directly */ - lstrcpynW(translatedUrl, url, (maxChars < srcLen) ? maxChars : srcLen); - - return S_OK; -} - -/************************************************************************* - * IsInternetESCEnabled [SHLWAPI.@] - */ -BOOL WINAPI IsInternetESCEnabled(void) -{ - FIXME(": stub\n"); - return FALSE; -}