cmd: DIR command outputs free space for the path.
[wine.git] / dlls / mscms / profile.c
blob5ecd5f832732c3ab349a30da930552480b1b55b8
1 /*
2 * MSCMS - Color Management System for Wine
4 * Copyright 2004, 2005, 2006, 2008 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdlib.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winnls.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winreg.h"
30 #include "shlwapi.h"
31 #include "icm.h"
32 #include "wine/debug.h"
34 #include "mscms_priv.h"
36 static void basename( const WCHAR *path, WCHAR *name )
38 int i = lstrlenW( path );
39 while (i > 0 && path[i - 1] != '\\' && path[i - 1] != '/') i--;
40 lstrcpyW( name, &path[i] );
43 static inline WCHAR *strdupW( const char *str )
45 WCHAR *ret = NULL;
46 if (str)
48 int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
49 if ((ret = malloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
51 return ret;
54 const char *dbgstr_tag( DWORD tag )
56 return wine_dbg_sprintf( "'%c%c%c%c'",
57 (char)(tag >> 24), (char)(tag >> 16), (char)(tag >> 8), (char)(tag) );
60 WINE_DEFAULT_DEBUG_CHANNEL(mscms);
62 /******************************************************************************
63 * AssociateColorProfileWithDeviceA [MSCMS.@]
65 BOOL WINAPI AssociateColorProfileWithDeviceA( PCSTR machine, PCSTR profile, PCSTR device )
67 int len;
68 BOOL ret = FALSE;
69 WCHAR *profileW, *deviceW;
71 TRACE( "( %s, %s, %s )\n", debugstr_a(machine), debugstr_a(profile), debugstr_a(device) );
73 if (!profile || !device)
75 SetLastError( ERROR_INVALID_PARAMETER );
76 return FALSE;
78 if (machine)
80 SetLastError( ERROR_NOT_SUPPORTED );
81 return FALSE;
84 len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
85 if (!(profileW = malloc( len * sizeof(WCHAR) ))) return FALSE;
87 MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
89 len = MultiByteToWideChar( CP_ACP, 0, device, -1, NULL, 0 );
90 if ((deviceW = malloc( len * sizeof(WCHAR) )))
92 MultiByteToWideChar( CP_ACP, 0, device, -1, deviceW, len );
93 ret = AssociateColorProfileWithDeviceW( NULL, profileW, deviceW );
96 free( profileW );
97 free( deviceW );
98 return ret;
101 static BOOL set_profile_device_key( PCWSTR file, const BYTE *value, DWORD size )
103 PROFILEHEADER header;
104 PROFILE profile;
105 HPROFILE handle;
106 HKEY icm_key, class_key;
107 WCHAR basenameW[MAX_PATH], classW[5];
109 profile.dwType = PROFILE_FILENAME;
110 profile.pProfileData = (PVOID)file;
111 profile.cbDataSize = (lstrlenW( file ) + 1) * sizeof(WCHAR);
113 /* FIXME is the profile installed? */
114 if (!(handle = OpenColorProfileW( &profile, PROFILE_READ, 0, OPEN_EXISTING )))
116 SetLastError( ERROR_INVALID_PROFILE );
117 return FALSE;
119 if (!GetColorProfileHeader( handle, &header ))
121 CloseColorProfile( handle );
122 SetLastError( ERROR_INVALID_PROFILE );
123 return FALSE;
125 RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ICM",
126 0, NULL, 0, KEY_ALL_ACCESS, NULL, &icm_key, NULL );
128 basename( file, basenameW );
129 swprintf( classW, ARRAY_SIZE(classW), L"%c%c%c%c",
130 (header.phClass >> 24) & 0xff, (header.phClass >> 16) & 0xff,
131 (header.phClass >> 8) & 0xff, header.phClass & 0xff );
133 RegCreateKeyExW( icm_key, classW, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &class_key, NULL );
134 if (value) RegSetValueExW( class_key, basenameW, 0, REG_BINARY, value, size );
135 else RegDeleteValueW( class_key, basenameW );
137 RegCloseKey( class_key );
138 RegCloseKey( icm_key );
139 CloseColorProfile( handle );
140 return TRUE;
143 /******************************************************************************
144 * AssociateColorProfileWithDeviceW [MSCMS.@]
146 BOOL WINAPI AssociateColorProfileWithDeviceW( PCWSTR machine, PCWSTR profile, PCWSTR device )
148 static const BYTE dummy_value[12];
150 TRACE( "( %s, %s, %s )\n", debugstr_w(machine), debugstr_w(profile), debugstr_w(device) );
152 if (!profile || !device)
154 SetLastError( ERROR_INVALID_PARAMETER );
155 return FALSE;
157 if (machine)
159 SetLastError( ERROR_NOT_SUPPORTED );
160 return FALSE;
163 return set_profile_device_key( profile, dummy_value, sizeof(dummy_value) );
166 /******************************************************************************
167 * DisassociateColorProfileFromDeviceA [MSCMS.@]
169 BOOL WINAPI DisassociateColorProfileFromDeviceA( PCSTR machine, PCSTR profile, PCSTR device )
171 int len;
172 BOOL ret = FALSE;
173 WCHAR *profileW, *deviceW;
175 TRACE( "( %s, %s, %s )\n", debugstr_a(machine), debugstr_a(profile), debugstr_a(device) );
177 if (!profile || !device)
179 SetLastError( ERROR_INVALID_PARAMETER );
180 return FALSE;
182 if (machine)
184 SetLastError( ERROR_NOT_SUPPORTED );
185 return FALSE;
188 len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
189 if (!(profileW = malloc( len * sizeof(WCHAR) ))) return FALSE;
191 MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
193 len = MultiByteToWideChar( CP_ACP, 0, device, -1, NULL, 0 );
194 if ((deviceW = malloc( len * sizeof(WCHAR) )))
196 MultiByteToWideChar( CP_ACP, 0, device, -1, deviceW, len );
197 ret = DisassociateColorProfileFromDeviceW( NULL, profileW, deviceW );
200 free( profileW );
201 free( deviceW );
202 return ret;
205 /******************************************************************************
206 * DisassociateColorProfileFromDeviceW [MSCMS.@]
208 BOOL WINAPI DisassociateColorProfileFromDeviceW( PCWSTR machine, PCWSTR profile, PCWSTR device )
210 TRACE( "( %s, %s, %s )\n", debugstr_w(machine), debugstr_w(profile), debugstr_w(device) );
212 if (!profile || !device)
214 SetLastError( ERROR_INVALID_PARAMETER );
215 return FALSE;
217 if (machine)
219 SetLastError( ERROR_NOT_SUPPORTED );
220 return FALSE;
223 return set_profile_device_key( profile, NULL, 0 );
226 /******************************************************************************
227 * GetColorDirectoryA [MSCMS.@]
229 * See GetColorDirectoryW.
231 BOOL WINAPI GetColorDirectoryA( PCSTR machine, PSTR buffer, PDWORD size )
233 INT len;
234 LPWSTR bufferW;
235 BOOL ret = FALSE;
236 DWORD sizeW;
238 TRACE( "( %p, %p )\n", buffer, size );
240 if (machine || !size) return FALSE;
242 if (!buffer)
244 ret = GetColorDirectoryW( NULL, NULL, &sizeW );
245 *size = sizeW / sizeof(WCHAR);
246 return ret;
249 sizeW = *size * sizeof(WCHAR);
251 if ((bufferW = malloc( sizeW )))
253 if ((ret = GetColorDirectoryW( NULL, bufferW, &sizeW )))
255 *size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
256 len = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, *size, NULL, NULL );
257 if (!len) ret = FALSE;
259 else *size = sizeW / sizeof(WCHAR);
260 free( bufferW );
262 return ret;
265 /******************************************************************************
266 * GetColorDirectoryW [MSCMS.@]
268 * Get the directory where color profiles are stored.
270 * PARAMS
271 * machine [I] Name of the machine for which to get the color directory.
272 * Must be NULL, which indicates the local machine.
273 * buffer [I] Buffer to receive the path name.
274 * size [I/O] Size of the buffer in bytes. On return the variable holds
275 * the number of bytes actually needed.
277 BOOL WINAPI GetColorDirectoryW( PCWSTR machine, PWSTR buffer, PDWORD size )
279 WCHAR colordir[MAX_PATH];
280 DWORD len;
282 TRACE( "( %p, %p )\n", buffer, size );
284 if (machine || !size) return FALSE;
286 GetSystemDirectoryW( colordir, ARRAY_SIZE( colordir ));
287 lstrcatW( colordir, L"\\spool\\drivers\\color" );
289 len = lstrlenW( colordir ) * sizeof(WCHAR);
291 if (buffer && len <= *size)
293 lstrcpyW( buffer, colordir );
294 *size = len;
295 return TRUE;
298 SetLastError( ERROR_MORE_DATA );
299 *size = len;
300 return FALSE;
303 /******************************************************************************
304 * GetColorProfileElement [MSCMS.@]
306 * Retrieve data for a specified tag type.
308 * PARAMS
309 * profile [I] Handle to a color profile.
310 * type [I] ICC tag type.
311 * offset [I] Offset in bytes to start copying from.
312 * size [I/O] Size of the buffer in bytes. On return the variable holds
313 * the number of bytes actually needed.
314 * buffer [O] Buffer to receive the tag data.
315 * ref [O] Pointer to a BOOL that specifies whether more than one tag
316 * references the data.
318 * RETURNS
319 * Success: TRUE
320 * Failure: FALSE
322 BOOL WINAPI GetColorProfileElement( HPROFILE handle, TAGTYPE type, DWORD offset, PDWORD size,
323 PVOID buffer, PBOOL ref )
325 BOOL ret;
326 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
328 TRACE( "( %p, %#lx, %lu, %p, %p, %p )\n", handle, type, offset, size, buffer, ref );
330 if (!profile) return FALSE;
332 if (!size || !ref)
334 release_object( &profile->hdr );
335 return FALSE;
337 ret = get_tag_data( profile, type, offset, buffer, size, ref );
338 release_object( &profile->hdr );
339 return ret;
342 /******************************************************************************
343 * GetColorProfileElementTag [MSCMS.@]
345 * Get the tag type from a color profile by index.
347 * PARAMS
348 * profile [I] Handle to a color profile.
349 * index [I] Index into the tag table of the color profile.
350 * type [O] Pointer to a variable that holds the ICC tag type on return.
352 * RETURNS
353 * Success: TRUE
354 * Failure: FALSE
356 * NOTES
357 * The tag table index starts at 1.
358 * Use GetCountColorProfileElements to retrieve a count of tagged elements.
360 BOOL WINAPI GetColorProfileElementTag( HPROFILE handle, DWORD index, PTAGTYPE type )
362 BOOL ret;
363 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
364 struct tag_entry tag;
366 TRACE( "( %p, %lu, %p )\n", handle, index, type );
368 if (!profile) return FALSE;
370 if (!type)
372 release_object( &profile->hdr );
373 return FALSE;
375 if ((ret = get_tag_entry( profile, index, &tag ))) *type = tag.sig;
376 release_object( &profile->hdr );
377 return ret;
380 /******************************************************************************
381 * GetColorProfileFromHandle [MSCMS.@]
383 * Retrieve an ICC color profile by handle.
385 * PARAMS
386 * profile [I] Handle to a color profile.
387 * buffer [O] Buffer to receive the ICC profile.
388 * size [I/O] Size of the buffer in bytes. On return the variable holds the
389 * number of bytes actually needed.
391 * RETURNS
392 * Success: TRUE
393 * Failure: FALSE
395 * NOTES
396 * The profile returned will be in big-endian format.
398 BOOL WINAPI GetColorProfileFromHandle( HPROFILE handle, PBYTE buffer, PDWORD size )
400 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
401 PROFILEHEADER header;
403 TRACE( "( %p, %p, %p )\n", handle, buffer, size );
405 if (!profile) return FALSE;
407 if (!size)
409 release_object( &profile->hdr );
410 return FALSE;
412 get_profile_header( profile, &header );
414 if (!buffer || header.phSize > *size)
416 *size = header.phSize;
417 release_object( &profile->hdr );
418 return FALSE;
421 /* No endian conversion needed */
422 memcpy( buffer, profile->data, profile->size );
423 *size = profile->size;
425 release_object( &profile->hdr );
426 return TRUE;
429 /******************************************************************************
430 * GetColorProfileHeader [MSCMS.@]
432 * Retrieve a color profile header by handle.
434 * PARAMS
435 * profile [I] Handle to a color profile.
436 * header [O] Buffer to receive the ICC profile header.
438 * RETURNS
439 * Success: TRUE
440 * Failure: FALSE
442 * NOTES
443 * The profile header returned will be adjusted for endianness.
445 BOOL WINAPI GetColorProfileHeader( HPROFILE handle, PPROFILEHEADER header )
447 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
449 TRACE( "( %p, %p )\n", handle, header );
451 if (!profile) return FALSE;
453 if (!header)
455 release_object( &profile->hdr );
456 return FALSE;
458 get_profile_header( profile, header );
459 release_object( &profile->hdr );
460 return TRUE;
463 /******************************************************************************
464 * GetCountColorProfileElements [MSCMS.@]
466 * Retrieve the number of elements in a color profile.
468 * PARAMS
469 * profile [I] Handle to a color profile.
470 * count [O] Pointer to a variable which is set to the number of elements
471 * in the color profile.
473 * RETURNS
474 * Success: TRUE
475 * Failure: FALSE
477 BOOL WINAPI GetCountColorProfileElements( HPROFILE handle, PDWORD count )
479 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
481 TRACE( "( %p, %p )\n", handle, count );
483 if (!profile) return FALSE;
485 if (!count)
487 release_object( &profile->hdr );
488 return FALSE;
490 *count = get_tag_count( profile );
491 release_object( &profile->hdr );
492 return TRUE;
495 /******************************************************************************
496 * GetStandardColorSpaceProfileA [MSCMS.@]
498 * See GetStandardColorSpaceProfileW.
500 BOOL WINAPI GetStandardColorSpaceProfileA( PCSTR machine, DWORD id, PSTR profile, PDWORD size )
502 INT len;
503 LPWSTR profileW;
504 BOOL ret = FALSE;
505 DWORD sizeW;
507 TRACE( "( %#lx, %p, %p )\n", id, profile, size );
509 if (machine)
511 SetLastError( ERROR_NOT_SUPPORTED );
512 return FALSE;
515 if (!size)
517 SetLastError( ERROR_INVALID_PARAMETER );
518 return FALSE;
521 sizeW = *size * sizeof(WCHAR);
523 if (!profile)
525 ret = GetStandardColorSpaceProfileW( NULL, id, NULL, &sizeW );
526 *size = sizeW / sizeof(WCHAR);
527 return ret;
530 if ((profileW = malloc( sizeW )))
532 if ((ret = GetStandardColorSpaceProfileW( NULL, id, profileW, &sizeW )))
534 *size = WideCharToMultiByte( CP_ACP, 0, profileW, -1, NULL, 0, NULL, NULL );
535 len = WideCharToMultiByte( CP_ACP, 0, profileW, -1, profile, *size, NULL, NULL );
536 if (!len) ret = FALSE;
538 else *size = sizeW / sizeof(WCHAR);
539 free( profileW );
541 return ret;
544 /******************************************************************************
545 * GetStandardColorSpaceProfileW [MSCMS.@]
547 * Retrieve the profile filename for a given standard color space id.
549 * PARAMS
550 * machine [I] Name of the machine for which to get the standard color space.
551 * Must be NULL, which indicates the local machine.
552 * id [I] Id of a standard color space.
553 * profile [O] Buffer to receive the profile filename.
554 * size [I/O] Size of the filename buffer in bytes.
556 * RETURNS
557 * Success: TRUE
558 * Failure: FALSE
560 BOOL WINAPI GetStandardColorSpaceProfileW( PCWSTR machine, DWORD id, PWSTR profile, PDWORD size )
562 WCHAR rgbprofile[MAX_PATH];
563 DWORD len = sizeof(rgbprofile);
565 TRACE( "( %#lx, %p, %p )\n", id, profile, size );
567 if (machine)
569 SetLastError( ERROR_NOT_SUPPORTED );
570 return FALSE;
573 if (!size)
575 SetLastError( ERROR_INVALID_PARAMETER );
576 return FALSE;
579 if (!profile)
581 SetLastError( ERROR_INSUFFICIENT_BUFFER );
582 return FALSE;
585 GetColorDirectoryW( machine, rgbprofile, &len );
587 switch (id)
589 case LCS_sRGB:
590 case LCS_WINDOWS_COLOR_SPACE: /* FIXME */
591 lstrcatW( rgbprofile, L"\\srgb color space profile.icm" );
592 len = lstrlenW( rgbprofile ) * sizeof(WCHAR);
594 if (*size < len)
596 *size = len;
597 SetLastError( ERROR_MORE_DATA );
598 return FALSE;
601 lstrcpyW( profile, rgbprofile );
602 break;
604 default:
605 SetLastError( ERROR_FILE_NOT_FOUND );
606 return FALSE;
608 return TRUE;
611 static BOOL header_from_file( LPCWSTR file, PPROFILEHEADER header )
613 BOOL ret;
614 PROFILE profile;
615 WCHAR path[MAX_PATH];
616 DWORD size = sizeof(path);
617 HANDLE handle;
619 ret = GetColorDirectoryW( NULL, path, &size );
620 if (!ret)
622 WARN( "Can't retrieve color directory\n" );
623 return FALSE;
625 if (size + sizeof(L"\\") + sizeof(WCHAR) * lstrlenW( file ) > sizeof(path))
627 WARN( "Filename too long\n" );
628 return FALSE;
631 lstrcatW( path, L"\\" );
632 lstrcatW( path, file );
634 profile.dwType = PROFILE_FILENAME;
635 profile.pProfileData = path;
636 profile.cbDataSize = lstrlenW( path ) + 1;
638 handle = OpenColorProfileW( &profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING );
639 if (!handle)
641 WARN( "Can't open color profile\n" );
642 return FALSE;
645 ret = GetColorProfileHeader( handle, header );
646 if (!ret)
647 WARN( "Can't retrieve color profile header\n" );
649 CloseColorProfile( handle );
650 return ret;
653 static BOOL match_profile( PENUMTYPEW rec, PPROFILEHEADER hdr )
655 if (rec->dwFields & ET_DEVICENAME)
657 FIXME( "ET_DEVICENAME: %s\n", debugstr_w(rec->pDeviceName) );
659 if (rec->dwFields & ET_MEDIATYPE)
661 FIXME( "ET_MEDIATYPE: %#lx\n", rec->dwMediaType );
663 if (rec->dwFields & ET_DITHERMODE)
665 FIXME( "ET_DITHERMODE: %#lx\n", rec->dwDitheringMode );
667 if (rec->dwFields & ET_RESOLUTION)
669 FIXME( "ET_RESOLUTION: %#lx, %#lx\n",
670 rec->dwResolution[0], rec->dwResolution[1] );
672 if (rec->dwFields & ET_DEVICECLASS)
674 FIXME( "ET_DEVICECLASS: %s\n", dbgstr_tag(rec->dwMediaType) );
676 if (rec->dwFields & ET_CMMTYPE)
678 TRACE( "ET_CMMTYPE: %s\n", dbgstr_tag(rec->dwCMMType) );
679 if (rec->dwCMMType != hdr->phCMMType) return FALSE;
681 if (rec->dwFields & ET_CLASS)
683 TRACE( "ET_CLASS: %s\n", dbgstr_tag(rec->dwClass) );
684 if (rec->dwClass != hdr->phClass) return FALSE;
686 if (rec->dwFields & ET_DATACOLORSPACE)
688 TRACE( "ET_DATACOLORSPACE: %s\n", dbgstr_tag(rec->dwDataColorSpace) );
689 if (rec->dwDataColorSpace != hdr->phDataColorSpace) return FALSE;
691 if (rec->dwFields & ET_CONNECTIONSPACE)
693 TRACE( "ET_CONNECTIONSPACE: %s\n", dbgstr_tag(rec->dwConnectionSpace) );
694 if (rec->dwConnectionSpace != hdr->phConnectionSpace) return FALSE;
696 if (rec->dwFields & ET_SIGNATURE)
698 TRACE( "ET_SIGNATURE: %s\n", dbgstr_tag(rec->dwSignature) );
699 if (rec->dwSignature != hdr->phSignature) return FALSE;
701 if (rec->dwFields & ET_PLATFORM)
703 TRACE( "ET_PLATFORM: %s\n", dbgstr_tag(rec->dwPlatform) );
704 if (rec->dwPlatform != hdr->phPlatform) return FALSE;
706 if (rec->dwFields & ET_PROFILEFLAGS)
708 TRACE( "ET_PROFILEFLAGS: %#lx\n", rec->dwProfileFlags );
709 if (rec->dwProfileFlags != hdr->phProfileFlags) return FALSE;
711 if (rec->dwFields & ET_MANUFACTURER)
713 TRACE( "ET_MANUFACTURER: %s\n", dbgstr_tag(rec->dwManufacturer) );
714 if (rec->dwManufacturer != hdr->phManufacturer) return FALSE;
716 if (rec->dwFields & ET_MODEL)
718 TRACE( "ET_MODEL: %s\n", dbgstr_tag(rec->dwModel) );
719 if (rec->dwModel != hdr->phModel) return FALSE;
721 if (rec->dwFields & ET_ATTRIBUTES)
723 TRACE( "ET_ATTRIBUTES: %#lx, %#lx\n",
724 rec->dwAttributes[0], rec->dwAttributes[1] );
725 if (rec->dwAttributes[0] != hdr->phAttributes[0] ||
726 rec->dwAttributes[1] != hdr->phAttributes[1]) return FALSE;
728 if (rec->dwFields & ET_RENDERINGINTENT)
730 TRACE( "ET_RENDERINGINTENT: %#lx\n", rec->dwRenderingIntent );
731 if (rec->dwRenderingIntent != hdr->phRenderingIntent) return FALSE;
733 if (rec->dwFields & ET_CREATOR)
735 TRACE( "ET_CREATOR: %s\n", dbgstr_tag(rec->dwCreator) );
736 if (rec->dwCreator != hdr->phCreator) return FALSE;
738 return TRUE;
741 /******************************************************************************
742 * EnumColorProfilesA [MSCMS.@]
744 * See EnumColorProfilesW.
746 BOOL WINAPI EnumColorProfilesA( PCSTR machine, PENUMTYPEA record, PBYTE buffer,
747 PDWORD size, PDWORD number )
749 BOOL match, ret = FALSE;
750 char spec[] = "\\*.icm";
751 char colordir[MAX_PATH], glob[MAX_PATH], **profiles = NULL;
752 DWORD i, len = sizeof(colordir), count = 0, totalsize = 0;
753 PROFILEHEADER header;
754 WIN32_FIND_DATAA data;
755 ENUMTYPEW recordW;
756 WCHAR *fileW = NULL, *deviceW = NULL;
757 HANDLE find;
759 TRACE( "( %p, %p, %p, %p, %p )\n", machine, record, buffer, size, number );
761 if (machine || !record || !size ||
762 record->dwSize != sizeof(ENUMTYPEA) ||
763 record->dwVersion != ENUM_TYPE_VERSION) return FALSE;
765 ret = GetColorDirectoryA( machine, colordir, &len );
766 if (!ret || len + sizeof(spec) > MAX_PATH)
768 WARN( "can't retrieve color directory\n" );
769 return FALSE;
772 lstrcpyA( glob, colordir );
773 lstrcatA( glob, spec );
775 find = FindFirstFileA( glob, &data );
776 if (find == INVALID_HANDLE_VALUE) return FALSE;
778 if (!(profiles = calloc( 1, sizeof(char *) + 1 ))) goto exit;
780 memcpy( &recordW, record, sizeof(ENUMTYPEA) );
781 if (record->pDeviceName)
783 deviceW = strdupW( record->pDeviceName );
784 if (!(recordW.pDeviceName = deviceW)) goto exit;
787 if (!(fileW = strdupW( data.cFileName ))) goto exit;
789 if ((ret = header_from_file( fileW, &header )))
791 if ((match = match_profile( &recordW, &header )))
793 len = sizeof(char) * (lstrlenA( data.cFileName ) + 1);
794 if (!(profiles[count] = malloc( len ))) goto exit;
795 else
797 TRACE( "matching profile: %s\n", debugstr_a(data.cFileName) );
798 lstrcpyA( profiles[count], data.cFileName );
799 totalsize += len;
800 count++;
804 free( fileW );
805 fileW = NULL;
807 while (FindNextFileA( find, &data ))
809 if (!(fileW = strdupW( data.cFileName ))) goto exit;
810 if (!(ret = header_from_file( fileW, &header )))
812 free( fileW );
813 fileW = NULL;
814 continue;
817 if ((match = match_profile( &recordW, &header )))
819 char **tmp = realloc( profiles, sizeof(char *) * (count + 1) );
820 if (!tmp) goto exit;
821 else profiles = tmp;
823 len = sizeof(char) * (lstrlenA( data.cFileName ) + 1);
824 if (!(profiles[count] = malloc( len ))) goto exit;
825 else
827 TRACE( "matching profile: %s\n", debugstr_a(data.cFileName) );
828 lstrcpyA( profiles[count], data.cFileName );
829 totalsize += len;
830 count++;
833 free( fileW );
834 fileW = NULL;
837 totalsize++;
838 if (buffer && *size >= totalsize)
840 char *p = (char *)buffer;
842 for (i = 0; i < count; i++)
844 lstrcpyA( p, profiles[i] );
845 p += lstrlenA( profiles[i] ) + 1;
847 *p = 0;
848 ret = TRUE;
850 else
852 SetLastError( ERROR_INSUFFICIENT_BUFFER );
853 ret = FALSE;
856 *size = totalsize;
857 if (number) *number = count;
859 exit:
860 for (i = 0; i < count; i++) free( profiles[i] );
861 free( profiles );
862 free( deviceW );
863 free( fileW );
864 FindClose( find );
866 return ret;
869 /******************************************************************************
870 * EnumColorProfilesW [MSCMS.@]
872 * Enumerate profiles that match given criteria.
874 * PARAMS
875 * machine [I] Name of the machine for which to enumerate profiles.
876 * Must be NULL, which indicates the local machine.
877 * record [I] Record of criteria that a profile must match.
878 * buffer [O] Buffer to receive a string array of profile filenames.
879 * size [I/O] Size of the filename buffer in bytes.
880 * number [O] Number of filenames copied into buffer.
882 * RETURNS
883 * Success: TRUE
884 * Failure: FALSE
886 BOOL WINAPI EnumColorProfilesW( PCWSTR machine, PENUMTYPEW record, PBYTE buffer,
887 PDWORD size, PDWORD number )
889 BOOL match, ret = FALSE;
890 WCHAR colordir[MAX_PATH], glob[MAX_PATH], **profiles = NULL;
891 DWORD i, len = sizeof(colordir), count = 0, totalsize = 0;
892 PROFILEHEADER header;
893 WIN32_FIND_DATAW data;
894 HANDLE find;
896 TRACE( "( %p, %p, %p, %p, %p )\n", machine, record, buffer, size, number );
898 if (machine || !record || !size ||
899 record->dwSize != sizeof(ENUMTYPEW) ||
900 record->dwVersion != ENUM_TYPE_VERSION) return FALSE;
902 ret = GetColorDirectoryW( machine, colordir, &len );
903 if (!ret || len + ARRAY_SIZE(L"\\*icm") > MAX_PATH)
905 WARN( "Can't retrieve color directory\n" );
906 return FALSE;
909 lstrcpyW( glob, colordir );
910 lstrcatW( glob, L"\\*icm" );
912 find = FindFirstFileW( glob, &data );
913 if (find == INVALID_HANDLE_VALUE) return FALSE;
915 if (!(profiles = calloc( 1, sizeof(WCHAR *) + 1 ))) goto exit;
917 if ((ret = header_from_file( data.cFileName, &header )))
919 if ((match = match_profile( record, &header )))
921 len = sizeof(WCHAR) * (lstrlenW( data.cFileName ) + 1);
922 if (!(profiles[count] = malloc( len ))) goto exit;
923 else
925 TRACE( "matching profile: %s\n", debugstr_w(data.cFileName) );
926 lstrcpyW( profiles[count], data.cFileName );
927 totalsize += len;
928 count++;
933 while (FindNextFileW( find, &data ))
935 if (!(ret = header_from_file( data.cFileName, &header ))) continue;
937 if ((match = match_profile( record, &header )))
939 WCHAR **tmp = realloc( profiles, sizeof(WCHAR *) * (count + 1) );
940 if (!tmp) goto exit;
941 else profiles = tmp;
943 len = sizeof(WCHAR) * (lstrlenW( data.cFileName ) + 1);
944 if (!(profiles[count] = malloc( len ))) goto exit;
945 else
947 TRACE( "matching profile: %s\n", debugstr_w(data.cFileName) );
948 lstrcpyW( profiles[count], data.cFileName );
949 totalsize += len;
950 count++;
955 totalsize++;
956 if (buffer && *size >= totalsize)
958 WCHAR *p = (WCHAR *)buffer;
960 for (i = 0; i < count; i++)
962 lstrcpyW( p, profiles[i] );
963 p += lstrlenW( profiles[i] ) + 1;
965 *p = 0;
966 ret = TRUE;
968 else
970 SetLastError( ERROR_INSUFFICIENT_BUFFER );
971 ret = FALSE;
974 *size = totalsize;
975 if (number) *number = count;
977 exit:
978 for (i = 0; i < count; i++) free( profiles[i] );
979 free( profiles );
980 FindClose( find );
982 return ret;
985 /******************************************************************************
986 * InstallColorProfileA [MSCMS.@]
988 * See InstallColorProfileW.
990 BOOL WINAPI InstallColorProfileA( PCSTR machine, PCSTR profile )
992 UINT len;
993 LPWSTR profileW;
994 BOOL ret = FALSE;
996 TRACE( "( %s )\n", debugstr_a(profile) );
998 if (machine || !profile) return FALSE;
1000 len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
1001 if ((profileW = malloc( len * sizeof(WCHAR) )))
1003 MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
1004 ret = InstallColorProfileW( NULL, profileW );
1005 free( profileW );
1007 return ret;
1010 /******************************************************************************
1011 * InstallColorProfileW [MSCMS.@]
1013 * Install a color profile.
1015 * PARAMS
1016 * machine [I] Name of the machine to install the profile on. Must be NULL,
1017 * which indicates the local machine.
1018 * profile [I] Full path name of the profile to install.
1020 * RETURNS
1021 * Success: TRUE
1022 * Failure: FALSE
1024 BOOL WINAPI InstallColorProfileW( PCWSTR machine, PCWSTR profile )
1026 WCHAR dest[MAX_PATH], base[MAX_PATH];
1027 DWORD size = sizeof(dest);
1029 TRACE( "( %s )\n", debugstr_w(profile) );
1031 if (machine || !profile) return FALSE;
1033 if (!GetColorDirectoryW( machine, dest, &size )) return FALSE;
1035 basename( profile, base );
1036 lstrcatW( dest, L"\\" );
1037 lstrcatW( dest, base );
1039 /* Is source equal to destination? */
1040 if (!wcscmp( profile, dest )) return TRUE;
1042 return CopyFileW( profile, dest, TRUE );
1045 /******************************************************************************
1046 * IsColorProfileTagPresent [MSCMS.@]
1048 * Determine if a given ICC tag type is present in a color profile.
1050 * PARAMS
1051 * profile [I] Color profile handle.
1052 * tag [I] ICC tag type.
1053 * present [O] Pointer to a BOOL variable. Set to TRUE if tag type is present,
1054 * FALSE otherwise.
1056 * RETURNS
1057 * Success: TRUE
1058 * Failure: FALSE
1060 BOOL WINAPI IsColorProfileTagPresent( HPROFILE handle, TAGTYPE type, PBOOL present )
1062 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
1063 struct tag_entry tag;
1065 TRACE( "( %p, %#lx, %p )\n", handle, type, present );
1067 if (!profile) return FALSE;
1069 if (!present)
1071 release_object( &profile->hdr );
1072 return FALSE;
1074 *present = get_adjusted_tag( profile, type, &tag );
1075 release_object( &profile->hdr );
1076 return TRUE;
1079 /******************************************************************************
1080 * IsColorProfileValid [MSCMS.@]
1082 * Determine if a given color profile is valid.
1084 * PARAMS
1085 * profile [I] Color profile handle.
1086 * valid [O] Pointer to a BOOL variable. Set to TRUE if profile is valid,
1087 * FALSE otherwise.
1089 * RETURNS
1090 * Success: TRUE
1091 * Failure: FALSE
1093 BOOL WINAPI IsColorProfileValid( HPROFILE handle, PBOOL valid )
1095 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
1097 TRACE( "( %p, %p )\n", handle, valid );
1099 if (!profile) return FALSE;
1101 if (!valid)
1103 release_object( &profile->hdr );
1104 return FALSE;
1106 *valid = !!profile->data;
1107 release_object( &profile->hdr );
1108 return *valid;
1111 /******************************************************************************
1112 * SetColorProfileElement [MSCMS.@]
1114 * Set data for a specified tag type.
1116 * PARAMS
1117 * profile [I] Handle to a color profile.
1118 * type [I] ICC tag type.
1119 * offset [I] Offset in bytes to start copying to.
1120 * size [I/O] Size of the buffer in bytes. On return the variable holds the
1121 * number of bytes actually needed.
1122 * buffer [O] Buffer holding the tag data.
1124 * RETURNS
1125 * Success: TRUE
1126 * Failure: FALSE
1128 BOOL WINAPI SetColorProfileElement( HPROFILE handle, TAGTYPE type, DWORD offset, PDWORD size,
1129 PVOID buffer )
1131 BOOL ret;
1132 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
1134 TRACE( "( %p, %#lx, %lu, %p, %p )\n", handle, type, offset, size, buffer );
1136 if (!profile) return FALSE;
1138 if (!size || !buffer || !(profile->access & PROFILE_READWRITE))
1140 release_object( &profile->hdr );
1141 return FALSE;
1143 ret = set_tag_data( profile, type, offset, buffer, size );
1144 release_object( &profile->hdr );
1145 return ret;
1148 /******************************************************************************
1149 * SetColorProfileHeader [MSCMS.@]
1151 * Set header data for a given profile.
1153 * PARAMS
1154 * profile [I] Handle to a color profile.
1155 * header [I] Buffer holding the header data.
1157 * RETURNS
1158 * Success: TRUE
1159 * Failure: FALSE
1161 BOOL WINAPI SetColorProfileHeader( HPROFILE handle, PPROFILEHEADER header )
1163 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
1165 TRACE( "( %p, %p )\n", handle, header );
1167 if (!profile) return FALSE;
1169 if (!header || !(profile->access & PROFILE_READWRITE))
1171 release_object( &profile->hdr );
1172 return FALSE;
1174 set_profile_header( profile, header );
1175 release_object( &profile->hdr );
1176 return TRUE;
1179 /******************************************************************************
1180 * UninstallColorProfileA [MSCMS.@]
1182 * See UninstallColorProfileW.
1184 BOOL WINAPI UninstallColorProfileA( PCSTR machine, PCSTR profile, BOOL delete )
1186 UINT len;
1187 LPWSTR profileW;
1188 BOOL ret = FALSE;
1190 TRACE( "( %s, %x )\n", debugstr_a(profile), delete );
1192 if (machine || !profile) return FALSE;
1194 len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
1195 if ((profileW = malloc( len * sizeof(WCHAR) )))
1197 MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
1198 ret = UninstallColorProfileW( NULL, profileW , delete );
1199 free( profileW );
1201 return ret;
1204 /******************************************************************************
1205 * UninstallColorProfileW [MSCMS.@]
1207 * Uninstall a color profile.
1209 * PARAMS
1210 * machine [I] Name of the machine to uninstall the profile on. Must be NULL,
1211 * which indicates the local machine.
1212 * profile [I] Full path name of the profile to uninstall.
1213 * delete [I] Bool that specifies whether the profile file should be deleted.
1215 * RETURNS
1216 * Success: TRUE
1217 * Failure: FALSE
1219 BOOL WINAPI UninstallColorProfileW( PCWSTR machine, PCWSTR profile, BOOL delete )
1221 TRACE( "( %s, %x )\n", debugstr_w(profile), delete );
1223 if (machine || !profile) return FALSE;
1225 if (delete) return DeleteFileW( profile );
1226 return TRUE;
1229 static BOOL profile_AtoW( const PROFILE *in, PROFILE *out )
1231 int len;
1232 if (!in->pProfileData) return FALSE;
1233 len = MultiByteToWideChar( CP_ACP, 0, in->pProfileData, -1, NULL, 0 );
1234 if (!(out->pProfileData = malloc( len * sizeof(WCHAR) ))) return FALSE;
1235 out->cbDataSize = len * sizeof(WCHAR);
1236 MultiByteToWideChar( CP_ACP, 0, in->pProfileData, -1, out->pProfileData, len );
1237 out->dwType = in->dwType;
1238 return TRUE;
1241 /******************************************************************************
1242 * OpenColorProfileA [MSCMS.@]
1244 * See OpenColorProfileW.
1246 HPROFILE WINAPI OpenColorProfileA( PPROFILE profile, DWORD access, DWORD sharing, DWORD creation )
1248 HPROFILE handle = NULL;
1249 PROFILE profileW;
1251 TRACE( "( %p, %#lx, %#lx, %#lx )\n", profile, access, sharing, creation );
1253 if (!profile || !profile->pProfileData) return NULL;
1255 /* No AW conversion needed for memory based profiles */
1256 if (profile->dwType & PROFILE_MEMBUFFER)
1257 return OpenColorProfileW( profile, access, sharing, creation );
1259 if (!profile_AtoW( profile, &profileW )) return FALSE;
1260 handle = OpenColorProfileW( &profileW, access, sharing, creation );
1261 free( profileW.pProfileData );
1262 return handle;
1265 void close_profile( struct object *obj )
1267 struct profile *profile = (struct profile *)obj;
1269 if (profile->file != INVALID_HANDLE_VALUE)
1271 if (profile->access & PROFILE_READWRITE)
1273 DWORD count;
1274 if (SetFilePointer( profile->file, 0, NULL, FILE_BEGIN ) ||
1275 !WriteFile( profile->file, profile->data, profile->size, &count, NULL ) || count != profile->size)
1277 ERR( "Unable to write color profile\n" );
1280 CloseHandle( profile->file );
1283 if (profile->cmsprofile) cmsCloseProfile( profile->cmsprofile );
1284 free( profile->data );
1287 /******************************************************************************
1288 * OpenColorProfileW [MSCMS.@]
1290 * Open a color profile.
1292 * PARAMS
1293 * profile [I] Pointer to a color profile structure.
1294 * access [I] Desired access.
1295 * sharing [I] Sharing mode.
1296 * creation [I] Creation mode.
1298 * RETURNS
1299 * Success: Handle to the opened profile.
1300 * Failure: NULL
1302 * NOTES
1303 * Values for access: PROFILE_READ or PROFILE_READWRITE.
1304 * Values for sharing: 0 (no sharing), FILE_SHARE_READ and/or FILE_SHARE_WRITE.
1305 * Values for creation: one of CREATE_NEW, CREATE_ALWAYS, OPEN_EXISTING,
1306 * OPEN_ALWAYS, TRUNCATE_EXISTING.
1307 * Sharing and creation flags are ignored for memory based profiles.
1309 HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing, DWORD creation )
1311 struct profile *prof;
1312 HPROFILE ret;
1313 cmsHPROFILE cmsprofile;
1314 char *data = NULL;
1315 HANDLE handle = INVALID_HANDLE_VALUE;
1316 DWORD size;
1318 TRACE( "( %p, %#lx, %#lx, %#lx )\n", profile, access, sharing, creation );
1320 if (!profile || !profile->pProfileData) return NULL;
1322 if (profile->dwType == PROFILE_MEMBUFFER)
1324 /* FIXME: access flags not implemented for memory based profiles */
1326 if (!(data = malloc( profile->cbDataSize ))) return NULL;
1327 memcpy( data, profile->pProfileData, profile->cbDataSize );
1329 if (!(cmsprofile = cmsOpenProfileFromMem( data, profile->cbDataSize )))
1331 free( data );
1332 return FALSE;
1334 size = profile->cbDataSize;
1336 else if (profile->dwType == PROFILE_FILENAME)
1338 DWORD read, flags = 0;
1340 TRACE( "profile file: %s\n", debugstr_w( profile->pProfileData ) );
1342 if (access & PROFILE_READ) flags = GENERIC_READ;
1343 if (access & PROFILE_READWRITE) flags = GENERIC_READ|GENERIC_WRITE;
1345 if (!flags) return NULL;
1346 if (!sharing) sharing = FILE_SHARE_READ;
1348 if (!PathIsRelativeW( profile->pProfileData ))
1349 handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
1350 else
1352 WCHAR *path;
1354 if (!GetColorDirectoryW( NULL, NULL, &size ) && GetLastError() == ERROR_MORE_DATA)
1356 size += (lstrlenW( profile->pProfileData ) + 2) * sizeof(WCHAR);
1357 if (!(path = malloc( size ))) return NULL;
1358 GetColorDirectoryW( NULL, path, &size );
1359 PathAddBackslashW( path );
1360 lstrcatW( path, profile->pProfileData );
1362 else return NULL;
1363 handle = CreateFileW( path, flags, sharing, NULL, creation, 0, NULL );
1364 free( path );
1366 if (handle == INVALID_HANDLE_VALUE)
1368 WARN( "Unable to open color profile %lu\n", GetLastError() );
1369 return NULL;
1371 if ((size = GetFileSize( handle, NULL )) == INVALID_FILE_SIZE)
1373 ERR( "Unable to retrieve size of color profile\n" );
1374 CloseHandle( handle );
1375 return NULL;
1377 if (!(data = malloc( size )))
1379 ERR( "Unable to allocate memory for color profile\n" );
1380 CloseHandle( handle );
1381 return NULL;
1383 if (!ReadFile( handle, data, size, &read, NULL ) || read != size)
1385 ERR( "Unable to read color profile\n" );
1386 CloseHandle( handle );
1387 free( data );
1388 return NULL;
1390 if (!(cmsprofile = cmsOpenProfileFromMem( data, size )))
1392 CloseHandle( handle );
1393 free( data );
1394 return NULL;
1397 else
1399 ERR( "Invalid profile type %lu\n", profile->dwType );
1400 return NULL;
1403 if ((prof = calloc( 1, sizeof(*prof) )))
1405 prof->hdr.type = OBJECT_TYPE_PROFILE;
1406 prof->hdr.close = close_profile;
1407 prof->file = handle;
1408 prof->access = access;
1409 prof->data = data;
1410 prof->size = size;
1411 prof->cmsprofile = cmsprofile;
1412 if ((ret = alloc_handle( &prof->hdr ))) return ret;
1413 free( prof );
1416 cmsCloseProfile( cmsprofile );
1417 free( data );
1418 CloseHandle( handle );
1419 return NULL;
1422 /******************************************************************************
1423 * CloseColorProfile [MSCMS.@]
1425 * Close a color profile.
1427 * PARAMS
1428 * profile [I] Handle to the profile.
1430 * RETURNS
1431 * Success: TRUE
1432 * Failure: FALSE
1434 BOOL WINAPI CloseColorProfile( HPROFILE handle )
1436 struct profile *profile = (struct profile *)grab_object( handle, OBJECT_TYPE_PROFILE );
1438 TRACE( "( %p )\n", handle );
1440 if (!profile) return FALSE;
1441 free_handle( handle );
1442 release_object( &profile->hdr );
1443 return TRUE;
1446 /******************************************************************************
1447 * WcsGetUsePerUserProfiles [MSCMS.@]
1449 BOOL WINAPI WcsGetUsePerUserProfiles( const WCHAR* name, DWORD class, BOOL* use_per_user_profile )
1451 FIXME( "%s %s %p\n", debugstr_w(name), dbgstr_tag(class), use_per_user_profile );
1452 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
1453 return FALSE;
1456 /******************************************************************************
1457 * WcsEnumColorProfilesSize [MSCMS.@]
1459 BOOL WINAPI WcsEnumColorProfilesSize( WCS_PROFILE_MANAGEMENT_SCOPE scope, ENUMTYPEW *record, DWORD *size )
1461 FIXME( "%d %p %p\n", scope, record, size );
1462 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
1463 return FALSE;
1466 /******************************************************************************
1467 * WcsGetDefaultColorProfileSize [MSCMS.@]
1469 BOOL WINAPI WcsGetDefaultColorProfileSize( WCS_PROFILE_MANAGEMENT_SCOPE scope, PCWSTR device_name,
1470 COLORPROFILETYPE type, COLORPROFILESUBTYPE subtype,
1471 DWORD profile_id, PDWORD profile_size)
1473 FIXME( "%d, %s, %d, %d, %lu, %p\n", scope, debugstr_w(device_name), type, subtype, profile_id, profile_size );
1474 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
1475 return FALSE;
1478 /******************************************************************************
1479 * WcsGetDefaultRednderingIntent [MSCMS.@]
1481 BOOL WINAPI WcsGetDefaultRenderingIntent( WCS_PROFILE_MANAGEMENT_SCOPE scope, PDWORD intent)
1483 FIXME( "%d %p\n", scope, intent );
1484 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
1485 return FALSE;
1488 /******************************************************************************
1489 * WcsOpenColorProfileA [MSCMS.@]
1491 HPROFILE WINAPI WcsOpenColorProfileA( PROFILE *cdm, PROFILE *camp, PROFILE *gmmp, DWORD access, DWORD sharing,
1492 DWORD creation, DWORD flags )
1494 PROFILE cdmW, campW = {0}, gmmpW = {0};
1495 HPROFILE ret = NULL;
1497 TRACE( "%p, %p, %p, %#lx, %#lx, %#lx, %#lx\n", cdm, camp, gmmp, access, sharing, creation, flags );
1499 if (!cdm || !profile_AtoW( cdm, &cdmW )) return NULL;
1500 if (camp && !profile_AtoW( camp, &campW )) goto done;
1501 if (gmmp && !profile_AtoW( gmmp, &gmmpW )) goto done;
1503 ret = WcsOpenColorProfileW( &cdmW, &campW, &gmmpW, access, sharing, creation, flags );
1505 done:
1506 free( cdmW.pProfileData );
1507 free( campW.pProfileData );
1508 free( gmmpW.pProfileData );
1509 return ret;
1512 /******************************************************************************
1513 * WcsOpenColorProfileW [MSCMS.@]
1515 HPROFILE WINAPI WcsOpenColorProfileW( PROFILE *cdm, PROFILE *camp, PROFILE *gmmp, DWORD access, DWORD sharing,
1516 DWORD creation, DWORD flags )
1518 TRACE( "%p, %p, %p, %#lx, %#lx, %#lx, %#lx\n", cdm, camp, gmmp, access, sharing, creation, flags );
1519 FIXME("no support for WCS profiles\n" );
1521 return OpenColorProfileW( cdm, access, sharing, creation );