[MSCMS] Sync with Wine Staging 4.0. CORE-15682
[reactos.git] / dll / win32 / mscms / profile.c
index c142a49..a0b9d41 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#define WIN32_NO_STATUS
+#include "config.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
 
-#include <config.h>
-#include <wine/debug.h>
-#include <wine/unicode.h>
+#include <stdarg.h>
 
-//#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winreg.h"
+#include "shlwapi.h"
+#include "icm.h"
 
-//#include "windef.h"
-//#include "winbase.h"
-//#include "winnls.h"
-#include <wingdi.h>
-#include <winuser.h>
-#include <winreg.h>
-//#include "shlwapi.h"
-#include <icm.h>
-
-//#include "mscms_priv.h"
+#include "mscms_priv.h"
 
 static void basename( LPCWSTR path, LPWSTR name )
 {
@@ -297,7 +295,7 @@ BOOL WINAPI GetColorDirectoryW( PCWSTR machine, PWSTR buffer, PDWORD size )
 
     if (machine || !size) return FALSE;
 
-    GetSystemDirectoryW( colordir, sizeof(colordir) / sizeof(WCHAR) );
+    GetSystemDirectoryW( colordir, ARRAY_SIZE( colordir ));
     lstrcatW( colordir, colorsubdir );
 
     len = lstrlenW( colordir ) * sizeof(WCHAR);
@@ -651,7 +649,7 @@ BOOL WINAPI GetStandardColorSpaceProfileW( PCWSTR machine, DWORD id, PWSTR profi
             lstrcatW( rgbprofile, rgbprofilefile );
             len = lstrlenW( rgbprofile ) * sizeof(WCHAR);
 
-            if (*size < len || !profile)
+            if (*size < len)
             {
                 *size = len;
                 SetLastError( ERROR_MORE_DATA );
@@ -670,9 +668,10 @@ BOOL WINAPI GetStandardColorSpaceProfileW( PCWSTR machine, DWORD id, PWSTR profi
 
 static BOOL header_from_file( LPCWSTR file, PPROFILEHEADER header )
 {
+    static const WCHAR slash[] = {'\\',0};
     BOOL ret;
     PROFILE profile;
-    WCHAR path[MAX_PATH], slash[] = {'\\',0};
+    WCHAR path[MAX_PATH];
     DWORD size = sizeof(path);
     HANDLE handle;
 
@@ -955,8 +954,8 @@ exit:
 BOOL WINAPI EnumColorProfilesW( PCWSTR machine, PENUMTYPEW record, PBYTE buffer,
                                 PDWORD size, PDWORD number )
 {
+    static const WCHAR spec[] = {'\\','*','i','c','m',0};
     BOOL match, ret = FALSE;
-    WCHAR spec[] = {'\\','*','i','c','m',0};
     WCHAR colordir[MAX_PATH], glob[MAX_PATH], **profiles = NULL;
     DWORD i, len = sizeof(colordir), count = 0, totalsize = 0;
     PROFILEHEADER header;
@@ -1154,7 +1153,7 @@ BOOL WINAPI IsColorProfileTagPresent( HPROFILE handle, TAGTYPE type, PBOOL prese
         release_profile( profile );
         return FALSE;
     }
-    *present = cmsIsTag( profile->cmsprofile, type );
+    *present = (cmsIsTag( profile->cmsprofile, type ) != 0);
     release_profile( profile );
     ret = TRUE;
 
@@ -1408,7 +1407,11 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
         if (!(data = HeapAlloc( GetProcessHeap(), 0, profile->cbDataSize ))) return NULL;
         memcpy( data, profile->pProfileData, profile->cbDataSize );
 
-        cmsprofile = cmsOpenProfileFromMem( data, profile->cbDataSize );
+        if (!(cmsprofile = cmsOpenProfileFromMem( data, profile->cbDataSize )))
+        {
+            HeapFree( GetProcessHeap(), 0, data );
+            return FALSE;
+        }
         size = profile->cbDataSize;
     }
     else if (profile->dwType == PROFILE_FILENAME)
@@ -1466,7 +1469,12 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
             HeapFree( GetProcessHeap(), 0, data );
             return NULL;
         }
-        cmsprofile = cmsOpenProfileFromMem( data, size );
+        if (!(cmsprofile = cmsOpenProfileFromMem( data, size )))
+        {
+            CloseHandle( handle );
+            HeapFree( GetProcessHeap(), 0, data );
+            return NULL;
+        }
     }
     else
     {
@@ -1518,3 +1526,23 @@ BOOL WINAPI CloseColorProfile( HPROFILE profile )
 #endif /* HAVE_LCMS2 */
     return ret;
 }
+
+/******************************************************************************
+ * WcsGetUsePerUserProfiles               [MSCMS.@]
+ */
+BOOL WINAPI WcsGetUsePerUserProfiles( const WCHAR* name, DWORD class, BOOL* use_per_user_profile )
+{
+    FIXME( "%s %s %p\n", debugstr_w(name), dbgstr_tag(class), use_per_user_profile );
+    SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+    return FALSE;
+}
+
+/******************************************************************************
+ * WcsEnumColorProfilesSize               [MSCMS.@]
+ */
+BOOL WINAPI WcsEnumColorProfilesSize( WCS_PROFILE_MANAGEMENT_SCOPE scope, ENUMTYPEW *record, DWORD *size )
+{
+    FIXME( "%d %p %p\n", scope, record, size );
+    SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
+    return FALSE;
+}