main() {
	int a, k, n, op, Mod;
	while(scanf("%d %d", &k, &Mod) == 2) {
		SpTree Tree[Mod];
		for(a = 0; a < Mod; a++)	Spinit(&Tree[a]);
		while(k--) {
			scanf("%d", &op);
			switch(op) {
				case 1:scanf("%d", &n);
						InsSp(&Tree[n%Mod], n);break;
				case 2:scanf("%d", &n);
						DelSp(&Tree[n%Mod], n);break;
				case 3:{
					puts("===== s =====");
					for(a = 0; a < Mod; a++) {
						printf("[%03d]:", a); SpPrint(&Tree[a], Tree[a].root);
						puts("NULL");
					}
					puts("===== e =====");
					break;
				}
			}
		}
		
		for(a = 0; a < Mod; a++)	SpFree(&Tree[a], Tree[a].root);
	}
	return 0;
}
Пример #2
0
/*--------------------------------------------------------------------
 * 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);
}
Пример #3
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 */
void SpFree(SpTree *tree, SpNode *now) {
	if(now == tree->NIL)	return;
	if(now->lc != tree->NIL)	SpFree(tree, now->lc);
	if(now->rc != tree->NIL)	SpFree(tree, now->rc);
	free(now);
}
Пример #5
0
SpStatus_t KSPAPI SpXformToLutDT(SpXform_t	Xform,
				KpInt32_t	SpDataType,
				SpLut_t		*Lut,
				SpTransRender_t	*WhichRender,
				SpTransType_t	*WhichTransform,
				SpSig_t		*SpaceIn,
				SpSig_t		*SpaceOut,
				KpF15d16XYZ_t	*HdrWhite,
				KpF15d16XYZ_t	*MedWhite,
				KpUInt32_t	*ChainIn,
				KpUInt32_t	*ChainOut)
{
SpHugeBuffer_t	Buf;
char			*LutBuf;
KpUInt32_t		BufSize;
SpStatus_t		Status;
SpXformData_t   FAR *XformData;
KpInt32_t		KcmDataType;

	Status = SpDTtoKcmDT (SpDataType, &KcmDataType);
	if (Status != SpStatSuccess) {
		return (Status);
	}

	/* Set Up Private Structure to Populate */
	XformData = lockBuffer ((KcmHandle)Xform);
	if (NULL == XformData)
		return SpStatBadXform;

	/* Set Up Lut Size based on Lut Type and size */
	switch ( XformData->LutType )
	{	
	case SpTypeLut8:
		XformData->LutSize =  SP_ICC_MFT1;
		break;
	case SpTypeLut16:
		XformData->LutSize = SP_ICC_MFT2;
		break;
	case SpTypeLutAB:
		if ((XformData->LutSize == 0) ||
		    (XformData->LutSize == 16))
			XformData->LutSize = SP_ICC_MAB2;
		else
			XformData->LutSize = SP_ICC_MAB1;
		break;
	case SpTypeLutBA:
		if ((XformData->LutSize == 0) ||
		    (XformData->LutSize == 16))
			XformData->LutSize = SP_ICC_MBA2;
		else
			XformData->LutSize = SP_ICC_MBA1;
		break;
	} /* end switch */

	#if defined KCP_DIAG_LOG
	{KpChar_t	string[256];
	sprintf (string, "\nSpXformToLutDT\n Xform %x, PTRefNum %x, Lut %x", 
		Xform, XformData->PTRefNum, Lut);
	kcpDiagLog (string); }
	#endif

	Status = SpXformGetDataFromCP  (XformData->PTRefNum,
					XformData->LutSize,
					KcmDataType,
					&BufSize,
					&Buf);

	if (Status != SpStatSuccess)
	{
		unlockBuffer ((KcmHandle)Xform);
		return Status;
	}

	Lut->LutType = XformData->LutType;

	/* Move past the tag and Reserved */
	LutBuf = (char *)Buf;
	LutBuf += 8;
	Status = SpLutToPublic(LutBuf, Lut);

	/* Clear White Points */
	HdrWhite->X = MedWhite->X =
	HdrWhite->Y = MedWhite->Y =
	HdrWhite->Z = MedWhite->Z = 0;

	if (Status == SpStatSuccess)
	{
		*WhichRender     = XformData->WhichRender;
		*WhichTransform  = XformData->WhichTransform;
		*SpaceIn         = XformData->SpaceIn;
		*SpaceOut        = XformData->SpaceOut;
		if (XformData->HdrWPValid) {
			HdrWhite->X       = XformData->HdrWtPoint.X;
			HdrWhite->Y       = XformData->HdrWtPoint.Y;
			HdrWhite->Z       = XformData->HdrWtPoint.Z;
		}
		if (XformData->MedWPValid) {
			MedWhite->X      = XformData->MedWtPoint.X;
			MedWhite->Y      = XformData->MedWtPoint.Y;
			MedWhite->Z      = XformData->MedWtPoint.Z;
		}
		*ChainIn         = XformData->ChainIn;
		*ChainOut        = XformData->ChainOut;
	}
	SpFree(Buf);
	unlockBuffer ((KcmHandle)Xform);
	return Status;
}