gdiplus: Get rid of no longer needed path and region fields.
[wine.git] / dlls / mscms / profile.c
blob6759a96305bea5f5078b9fdc2af011383e2d66a8
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 "config.h"
22 #include "wine/debug.h"
23 #include "wine/unicode.h"
25 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winnls.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "winreg.h"
33 #include "shlwapi.h"
34 #include "icm.h"
36 #include "mscms_priv.h"
38 static void basename( LPCWSTR path, LPWSTR name )
40 INT i = lstrlenW( path );
42 while (i > 0 && path[i - 1] != '\\' && path[i - 1] != '/') i--;
43 lstrcpyW( name, &path[i] );
46 static inline LPWSTR strdupW( LPCSTR str )
48 LPWSTR ret = NULL;
49 if (str)
51 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
52 if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
53 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
55 return ret;
58 const char *dbgstr_tag( DWORD tag )
60 return wine_dbg_sprintf( "'%c%c%c%c'",
61 (char)(tag >> 24), (char)(tag >> 16), (char)(tag >> 8), (char)(tag) );
64 WINE_DEFAULT_DEBUG_CHANNEL(mscms);
66 /******************************************************************************
67 * AssociateColorProfileWithDeviceA [MSCMS.@]
69 BOOL WINAPI AssociateColorProfileWithDeviceA( PCSTR machine, PCSTR profile, PCSTR device )
71 int len;
72 BOOL ret = FALSE;
73 WCHAR *profileW, *deviceW;
75 TRACE( "( %s, %s, %s )\n", debugstr_a(machine), debugstr_a(profile), debugstr_a(device) );
77 if (!profile || !device)
79 SetLastError( ERROR_INVALID_PARAMETER );
80 return FALSE;
82 if (machine)
84 SetLastError( ERROR_NOT_SUPPORTED );
85 return FALSE;
88 len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
89 if (!(profileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return FALSE;
91 MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
93 len = MultiByteToWideChar( CP_ACP, 0, device, -1, NULL, 0 );
94 if ((deviceW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
96 MultiByteToWideChar( CP_ACP, 0, device, -1, deviceW, len );
97 ret = AssociateColorProfileWithDeviceW( NULL, profileW, deviceW );
100 HeapFree( GetProcessHeap(), 0, profileW );
101 HeapFree( GetProcessHeap(), 0, deviceW );
102 return ret;
105 static BOOL set_profile_device_key( PCWSTR file, const BYTE *value, DWORD size )
107 static const WCHAR fmtW[] = {'%','c','%','c','%','c','%','c',0};
108 static const WCHAR icmW[] = {'S','o','f','t','w','a','r','e','\\',
109 'M','i','c','r','o','s','o','f','t','\\',
110 'W','i','n','d','o','w','s',' ','N','T','\\',
111 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
112 'I','C','M',0};
113 PROFILEHEADER header;
114 PROFILE profile;
115 HPROFILE handle;
116 HKEY icm_key, class_key;
117 WCHAR basenameW[MAX_PATH], classW[5];
119 profile.dwType = PROFILE_FILENAME;
120 profile.pProfileData = (PVOID)file;
121 profile.cbDataSize = (lstrlenW( file ) + 1) * sizeof(WCHAR);
123 /* FIXME is the profile installed? */
124 if (!(handle = OpenColorProfileW( &profile, PROFILE_READ, 0, OPEN_EXISTING )))
126 SetLastError( ERROR_INVALID_PROFILE );
127 return FALSE;
129 if (!GetColorProfileHeader( handle, &header ))
131 CloseColorProfile( handle );
132 SetLastError( ERROR_INVALID_PROFILE );
133 return FALSE;
135 RegCreateKeyExW( HKEY_LOCAL_MACHINE, icmW, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &icm_key, NULL );
137 basename( file, basenameW );
138 sprintfW( classW, fmtW, (header.phClass >> 24) & 0xff, (header.phClass >> 16) & 0xff,
139 (header.phClass >> 8) & 0xff, header.phClass & 0xff );
141 RegCreateKeyExW( icm_key, classW, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &class_key, NULL );
142 if (value) RegSetValueExW( class_key, basenameW, 0, REG_BINARY, value, size );
143 else RegDeleteValueW( class_key, basenameW );
145 RegCloseKey( class_key );
146 RegCloseKey( icm_key );
147 CloseColorProfile( handle );
148 return TRUE;
151 /******************************************************************************
152 * AssociateColorProfileWithDeviceW [MSCMS.@]
154 BOOL WINAPI AssociateColorProfileWithDeviceW( PCWSTR machine, PCWSTR profile, PCWSTR device )
156 static const BYTE dummy_value[12];
158 TRACE( "( %s, %s, %s )\n", debugstr_w(machine), debugstr_w(profile), debugstr_w(device) );
160 if (!profile || !device)
162 SetLastError( ERROR_INVALID_PARAMETER );
163 return FALSE;
165 if (machine)
167 SetLastError( ERROR_NOT_SUPPORTED );
168 return FALSE;
171 return set_profile_device_key( profile, dummy_value, sizeof(dummy_value) );
174 /******************************************************************************
175 * DisassociateColorProfileFromDeviceA [MSCMS.@]
177 BOOL WINAPI DisassociateColorProfileFromDeviceA( PCSTR machine, PCSTR profile, PCSTR device )
179 int len;
180 BOOL ret = FALSE;
181 WCHAR *profileW, *deviceW;
183 TRACE( "( %s, %s, %s )\n", debugstr_a(machine), debugstr_a(profile), debugstr_a(device) );
185 if (!profile || !device)
187 SetLastError( ERROR_INVALID_PARAMETER );
188 return FALSE;
190 if (machine)
192 SetLastError( ERROR_NOT_SUPPORTED );
193 return FALSE;
196 len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
197 if (!(profileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return FALSE;
199 MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
201 len = MultiByteToWideChar( CP_ACP, 0, device, -1, NULL, 0 );
202 if ((deviceW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
204 MultiByteToWideChar( CP_ACP, 0, device, -1, deviceW, len );
205 ret = DisassociateColorProfileFromDeviceW( NULL, profileW, deviceW );
208 HeapFree( GetProcessHeap(), 0, profileW );
209 HeapFree( GetProcessHeap(), 0, deviceW );
210 return ret;
213 /******************************************************************************
214 * DisassociateColorProfileFromDeviceW [MSCMS.@]
216 BOOL WINAPI DisassociateColorProfileFromDeviceW( PCWSTR machine, PCWSTR profile, PCWSTR device )
218 TRACE( "( %s, %s, %s )\n", debugstr_w(machine), debugstr_w(profile), debugstr_w(device) );
220 if (!profile || !device)
222 SetLastError( ERROR_INVALID_PARAMETER );
223 return FALSE;
225 if (machine)
227 SetLastError( ERROR_NOT_SUPPORTED );
228 return FALSE;
231 return set_profile_device_key( profile, NULL, 0 );
234 /******************************************************************************
235 * GetColorDirectoryA [MSCMS.@]
237 * See GetColorDirectoryW.
239 BOOL WINAPI GetColorDirectoryA( PCSTR machine, PSTR buffer, PDWORD size )
241 INT len;
242 LPWSTR bufferW;
243 BOOL ret = FALSE;
244 DWORD sizeW;
246 TRACE( "( %p, %p )\n", buffer, size );
248 if (machine || !size) return FALSE;
250 if (!buffer)
252 ret = GetColorDirectoryW( NULL, NULL, &sizeW );
253 *size = sizeW / sizeof(WCHAR);
254 return ret;
257 sizeW = *size * sizeof(WCHAR);
259 bufferW = HeapAlloc( GetProcessHeap(), 0, sizeW );
260 if (bufferW)
262 if ((ret = GetColorDirectoryW( NULL, bufferW, &sizeW )))
264 *size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
265 len = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, *size, NULL, NULL );
266 if (!len) ret = FALSE;
268 else *size = sizeW / sizeof(WCHAR);
270 HeapFree( GetProcessHeap(), 0, bufferW );
272 return ret;
275 /******************************************************************************
276 * GetColorDirectoryW [MSCMS.@]
278 * Get the directory where color profiles are stored.
280 * PARAMS
281 * machine [I] Name of the machine for which to get the color directory.
282 * Must be NULL, which indicates the local machine.
283 * buffer [I] Buffer to receive the path name.
284 * size [I/O] Size of the buffer in bytes. On return the variable holds
285 * the number of bytes actually needed.
287 BOOL WINAPI GetColorDirectoryW( PCWSTR machine, PWSTR buffer, PDWORD size )
289 WCHAR colordir[MAX_PATH];
290 static const WCHAR colorsubdir[] =
291 {'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\','c','o','l','o','r',0};
292 DWORD len;
294 TRACE( "( %p, %p )\n", buffer, size );
296 if (machine || !size) return FALSE;
298 GetSystemDirectoryW( colordir, sizeof(colordir) / sizeof(WCHAR) );
299 lstrcatW( colordir, colorsubdir );
301 len = lstrlenW( colordir ) * sizeof(WCHAR);
303 if (buffer && len <= *size)
305 lstrcpyW( buffer, colordir );
306 *size = len;
307 return TRUE;
310 SetLastError( ERROR_MORE_DATA );
311 *size = len;
312 return FALSE;
315 /******************************************************************************
316 * GetColorProfileElement [MSCMS.@]
318 * Retrieve data for a specified tag type.
320 * PARAMS
321 * profile [I] Handle to a color profile.
322 * type [I] ICC tag type.
323 * offset [I] Offset in bytes to start copying from.
324 * size [I/O] Size of the buffer in bytes. On return the variable holds
325 * the number of bytes actually needed.
326 * buffer [O] Buffer to receive the tag data.
327 * ref [O] Pointer to a BOOL that specifies whether more than one tag
328 * references the data.
330 * RETURNS
331 * Success: TRUE
332 * Failure: FALSE
334 BOOL WINAPI GetColorProfileElement( HPROFILE handle, TAGTYPE type, DWORD offset, PDWORD size,
335 PVOID buffer, PBOOL ref )
337 BOOL ret = FALSE;
338 #ifdef HAVE_LCMS2
339 struct profile *profile = grab_profile( handle );
341 TRACE( "( %p, 0x%08x, %d, %p, %p, %p )\n", handle, type, offset, size, buffer, ref );
343 if (!profile) return FALSE;
345 if (!size || !ref)
347 release_profile( profile );
348 return FALSE;
350 if (!get_tag_data( profile, type, offset, buffer, size ))
352 release_profile( profile );
353 return FALSE;
355 ret = get_tag_data( profile, type, offset, buffer, size );
356 *ref = cmsTagLinkedTo( profile->cmsprofile, type ) != 0;
357 release_profile( profile );
358 return ret;
360 #endif /* HAVE_LCMS2 */
361 return ret;
364 /******************************************************************************
365 * GetColorProfileElementTag [MSCMS.@]
367 * Get the tag type from a color profile by index.
369 * PARAMS
370 * profile [I] Handle to a color profile.
371 * index [I] Index into the tag table of the color profile.
372 * type [O] Pointer to a variable that holds the ICC tag type on return.
374 * RETURNS
375 * Success: TRUE
376 * Failure: FALSE
378 * NOTES
379 * The tag table index starts at 1.
380 * Use GetCountColorProfileElements to retrieve a count of tagged elements.
382 BOOL WINAPI GetColorProfileElementTag( HPROFILE handle, DWORD index, PTAGTYPE type )
384 BOOL ret = FALSE;
385 #ifdef HAVE_LCMS2
386 struct profile *profile = grab_profile( handle );
387 cmsInt32Number num_tags;
388 cmsTagSignature sig;
390 TRACE( "( %p, %d, %p )\n", handle, index, type );
392 if (!profile) return FALSE;
394 if (!type)
396 release_profile( profile );
397 return FALSE;
399 num_tags = cmsGetTagCount( profile->cmsprofile );
400 if (num_tags < 0 || index > num_tags || index < 1)
402 release_profile( profile );
403 return FALSE;
405 if ((sig = cmsGetTagSignature( profile->cmsprofile, index - 1 )))
407 *type = sig;
408 ret = TRUE;
410 release_profile( profile );
412 #endif /* HAVE_LCMS2 */
413 return ret;
416 /******************************************************************************
417 * GetColorProfileFromHandle [MSCMS.@]
419 * Retrieve an ICC color profile by handle.
421 * PARAMS
422 * profile [I] Handle to a color profile.
423 * buffer [O] Buffer to receive the ICC profile.
424 * size [I/O] Size of the buffer in bytes. On return the variable holds the
425 * number of bytes actually needed.
427 * RETURNS
428 * Success: TRUE
429 * Failure: FALSE
431 * NOTES
432 * The profile returned will be in big-endian format.
434 BOOL WINAPI GetColorProfileFromHandle( HPROFILE handle, PBYTE buffer, PDWORD size )
436 BOOL ret = FALSE;
437 #ifdef HAVE_LCMS2
438 struct profile *profile = grab_profile( handle );
439 PROFILEHEADER header;
441 TRACE( "( %p, %p, %p )\n", handle, buffer, size );
443 if (!profile) return FALSE;
445 if (!size)
447 release_profile( profile );
448 return FALSE;
450 get_profile_header( profile, &header );
452 if (!buffer || header.phSize > *size)
454 *size = header.phSize;
455 release_profile( profile );
456 return FALSE;
459 /* No endian conversion needed */
460 memcpy( buffer, profile->data, profile->size );
461 *size = profile->size;
463 release_profile( profile );
464 ret = TRUE;
466 #endif /* HAVE_LCMS2 */
467 return ret;
470 /******************************************************************************
471 * GetColorProfileHeader [MSCMS.@]
473 * Retrieve a color profile header by handle.
475 * PARAMS
476 * profile [I] Handle to a color profile.
477 * header [O] Buffer to receive the ICC profile header.
479 * RETURNS
480 * Success: TRUE
481 * Failure: FALSE
483 * NOTES
484 * The profile header returned will be adjusted for endianness.
486 BOOL WINAPI GetColorProfileHeader( HPROFILE handle, PPROFILEHEADER header )
488 #ifdef HAVE_LCMS2
489 struct profile *profile = grab_profile( handle );
491 TRACE( "( %p, %p )\n", handle, header );
493 if (!profile) return FALSE;
495 if (!header)
497 release_profile( profile );
498 return FALSE;
500 get_profile_header( profile, header );
501 release_profile( profile );
502 return TRUE;
504 #else
505 return FALSE;
506 #endif /* HAVE_LCMS2 */
509 /******************************************************************************
510 * GetCountColorProfileElements [MSCMS.@]
512 * Retrieve the number of elements in a color profile.
514 * PARAMS
515 * profile [I] Handle to a color profile.
516 * count [O] Pointer to a variable which is set to the number of elements
517 * in the color profile.
519 * RETURNS
520 * Success: TRUE
521 * Failure: FALSE
523 BOOL WINAPI GetCountColorProfileElements( HPROFILE handle, PDWORD count )
525 BOOL ret = FALSE;
526 #ifdef HAVE_LCMS2
527 struct profile *profile = grab_profile( handle );
528 cmsInt32Number num_tags;
530 TRACE( "( %p, %p )\n", handle, count );
532 if (!profile) return FALSE;
534 if (!count)
536 release_profile( profile );
537 return FALSE;
539 if ((num_tags = cmsGetTagCount( profile->cmsprofile )) >= 0)
541 *count = num_tags;
542 ret = TRUE;
544 release_profile( profile );
546 #endif /* HAVE_LCMS2 */
547 return ret;
550 /******************************************************************************
551 * GetStandardColorSpaceProfileA [MSCMS.@]
553 * See GetStandardColorSpaceProfileW.
555 BOOL WINAPI GetStandardColorSpaceProfileA( PCSTR machine, DWORD id, PSTR profile, PDWORD size )
557 INT len;
558 LPWSTR profileW;
559 BOOL ret = FALSE;
560 DWORD sizeW;
562 TRACE( "( 0x%08x, %p, %p )\n", id, profile, size );
564 if (machine)
566 SetLastError( ERROR_NOT_SUPPORTED );
567 return FALSE;
570 if (!size)
572 SetLastError( ERROR_INVALID_PARAMETER );
573 return FALSE;
576 sizeW = *size * sizeof(WCHAR);
578 if (!profile)
580 ret = GetStandardColorSpaceProfileW( NULL, id, NULL, &sizeW );
581 *size = sizeW / sizeof(WCHAR);
582 return ret;
585 profileW = HeapAlloc( GetProcessHeap(), 0, sizeW );
586 if (profileW)
588 if ((ret = GetStandardColorSpaceProfileW( NULL, id, profileW, &sizeW )))
590 *size = WideCharToMultiByte( CP_ACP, 0, profileW, -1, NULL, 0, NULL, NULL );
591 len = WideCharToMultiByte( CP_ACP, 0, profileW, -1, profile, *size, NULL, NULL );
592 if (!len) ret = FALSE;
594 else *size = sizeW / sizeof(WCHAR);
596 HeapFree( GetProcessHeap(), 0, profileW );
598 return ret;
601 /******************************************************************************
602 * GetStandardColorSpaceProfileW [MSCMS.@]
604 * Retrieve the profile filename for a given standard color space id.
606 * PARAMS
607 * machine [I] Name of the machine for which to get the standard color space.
608 * Must be NULL, which indicates the local machine.
609 * id [I] Id of a standard color space.
610 * profile [O] Buffer to receive the profile filename.
611 * size [I/O] Size of the filename buffer in bytes.
613 * RETURNS
614 * Success: TRUE
615 * Failure: FALSE
617 BOOL WINAPI GetStandardColorSpaceProfileW( PCWSTR machine, DWORD id, PWSTR profile, PDWORD size )
619 static const WCHAR rgbprofilefile[] =
620 { '\\','s','r','g','b',' ','c','o','l','o','r',' ',
621 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
622 WCHAR rgbprofile[MAX_PATH];
623 DWORD len = sizeof(rgbprofile);
625 TRACE( "( 0x%08x, %p, %p )\n", id, profile, size );
627 if (machine)
629 SetLastError( ERROR_NOT_SUPPORTED );
630 return FALSE;
633 if (!size)
635 SetLastError( ERROR_INVALID_PARAMETER );
636 return FALSE;
639 if (!profile)
641 SetLastError( ERROR_INSUFFICIENT_BUFFER );
642 return FALSE;
645 GetColorDirectoryW( machine, rgbprofile, &len );
647 switch (id)
649 case LCS_sRGB:
650 case LCS_WINDOWS_COLOR_SPACE: /* FIXME */
651 lstrcatW( rgbprofile, rgbprofilefile );
652 len = lstrlenW( rgbprofile ) * sizeof(WCHAR);
654 if (*size < len || !profile)
656 *size = len;
657 SetLastError( ERROR_MORE_DATA );
658 return FALSE;
661 lstrcpyW( profile, rgbprofile );
662 break;
664 default:
665 SetLastError( ERROR_FILE_NOT_FOUND );
666 return FALSE;
668 return TRUE;
671 static BOOL header_from_file( LPCWSTR file, PPROFILEHEADER header )
673 BOOL ret;
674 PROFILE profile;
675 WCHAR path[MAX_PATH], slash[] = {'\\',0};
676 DWORD size = sizeof(path);
677 HANDLE handle;
679 ret = GetColorDirectoryW( NULL, path, &size );
680 if (!ret)
682 WARN( "Can't retrieve color directory\n" );
683 return FALSE;
685 if (size + sizeof(slash) + sizeof(WCHAR) * lstrlenW( file ) > sizeof(path))
687 WARN( "Filename too long\n" );
688 return FALSE;
691 lstrcatW( path, slash );
692 lstrcatW( path, file );
694 profile.dwType = PROFILE_FILENAME;
695 profile.pProfileData = path;
696 profile.cbDataSize = lstrlenW( path ) + 1;
698 handle = OpenColorProfileW( &profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING );
699 if (!handle)
701 WARN( "Can't open color profile\n" );
702 return FALSE;
705 ret = GetColorProfileHeader( handle, header );
706 if (!ret)
707 WARN( "Can't retrieve color profile header\n" );
709 CloseColorProfile( handle );
710 return ret;
713 static BOOL match_profile( PENUMTYPEW rec, PPROFILEHEADER hdr )
715 if (rec->dwFields & ET_DEVICENAME)
717 FIXME( "ET_DEVICENAME: %s\n", debugstr_w(rec->pDeviceName) );
719 if (rec->dwFields & ET_MEDIATYPE)
721 FIXME( "ET_MEDIATYPE: 0x%08x\n", rec->dwMediaType );
723 if (rec->dwFields & ET_DITHERMODE)
725 FIXME( "ET_DITHERMODE: 0x%08x\n", rec->dwDitheringMode );
727 if (rec->dwFields & ET_RESOLUTION)
729 FIXME( "ET_RESOLUTION: 0x%08x, 0x%08x\n",
730 rec->dwResolution[0], rec->dwResolution[1] );
732 if (rec->dwFields & ET_DEVICECLASS)
734 FIXME( "ET_DEVICECLASS: %s\n", dbgstr_tag(rec->dwMediaType) );
736 if (rec->dwFields & ET_CMMTYPE)
738 TRACE( "ET_CMMTYPE: %s\n", dbgstr_tag(rec->dwCMMType) );
739 if (rec->dwCMMType != hdr->phCMMType) return FALSE;
741 if (rec->dwFields & ET_CLASS)
743 TRACE( "ET_CLASS: %s\n", dbgstr_tag(rec->dwClass) );
744 if (rec->dwClass != hdr->phClass) return FALSE;
746 if (rec->dwFields & ET_DATACOLORSPACE)
748 TRACE( "ET_DATACOLORSPACE: %s\n", dbgstr_tag(rec->dwDataColorSpace) );
749 if (rec->dwDataColorSpace != hdr->phDataColorSpace) return FALSE;
751 if (rec->dwFields & ET_CONNECTIONSPACE)
753 TRACE( "ET_CONNECTIONSPACE: %s\n", dbgstr_tag(rec->dwConnectionSpace) );
754 if (rec->dwConnectionSpace != hdr->phConnectionSpace) return FALSE;
756 if (rec->dwFields & ET_SIGNATURE)
758 TRACE( "ET_SIGNATURE: %s\n", dbgstr_tag(rec->dwSignature) );
759 if (rec->dwSignature != hdr->phSignature) return FALSE;
761 if (rec->dwFields & ET_PLATFORM)
763 TRACE( "ET_PLATFORM: %s\n", dbgstr_tag(rec->dwPlatform) );
764 if (rec->dwPlatform != hdr->phPlatform) return FALSE;
766 if (rec->dwFields & ET_PROFILEFLAGS)
768 TRACE( "ET_PROFILEFLAGS: 0x%08x\n", rec->dwProfileFlags );
769 if (rec->dwProfileFlags != hdr->phProfileFlags) return FALSE;
771 if (rec->dwFields & ET_MANUFACTURER)
773 TRACE( "ET_MANUFACTURER: %s\n", dbgstr_tag(rec->dwManufacturer) );
774 if (rec->dwManufacturer != hdr->phManufacturer) return FALSE;
776 if (rec->dwFields & ET_MODEL)
778 TRACE( "ET_MODEL: %s\n", dbgstr_tag(rec->dwModel) );
779 if (rec->dwModel != hdr->phModel) return FALSE;
781 if (rec->dwFields & ET_ATTRIBUTES)
783 TRACE( "ET_ATTRIBUTES: 0x%08x, 0x%08x\n",
784 rec->dwAttributes[0], rec->dwAttributes[1] );
785 if (rec->dwAttributes[0] != hdr->phAttributes[0] ||
786 rec->dwAttributes[1] != hdr->phAttributes[1]) return FALSE;
788 if (rec->dwFields & ET_RENDERINGINTENT)
790 TRACE( "ET_RENDERINGINTENT: 0x%08x\n", rec->dwRenderingIntent );
791 if (rec->dwRenderingIntent != hdr->phRenderingIntent) return FALSE;
793 if (rec->dwFields & ET_CREATOR)
795 TRACE( "ET_CREATOR: %s\n", dbgstr_tag(rec->dwCreator) );
796 if (rec->dwCreator != hdr->phCreator) return FALSE;
798 return TRUE;
801 /******************************************************************************
802 * EnumColorProfilesA [MSCMS.@]
804 * See EnumColorProfilesW.
806 BOOL WINAPI EnumColorProfilesA( PCSTR machine, PENUMTYPEA record, PBYTE buffer,
807 PDWORD size, PDWORD number )
809 BOOL match, ret = FALSE;
810 char spec[] = "\\*.icm";
811 char colordir[MAX_PATH], glob[MAX_PATH], **profiles = NULL;
812 DWORD i, len = sizeof(colordir), count = 0, totalsize = 0;
813 PROFILEHEADER header;
814 WIN32_FIND_DATAA data;
815 ENUMTYPEW recordW;
816 WCHAR *fileW = NULL, *deviceW = NULL;
817 HANDLE find;
819 TRACE( "( %p, %p, %p, %p, %p )\n", machine, record, buffer, size, number );
821 if (machine || !record || !size ||
822 record->dwSize != sizeof(ENUMTYPEA) ||
823 record->dwVersion != ENUM_TYPE_VERSION) return FALSE;
825 ret = GetColorDirectoryA( machine, colordir, &len );
826 if (!ret || len + sizeof(spec) > MAX_PATH)
828 WARN( "can't retrieve color directory\n" );
829 return FALSE;
832 lstrcpyA( glob, colordir );
833 lstrcatA( glob, spec );
835 find = FindFirstFileA( glob, &data );
836 if (find == INVALID_HANDLE_VALUE) return FALSE;
838 profiles = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(char *) + 1 );
839 if (!profiles) goto exit;
841 memcpy( &recordW, record, sizeof(ENUMTYPEA) );
842 if (record->pDeviceName)
844 deviceW = strdupW( record->pDeviceName );
845 if (!(recordW.pDeviceName = deviceW)) goto exit;
848 fileW = strdupW( data.cFileName );
849 if (!fileW) goto exit;
851 ret = header_from_file( fileW, &header );
852 if (ret)
854 match = match_profile( &recordW, &header );
855 if (match)
857 len = sizeof(char) * (lstrlenA( data.cFileName ) + 1);
858 profiles[count] = HeapAlloc( GetProcessHeap(), 0, len );
860 if (!profiles[count]) goto exit;
861 else
863 TRACE( "matching profile: %s\n", debugstr_a(data.cFileName) );
864 lstrcpyA( profiles[count], data.cFileName );
865 totalsize += len;
866 count++;
870 HeapFree( GetProcessHeap(), 0, fileW );
871 fileW = NULL;
873 while (FindNextFileA( find, &data ))
875 fileW = strdupW( data.cFileName );
876 if (!fileW) goto exit;
878 ret = header_from_file( fileW, &header );
879 if (!ret)
881 HeapFree( GetProcessHeap(), 0, fileW );
882 continue;
885 match = match_profile( &recordW, &header );
886 if (match)
888 char **tmp = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
889 profiles, sizeof(char *) * (count + 1) );
890 if (!tmp) goto exit;
891 else profiles = tmp;
893 len = sizeof(char) * (lstrlenA( data.cFileName ) + 1);
894 profiles[count] = HeapAlloc( GetProcessHeap(), 0, len );
896 if (!profiles[count]) goto exit;
897 else
899 TRACE( "matching profile: %s\n", debugstr_a(data.cFileName) );
900 lstrcpyA( profiles[count], data.cFileName );
901 totalsize += len;
902 count++;
905 HeapFree( GetProcessHeap(), 0, fileW );
906 fileW = NULL;
909 totalsize++;
910 if (buffer && *size >= totalsize)
912 char *p = (char *)buffer;
914 for (i = 0; i < count; i++)
916 lstrcpyA( p, profiles[i] );
917 p += lstrlenA( profiles[i] ) + 1;
919 *p = 0;
920 ret = TRUE;
922 else ret = FALSE;
924 *size = totalsize;
925 if (number) *number = count;
927 exit:
928 for (i = 0; i < count; i++)
929 HeapFree( GetProcessHeap(), 0, profiles[i] );
930 HeapFree( GetProcessHeap(), 0, profiles );
931 HeapFree( GetProcessHeap(), 0, deviceW );
932 HeapFree( GetProcessHeap(), 0, fileW );
933 FindClose( find );
935 return ret;
938 /******************************************************************************
939 * EnumColorProfilesW [MSCMS.@]
941 * Enumerate profiles that match given criteria.
943 * PARAMS
944 * machine [I] Name of the machine for which to enumerate profiles.
945 * Must be NULL, which indicates the local machine.
946 * record [I] Record of criteria that a profile must match.
947 * buffer [O] Buffer to receive a string array of profile filenames.
948 * size [I/O] Size of the filename buffer in bytes.
949 * number [O] Number of filenames copied into buffer.
951 * RETURNS
952 * Success: TRUE
953 * Failure: FALSE
955 BOOL WINAPI EnumColorProfilesW( PCWSTR machine, PENUMTYPEW record, PBYTE buffer,
956 PDWORD size, PDWORD number )
958 BOOL match, ret = FALSE;
959 WCHAR spec[] = {'\\','*','i','c','m',0};
960 WCHAR colordir[MAX_PATH], glob[MAX_PATH], **profiles = NULL;
961 DWORD i, len = sizeof(colordir), count = 0, totalsize = 0;
962 PROFILEHEADER header;
963 WIN32_FIND_DATAW data;
964 HANDLE find;
966 TRACE( "( %p, %p, %p, %p, %p )\n", machine, record, buffer, size, number );
968 if (machine || !record || !size ||
969 record->dwSize != sizeof(ENUMTYPEW) ||
970 record->dwVersion != ENUM_TYPE_VERSION) return FALSE;
972 ret = GetColorDirectoryW( machine, colordir, &len );
973 if (!ret || len + sizeof(spec) > MAX_PATH)
975 WARN( "Can't retrieve color directory\n" );
976 return FALSE;
979 lstrcpyW( glob, colordir );
980 lstrcatW( glob, spec );
982 find = FindFirstFileW( glob, &data );
983 if (find == INVALID_HANDLE_VALUE) return FALSE;
985 profiles = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR *) + 1 );
986 if (!profiles) goto exit;
988 ret = header_from_file( data.cFileName, &header );
989 if (ret)
991 match = match_profile( record, &header );
992 if (match)
994 len = sizeof(WCHAR) * (lstrlenW( data.cFileName ) + 1);
995 profiles[count] = HeapAlloc( GetProcessHeap(), 0, len );
997 if (!profiles[count]) goto exit;
998 else
1000 TRACE( "matching profile: %s\n", debugstr_w(data.cFileName) );
1001 lstrcpyW( profiles[count], data.cFileName );
1002 totalsize += len;
1003 count++;
1008 while (FindNextFileW( find, &data ))
1010 ret = header_from_file( data.cFileName, &header );
1011 if (!ret) continue;
1013 match = match_profile( record, &header );
1014 if (match)
1016 WCHAR **tmp = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
1017 profiles, sizeof(WCHAR *) * (count + 1) );
1018 if (!tmp) goto exit;
1019 else profiles = tmp;
1021 len = sizeof(WCHAR) * (lstrlenW( data.cFileName ) + 1);
1022 profiles[count] = HeapAlloc( GetProcessHeap(), 0, len );
1024 if (!profiles[count]) goto exit;
1025 else
1027 TRACE( "matching profile: %s\n", debugstr_w(data.cFileName) );
1028 lstrcpyW( profiles[count], data.cFileName );
1029 totalsize += len;
1030 count++;
1035 totalsize++;
1036 if (buffer && *size >= totalsize)
1038 WCHAR *p = (WCHAR *)buffer;
1040 for (i = 0; i < count; i++)
1042 lstrcpyW( p, profiles[i] );
1043 p += lstrlenW( profiles[i] ) + 1;
1045 *p = 0;
1046 ret = TRUE;
1048 else ret = FALSE;
1050 *size = totalsize;
1051 if (number) *number = count;
1053 exit:
1054 for (i = 0; i < count; i++)
1055 HeapFree( GetProcessHeap(), 0, profiles[i] );
1056 HeapFree( GetProcessHeap(), 0, profiles );
1057 FindClose( find );
1059 return ret;
1062 /******************************************************************************
1063 * InstallColorProfileA [MSCMS.@]
1065 * See InstallColorProfileW.
1067 BOOL WINAPI InstallColorProfileA( PCSTR machine, PCSTR profile )
1069 UINT len;
1070 LPWSTR profileW;
1071 BOOL ret = FALSE;
1073 TRACE( "( %s )\n", debugstr_a(profile) );
1075 if (machine || !profile) return FALSE;
1077 len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
1078 profileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1080 if (profileW)
1082 MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
1084 ret = InstallColorProfileW( NULL, profileW );
1085 HeapFree( GetProcessHeap(), 0, profileW );
1087 return ret;
1090 /******************************************************************************
1091 * InstallColorProfileW [MSCMS.@]
1093 * Install a color profile.
1095 * PARAMS
1096 * machine [I] Name of the machine to install the profile on. Must be NULL,
1097 * which indicates the local machine.
1098 * profile [I] Full path name of the profile to install.
1100 * RETURNS
1101 * Success: TRUE
1102 * Failure: FALSE
1104 BOOL WINAPI InstallColorProfileW( PCWSTR machine, PCWSTR profile )
1106 WCHAR dest[MAX_PATH], base[MAX_PATH];
1107 DWORD size = sizeof(dest);
1108 static const WCHAR slash[] = { '\\', 0 };
1110 TRACE( "( %s )\n", debugstr_w(profile) );
1112 if (machine || !profile) return FALSE;
1114 if (!GetColorDirectoryW( machine, dest, &size )) return FALSE;
1116 basename( profile, base );
1118 lstrcatW( dest, slash );
1119 lstrcatW( dest, base );
1121 /* Is source equal to destination? */
1122 if (!lstrcmpW( profile, dest )) return TRUE;
1124 return CopyFileW( profile, dest, TRUE );
1127 /******************************************************************************
1128 * IsColorProfileTagPresent [MSCMS.@]
1130 * Determine if a given ICC tag type is present in a color profile.
1132 * PARAMS
1133 * profile [I] Color profile handle.
1134 * tag [I] ICC tag type.
1135 * present [O] Pointer to a BOOL variable. Set to TRUE if tag type is present,
1136 * FALSE otherwise.
1138 * RETURNS
1139 * Success: TRUE
1140 * Failure: FALSE
1142 BOOL WINAPI IsColorProfileTagPresent( HPROFILE handle, TAGTYPE type, PBOOL present )
1144 BOOL ret = FALSE;
1145 #ifdef HAVE_LCMS2
1146 struct profile *profile = grab_profile( handle );
1148 TRACE( "( %p, 0x%08x, %p )\n", handle, type, present );
1150 if (!profile) return FALSE;
1152 if (!present)
1154 release_profile( profile );
1155 return FALSE;
1157 *present = cmsIsTag( profile->cmsprofile, type );
1158 release_profile( profile );
1159 ret = TRUE;
1161 #endif /* HAVE_LCMS2 */
1162 return ret;
1165 /******************************************************************************
1166 * IsColorProfileValid [MSCMS.@]
1168 * Determine if a given color profile is valid.
1170 * PARAMS
1171 * profile [I] Color profile handle.
1172 * valid [O] Pointer to a BOOL variable. Set to TRUE if profile is valid,
1173 * FALSE otherwise.
1175 * RETURNS
1176 * Success: TRUE
1177 * Failure: FALSE
1179 BOOL WINAPI IsColorProfileValid( HPROFILE handle, PBOOL valid )
1181 BOOL ret = FALSE;
1182 #ifdef HAVE_LCMS2
1183 struct profile *profile = grab_profile( handle );
1185 TRACE( "( %p, %p )\n", handle, valid );
1187 if (!profile) return FALSE;
1189 if (!valid)
1191 release_profile( profile );
1192 return FALSE;
1194 if (profile->data) ret = *valid = TRUE;
1195 release_profile( profile );
1197 #endif /* HAVE_LCMS2 */
1198 return ret;
1201 /******************************************************************************
1202 * SetColorProfileElement [MSCMS.@]
1204 * Set data for a specified tag type.
1206 * PARAMS
1207 * profile [I] Handle to a color profile.
1208 * type [I] ICC tag type.
1209 * offset [I] Offset in bytes to start copying to.
1210 * size [I/O] Size of the buffer in bytes. On return the variable holds the
1211 * number of bytes actually needed.
1212 * buffer [O] Buffer holding the tag data.
1214 * RETURNS
1215 * Success: TRUE
1216 * Failure: FALSE
1218 BOOL WINAPI SetColorProfileElement( HPROFILE handle, TAGTYPE type, DWORD offset, PDWORD size,
1219 PVOID buffer )
1221 BOOL ret = FALSE;
1222 #ifdef HAVE_LCMS2
1223 struct profile *profile = grab_profile( handle );
1225 TRACE( "( %p, 0x%08x, %d, %p, %p )\n", handle, type, offset, size, buffer );
1227 if (!profile) return FALSE;
1229 if (!size || !buffer || !(profile->access & PROFILE_READWRITE))
1231 release_profile( profile );
1232 return FALSE;
1234 ret = set_tag_data( profile, type, offset, buffer, size );
1235 release_profile( profile );
1236 return ret;
1238 #endif /* HAVE_LCMS2 */
1239 return ret;
1242 /******************************************************************************
1243 * SetColorProfileHeader [MSCMS.@]
1245 * Set header data for a given profile.
1247 * PARAMS
1248 * profile [I] Handle to a color profile.
1249 * header [I] Buffer holding the header data.
1251 * RETURNS
1252 * Success: TRUE
1253 * Failure: FALSE
1255 BOOL WINAPI SetColorProfileHeader( HPROFILE handle, PPROFILEHEADER header )
1257 #ifdef HAVE_LCMS2
1258 struct profile *profile = grab_profile( handle );
1260 TRACE( "( %p, %p )\n", handle, header );
1262 if (!profile) return FALSE;
1264 if (!header || !(profile->access & PROFILE_READWRITE))
1266 release_profile( profile );
1267 return FALSE;
1269 set_profile_header( profile, header );
1270 release_profile( profile );
1271 return TRUE;
1273 #else
1274 return FALSE;
1275 #endif /* HAVE_LCMS2 */
1278 /******************************************************************************
1279 * UninstallColorProfileA [MSCMS.@]
1281 * See UninstallColorProfileW.
1283 BOOL WINAPI UninstallColorProfileA( PCSTR machine, PCSTR profile, BOOL delete )
1285 UINT len;
1286 LPWSTR profileW;
1287 BOOL ret = FALSE;
1289 TRACE( "( %s, %x )\n", debugstr_a(profile), delete );
1291 if (machine || !profile) return FALSE;
1293 len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
1294 profileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1296 if (profileW)
1298 MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
1300 ret = UninstallColorProfileW( NULL, profileW , delete );
1302 HeapFree( GetProcessHeap(), 0, profileW );
1304 return ret;
1307 /******************************************************************************
1308 * UninstallColorProfileW [MSCMS.@]
1310 * Uninstall a color profile.
1312 * PARAMS
1313 * machine [I] Name of the machine to uninstall the profile on. Must be NULL,
1314 * which indicates the local machine.
1315 * profile [I] Full path name of the profile to uninstall.
1316 * delete [I] Bool that specifies whether the profile file should be deleted.
1318 * RETURNS
1319 * Success: TRUE
1320 * Failure: FALSE
1322 BOOL WINAPI UninstallColorProfileW( PCWSTR machine, PCWSTR profile, BOOL delete )
1324 TRACE( "( %s, %x )\n", debugstr_w(profile), delete );
1326 if (machine || !profile) return FALSE;
1328 if (delete) return DeleteFileW( profile );
1330 return TRUE;
1333 /******************************************************************************
1334 * OpenColorProfileA [MSCMS.@]
1336 * See OpenColorProfileW.
1338 HPROFILE WINAPI OpenColorProfileA( PPROFILE profile, DWORD access, DWORD sharing, DWORD creation )
1340 HPROFILE handle = NULL;
1342 TRACE( "( %p, 0x%08x, 0x%08x, 0x%08x )\n", profile, access, sharing, creation );
1344 if (!profile || !profile->pProfileData) return NULL;
1346 /* No AW conversion needed for memory based profiles */
1347 if (profile->dwType & PROFILE_MEMBUFFER)
1348 return OpenColorProfileW( profile, access, sharing, creation );
1350 if (profile->dwType & PROFILE_FILENAME)
1352 UINT len;
1353 PROFILE profileW;
1355 profileW.dwType = profile->dwType;
1357 len = MultiByteToWideChar( CP_ACP, 0, profile->pProfileData, -1, NULL, 0 );
1358 profileW.pProfileData = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1360 if (profileW.pProfileData)
1362 profileW.cbDataSize = len * sizeof(WCHAR);
1363 MultiByteToWideChar( CP_ACP, 0, profile->pProfileData, -1, profileW.pProfileData, len );
1365 handle = OpenColorProfileW( &profileW, access, sharing, creation );
1366 HeapFree( GetProcessHeap(), 0, profileW.pProfileData );
1369 return handle;
1372 /******************************************************************************
1373 * OpenColorProfileW [MSCMS.@]
1375 * Open a color profile.
1377 * PARAMS
1378 * profile [I] Pointer to a color profile structure.
1379 * access [I] Desired access.
1380 * sharing [I] Sharing mode.
1381 * creation [I] Creation mode.
1383 * RETURNS
1384 * Success: Handle to the opened profile.
1385 * Failure: NULL
1387 * NOTES
1388 * Values for access: PROFILE_READ or PROFILE_READWRITE.
1389 * Values for sharing: 0 (no sharing), FILE_SHARE_READ and/or FILE_SHARE_WRITE.
1390 * Values for creation: one of CREATE_NEW, CREATE_ALWAYS, OPEN_EXISTING,
1391 * OPEN_ALWAYS, TRUNCATE_EXISTING.
1392 * Sharing and creation flags are ignored for memory based profiles.
1394 HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing, DWORD creation )
1396 #ifdef HAVE_LCMS2
1397 cmsHPROFILE cmsprofile = NULL;
1398 char *data = NULL;
1399 HANDLE handle = INVALID_HANDLE_VALUE;
1400 DWORD size;
1402 TRACE( "( %p, 0x%08x, 0x%08x, 0x%08x )\n", profile, access, sharing, creation );
1404 if (!profile || !profile->pProfileData) return NULL;
1406 if (profile->dwType == PROFILE_MEMBUFFER)
1408 /* FIXME: access flags not implemented for memory based profiles */
1410 if (!(data = HeapAlloc( GetProcessHeap(), 0, profile->cbDataSize ))) return NULL;
1411 memcpy( data, profile->pProfileData, profile->cbDataSize );
1413 cmsprofile = cmsOpenProfileFromMem( data, profile->cbDataSize );
1414 size = profile->cbDataSize;
1416 else if (profile->dwType == PROFILE_FILENAME)
1418 DWORD read, flags = 0;
1420 TRACE( "profile file: %s\n", debugstr_w( profile->pProfileData ) );
1422 if (access & PROFILE_READ) flags = GENERIC_READ;
1423 if (access & PROFILE_READWRITE) flags = GENERIC_READ|GENERIC_WRITE;
1425 if (!flags) return NULL;
1426 if (!sharing) sharing = FILE_SHARE_READ;
1428 if (!PathIsRelativeW( profile->pProfileData ))
1429 handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
1430 else
1432 WCHAR *path;
1434 if (!GetColorDirectoryW( NULL, NULL, &size ) && GetLastError() == ERROR_MORE_DATA)
1436 size += (strlenW( profile->pProfileData ) + 2) * sizeof(WCHAR);
1437 if (!(path = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL;
1438 GetColorDirectoryW( NULL, path, &size );
1439 PathAddBackslashW( path );
1440 strcatW( path, profile->pProfileData );
1442 else return NULL;
1443 handle = CreateFileW( path, flags, sharing, NULL, creation, 0, NULL );
1444 HeapFree( GetProcessHeap(), 0, path );
1446 if (handle == INVALID_HANDLE_VALUE)
1448 WARN( "Unable to open color profile %u\n", GetLastError() );
1449 return NULL;
1451 if ((size = GetFileSize( handle, NULL )) == INVALID_FILE_SIZE)
1453 ERR( "Unable to retrieve size of color profile\n" );
1454 CloseHandle( handle );
1455 return NULL;
1457 if (!(data = HeapAlloc( GetProcessHeap(), 0, size )))
1459 ERR( "Unable to allocate memory for color profile\n" );
1460 CloseHandle( handle );
1461 return NULL;
1463 if (!ReadFile( handle, data, size, &read, NULL ) || read != size)
1465 ERR( "Unable to read color profile\n" );
1467 CloseHandle( handle );
1468 HeapFree( GetProcessHeap(), 0, data );
1469 return NULL;
1471 cmsprofile = cmsOpenProfileFromMem( data, size );
1473 else
1475 ERR( "Invalid profile type %u\n", profile->dwType );
1476 return NULL;
1479 if (cmsprofile)
1481 struct profile profile;
1482 HPROFILE hprof;
1484 profile.file = handle;
1485 profile.access = access;
1486 profile.data = data;
1487 profile.size = size;
1488 profile.cmsprofile = cmsprofile;
1490 if ((hprof = create_profile( &profile ))) return hprof;
1491 HeapFree( GetProcessHeap(), 0, data );
1492 cmsCloseProfile( cmsprofile );
1494 CloseHandle( handle );
1496 #endif /* HAVE_LCMS2 */
1497 return NULL;
1500 /******************************************************************************
1501 * CloseColorProfile [MSCMS.@]
1503 * Close a color profile.
1505 * PARAMS
1506 * profile [I] Handle to the profile.
1508 * RETURNS
1509 * Success: TRUE
1510 * Failure: FALSE
1512 BOOL WINAPI CloseColorProfile( HPROFILE profile )
1514 BOOL ret = FALSE;
1515 #ifdef HAVE_LCMS2
1517 TRACE( "( %p )\n", profile );
1518 ret = close_profile( profile );
1520 #endif /* HAVE_LCMS2 */
1521 return ret;