PrOfId.c revision 61b2299d
11ab64890Smrg/* $Xorg: PrOfId.c,v 1.3 2000/08/17 19:44:48 cpqbld Exp $ */ 21ab64890Smrg 31ab64890Smrg/* 41ab64890Smrg * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc. 51ab64890Smrg * All Rights Reserved 661b2299dSmrg * 71ab64890Smrg * This file is a component of an X Window System-specific implementation 81ab64890Smrg * of Xcms based on the TekColor Color Management System. Permission is 91ab64890Smrg * hereby granted to use, copy, modify, sell, and otherwise distribute this 101ab64890Smrg * software and its documentation for any purpose and without fee, provided 111ab64890Smrg * that this copyright, permission, and disclaimer notice is reproduced in 121ab64890Smrg * all copies of this software and in supporting documentation. TekColor 131ab64890Smrg * is a trademark of Tektronix, Inc. 1461b2299dSmrg * 151ab64890Smrg * Tektronix makes no representation about the suitability of this software 161ab64890Smrg * for any purpose. It is provided "as is" and with all faults. 1761b2299dSmrg * 181ab64890Smrg * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE, 191ab64890Smrg * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 201ab64890Smrg * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY 211ab64890Smrg * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 221ab64890Smrg * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF 231ab64890Smrg * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 241ab64890Smrg * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE. 251ab64890Smrg * 261ab64890Smrg * 271ab64890Smrg * NAME 281ab64890Smrg * XcmsPrOfId.c 291ab64890Smrg * 301ab64890Smrg * DESCRIPTION 311ab64890Smrg * Source for XcmsPrefixOfFormat() 321ab64890Smrg * 331ab64890Smrg * 341ab64890Smrg */ 351ab64890Smrg/* $XFree86$ */ 361ab64890Smrg 371ab64890Smrg#ifdef HAVE_CONFIG_H 381ab64890Smrg#include <config.h> 391ab64890Smrg#endif 401ab64890Smrg#include "Xlibint.h" 411ab64890Smrg#include "Xcmsint.h" 421ab64890Smrg#include "Cv.h" 431ab64890Smrg 441ab64890Smrg 451ab64890Smrg/* 461ab64890Smrg * NAME 471ab64890Smrg * XcmsPrefixOfId 481ab64890Smrg * 491ab64890Smrg * SYNOPSIS 501ab64890Smrg */ 511ab64890Smrgchar * 521ab64890SmrgXcmsPrefixOfFormat( 531ab64890Smrg XcmsColorFormat id) 541ab64890Smrg/* 551ab64890Smrg * DESCRIPTION 561ab64890Smrg * Returns the color space prefix for the specified color 571ab64890Smrg * space ID if the color space is found in the Color 581ab64890Smrg * Conversion Context. 591ab64890Smrg * 601ab64890Smrg * RETURNS 611ab64890Smrg * Returns a color space prefix. 621ab64890Smrg * 631ab64890Smrg * CAVEATS 641ab64890Smrg * Space is allocated for the returned string, therefore, 651ab64890Smrg * the application is responsible for freeing (using XFree) 661ab64890Smrg * the space. 671ab64890Smrg * 681ab64890Smrg */ 691ab64890Smrg{ 701ab64890Smrg XcmsColorSpace **papColorSpaces; 711ab64890Smrg char *prefix; 721ab64890Smrg 731ab64890Smrg /* 741ab64890Smrg * First try Device-Independent color spaces 751ab64890Smrg */ 761ab64890Smrg papColorSpaces = _XcmsDIColorSpaces; 771ab64890Smrg if (papColorSpaces != NULL) { 781ab64890Smrg while (*papColorSpaces != NULL) { 791ab64890Smrg if ((*papColorSpaces)->id == id) { 801ab64890Smrg prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) + 811ab64890Smrg 1) * sizeof(char)); 821ab64890Smrg strcpy(prefix, (*papColorSpaces)->prefix); 831ab64890Smrg return(prefix); 841ab64890Smrg } 851ab64890Smrg papColorSpaces++; 861ab64890Smrg } 871ab64890Smrg } 881ab64890Smrg 891ab64890Smrg /* 901ab64890Smrg * Next try Device-Dependent color spaces 911ab64890Smrg */ 921ab64890Smrg papColorSpaces = _XcmsDDColorSpaces; 931ab64890Smrg if (papColorSpaces != NULL) { 941ab64890Smrg while (*papColorSpaces != NULL) { 951ab64890Smrg if ((*papColorSpaces)->id == id) { 961ab64890Smrg prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) + 971ab64890Smrg 1) * sizeof(char)); 981ab64890Smrg strcpy(prefix, (*papColorSpaces)->prefix); 991ab64890Smrg return(prefix); 1001ab64890Smrg } 1011ab64890Smrg papColorSpaces++; 1021ab64890Smrg } 1031ab64890Smrg } 1041ab64890Smrg 1051ab64890Smrg return(NULL); 1061ab64890Smrg} 107