/*-------------------------------------------------------------------- * DESCRIPTION * Return the Tag from the profile. * If the tag is MultiLang return Ascii * * AUTHOR * doro * * DATE CREATED * October 23, 1995 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpProfileLoadTag( char *Filename, SpFileProps_t *Props, SpTagId_t TagId, SpTagValue_t FAR *Value) { SpStatus_t Status = SpStatSuccess; SpTagType_t TagType; SpUnicodeInfo_t StringInfo; KpInt32_t StringLength; KpChar_p Text; KpInt16_t Language = 0; KpInt16_t Country = 0; Status = SpProfileLoadTagEx(Filename, Props,TagId,Value); if (SpStatSuccess == Status) { if (Sp_AT_MultiLanguage == Value->TagType) { StringInfo = Value->Data.MultiLang.StringInfo[0]; StringLength = StringInfo.StringLength + 1; Text = SpMalloc (StringLength); SpTagGetType(SPICCVER23, TagId, &TagType); if (Sp_AT_Text == TagType) { Status = MultiLangToMLString(Value, &Language, &Country, &StringLength, Text); SpFreeMultiLang(&Value->Data.MultiLang); Value->TagType = TagType; Value->Data.Text = Text; } else if (Sp_AT_TextDesc == TagType) { Status = MultiLangToMLString(Value, &Language, &Country, &StringLength, Text); SpFreeMultiLang(&Value->Data.MultiLang); Status = SpStringToTextDesc(Text, &Value->Data.TextDesc); Value->TagType = TagType; SpFree (Text); } else { SpFree (Text); /* what's going on? something must be wrong! */ } } } return (Status); }
/*************************************************************************** * FUNCTION NAME * SpProfileFreeDeviceDesc * * DESCRIPTION * This function frees the memory associated with the Desc * record pointed to by DeviceDesc. * ***************************************************************************/ SpStatus_t SpFreeDeviceDesc(SpDeviceDesc_t *DeviceDesc) { SpTextDesc_t *TextDesc; if (DeviceDesc->TagType == SpTypeMultiLanguage) SpFreeMultiLang(&DeviceDesc->MLDesc); else { TextDesc = (SpTextDesc_t *)DeviceDesc; SpFreeTextDesc(TextDesc); } return SpStatSuccess; } /* SpFreeDeviceDesc */
/*************************************************************************** * FUNCTION NAME * SpProfileFreeMLSeqRecord * * DESCRIPTION * This function frees the memory associated with the Profile Sequence * record pointed to by pSeqRecord. * ***************************************************************************/ static SpStatus_t SpProfileFreeMLSeqRecord(SpProfileSeqDescRecord2_t *pSeqRecord) { SpFreeMultiLang(&pSeqRecord->DeviceManufacturerDesc.MLDesc); SpFreeMultiLang(&pSeqRecord->DeviceModelDesc.MLDesc); return SpStatSuccess; } /* SpProfileFreeMLSeqRecord */
/*************************************************************************** * FUNCTION NAME * SpProfileSetLinkMLDesc * * 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 SpProfileSetLinkMLDesc(SpProfile_t pProfile, SpDevLinkPB_p pDevLinkDesc) { KpTChar_t manufacturer1[SpMaxTextDesc], model1[SpMaxTextDesc]; KpTChar_t manufacturer2[SpMaxTextDesc], model2[SpMaxTextDesc]; KpTChar_p pDescStr; KpInt32_t length; KpInt16_t Language = -1; KpInt16_t Country = -1; 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); SpTagGetMLString(&tagValue, &Language, &Country, &length, manufacturer1); SpTagFree(&tagValue); } if (Language == -1) Language = SpEnglish; if (Country == -1) Country = SpUSA; /* Get the model information from the first profile */ strcpy(model1, "Unknown"); spStatus = SpTagGetById(pCurProfEntry->profile, SpTagDeviceModelDesc, &tagValue); if (SpStatSuccess == spStatus) { length = sizeof (model1); SpTagGetMLString(&tagValue, &Language, &Country, &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); SpTagGetMLString(&tagValue, &Language, &Country, &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); SpTagGetMLString(&tagValue, &Language, &Country, &length, model2); SpTagFree(&tagValue); } /* Allocate memory for the description string */ length = strlen(manufacturer1) + strlen(model1) + strlen(manufacturer2) + strlen(model2) + 6; 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, " - "); strcat(pDescStr, manufacturer2); strcat(pDescStr, " "); strcat(pDescStr, model2); /* Convert the string to a text description tag and add it to the profile */ spStatus = SpStringToMultiLang(pDescStr, Language, Country, &tagValue.Data.MultiLang); freeBufferPtr(pDescStr); if (SpStatSuccess != spStatus) { return spStatus; } tagValue.TagId = SpTagProfileDesc; tagValue.TagType = Sp_AT_MultiLanguage; spStatus = SpTagSet (pProfile, &tagValue); SpFreeMultiLang (&tagValue.Data.MultiLang); return spStatus; } /* SpProfileSetMLLinkDesc */