/*************************************************************************** * FUNCTION NAME * SpProfileCreateMLSeqRecord * * DESCRIPTION * This function creates the Profile Sequence record for the * profile pointed to by pProfile. The Profile Sequence record to * build is pointed to by pSeqRecord. * ***************************************************************************/ SpStatus_t SpProfileCreateMLSeqRecord(SpProfile_t pProfile, SpProfileSeqDescRecord2_t *pSeqRecord) { SpHeader_t header; SpTagValue_t tagValue; SpStatus_t spStatus; KpChar_p CString; KpInt32_t BufSize; /* Get the profiles header */ spStatus = SpProfileGetHeader (pProfile, &header); if (SpStatSuccess != spStatus) { return spStatus; } /* Copy the manufacturer, model, attributes and technology fields into the sequence record */ pSeqRecord->DeviceManufacturer = header.DeviceManufacturer; pSeqRecord->DeviceModel = header.DeviceModel; pSeqRecord->DeviceAttributes.hi = header.DeviceAttributes.hi; pSeqRecord->DeviceAttributes.lo = header.DeviceAttributes.lo; /* Get the technology tag*/ spStatus = SpTagGetById(pProfile, SpTagTechnology, &tagValue); if (SpStatSuccess != spStatus) pSeqRecord->Technology = SpSigNone; else { pSeqRecord->Technology = tagValue.Data.Signature; SpTagFree(&tagValue); } /* Get the manufacturer description */ spStatus = SpTagGetById(pProfile, SpTagDeviceMfgDesc, &tagValue); if (SpStatSuccess != spStatus) { spStatus = SpStringToMultiLang("", SpEnglish, SpUSA, &tagValue.Data.MultiLang); if (SpStatSuccess != spStatus) { return spStatus; } } else if (tagValue.TagType == Sp_AT_TextDesc) { BufSize = strlen(tagValue.Data.TextDesc.IsoStr) + 1; CString = (char *) allocBufferPtr (BufSize); spStatus = SpTagGetString(&tagValue, &BufSize, CString); SpTagFree(&tagValue); spStatus = SpStringToMultiLang(CString, SpEnglish, SpUSA, &tagValue.Data.MultiLang); freeBufferPtr(CString); if (SpStatSuccess != spStatus) return spStatus; } pSeqRecord->DeviceManufacturerDesc.TagType = SpTypeMultiLanguage; pSeqRecord->DeviceManufacturerDesc.Reserved = 0; pSeqRecord->DeviceManufacturerDesc.MLDesc = tagValue.Data.MultiLang; /* Get the model description */ spStatus = SpTagGetById(pProfile, SpTagDeviceModelDesc, &tagValue); if (SpStatSuccess != spStatus) { spStatus = SpStringToMultiLang("", SpEnglish, SpUSA, &tagValue.Data.MultiLang); if (SpStatSuccess != spStatus) { return spStatus; } } else if (tagValue.TagType == Sp_AT_TextDesc) { BufSize = strlen(tagValue.Data.TextDesc.IsoStr) + 1; CString = (char *) allocBufferPtr (BufSize+1); spStatus = SpTagGetString(&tagValue, &BufSize, CString); SpTagFree(&tagValue); spStatus = SpStringToMultiLang(CString, SpEnglish, SpUSA, &tagValue.Data.MultiLang); freeBufferPtr(CString); if (SpStatSuccess != spStatus) return spStatus; } pSeqRecord->DeviceModelDesc.TagType = SpTypeMultiLanguage; pSeqRecord->DeviceModelDesc.Reserved = 0; pSeqRecord->DeviceModelDesc.MLDesc = tagValue.Data.MultiLang; return SpStatSuccess; } /* SpProfileCreateMLSeqRecord */
/*************************************************************************** * FUNCTION NAME * SpProfileSetLinkDesc * * DESCRIPTION * This function creates the Profile Description tag for the * device link profile pointed to by pProfile. The information needed * to form the description string is contained in the SpDevLinkPB * structure pointed to by pDevLinkDesc. The description string * is formed by taking the manufacture, model and device color space * from the first profile in the profile list and taking the * manufacturer, model and connection color space from the last profile * in the list. * ***************************************************************************/ SpStatus_t SpProfileSetLinkDesc(SpProfile_t pProfile, SpDevLinkPB_p pDevLinkDesc) { KpTChar_t manufacturer1[SpMaxTextDesc], model1[SpMaxTextDesc]; KpTChar_t manufacturer2[SpMaxTextDesc], model2[SpMaxTextDesc]; KpTChar_p pDescStr; KpInt32_t length; SpProfListEntry_p pCurProfEntry; SpTagValue_t tagValue; SpStatus_t spStatus; /* Get the manufacturer information from the first profile */ pCurProfEntry = pDevLinkDesc->pProfileList; strcpy (manufacturer1, "Unknown"); spStatus = SpTagGetById(pCurProfEntry->profile, SpTagDeviceMfgDesc, &tagValue); if (SpStatSuccess == spStatus) { length = sizeof (manufacturer1); SpTagGetString(&tagValue, &length, manufacturer1); SpTagFree(&tagValue); } /* Get the model information from the first profile */ strcpy(model1, "Unknown"); spStatus = SpTagGetById(pCurProfEntry->profile, SpTagDeviceModelDesc, &tagValue); if (SpStatSuccess == spStatus) { length = sizeof (model1); SpTagGetString(&tagValue, &length, model1); SpTagFree(&tagValue); } /* Get the manufacturer information from the last profile */ pCurProfEntry = pDevLinkDesc->pProfileList + (pDevLinkDesc->numProfiles - 1); strcpy(manufacturer2, "Unknown"); spStatus = SpTagGetById(pCurProfEntry->profile, SpTagDeviceMfgDesc, &tagValue); if (SpStatSuccess == spStatus) { length = sizeof (manufacturer2); SpTagGetString(&tagValue, &length, manufacturer2); SpTagFree(&tagValue); } /* Get the model information from the last profile */ strcpy(model2, "Unknown"); spStatus = SpTagGetById(pCurProfEntry->profile, SpTagDeviceModelDesc, &tagValue); if (SpStatSuccess == spStatus) { length = sizeof (model2); SpTagGetString(&tagValue, &length, model2); SpTagFree(&tagValue); } /* Allocate memory for the description string */ length = strlen(manufacturer1) + strlen(model1) + strlen(manufacturer2) + strlen(model2) + 7; pDescStr = (KpTChar_p)allocBufferPtr(length+1); if (NULL == pDescStr) { return SpStatMemory; } /* Form the description string */ /* sprintf(pDescStr, "%s %s %s to %s %s %s", manufacturer1, model1, colorSpace1, manufacturer2, model2, colorSpace2); */ strcpy(pDescStr, manufacturer1); strcat(pDescStr, " "); strcat(pDescStr, model1); strcat(pDescStr, " to "); strcat(pDescStr, manufacturer2); strcat(pDescStr, " "); strcat(pDescStr, model2); /* Convert the string to a text description tag and add it to the profile */ spStatus = SpStringToTextDesc(pDescStr, &tagValue.Data.TextDesc); freeBufferPtr(pDescStr); if (SpStatSuccess != spStatus) { return spStatus; } tagValue.TagId = SpTagProfileDesc; tagValue.TagType = Sp_AT_TextDesc; spStatus = SpTagSet (pProfile, &tagValue); SpFreeTextDesc (&tagValue.Data.TextDesc); return spStatus; } /* SpProfileSetLinkDesc */
/*-------------------------------------------------------------------- * DESCRIPTION * Test profile with header and or tag search criteria and report status * * AUTHOR * Sakey * * DATE CREATED * July, 2002 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpProfileCheckEx( SpSearch_p SearchValue, char *Filename, SpFileProps_t *Props) { SpStatus_t status; SpHeader_t Header; SpTagValue_t tagValue; KpInt32_t Passed[SPSEARCH_LIST]; KpInt32_t Tested[SPSEARCH_LIST]; KpInt32_t i, j, critSize; SpSearchCriterion_t *criterion; #define TAGID_LIST 5 SpTagId_t TagIdsPassed[TAGID_LIST]; SpTagId_t TagIdsTested[TAGID_LIST]; SpTagId_t *pTagIdsPassed = TagIdsPassed; SpTagId_t *pTagIdsTested = TagIdsTested; KpInt32_t TagCount = 0; if (NULL == SearchValue) return SpStatIncompatibleArguments; critSize = SearchValue->critSize; criterion = SearchValue->criterion; status = SpProfileLoadHeader (Filename, Props, &Header); if (SpStatSuccess != status) return status; for (i = 0; i < SPSEARCH_LIST; i++) { /* preset all entries in PassedEvalArray to Not Tested and failed . */ Passed[i] = 0; Tested[i] = 0; } /* count up the number of tag checks requested. */ for (i = 0; i < SearchValue->critCount; i++) { if ((SPSEARCH_ENUMTAGVALUE_EQUAL == criterion->SearchElement) || (SPSEARCH_ENUMTAGVALUE_NOTEQUAL == criterion->SearchElement)) TagCount++; criterion = (SpSearchCriterion_t *)(critSize + (KpUInt8_p)criterion); } criterion = SearchValue->criterion; if (TAGID_LIST < TagCount) { /* allocate the tested/passed arrays */ pTagIdsTested = allocBufferPtr( TagCount * sizeof(SpTagId_t)); if (NULL == pTagIdsTested) return SpStatMemory; pTagIdsPassed = allocBufferPtr( TagCount * sizeof(SpTagId_t)); if (NULL == pTagIdsPassed) return SpStatMemory; } /* preset all entries in Tag PassedEvalArrays to Not Tested and failed . */ for (i = 0; i < TagCount; i++) { pTagIdsTested[i] = 0; pTagIdsPassed[i] = 0; } /* Loop thru the parameters, test the value based upon the Field * Set that it Passed if it did. Set that it was tested always */ for (i = 0; i < SearchValue->critCount; i++) { switch (criterion->SearchElement) { case SPSEARCH_PREFERREDCMM : if (criterion->SearchValue.Signature == (KpInt32_t) Header.CMMType) Passed[SPSEARCH_PREFERREDCMM] = 1; Tested[SPSEARCH_PREFERREDCMM] = 1; break; case SPSEARCH_VERSION : if (criterion->SearchValue.Value == Header.ProfileVersion) Passed[SPSEARCH_VERSION] = 1; Tested[SPSEARCH_VERSION] = 1; break; case SPSEARCH_PROFILECLASS : if (criterion->SearchValue.Signature == Header.DeviceClass) Passed[SPSEARCH_PROFILECLASS] = 1; Tested[SPSEARCH_PROFILECLASS] = 1; break; case SPSEARCH_DEVICECOLORSPACE : if (criterion->SearchValue.Signature == Header.DataColorSpace) Passed[SPSEARCH_DEVICECOLORSPACE] = 1; Tested[SPSEARCH_DEVICECOLORSPACE] = 1; break; case SPSEARCH_CONNECTIONSPACE : if (criterion->SearchValue.Signature == Header.InterchangeColorSpace) Passed[SPSEARCH_CONNECTIONSPACE] = 1; Tested[SPSEARCH_CONNECTIONSPACE] = 1; break; /* Only use ONDATE value for all date testing since more * than one value can be given for an attribute */ case SPSEARCH_BEFOREDATE : if (BEFORE == TestHeaderDate( &Header.DateTime, &criterion->SearchValue.Date)) Passed[SPSEARCH_ONDATE] = 1; Tested[SPSEARCH_ONDATE] = 1; break; case SPSEARCH_ONDATE : if (SAME == TestHeaderDate( &Header.DateTime, &criterion->SearchValue.Date)) Passed[SPSEARCH_ONDATE] = 1; Tested[SPSEARCH_ONDATE] = 1; break; case SPSEARCH_AFTERDATE : if (AFTER == TestHeaderDate( &Header.DateTime, &criterion->SearchValue.Date)) Passed[SPSEARCH_ONDATE] = 1; Tested[SPSEARCH_ONDATE] = 1; break; case SPSEARCH_PLATFORM : if (criterion->SearchValue.Signature == Header.Platform) Passed[SPSEARCH_PLATFORM] = 1; Tested[SPSEARCH_PLATFORM] = 1; break; case SPSEARCH_PROFILEFLAGS : if (criterion->SearchValue.Value == Header.Flags) Passed[SPSEARCH_PROFILEFLAGS] = 1; Tested[SPSEARCH_PROFILEFLAGS] = 1; break; case SPSEARCH_DEVICEMFG : if (criterion->SearchValue.Signature == Header.DeviceManufacturer) Passed[SPSEARCH_DEVICEMFG] = 1; Tested[SPSEARCH_DEVICEMFG] = 1; break; case SPSEARCH_DEVICEMODEL : if (criterion->SearchValue.Signature == Header.DeviceModel) Passed[SPSEARCH_DEVICEMODEL] = 1; Tested[SPSEARCH_DEVICEMODEL] = 1; break; case SPSEARCH_DEVICEATTRIBUTESHI : if (criterion->SearchValue.Value == Header.DeviceAttributes.hi) Passed[SPSEARCH_DEVICEATTRIBUTESHI] = 1; Tested[SPSEARCH_DEVICEATTRIBUTESHI] = 1; break; case SPSEARCH_DEVICEATTRIBUTESLO : if (criterion->SearchValue.Value == Header.DeviceAttributes.lo) Passed[SPSEARCH_DEVICEATTRIBUTESLO] = 1; Tested[SPSEARCH_DEVICEATTRIBUTESLO] = 1; break; case SPSEARCH_RENDERINGINTENT : if (criterion->SearchValue.Signature == (KpInt32_t) Header.RenderingIntent) Passed[SPSEARCH_RENDERINGINTENT] = 1; Tested[SPSEARCH_RENDERINGINTENT] = 1; break; case SPSEARCH_ILLUMINANT : if ((criterion->SearchValue.XYZ.X == Header.Illuminant.X) && (criterion->SearchValue.XYZ.Y == Header.Illuminant.Y) && (criterion->SearchValue.XYZ.Z == Header.Illuminant.Z)) Passed[SPSEARCH_ILLUMINANT] = 1; Tested[SPSEARCH_ILLUMINANT] = 1; break; case SPSEARCH_ORIGINATOR : if (criterion->SearchValue.Signature == Header.Originator) Passed[SPSEARCH_ORIGINATOR] = 1; Tested[SPSEARCH_ORIGINATOR] = 1; break; case SPSEARCH_PROFILEID : if ((criterion->SearchValue.ProfileID.a == Header.ProfileID.a) && (criterion->SearchValue.ProfileID.b == Header.ProfileID.b) && (criterion->SearchValue.ProfileID.c == Header.ProfileID.c) && (criterion->SearchValue.ProfileID.d == Header.ProfileID.d)) Passed[SPSEARCH_ORIGINATOR] = 1; Tested[SPSEARCH_ORIGINATOR] = 1; break; case SPSEARCH_ENUMTAGVALUE_EQUAL : case SPSEARCH_ENUMTAGVALUE_NOTEQUAL : /* find the matching tag ID or the first unused one */ for(j = 0; j < TagCount; j++) { if ((pTagIdsTested[j] == criterion->SearchValue.Tag.TagId) || (0 == pTagIdsTested[j])) { /* mark this tag as tested */ pTagIdsTested[j] = criterion->SearchValue.Tag.TagId; break; } } /* load the tag */ status = SpProfileLoadTag(Filename, Props, criterion->SearchValue.Tag.TagId, &tagValue); if (SPSEARCH_ENUMTAGVALUE_EQUAL == criterion->SearchElement) { if ((SpStatSuccess == status) && (criterion->SearchValue.Tag.TagEnum == tagValue.Data.TagEnum)) { pTagIdsPassed[j] = pTagIdsTested[j]; } } else { if ((SpStatSuccess != status) || (criterion->SearchValue.Tag.TagEnum != tagValue.Data.TagEnum)) { pTagIdsPassed[j] = pTagIdsTested[j]; } } if (SpStatSuccess == status) { /* free allocated resources */ SpTagFree(&tagValue); } break; case SPSEARCH_TIMEORDER: default: /* No special processing */ break; } criterion = (SpSearchCriterion_t *)(critSize + (KpUInt8_p)criterion); } /* assume success */ status = SpStatSuccess; /* Loop thru enumeration types, Checking Passed vs Tested * for return value */ for (i = 0; i < SPSEARCH_LIST; i++) { if (Tested[i] && !Passed[i]) status = SpStatBadProfile; } if (0 < TagCount) { for(j = 0; j < TagCount; j++) { if (pTagIdsTested[j] != pTagIdsPassed[j]) status = SpStatBadProfile; } if (TAGID_LIST < TagCount) { freeBufferPtr( (KpGenericPtr_t)pTagIdsTested); freeBufferPtr( (KpGenericPtr_t)pTagIdsPassed); } } return status; }