PrOfId.c revision 61b2299d
1/* $Xorg: PrOfId.c,v 1.3 2000/08/17 19:44:48 cpqbld Exp $ */ 2 3/* 4 * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc. 5 * All Rights Reserved 6 * 7 * This file is a component of an X Window System-specific implementation 8 * of Xcms based on the TekColor Color Management System. Permission is 9 * hereby granted to use, copy, modify, sell, and otherwise distribute this 10 * software and its documentation for any purpose and without fee, provided 11 * that this copyright, permission, and disclaimer notice is reproduced in 12 * all copies of this software and in supporting documentation. TekColor 13 * is a trademark of Tektronix, Inc. 14 * 15 * Tektronix makes no representation about the suitability of this software 16 * for any purpose. It is provided "as is" and with all faults. 17 * 18 * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE, 19 * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY 21 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 22 * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF 23 * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 24 * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE. 25 * 26 * 27 * NAME 28 * XcmsPrOfId.c 29 * 30 * DESCRIPTION 31 * Source for XcmsPrefixOfFormat() 32 * 33 * 34 */ 35/* $XFree86$ */ 36 37#ifdef HAVE_CONFIG_H 38#include <config.h> 39#endif 40#include "Xlibint.h" 41#include "Xcmsint.h" 42#include "Cv.h" 43 44 45/* 46 * NAME 47 * XcmsPrefixOfId 48 * 49 * SYNOPSIS 50 */ 51char * 52XcmsPrefixOfFormat( 53 XcmsColorFormat id) 54/* 55 * DESCRIPTION 56 * Returns the color space prefix for the specified color 57 * space ID if the color space is found in the Color 58 * Conversion Context. 59 * 60 * RETURNS 61 * Returns a color space prefix. 62 * 63 * CAVEATS 64 * Space is allocated for the returned string, therefore, 65 * the application is responsible for freeing (using XFree) 66 * the space. 67 * 68 */ 69{ 70 XcmsColorSpace **papColorSpaces; 71 char *prefix; 72 73 /* 74 * First try Device-Independent color spaces 75 */ 76 papColorSpaces = _XcmsDIColorSpaces; 77 if (papColorSpaces != NULL) { 78 while (*papColorSpaces != NULL) { 79 if ((*papColorSpaces)->id == id) { 80 prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) + 81 1) * sizeof(char)); 82 strcpy(prefix, (*papColorSpaces)->prefix); 83 return(prefix); 84 } 85 papColorSpaces++; 86 } 87 } 88 89 /* 90 * Next try Device-Dependent color spaces 91 */ 92 papColorSpaces = _XcmsDDColorSpaces; 93 if (papColorSpaces != NULL) { 94 while (*papColorSpaces != NULL) { 95 if ((*papColorSpaces)->id == id) { 96 prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) + 97 1) * sizeof(char)); 98 strcpy(prefix, (*papColorSpaces)->prefix); 99 return(prefix); 100 } 101 papColorSpaces++; 102 } 103 } 104 105 return(NULL); 106} 107