Example #1
0
/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Delete a profile. If there is a file associated with the profile,
 *	it is also deleted.
 *
 * AUTHOR
 * 	lsh & mlb
 *
 * DATE CREATED
 *	May 4, 1995
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileDelete (
    SpProfile_t FAR *Profile)
{
    KpChar_t		*fileName;
    SpProfileData_t	FAR *ProfileData;
    KpFileProps_t		Props;

    /* convert profile handle to data pointer */
    ProfileData = SpProfileLock (*Profile);
    if (NULL == ProfileData)
        return SpStatBadProfile;

    /* lock FileName handle and return  ptr */
    fileName = (char *) lockBuffer (ProfileData->FileName);

#if defined (KPMAC)
    /* Convert SpIOFileChar_t to KpFileProps_t */
    SpCvrtSpFileProps (&(ProfileData->Props), &Props);
#endif

    /* delete associated file name */
    if (NULL != fileName)
        KpFileDelete (fileName, &Props);

    /* unlock handles */
    unlockBuffer (ProfileData->FileName);
    SpProfileUnlock (*Profile);
    return SpProfileFree (Profile);
}
Example #2
0
/*--------------------------------------------------------------------
 * DESCRIPTION	(Public)
 *	Load a profile from a file.
 *
 * AUTHOR
 * 	doro
 *
 * DATE CREATED
 *	December 5, 1995
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileLoadProfile (
    SpCallerId_t	CallerId,
    KpChar_t	*FileName,
    SpFileProps_t	*Props,
    SpProfile_t	FAR *Profile)
{
    KpMapFile_t	MapFileCtl;
    KpFileProps_t	props;
    SpStatus_t	Status;
    char		KPHUGE *Ptr;
    KpInt32_t	ProfileSize;


#if defined (KPMAC)
    /* Convert file information into useable form */
    SpCvrtSpFileProps(Props, &props);
