Sync to Wine-20040716:

Mike McCormack <mike@codeweavers.com>
- Fix memory allocation problems.
Marcus Meissner <marcus@jet.franken.de>
- Do not assign to casted values.
Alexandre Julliard
- Implemented GetUIVersion (based on a patch by Stefan Leichter).
Stefan Leichter <Stefan.Leichter@camLine.com>
- Removed the crosscalls (unicode to ascii) from GetAcceptLanguagesW.
- Removed todo_wine from GetAcceptLanguagesA tests.
- Added tests for GetAcceptLanguagesA.
Henning Gerhardt <henning.gerhardt@web.de>
- Translated some English resource files into German.
Hajime Segawa <winetips@sidenet.ddo.jp>
- Added some Japanese translations.

svn path=/trunk/; revision=10434
This commit is contained in:
Gé van Geldorp 2004-08-08 21:15:48 +00:00
parent 9811098a69
commit 760a5fbb46
9 changed files with 191 additions and 101 deletions

View file

@ -75,7 +75,7 @@ static IQueryAssociations* IQueryAssociations_Constructor(void)
{
IQueryAssociationsImpl* iface;
iface =(IQueryAssociationsImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
iface = HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
iface->lpVtbl = &IQueryAssociations_vtbl;
iface->ref = 1;
iface->hkeySource = NULL;
@ -95,7 +95,7 @@ static BOOL SHLWAPI_ParamAToW(LPCSTR lpszParam, LPWSTR lpszBuff, DWORD dwLen,
{
if (lpszParam)
{
DWORD dwStrLen = lstrlenA(lpszParam);
DWORD dwStrLen = MultiByteToWideChar(CP_ACP, 0, lpszParam, -1, NULL, 0);
if (dwStrLen < dwLen)
{
@ -104,12 +104,12 @@ static BOOL SHLWAPI_ParamAToW(LPCSTR lpszParam, LPWSTR lpszBuff, DWORD dwLen,
else
{
/* Create a new buffer big enough for the string */
*lpszOut = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
(dwStrLen + 1) * sizeof(WCHAR));
*lpszOut = HeapAlloc(GetProcessHeap(), 0,
dwStrLen * sizeof(WCHAR));
if (!*lpszOut)
return FALSE;
}
MultiByteToWideChar(0, 0, lpszParam, -1, *lpszOut, -1);
MultiByteToWideChar(CP_ACP, 0, lpszParam, -1, *lpszOut, dwStrLen);
}
else
*lpszOut = NULL;
@ -298,7 +298,7 @@ HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
DWORD dwLenOut = *pcchOut;
if (dwLenOut >= MAX_PATH)
lpszReturnW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
(dwLenOut + 1) * sizeof(WCHAR));
if (!lpszReturnW)
@ -389,7 +389,7 @@ HRESULT WINAPI AssocQueryStringByKeyA(ASSOCF cfFlags, ASSOCSTR str, HKEY hkAssoc
{
DWORD dwLenOut = *pcchOut;
if (dwLenOut >= MAX_PATH)
lpszReturnW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
(dwLenOut + 1) * sizeof(WCHAR));
if (lpszReturnW)

View file

@ -84,11 +84,11 @@ static INT_PTR CALLBACK SHDlgProcEx(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
switch (LOWORD(wParam))
{
case IDYES:
LOWORD(wParam) = IDOK;
wParam = MAKELONG(IDOK, HIWORD(wParam));
/* Fall through ... */
case IDNO:
if (LOWORD(wParam) == IDNO)
LOWORD(wParam) = IDCANCEL;
wParam = MAKELONG(IDCANCEL, HIWORD(wParam));
/* Fall through ... */
case IDOK:
case IDCANCEL:

View file

@ -518,109 +518,99 @@ RegisterDefaultAcceptHeaders_Exit:
}
/*************************************************************************
* @ [SHLWAPI.14]
* @ [SHLWAPI.15]
*
* Get Explorers "AcceptLanguage" setting.
*
* PARAMS
* langbuf [O] Destination for language string
* buflen [I] Length of langbuf
* [0] Success: used length of langbuf
*
* RETURNS
* Success: S_OK. langbuf is set to the language string found.
* Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer
* does not contain the setting.
* E_INVALIDARG, If the buffer is not big enough
*/
HRESULT WINAPI GetAcceptLanguagesA(
LPSTR langbuf,
LPDWORD buflen)
HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen)
{
CHAR *mystr;
DWORD mystrlen, mytype;
HKEY mykey;
LCID mylcid;
static const WCHAR szkeyW[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
'I','n','t','e','r','n','a','t','i','o','n','a','l',0};
static const WCHAR valueW[] = {
'A','c','c','e','p','t','L','a','n','g','u','a','g','e',0};
static const WCHAR enusW[] = {'e','n','-','u','s',0};
DWORD mystrlen, mytype;
HKEY mykey;
HRESULT retval;
LCID mylcid;
WCHAR *mystr;
mystrlen = (*buflen > 6) ? *buflen : 6;
mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, mystrlen);
RegOpenKeyA(HKEY_CURRENT_USER,
"Software\\Microsoft\\Internet Explorer\\International",
&mykey);
if (RegQueryValueExA(mykey, "AcceptLanguage",
0, &mytype, (PBYTE)mystr, &mystrlen)) {
/* Did not find value */
mylcid = GetUserDefaultLCID();
/* somehow the mylcid translates into "en-us"
* this is similar to "LOCALE_SABBREVLANGNAME"
* which could be gotten via GetLocaleInfo.
* The only problem is LOCALE_SABBREVLANGUAGE" is
* a 3 char string (first 2 are country code and third is
* letter for "sublanguage", which does not come close to
* "en-us"
*/
lstrcpyA(mystr, "en-us");
mystrlen = lstrlenA(mystr);
}
else {
/* handle returned string */
FIXME("missing code\n");
}
if (mystrlen > *buflen)
lstrcpynA(langbuf, mystr, *buflen);
else {
lstrcpyA(langbuf, mystr);
*buflen = lstrlenA(langbuf);
}
RegCloseKey(mykey);
HeapFree(GetProcessHeap(), 0, mystr);
TRACE("language is %s\n", debugstr_a(langbuf));
return 0;
if(!langbuf || !buflen || !*buflen)
return E_FAIL;
mystrlen = (*buflen > 20) ? *buflen : 20 ;
mystr = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * mystrlen);
RegOpenKeyW(HKEY_CURRENT_USER, szkeyW, &mykey);
if(RegQueryValueExW(mykey, valueW, 0, &mytype, (PBYTE)mystr, &mystrlen)) {
/* Did not find value */
mylcid = GetUserDefaultLCID();
/* somehow the mylcid translates into "en-us"
* this is similar to "LOCALE_SABBREVLANGNAME"
* which could be gotten via GetLocaleInfo.
* The only problem is LOCALE_SABBREVLANGUAGE" is
* a 3 char string (first 2 are country code and third is
* letter for "sublanguage", which does not come close to
* "en-us"
*/
lstrcpyW(mystr, enusW);
mystrlen = lstrlenW(mystr);
} else {
/* handle returned string */
FIXME("missing code\n");
}
memcpy( langbuf, mystr, min(*buflen,strlenW(mystr)+1)*sizeof(WCHAR) );
if(*buflen > lstrlenW(mystr)) {
*buflen = lstrlenW(mystr);
retval = S_OK;
} else {
*buflen = 0;
retval = E_INVALIDARG;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
}
RegCloseKey(mykey);
HeapFree(GetProcessHeap(), 0, mystr);
return retval;
}
/*************************************************************************
* @ [SHLWAPI.15]
* @ [SHLWAPI.14]
*
* Unicode version of GetAcceptLanguagesA.
* Ascii version of GetAcceptLanguagesW.
*/
HRESULT WINAPI GetAcceptLanguagesW(
LPWSTR langbuf,
LPDWORD buflen)
HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen)
{
CHAR *mystr;
DWORD mystrlen, mytype;
HKEY mykey;
LCID mylcid;
WCHAR *langbufW;
DWORD buflenW, convlen;
HRESULT retval;
mystrlen = (*buflen > 6) ? *buflen : 6;
mystr = (CHAR*)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, mystrlen);
RegOpenKeyA(HKEY_CURRENT_USER,
"Software\\Microsoft\\Internet Explorer\\International",
&mykey);
if (RegQueryValueExA(mykey, "AcceptLanguage",
0, &mytype, (PBYTE)mystr, &mystrlen)) {
/* Did not find value */
mylcid = GetUserDefaultLCID();
/* somehow the mylcid translates into "en-us"
* this is similar to "LOCALE_SABBREVLANGNAME"
* which could be gotten via GetLocaleInfo.
* The only problem is LOCALE_SABBREVLANGUAGE" is
* a 3 char string (first 2 are country code and third is
* letter for "sublanguage", which does not come close to
* "en-us"
*/
lstrcpyA(mystr, "en-us");
mystrlen = lstrlenA(mystr);
}
else {
/* handle returned string */
FIXME("missing code\n");
}
RegCloseKey(mykey);
*buflen = MultiByteToWideChar(0, 0, mystr, -1, langbuf, (*buflen)-1);
HeapFree(GetProcessHeap(), 0, mystr);
TRACE("language is %s\n", debugstr_w(langbuf));
return 0;
if(!langbuf || !buflen || !*buflen) return E_FAIL;
buflenW = *buflen;
langbufW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * buflenW);
retval = GetAcceptLanguagesW(langbufW, &buflenW);
/* FIXME: this is wrong, the string may not be null-terminated */
convlen = WideCharToMultiByte(CP_ACP, 0, langbufW, -1, langbuf,
*buflen, NULL, NULL);
*buflen = buflenW ? convlen : 0;
if(langbufW) HeapFree(GetProcessHeap(), 0, langbufW);
return retval;
}
/*************************************************************************
@ -3965,3 +3955,31 @@ HRESULT WINAPI SKGetValueW(DWORD a, LPWSTR b, LPWSTR c, DWORD d, DWORD e, DWORD
FIXME("(%lx, %s, %s, %lx, %lx, %lx): stub\n", a, debugstr_w(b), debugstr_w(c), d, e, f);
return E_FAIL;
}
typedef HRESULT (WINAPI *DllGetVersion_func)(DLLVERSIONINFO *);
/***********************************************************************
* GetUIVersion (SHLWAPI.452)
*/
DWORD WINAPI GetUIVersion(void)
{
static DWORD version;
if (!version)
{
DllGetVersion_func pDllGetVersion;
HMODULE dll = LoadLibraryA("shell32.dll");
if (!dll) return 0;
pDllGetVersion = (DllGetVersion_func)GetProcAddress(dll, "DllGetVersion");
if (pDllGetVersion)
{
DLLVERSIONINFO dvi;
dvi.cbSize = sizeof(DLLVERSIONINFO);
if (pDllGetVersion(&dvi) == S_OK) version = dvi.dwMajorVersion;
}
FreeLibrary( dll );
if (!version) version = 3; /* old shell dlls don't have DllGetVersion */
}
return version;
}

