Ejemplo n.º 1
0
/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Map an entire file. (non-win32 version)
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	November 9, 1993
 *------------------------------------------------------------------*/
void FAR *KpMapFile (
				KpChar_p		FileName,
				ioFileChar	FAR *FileProps,
				KpChar_p		Mode,
				KpMapFile_t	FAR *MapFileCtl)
{
KpFileProps_t	kpFileProps, *kpFilePropsPtr;

	/* convert FileProps to KpFileProps_t and call
	   KpMapFileEx */
#if defined (KPMAC) || defined (KPMSMAC)
	if (FileProps != NULL) {
		kpFileProps.vRefNum = FileProps->vRefNum;
		kpFileProps.dirID= 0;
		strncpy(kpFileProps.fileType, FileProps->fileType, 5);
		strncpy(kpFileProps.creatorType, FileProps->creatorType, 5);
	}
	else {
		kpFileProps.vRefNum = 0;
		kpFileProps.dirID= 0;
		strncpy(kpFileProps.fileType, "    ", 5);
		strncpy(kpFileProps.creatorType, "    ", 5);
	}
	kpFilePropsPtr = &kpFileProps;
#else
	kpFilePropsPtr = FileProps;
#endif
	return (KpMapFileEx (FileName, kpFilePropsPtr, Mode, MapFileCtl) );
}
Ejemplo n.º 2
0
/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Map an entire file. (WIN32 Version)
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	November 9, 1993
 *------------------------------------------------------------------*/
void FAR *KpMapFile (
				KpChar_p		FileName,
				ioFileChar	FAR *FileProps,
				KpChar_p		Mode,
				KpMapFile_t	FAR *MapFileCtl)
{
	/* just call KpMapFileEx */
	return ( KpMapFileEx(FileName, (KpFileProps_t FAR *)FileProps,
			Mode, MapFileCtl) );
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
/* getPTFromFile
 *
 *	This routine is used when the uvL/LAB conversion PTs are 
 *	read from a file versus being generated by sprofile 
 *
 *	Only PTs are supported by this routine.
*/
KpInt32_t getPTFromFile(SpDirection_t direction, KpInt32_t Render, PTRefNum_t *thePT)
{
	KpMapFile_t	mappedFile;
	KpFileProps_t	props;
	KpChar_p	file;

	if (direction == SpDir2LAB) 
		file = uvl2labName;
	else
	{
		switch (Render)
		{
			case KCM_COLORIMETRIC:
				file = lab2uvlCName; 
				break;
			case KCM_SATURATION_MATCH:
				file = lab2uvlSName; 
				break;
			case KCM_PERCEPTUAL:
			default:
				file = lab2uvlPName; 
				break;
		}
	}

	if( !KpMapFileEx(file,&props,"r",&mappedFile) )
		return -1;

	if( PTCheckIn(thePT,mappedFile.Ptr) != KCP_SUCCESS )  {
		KpUnMapFile(&mappedFile);
		return -1;
	}

	if( PTActivate(*thePT,mappedFile.NumBytes,mappedFile.Ptr) != KCP_SUCCESS )  {
		KpUnMapFile(&mappedFile);
		PTCheckOut( *thePT );
		return -1;
	}

	KpUnMapFile(&mappedFile);

	return   0;
}
Ejemplo n.º 5
0
/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Unmap an entire file. (WIN32 Version)
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	November 9, 1993
 *------------------------------------------------------------------*/
KpInt32_t KpUnMapFile (KpMapFile_t FAR *MapFileCtl)
{
	int	Status;

	Status = KCMS_IO_SUCCESS;
	if (!UnmapViewOfFile (MapFileCtl->Ptr))
		Status = KCMS_IO_ERROR;

	if (!CloseHandle (MapFileCtl->hMapObject))
		Status = KCMS_IO_ERROR;

#if defined(_M_IA64)
	if (!CloseHandle (MapFileCtl->hFile)) {
#else /* non-64-bit case */
	if (_lclose (MapFileCtl->hFile)) {
#endif /* defined(_M_IA64) */
		Status = KCMS_IO_ERROR;
	}

	return Status;
}

#else


/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Map an entire file.
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	November 9, 1993
 *------------------------------------------------------------------*/
void FAR *KpMapFileEx (
				KpChar_p		FileName,
				KpFileProps_t	FAR *FileProps,
				KpChar_p		Mode,
				KpMapFile_t	FAR *MapFileCtl)
{
/* validate mode */
	switch (*Mode) {
	case 'R':
	case 'r':
#if 0
	case 'w':
#endif
		break;
	
	default:
		return NULL;
	}

/* get the size of the file */
	if (!KpFileSize (FileName, FileProps, &MapFileCtl->NumBytes))
		return NULL;

/* allocate buffer to hold file */
	MapFileCtl->Ptr = allocBufferPtr (MapFileCtl->NumBytes);
	if (NULL == MapFileCtl->Ptr)
		return NULL;

/* open the file */
	if (!KpFileOpen (FileName, Mode, FileProps, &MapFileCtl->Fd)) {
		freeBufferPtr (MapFileCtl->Ptr);
		return NULL;
	}

/* read file into the buffer */
	if (!KpFileRead (MapFileCtl->Fd, MapFileCtl->Ptr, &MapFileCtl->NumBytes)) {
		freeBufferPtr (MapFileCtl->Ptr);
		KpFileClose (MapFileCtl->Fd);
		return NULL;
	}

/* done with file, close it */
	if ('r' == *Mode) {
		KpFileClose (MapFileCtl->Fd);
		MapFileCtl->Fd = -1;
	}
	MapFileCtl->Mode = *Mode;

	return MapFileCtl->Ptr;
}


/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Map an entire file. (non-win32 version)
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	November 9, 1993
 *------------------------------------------------------------------*/
void FAR *KpMapFile (
				KpChar_p		FileName,
				ioFileChar	FAR *FileProps,
				KpChar_p		Mode,
				KpMapFile_t	FAR *MapFileCtl)
{
KpFileProps_t	kpFileProps, *kpFilePropsPtr;

	/* convert FileProps to KpFileProps_t and call
	   KpMapFileEx */
#if defined (KPMAC) || defined (KPMSMAC)
	if (FileProps != NULL) {
		kpFileProps.vRefNum = FileProps->vRefNum;
		kpFileProps.dirID= 0;
		strncpy(kpFileProps.fileType, FileProps->fileType, 5);
		strncpy(kpFileProps.creatorType, FileProps->creatorType, 5);
	}
	else {
		kpFileProps.vRefNum = 0;
		kpFileProps.dirID= 0;
		strncpy(kpFileProps.fileType, "    ", 5);
		strncpy(kpFileProps.creatorType, "    ", 5);
	}
	kpFilePropsPtr = &kpFileProps;
#else
	kpFilePropsPtr = FileProps;
#endif
	return (KpMapFileEx (FileName, kpFilePropsPtr, Mode, MapFileCtl) );
}