示例#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);
}
示例#2
0
/*--------------------------------------------------------------------
 * DESCRIPTION	(Public)
 *	Return the List of Profiles with those that pass the new
 *	search criteria in the front.  foundCount is the number
 *      of Profiles that were found that passed the search criteria
 *
 * AUTHOR
 * 	doro
 *
 * DATE CREATED
 *	November 20, 1995
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileSearchRefine(
                                SpSearch_t	*SearchCriterion,
                                SpProfile_t	*profileList,
                                KpInt32_t	listSize,
                                KpInt32_t	*foundCount)
{

SpProfileData_t		*Pf;
SpProfile_t		ThisProfile;
SpStatus_t		status;
KpInt32_t		i, j, critSize;
SpSearchCriterion_t *criterion;

   *foundCount = 0;

   /* Loop thru those profiles given and test header information
    * against search criteria
    */
   for (i = 0; i < listSize; i++)
   {
      Pf = SpProfileLock(profileList[i]);
      if (Pf == NULL)
         return SpStatBadProfile;

      if ((status = SpProfileCheck(SearchCriterion, &Pf->Header)) ==
          SpStatSuccess)
      {
         if (*foundCount == i)
            (*foundCount)++;
         else
         {
            ThisProfile = profileList[i];
            for (j = i; j > *foundCount;  j--)
            {
               profileList[j] = profileList[j - 1];
            }
            profileList[(*foundCount)++] = ThisProfile;
         }
      }
      SpProfileUnlock(profileList[i]);
   }
   if ((*foundCount > 0) &&
       (SearchCriterion != (SpSearch_t *)NULL))
   {
		critSize = SearchCriterion->critSize;
		criterion = SearchCriterion->criterion;
		for (i = 0; i < SearchCriterion->critCount; i++)
		{
			if (criterion->SearchElement == SPSEARCH_TIMEORDER) 
			{
				status = SpProfileOrderList(profileList, *foundCount);
				break;
			}
			criterion = (SpSearchCriterion_t *)(critSize + (KpUInt8_p)criterion);
		}
   }

   return SpStatSuccess;
}
示例#3
0
/*--------------------------------------------------------------------
 * DESCRIPTION
 *	Set the header for the profile.
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	March 18, 1994
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileSetHeader (
				SpProfile_t		Profile,
				SpHeader_t		FAR *Header)
{
	SpProfileData_t FAR *ProfileData;
	
/* convert profile handle to data pointer */
	ProfileData = SpProfileLock (Profile);
	if (NULL == ProfileData)
		return SpStatBadProfile;

	ProfileData->Header = *Header;
	SpProfileUnlock (Profile);
	return SpStatSuccess;
}
示例#4
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;
}
示例#5
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;
}
示例#6
0
/*--------------------------------------------------------------------
 * DESCRIPTION  (Semi-Private)
 *      Valid the handle points to memory with Sig set correctly
 *
 * AUTHOR
 *      doro
 *
 * DATE CREATED
 *      January 31, 1996
 *------------------------------------------------------------------*/
KpBool_t KSPAPI SpProfileValidHandle(SpProfile_t SpProf)
{
    SpProfileData_t		*Pf;
    KpBool_t		Result = KPFALSE;

    if (SpProf != NULL)
    {

        Pf = SpProfileLock(SpProf);
        if (Pf != NULL)
        {
            if (Pf->Signature == SpProfileDataSig)
                Result = KPTRUE;
            SpProfileUnlock(SpProf);
        }
    }
    return Result;
}
示例#7
0
/*--------------------------------------------------------------------
 * DESCRIPTION	(Public)
 *	Return the name of the currently associated file.
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	September 20, 1993
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileGetDiskName (
    SpProfile_t		Profile,
    size_t			BufferSize,
    KpChar_t		*Buffer,
    SpIOFileChar_t	*Props)
{
    char				FAR *fileName;
    SpProfileData_t		FAR *ProfileData;

    /* 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);

    /* check for case of no file name */
    if (NULL == fileName) {
        *Buffer = '\0';
        SpProfileUnlock (Profile);
        return SpStatNoFileName;
    }

    /* check for buffer large enough */
    if (BufferSize < strlen (fileName) + 1) {
        unlockBuffer (ProfileData->FileName);
        SpProfileUnlock (Profile);
        return SpStatBufferTooSmall;
    }

    strcpy (Buffer, fileName);

    /* Get file properties */
#if defined (KPMAC)
    SpProfSetSpFileData (&(ProfileData->Props), Props);
#endif

    /* unlock handles */
    unlockBuffer (ProfileData->FileName);
    SpProfileUnlock (Profile);

    return SpStatSuccess;
}
示例#8
0
/*--------------------------------------------------------------------
 * DESCRIPTION	(Private -- phase out 5/4/95)
 *	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
 *
 * DATE CREATED
 *	Octorber 22, 1993
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileSetFileName (
    SpProfile_t		Profile,
    char			FAR *FileName)
{
    char			FAR *fileName;
    SpProfileData_t	FAR *ProfileData;

    /* 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)
        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);

#if defined (KPMAC)
    SpProfileClearProps(&(ProfileData->Props));
#endif

    /* unlock handles */
    unlockBuffer (ProfileData->FileName);
    SpProfileUnlock (Profile);
    return SpStatSuccess;
}
示例#9
0
/*--------------------------------------------------------------------
 * DESCRIPTION	(Private -- phase out 5/4/95)
 *	Return the name of the currently associated file.
 *
 * AUTHOR
 * 	lsh
 *
 * DATE CREATED
 *	September 20, 1993
 *------------------------------------------------------------------*/
SpStatus_t KSPAPI SpProfileGetFileName (
    SpProfile_t		Profile,
    size_t			BufferSize,
    char			FAR *Buffer)
{
    char				FAR *fileName;
    SpProfileData_t		FAR *ProfileData;

    /* 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);

    /* check for case of no file name */
    if (NULL == fileName) {
        *Buffer = '\0';
        SpProfileUnlock (Profile);
        return SpStatNoFileName;
    }

    /* check for buffer large enough */
    if (BufferSize < strlen (fileName) + 1) {
        unlockBuffer (ProfileData->FileName);
        SpProfileUnlock (Profile);
        return SpStatBufferTooSmall;
    }

    strcpy (Buffer, fileName);

    /* unlock handles */
    unlockBuffer (ProfileData->FileName);
    SpProfileUnlock (Profile);

    return SpStatSuccess;
}