Commit in reactos/lib/shlwapi on MAIN
shlwapi_De.rc+35added 1.1
shlwapi_Ja.rc+35added 1.1
assoc.c+7-71.5 -> 1.6
msgbox.c+2-21.1 -> 1.2
ordinal.c+104-861.9 -> 1.10
reg.c+4-41.9 -> 1.10
shlwapi.rc+21.1 -> 1.2
shlwapi.spec+1-11.7 -> 1.8
url.c+5-51.8 -> 1.9
+195-105
2 added + 7 modified, total 9 files
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.

reactos/lib/shlwapi
shlwapi_De.rc added at 1.1
diff -N shlwapi_De.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ shlwapi_De.rc	8 Aug 2004 21:15:48 -0000	1.1
@@ -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
+}

reactos/lib/shlwapi
shlwapi_Ja.rc added at 1.1
diff -N shlwapi_Ja.rc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ shlwapi_Ja.rc	8 Aug 2004 21:15:48 -0000	1.1
@@ -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 "�G���[!"
+FONT 9, "MS UI Gothic"
+{
+ LTEXT "", IDS_ERR_USER_MSG2, 15, 5, 28, 20
+ LTEXT "", IDS_ERR_USER_MSG, 15, 5, 210, 8
+ CHECKBOX "�������������b�Z�[�W���\��������(&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"�L�����Z��(&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
+}

reactos/lib/shlwapi
assoc.c 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- assoc.c	11 Mar 2004 22:30:39 -0000	1.5
+++ assoc.c	8 Aug 2004 21:15:48 -0000	1.6
@@ -75,7 +75,7 @@
 {
   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 @@
 {
   if (lpszParam)
   {
-    DWORD dwStrLen = lstrlenA(lpszParam);
+    DWORD dwStrLen = MultiByteToWideChar(CP_ACP, 0, lpszParam, -1, NULL, 0);
 
     if (dwStrLen < dwLen)
     {
@@ -104,12 +104,12 @@
     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 @@
     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 @@
   {
     DWORD dwLenOut = *pcchOut;
     if (dwLenOut >= MAX_PATH)
-      lpszReturnW = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
+      lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
                                       (dwLenOut + 1) * sizeof(WCHAR));
 
     if (lpszReturnW)

reactos/lib/shlwapi
msgbox.c 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- msgbox.c	16 Apr 2004 08:47:55 -0000	1.1
+++ msgbox.c	8 Aug 2004 21:15:48 -0000	1.2
@@ -84,11 +84,11 @@
     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:

reactos/lib/shlwapi
ordinal.c 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- ordinal.c	16 Jun 2004 18:27:33 -0000	1.9
+++ ordinal.c	8 Aug 2004 21:15:48 -0000	1.10
@@ -518,109 +518,99 @@
 }
 
 /*************************************************************************
- *      @	[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)
-{
-	CHAR *mystr;
-	DWORD mystrlen, mytype;
-	HKEY mykey;
-	LCID mylcid;
-
-	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;
+HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen)
+{
+    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;
+
+    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)
-{
-	CHAR *mystr;
-	DWORD mystrlen, mytype;
-	HKEY mykey;
-	LCID mylcid;
-
-	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;
+HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen)
+{
+    WCHAR *langbufW;
+    DWORD buflenW, convlen;
+    HRESULT retval;
+
+    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 @@
     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;
+}

reactos/lib/shlwapi
reg.c 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- reg.c	8 May 2004 13:49:05 -0000	1.9
+++ reg.c	8 Aug 2004 21:15:48 -0000	1.10
@@ -1204,8 +1204,8 @@
     }
     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 @@
     }
     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;

reactos/lib/shlwapi
shlwapi.rc 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- shlwapi.rc	16 Apr 2004 08:47:55 -0000	1.1
+++ shlwapi.rc	8 Aug 2004 21:15:48 -0000	1.2
@@ -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"

reactos/lib/shlwapi
shlwapi.spec 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- shlwapi.spec	16 Jun 2004 18:27:33 -0000	1.7
+++ shlwapi.spec	8 Aug 2004 21:15:48 -0000	1.8
@@ -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

reactos/lib/shlwapi
url.c 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- url.c	16 Jun 2004 18:27:33 -0000	1.8
+++ url.c	8 Aug 2004 21:15:48 -0000	1.9
@@ -369,8 +369,8 @@
 
     /* 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 @@
     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 @@
     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 @@
     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;
 
CVSspam 0.2.8