Exemplo n.º 1
0
/*--------------------------------------------------------------------
 * DESCRIPTION	(Public)
 *	Set the name of the file to associate with the profile.
 *	If the Name is NULL no file will be associated with the profile.
 *
 * AUTHOR
 * 	lsh & mlb
 *
 * DATE Copied
 *	November 15, 1995
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileSetName (
    SpProfile_t		Profile,
    KpChar_t		*FileName,
    SpFileProps_t	*Props)
{
    char			FAR *fileName;
    SpProfileData_t		FAR *ProfileData;
    SpStatus_t		status;

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

    /* Free current FileName if one is there */
    if (ProfileData->FileName != NULL)
    {
        if (ProfileData->TagArray == NULL)
            status = SpProfilePopTagArray(ProfileData);

        freeBuffer(ProfileData->FileName);
    }

    /* create the FileName handle */
    ProfileData->FileName = allocBufferHandle (strlen (FileName) + 1);
    if (ProfileData->FileName == NULL)
        return SpStatMemory;

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

    /* copy text data into the newly allocated space */
    strcpy (fileName, FileName);

    /* Copy props information into internal profile data structure */
#if defined (KPMAC)
    SpProfSetSpFileProps (Props, &(ProfileData->Props));
#endif

    /* unlock handles */
    unlockBuffer (ProfileData->FileName);
    SpProfileUnlock (Profile);
    return SpStatSuccess;
}
Exemplo n.º 2
0
/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Iterate over all the tags in a profile.  Call user supplied
 *	function with the Id of each tag.
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	July 7, 1994
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpTagIter (
				SpProfile_t		Profile,
				SpTagIter_t		TagIterFunc,
				void			FAR *Data)
{
	KpInt32_t		index;
	SpProfileData_t		FAR *ProfileData;
	SpTagDirEntry_t	FAR *tagArray;
	SpStatus_t			Status;

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

	Status = SpDoIter ( TagIterFunc, SpIterInit, NULL, 0, Data);

	/* Check if Profile found via Search function */
	if (ProfileData->TagArray == NULL)
		/* If so, it needs the Tag Array Loaded */
		SpProfilePopTagArray(ProfileData);

	for (index = 0; (index < ProfileData->TotalCount) && (Status == SpStatSuccess); index++)
	{
		/* User Callback Function could unlock since the
		   Profile is available, so lock before calling */
		/* lock TagArray handle and return ptr */
		tagArray = (SpTagDirEntry_t FAR *) 
				lockBuffer (ProfileData->TagArray);

		/* call users function ONLY IF VALID ENTRY */	
		if (tagArray[index].TagDataSize != -1)
			Status = SpDoIter(TagIterFunc,
					SpIterProcessing, 
					Profile, 
					tagArray[index].TagId, 
					Data);
	}

	unlockBuffer (ProfileData->TagArray);

	SpDoIter ( TagIterFunc, SpIterTerm, NULL, 0, Data);

	SpProfileUnlock (Profile);
	return Status;
}