KCMS Application Developer's Guide

KcsSetAttribute()

KcsStatusId
 KcsSetAttribute(KcsProfileId profile,
         KcsAttributeName name,
         KcsAttributeValue *value)

Purpose

Use KcsSetAttribute() to create, to modify, or to delete a specific attribute in a profile. See Chapter 5, KCMS Profile Attributes for details on attributes.


Note -

KcsSetAttribute() cannot be used to modify the value of the icSigProfileSequenceDescriptionTag attribute. The attribute is read only.


Arguments

Table 4-23 KcsSetAttribute() Arguments

Argument  

Description  

profile

The identifier of the profile.  

name

The name of the attribute to be created, modified, or deleted. If this attribute is already used in the profile, this function overwrites its value. If this attribute does not already exist, the function creates it. See "List of All Attributes" for the names of all the attributes KCMS allows your application to specify in a call to this function.

value

A pointer to the value for the attribute. If the attribute already exists, value becomes the attribute's new value. If the attribute does not already exist, this function creates it and sets its original value to value. To delete an existing attribute, set value to NULL.


Note -

For this function to execute correctly, your application must check what needs to be set in the KcsAttributeBase structure (part of the KcsAttributeValue structure). A valid type and number of tokens found in the attribute must be set.


Returns

Table 4-24 KcsConnectProfiles() Return Strings

KCS_SUCCESS

KCS_MEM_ALLOC_ERROR

KCS_PROF_ID_BAD

KCS_ATTR_NAME_OUT_OF_RANGE

KCS_ATTR_TYPE_UNKNOWN

KCS_ATTR_NEG_CT_SUPPLIED

KCS_ATTR_LARGE_CT_SUPPLIED

Example


Example 4-11 KcsSetAttribute()

#include "kcms_utils.h"
 #define SAMPLE_WORDS "A profile created using kcms_create"

 KcsProfileId                    profileid;
 KcsStatusId                    status;
 KcsAttributeValue                    attrValue;
 KcsAttributeValue                    *attrValue2;
 KcsAttributeValue                    *attrValuePtr;
 KcsErrDesc                    errDesc;
 int                    sizemeas, size, nvalues, i, j;
 time_t                    clocktime;
 struct tm                    *datetime;
 size_t                    rc;
 char                    *description;
 char                    attr[256];
 double                    test_double[3];

 /* Fill out the measurement structures - The illuminant must be D50 */
 test_double[0] = 0.9642;
 test_double[1] = 1.0;
 test_double[2] = 0.8249;

 /*  open or create a profile, then set some attributes */
 if ((description = (char *)malloc(strlen(SAMPLE_WORDS) + 1)) == NULL) {
     perror("malloc failed : ");
     KcsFreeProfile(profileid);
     exit(1);
 }
 memset(description, 0, strlen(SAMPLE_WORDS) + 1);
 strcpy(description, SAMPLE_WORDS);
 /* the function used below can be found in kcms_utils.c in appendix */
 if ((attrValue2 = string2icTextAttrValue(description)) == NULL) {
     fprintf(stderr, "conversion to AttrValue failed \n");
     KcsFreeProfile(profileid);
     exit(1);
 }
 if (KcsSetAttribute(profileid, icSigProfileDescriptionTag, attrValue2)
     != KCS_SUCCESS) {
     KcsGetLastError(&errDesc);
     printf("Set Attribute error: %s\n", errDesc.desc);
     exit(1);
 }
 free(attrValue2);
 free(description);
 size = sizeof(KcsAttributeBase) + sizeof(icHeader);
 attrValuePtr = (KcsAttributeValue *)malloc(size);

 /* Build the header */
 attrValuePtr->base.type = icSigHeaderType;
 attrValuePtr->base.sizeOfType = sizeof(icHeader);
 attrValuePtr->base.countSupplied = 1;
 KcsGetAttribute(profileid, icSigHeaderTag, attrValuePtr);
 attrValuePtr->val.icHeader.size = 0;

 /* The following three values do not have to be set if you do a
  * GetAttribute on the header, since the Create should set them for you.
  * If you do not do a GetAttribute of the header, you must set these:
  *   attrValuePtr->val.icHeader.cmmId = 0x4b434d53;
  *   attrValuePtr->val.icHeader.version =icVersionNumber;
  *   attrValuePtr->val.icHeader.magic = icMagicNumber;
 */
 attrValuePtr->val.icHeader.deviceClass = icSigDisplayClass;
 attrValuePtr->val.icHeader.colorSpace = icSigRgbData;
 attrValuePtr->val.icHeader.pcs = icSigXYZData;

 /* Get the time from the system */
 clocktime = time(NULL);
 datetime = localtime(&clocktime);

 attrValuePtr->val.icHeader.date.seconds =
         (icUInt16Number)datetime->tm_sec;
 attrValuePtr->val.icHeader.date.minutes =
         (icUInt16Number)datetime->tm_min;
 attrValuePtr->val.icHeader.date.hours =
         (icUInt16Number)datetime->tm_hour;
 attrValuePtr->val.icHeader.date.day =
         (icUInt16Number)datetime->tm_mday;
 attrValuePtr->val.icHeader.date.month =
         (icUInt16Number)datetime->tm_mon + 1;
 attrValuePtr->val.icHeader.date.year =
         (icUInt16Number)datetime->tm_year;
 attrValuePtr->val.icHeader.platform = icSigSolaris;
 attrValuePtr->val.icHeader.flags =
         icEmbeddedProfileFalse || icUseAnywhere;
 strcpy(description,"SUNW ");
 memcpy(&attrValuePtr->val.icHeader.manufacturer, description, 4);
 attrValuePtr->val.icHeader.model = 0;
 attrValuePtr->val.icHeader.attributes[0] = 0;
 attrValuePtr->val.icHeader.attributes[1] = 0;
 attrValuePtr->val.icHeader.renderingIntent = icPerceptual;
 attrValuePtr->val.icHeader.illuminant.X =
         double2icfixed(test_double[0], icSigS15Fixed16ArrayType);
 attrValuePtr->val.icHeader.illuminant.Y =
         double2icfixed(test_double[1], icSigS15Fixed16ArrayType);
 attrValuePtr->val.icHeader.illuminant.Z =
         double2icfixed(test_double[2], icSigS15Fixed16ArrayType);
 rc = KcsSetAttribute(profileid, icSigHeaderTag, attrValuePtr);
 if(rc != KCS_SUCCESS) {
     rc =KcsGetLastError(&errDesc);
     fprintf(stderr, "unable to set header: %s\n", errDesc.desc);
     KcsFreeProfile(profileid);
     return(-1)