示例#1
0
BioAPI_RETURN BioAPI mdsutil_GetBspCredentialInfo(char* UuidStr,
												 CSSM_DATA_PTR Credential,
												 CSSM_DATA_PTR BspName,
												 CSSM_DATA_PTR BspPath)
{
	bioapi_MDS_BSP_RECORD Record;
	CSSM_DB_ATTRIBUTE_DATA BspAttributes[BIOAPI_BSP_NUM_ATTRIBUTES];
	BioAPI_RETURN retValue = CSSM_OK;

	memset( &Record, 0, sizeof( bioapi_MDS_BSP_RECORD ));
	memset( &BspAttributes, 0, BIOAPI_BSP_NUM_ATTRIBUTES * sizeof( CSSM_DB_ATTRIBUTE_DATA));

	if ((retValue = mdsutil_GetBspRecord(hDLDBBioAPI,
											 UuidStr,
											 &Record,
											 BspAttributes)) != CSSM_OK)
	{
		return (retValue);
	}

	if (BspName)
	{
		if ((BspName->Data = (uint8 *)BioAPI_calloc (1, Record.bspname.Length, NULL)) == NULL)
		{
			mdsutil_FreeRecord (BIOAPI_BSP_NUM_ATTRIBUTES, BspAttributes);
			return (CSSM_ERRCODE_MEMORY_ERROR);
		}

		memcpy (BspName->Data, Record.bspname.Data, Record.bspname.Length);
		BspName->Length = Record.bspname.Length;
	}

	if (BspPath)
	{
		if ((BspPath->Data = (uint8 *)BioAPI_calloc (1, Record.path.Length, NULL)) == NULL)
		{
			mdsutil_FreeRecord (BIOAPI_BSP_NUM_ATTRIBUTES, BspAttributes);
			return (CSSM_ERRCODE_MEMORY_ERROR);
		}

		memcpy (BspPath->Data, Record.path.Data, Record.path.Length);
		BspPath->Length = Record.path.Length;
	}

	mdsutil_FreeRecord (BIOAPI_BSP_NUM_ATTRIBUTES, BspAttributes);

	return (retValue);
}
示例#2
0
CSSM_RETURN ffutil_CopyData(CSSM_DATA_PTR pDestination, DAL_CONST_DATA_PTR pSource)
{
	VERIFY_PTR(pDestination);
	VERIFY_PTR(pSource);

	if (pDestination->Data)
	{
		BioAPI_free(pDestination->Data, NULL);
		pDestination->Data = NULL;
	}
	/* Destination->Data is now NULL */

	pDestination->Length = pSource->Length;

	if (!pDestination->Length)
		return CSSM_OK;

	pDestination->Data = (uint8*)BioAPI_calloc(pDestination->Length, 1, NULL);

	if (!pDestination->Data)
	{
		pDestination->Length = 0;
		return CSSMERR_DL_MEMORY_ERROR;
	}

	memcpy(pDestination->Data, pSource->Data, pDestination->Length);

	return CSSM_OK;
}
示例#3
0
文件: ff_func.cpp 项目: ozgend/hive
/*-----------------------------------------------------------------------------
 * Name: dlbe_OpenDatabase
 *
 * Description:
 * Will allocate memory for a database and then open it up using flat file commands
 *
 * Parameters:
 * FUNCTION_ARG (input/output)
 *
 * Return value:
 * CSSM_OK on success, otherwise CSSM_FAIL
 *
 * Error Codes:
 * TODO
 *---------------------------------------------------------------------------*/
CSSM_RETURN dlbe_OpenDatabase(DATABASE_BACKEND_HANDLE *phDatabase, const char *DbName,
	DAL_MODULE_PARAMETERS const * Parameters)
{
	char * DbNameCopy;

	ASSERT(phDatabase);
	ASSERT(DbName);
	ASSERT(Parameters);

	FF_FUNCTION_BEGIN(dlbe_OpenDatabase);

	if (!phDatabase)
		return CSSMERR_DL_FUNCTION_FAILED;

	DbNameCopy = (char *)BioAPI_calloc(strlen(DbName)+1, 1, NULL);
	if (!DbNameCopy)
		return CSSMERR_DL_MEMORY_ERROR;

	strcpy(DbNameCopy, DbName);

	DATABASE_BACKEND* pDatabase = DbNameCopy;

	*phDatabase = (void *)pDatabase;

	return CSSM_OK;
}
示例#4
0
/*-----------------------------------------------------------------------------
 * Name: ffutil_AllocateData
 *
 * Description:
 * Allocates an array of CSSM_DATA structures (w/ DL's mem functions)
 *
 * Parameters:
 * prgData (output) : Pointer to a CSSM_DATA_PTR to hold the beggining address of the array
 * NumDataStructs (input) : Number of CSSM_DATA structs in the array
 *
 * Return value:
 * None.
 *
 * Error Codes:
 * None.
 *---------------------------------------------------------------------------*/
CSSM_RETURN ffutil_AllocateData(CSSM_DATA_PTR * prgData, uint32 NumDataStructs)
{
	if (NumDataStructs == 0)
	{
		*prgData = NULL;
		return CSSM_OK;
	}

	*prgData = (CSSM_DATA_PTR)BioAPI_calloc(sizeof(CSSM_DATA), NumDataStructs, NULL);

	if (!(*prgData))
		return CSSMERR_DL_MEMORY_ERROR;

	return CSSM_OK;
}
示例#5
0
BioAPI_RETURN BioAPI mdsutil_GetHLayerCredentialInfo(char* UuidStr,
												 CSSM_DATA_PTR Credential,
												 CSSM_DATA_PTR ModuleName,
												 CSSM_DATA_PTR ModulePath)
{
	bioapi_MDS_H_LAYER Record;
	CSSM_DB_ATTRIBUTE_DATA HLayerAttributes[BIOAPI_H_LAYER_NUM_ATTRIBUTES];
	BioAPI_RETURN retValue = CSSM_OK;

	memset( &Record, 0, sizeof( bioapi_MDS_H_LAYER ));
	memset( &HLayerAttributes, 0, BIOAPI_H_LAYER_NUM_ATTRIBUTES * sizeof( CSSM_DB_ATTRIBUTE_DATA));

	if ((retValue = mdsutil_GetBioAPIRecord(hDLDBBioAPI,
											 UuidStr,
											 &Record,
											 HLayerAttributes)) != CSSM_OK)
	{
		return (retValue);
	}

	if (ModuleName)
	{
		if ((ModuleName->Data = (uint8 *)BioAPI_calloc (1, Record.modulename.Length, NULL)) == NULL)
		{
			mdsutil_FreeRecord (BIOAPI_H_LAYER_NUM_ATTRIBUTES, HLayerAttributes);
			return (CSSM_ERRCODE_MEMORY_ERROR);
		}

		memcpy (ModuleName->Data, Record.modulename.Data, Record.modulename.Length);
		ModuleName->Length = Record.modulename.Length;
	}

	if (ModulePath)
	{
		ModulePath->Data = NULL;
		ModulePath->Length = 0;
	}

	mdsutil_FreeRecord (BIOAPI_H_LAYER_NUM_ATTRIBUTES, HLayerAttributes);

	return (retValue);
}