// Read both, profile sequence description and profile sequence id if present. Then combine both to // create qa unique structure holding both. Shame on ICC to store things in such complicated way. cmsSEQ* _cmsReadProfileSequence(cmsHPROFILE hProfile) { cmsSEQ* ProfileSeq; cmsSEQ* ProfileId; cmsSEQ* NewSeq; cmsUInt32Number i; // Take profile sequence description first ProfileSeq = (cmsSEQ*) cmsReadTag(hProfile, cmsSigProfileSequenceDescTag); // Take profile sequence ID ProfileId = (cmsSEQ*) cmsReadTag(hProfile, cmsSigProfileSequenceIdTag); if (ProfileSeq == NULL && ProfileId == NULL) return NULL; if (ProfileSeq == NULL) return cmsDupProfileSequenceDescription(ProfileId); if (ProfileId == NULL) return cmsDupProfileSequenceDescription(ProfileSeq); // We have to mix both together. For that they must agree if (ProfileSeq ->n != ProfileId ->n) return cmsDupProfileSequenceDescription(ProfileSeq); NewSeq = cmsDupProfileSequenceDescription(ProfileSeq); // Ok, proceed to the mixing if (NewSeq != NULL) { for (i=0; i < ProfileSeq ->n; i++) { memmove(&NewSeq ->seq[i].ProfileID, &ProfileId ->seq[i].ProfileID, sizeof(cmsProfileID)); NewSeq ->seq[i].Description = cmsMLUdup(ProfileId ->seq[i].Description); } } return NewSeq; }
// Auxiliary, read and duplicate a MLU if found. static cmsMLU* GetMLUFromProfile(cmsHPROFILE h, cmsTagSignature sig) { cmsMLU* mlu = (cmsMLU*) cmsReadTag(h, sig); if (mlu == NULL) return NULL; return cmsMLUdup(mlu); }
// Add a new entry to the linked list cmsBool CMSEXPORT cmsDictAddEntry(cmsHANDLE hDict, const wchar_t* Name, const wchar_t* Value, const cmsMLU *DisplayName, const cmsMLU *DisplayValue) { _cmsDICT* dict = (_cmsDICT*) hDict; cmsDICTentry *entry; _cmsAssert(dict != NULL); _cmsAssert(Name != NULL); entry = (cmsDICTentry*) _cmsMallocZero(dict ->ContextID, sizeof(cmsDICTentry)); if (entry == NULL) return FALSE; entry ->DisplayName = cmsMLUdup(DisplayName); entry ->DisplayValue = cmsMLUdup(DisplayValue); entry ->Name = DupWcs(dict ->ContextID, Name); entry ->Value = DupWcs(dict ->ContextID, Value); entry ->Next = dict ->head; dict ->head = entry; return TRUE; }
cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq) { cmsSEQ *NewSeq; cmsUInt32Number i; if (pseq == NULL) return NULL; NewSeq = (cmsSEQ*) _cmsMalloc(pseq -> ContextID, sizeof(cmsSEQ)); if (NewSeq == NULL) return NULL; NewSeq -> seq = (cmsPSEQDESC*) _cmsCalloc(pseq ->ContextID, pseq ->n, sizeof(cmsPSEQDESC)); if (NewSeq ->seq == NULL) goto Error; NewSeq -> ContextID = pseq ->ContextID; NewSeq -> n = pseq ->n; for (i=0; i < pseq->n; i++) { memmove(&NewSeq ->seq[i].attributes, &pseq ->seq[i].attributes, sizeof(cmsUInt64Number)); NewSeq ->seq[i].deviceMfg = pseq ->seq[i].deviceMfg; NewSeq ->seq[i].deviceModel = pseq ->seq[i].deviceModel; memmove(&NewSeq ->seq[i].ProfileID, &pseq ->seq[i].ProfileID, sizeof(cmsProfileID)); NewSeq ->seq[i].technology = pseq ->seq[i].technology; NewSeq ->seq[i].Manufacturer = cmsMLUdup(pseq ->seq[i].Manufacturer); NewSeq ->seq[i].Model = cmsMLUdup(pseq ->seq[i].Model); NewSeq ->seq[i].Description = cmsMLUdup(pseq ->seq[i].Description); } return NewSeq; Error: cmsFreeProfileSequenceDescription(NewSeq); return NULL; }