#endif

    /* Map the file */
    if (NULL == KpMapFileEx (FileName, &props, "r", &MapFileCtl))
        return SpStatFileNotFound;

    Ptr = (char *)MapFileCtl.Ptr;
    ProfileSize = (KpInt32_t)SpGetUInt32 (&Ptr);

    if (ProfileSize > MapFileCtl.NumBytes)
    {
        KpUnMapFile (&MapFileCtl);
        return SpStatBadProfile;
    }

    /* Load the profile */
    Status = SpProfileLoadFromBuffer (CallerId, MapFileCtl.Ptr,
                                      Profile);

    /* Unmap the file */
    KpUnMapFile (&MapFileCtl);

    /* Remember the file name */
    if (SpStatSuccess == Status) {
        Status = SpProfileSetName (*Profile, FileName, Props);
        if (SpStatSuccess != Status)
            SpProfileFree (Profile);
    }

    return Status;
}
Example #3
0
/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Create profile that uses supplied buffer as the profile data.
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	October 20, 1993
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileLoadFromBuffer (
				SpCallerId_t	CallerId,
				void			FAR *Buffer,
				SpProfile_t		FAR *Profile)
{
	SpStatus_t		Status;
	SpProfileData_t	FAR *ProfileData;
	
	Status = SpProfileAlloc (CallerId, Profile, &ProfileData);
	if (SpStatSuccess != Status)
		return Status;

/* get profile header into internal format */
	Status = SpProfileLoadFromBufferImp (ProfileData,  Buffer);

	SpProfileUnlock (*Profile);

/* free profile if an error occurred */
	if (SpStatSuccess != Status)
		SpProfileFree (Profile);

	return Status;
}
Example #4
0
SpStatus_t KSPAPI SpProfileMakeDeviceLinkEx(SpCallerId_t	callerId,
				   SpDevLinkPB_p	pDevLinkDesc,
				   KpUInt32_t		ProfileVersion,
				   SpProfile_t		FAR *pProfile)
{
 
SpStatus_t	spStatus;
KpInt32_t	eachXform, badXform, LutType;
SpXform_t	*aXform;
KpBool_t	madeXform = KPFALSE;
 
	/*	Create a new empty profile      */
	spStatus = SpProfileCreateEx (callerId, SP_ICC_TYPE_0, ProfileVersion, pProfile);
	if (SpStatSuccess != spStatus) {
		return spStatus;
	}
 
	/*	Fill in the header information  */
	spStatus = SpProfileSetLinkHeader (*pProfile, pDevLinkDesc);
	if (SpStatSuccess != spStatus) {
		SpProfileFree (pProfile);
		return spStatus;
	}
 
	if (pDevLinkDesc->xform == NULL)
	{
		if (pDevLinkDesc->numProfiles < 2)
		{
			SpProfileFree (pProfile);
			return SpStatIncompatibleArguments;
		}

		aXform = SpMalloc(sizeof(SpXform_t) * pDevLinkDesc->numProfiles);

		if (aXform == NULL)
		{
			SpProfileFree (pProfile);
			return SpStatMemory;
		}

		for (eachXform = 0; 
		     eachXform < pDevLinkDesc->numProfiles;
		     eachXform++)
		{
			aXform[eachXform] = NULL;
			spStatus = SpXformGet(
				pDevLinkDesc->pProfileList[eachXform].profile,
				pDevLinkDesc->pProfileList[eachXform].whichRender,
				pDevLinkDesc->pProfileList[eachXform].whichTransform,
				&aXform[eachXform]);

			if ((SpStatSuccess != spStatus) &&
			    (SpStatXformIsPerceptual != spStatus) &&
			    (SpStatXformIsColormetric != spStatus) &&
			    (SpStatXformIsSaturation != spStatus))
			{
				for (eachXform--; eachXform >= 0; eachXform--)
					SpXformFree (&aXform[eachXform]);
				SpFree ((void *) aXform);
				SpProfileFree (pProfile);
				return spStatus;
			}
		}
		spStatus = SpCombineXforms(pDevLinkDesc->numProfiles,
					   aXform, &pDevLinkDesc->xform, 
					   &badXform, NULL, NULL);
		madeXform = KPTRUE;

		for (eachXform = 0; 
		     	    eachXform < pDevLinkDesc->numProfiles;
		     	    eachXform++)
			SpXformFree (&aXform[eachXform]);

		SpFree ((void *) aXform);

		if (SpStatSuccess != spStatus) {
			SpXformFree (&pDevLinkDesc->xform);
			SpProfileFree (pProfile);
			return spStatus;
		}
	}

	/*	Add the transform to the profile        */
	if (ProfileVersion < SPICCVER40)
	{
		LutType = SP_ICC_MFT1;
		if (pDevLinkDesc->lutSize == 16)
			LutType = SP_ICC_MFT2;
	} else
	{
		LutType = SP_ICC_MAB1;
		if (pDevLinkDesc->lutSize == 16)
			LutType = SP_ICC_MAB2;
	}
	spStatus = SpXformSet(	*pProfile,
				LutType,
				SpTransRenderPerceptual,
				SpTransTypeIn,
				pDevLinkDesc->xform);

	/*	Only free the device link transform if it was made by this function	*/
	if (madeXform) {
		SpXformFree (&pDevLinkDesc->xform);
	}

	if (SpStatSuccess != spStatus) {
		SpProfileFree (pProfile);
		return spStatus;
	}

	/*	Add the Profile Description Tag */
	if (ProfileVersion < SPICCVER40)
	{
		spStatus = SpProfileSetLinkDesc(*pProfile, pDevLinkDesc);
	} else
	{
		spStatus = SpProfileSetLinkMLDesc(*pProfile, pDevLinkDesc);
	}
	if (SpStatSuccess != spStatus) {
		SpProfileFree (pProfile);
		return spStatus;
	}

	/*	Add the Profile Sequence Description Tag */
	if (ProfileVersion < SPICCVER40)
	{
		spStatus = SpProfileSetLinkSeqDesc(*pProfile, pDevLinkDesc);
	} else
	{
		spStatus = SpProfileSetLinkMLSeqDesc(*pProfile, pDevLinkDesc);
	}
	if (SpStatSuccess != spStatus) {
		SpProfileFree (pProfile);
		return spStatus;
	}
 
 
	return SpStatSuccess;
} /* SpProfileMakeDeviceLinkEx */
Example #5
0
static KpBool_t TestFile(KpfileDirEntry_t FAR *fileSearch,
		  SpCallerId_t	CallerId,
		  SpStatus_t	*ReturnStatus,
                  SpSearch_t	*SearchCriterion,
		  SpProfile_t	*profileList,
		  KpInt32_t	listSize,
		  KpInt32_t	TotalAvailable,
		  KpInt32_t	*CurrentIndex)
{

SpProfile_t		*profPtr;
SpHeader_t		Header;
SpStatus_t		Status;
SpFileProps_t	FileProp;
SpProfileData_t FAR	*ProfData;
KpBool_t		returnBool = KPTRUE;	/* assume we will continue */
char			*filename;
KpInt32_t		searchMode = SEARCH_RECURSIVE | SPSEARCHFORALL;
SpDataBase_t		DataBase;
char			Dir1[MAX_PATH];
SpDataBaseEntry_t	List[1];

#if defined (KPMAC)
KpUInt16_t		vRefNumSave;
KpUInt32_t		dirIDSave;
int			i;
#endif

if ((fileSearch->opStatus == IOFILE_FINISHED) ||
    (fileSearch->opStatus == IOFILE_STARTED) ||
	(fileSearch->opStatus == IOFILE_ERROR))
{
   return returnBool;
}

#if defined (KPMAC)
   FileProp.vRefNum = fileSearch->osfPrivate.parm.dirInfo.ioVRefNum;
   FileProp.dirID   = fileSearch->osfPrivate.parm.dirInfo.ioDrParID;
#endif

   /* Search into sub-directories */
   if (IsDirectory(fileSearch))
   {
      DataBase.numEntries = 1;
      if (fileSearch->nwAttr & ATTR_DIRECTORY)
      	searchMode |= SEARCH_NOT_RECURSIVE;
      if (fileSearch->nwAttr & ATTR_LINK)
      	searchMode |= SEARCH_NOT_RESOLVE_ALIAS;
      	
#if defined (KPMAC)
	// Setup vRefNum/DirID of subdirectory.  Save original and restore vefore returning
  	 List[0].fileProps.vRefNum = fileSearch->osfPrivate.parm.dirInfo.ioVRefNum;
   	List[0].fileProps.dirID   = fileSearch->osfPrivate.parm.dirInfo.ioDrParID;
	vRefNumSave = fileSearch->osfPrivate.vRefNum;
	dirIDSave = fileSearch->osfPrivate.dirID;
	
	// Only search one level of subdirectory on Mac
	searchMode |= SEARCH_NOT_RECURSIVE;
#endif
#if defined (KPUNIX)
      strcpy(Dir1, fileSearch->osfPrivate.base_Dir);
      strcat(Dir1, "/");
      strcat(Dir1, fileSearch->fileName);
#else
      strcpy(Dir1, fileSearch->fileName);
#endif

      List[0].dirName  = (char *)Dir1;
      DataBase.Entries = List;
      Status = SpSearchEngine(CallerId, &DataBase, SearchCriterion, KPFALSE,
                    profileList, listSize, CurrentIndex, searchMode,
                    (KpfileCallBack_t)TestFileCB);
#if defined (KPMAC)
	 fileSearch->osfPrivate.vRefNum = vRefNumSave;
	 fileSearch->osfPrivate.dirID = dirIDSave;
#endif
      if (Status == SpStatSuccess)
         return KPTRUE;
      else
         return KPFALSE;
   }

   Status = SpProfileLoadHeader(fileSearch->fileName,
                                    &FileProp, &Header);
   if (Status == SpStatSuccess)
   {
      Status = SpProfileCheck(SearchCriterion, &Header);
      if (Status == SpStatSuccess)
      {
         if (*CurrentIndex < listSize)
         {
            profPtr = &profileList[*CurrentIndex];

            Status = SpProfileAlloc(CallerId,
                                    profPtr,
                                    &ProfData);
            if (Status == SpStatSuccess)
            {
               if ((Status = SpProfileSetHeader(*profPtr,
                                                &Header)) ==
                    SpStatSuccess)
               {
                  ProfData->FileName = allocBufferHandle(
                     strlen(fileSearch->fileName) + 1);
                  if (ProfData->FileName == 0)
                  {
                     SpProfileFree(profPtr);
                     return KPFALSE;
                  }
                  filename = (char *)lockBuffer(ProfData->FileName);
                  if (filename == 0)
                  {
                     freeBuffer(ProfData->FileName);
                     SpProfileFree(profPtr);
                     return KPFALSE;
                  }
                  strcpy(filename, fileSearch->fileName);
	              unlockBuffer (ProfData->FileName);
                  ProfData->TotalCount = 0;
                  freeBuffer(ProfData->TagArray);
                  ProfData->TagArray   = NULL;
#if defined (KPMAC)
                  ProfData->Props.vRefNum     = fileSearch->osfPrivate.vRefNum;
                  ProfData->Props.dirID       = fileSearch->osfPrivate.dirID;
                  for (i= 0; i < 5; i++)
                  {
                     ProfData->Props.fileType[i]    = NULL;
                     ProfData->Props.creatorType[i] = NULL;
                  }
#endif

                  (*CurrentIndex)++;
                  if ((*CurrentIndex >= listSize) &&
                      (TotalAvailable == 0))
                     returnBool = KPFALSE;
               } else 
               {
                  *ReturnStatus = Status;
                  returnBool = KPFALSE;
               } /* if SpProfileSetHeader */
               SpProfileUnlock(*profPtr);
            } else
            {
               *ReturnStatus = (KpInt32_t)Status;
               returnBool = KPFALSE;
            } /* if SpProfileAlloc */
         } else
            (*CurrentIndex)++;
      } /* if SpProfileCheck */
   } /* if SpProfileLoadHeader */
   return returnBool;
}