View file

@ -1204,8 +1204,8 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue,
}
else
{
nBytesToAlloc = lstrlenA(pvData) * sizeof (CHAR);
szData = (LPSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc + 1);
nBytesToAlloc = (lstrlenA(pvData)+1) * sizeof (CHAR);
szData = (LPSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc );
lstrcpyA(szData, pvData);
dwExpDataLen = ExpandEnvironmentStringsA(szData, pvData, *pcbData / sizeof(CHAR));
if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA;
@ -1265,8 +1265,8 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue,
}
else
{
nBytesToAlloc = lstrlenW(pvData) * sizeof(WCHAR);
szData = (LPWSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc + 1);
nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR);
szData = (LPWSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc );
lstrcpyW(szData, pvData);
dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, *pcbData/sizeof(WCHAR) );
if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA;

View file

@ -23,5 +23,7 @@
#include "winuser.h"
#include "resource.h"
#include "shlwapi_De.rc"
#include "shlwapi_En.rc"
#include "shlwapi_Es.rc"
#include "shlwapi_Ja.rc"

View file

@ -535,7 +535,7 @@
539 stub -noname IUnknown_ShowBrowserBar
540 stub -noname SHInvokeCommandOnContextMenu
541 stub -noname SHInvokeCommandsOnContextMen
542 stub -noname GetUIVersion
542 stdcall -noname GetUIVersion()
543 stub -noname CreateColorSpaceWrapW
544 stub -noname QuerySourceCreateFromKey
545 stub -noname SHForwardContextMenuMsg

View file

@ -0,0 +1,35 @@
/*
* German resources for shlwapi
*
* Copyright 2004 Henning Gerhardt
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
LANGUAGE LANG_GERMAN, SUBLANG_DEFAULT
IDD_ERR_DIALOG DIALOG MOVEABLE DISCARDABLE 0, 0, 220, 60
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Fehler!"
FONT 8, "MS Shell Dlg"
{
LTEXT "", IDS_ERR_USER_MSG2, 15, 5, 28, 20
LTEXT "", IDS_ERR_USER_MSG, 15, 5, 210, 8
CHECKBOX "&Diesen Dialog nicht mehr anzeigen", IDC_ERR_DONT_SHOW, 5, 20, 210, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
PUSHBUTTON L"&OK" IDOK, 105, 40, 50, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON L"&Abbrechen" IDCANCEL, 160, 40, 50, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON L"&Ja" IDYES, 105, 40, 50, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON L"&Nein" IDNO, 160, 40, 50, 14, WS_GROUP | WS_TABSTOP
}

View file

@ -0,0 +1,35 @@
/*
* Japanese resources for shlwapi
*
* Copyright 2004 Hajime Segawa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
IDD_ERR_DIALOG DIALOG MOVEABLE DISCARDABLE 0, 0, 220, 60
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "エラー!"
FONT 9, "MS UI Gothic"
{
LTEXT "", IDS_ERR_USER_MSG2, 15, 5, 28, 20
LTEXT "", IDS_ERR_USER_MSG, 15, 5, 210, 8
CHECKBOX "今後はこのメッセージを表示しない(&i)", IDC_ERR_DONT_SHOW, 5, 20, 210, 10, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
PUSHBUTTON L"&OK" IDOK, 105, 40, 50, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON L"キャンセル(&C)" IDCANCEL, 160, 40, 50, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON L"はい(&Y)" IDYES, 105, 40, 50, 14, WS_GROUP | WS_TABSTOP
PUSHBUTTON L"いいえ(&N)" IDNO, 160, 40, 50, 14, WS_GROUP | WS_TABSTOP
}

View file

@ -369,8 +369,8 @@ DWORD WINAPI ParseURLW(LPCWSTR x, UNKNOWN_SHLWAPI_2 *y)
/* see if known scheme and return indicator number */
len = WideCharToMultiByte(0, 0, y->ap1, y->sizep1, 0, 0, 0, 0);
cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len+1);
WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len+1, 0, 0);
cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len);
WideCharToMultiByte(0, 0, y->ap1, y->sizep1, cmpstr, len, 0, 0);
y->fcncde = URL_SCHEME_UNKNOWN;
inet_pro = shlwapi_schemes;
while (inet_pro->scheme_name) {
@ -422,7 +422,7 @@ HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
if(!pszUrl || !pszCanonicalized || !pcchCanonicalized)
return E_INVALIDARG;
base = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
base = HeapAlloc(GetProcessHeap(), 0,
(2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
canonical = base + INTERNET_MAX_URL_LENGTH;
@ -1482,7 +1482,7 @@ HRESULT WINAPI UrlApplySchemeA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut, DWOR
TRACE("(in %s, out size %ld, flags %08lx) using W version\n",
debugstr_a(pszIn), *pcchOut, dwFlags);
in = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
in = HeapAlloc(GetProcessHeap(), 0,
(2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
out = in + INTERNET_MAX_URL_LENGTH;
@ -1968,7 +1968,7 @@ HRESULT WINAPI UrlGetPartA(LPCSTR pszIn, LPSTR pszOut, LPDWORD pcchOut,
LPWSTR in, out;
DWORD ret, len, len2;
in = (LPWSTR) HeapAlloc(GetProcessHeap(), 0,
in = HeapAlloc(GetProcessHeap(), 0,
(2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
out = in + INTERNET_MAX_URL_LENGTH;