示例#1
0
文件: mds_util.c 项目: ozgend/hive
BioAPI_RETURN BioAPI MDSU_Term( MDSU_CONTEXT *pContext )
{
	BioAPI_RETURN rv = CSSM_OK;

	/* Parameter check */
	if ( pContext == NULL )
	{
		rv = CSSMERR_CSSM_INVALID_POINTER;
	}
	else
	{
		/* Commit the records in the cache */
		MDSU_Commit( pContext );

		/* Free the commit cache */
		MDSU_free( pContext, pContext->pCommitCache );

		/* Close the database handle */
		if ( ( rv = s_MDSUFuncs.DbClose( pContext->hDb ) ) == CSSM_OK )
		{
			/* Close the MDS connection */
			if ( ( rv = MDS_Terminate( pContext->hMds ) ) == CSSM_OK )
			{
				/* Wipe the context */
				memset( pContext, 0, sizeof(MDSU_CONTEXT) );
			}
		} /* DbClose */
	} /* Validation */

	return rv;
}
示例#2
0
文件: bsp_schema.c 项目: ozgend/hive
static BioAPI_RETURN BioAPI DestructBioAPIBspCapabiltiesAttributes(
							MDSU_CONTEXT *pContext,
							CSSM_DB_RECORD_ATTRIBUTE_DATA *DbRecord,
							CSSM_BOOL bFreeAll,
							void *pAttrState )
{
	CSSM_DB_ATTRIBUTE_DATA *DbRecordAttributes;
	uint32 i;

	assert( pContext && DbRecord && pAttrState );

	/* Free the buffers allocated for the attribute values */
	DbRecordAttributes = DbRecord->AttributeData;
	if ( bFreeAll == CSSM_TRUE )
	{
		for ( i = 0; i < DbRecord->NumberOfAttributes; i++ )
		{
			if ( DbRecordAttributes[i].Value )
			{
				if ( DbRecordAttributes[i].Value->Data )
				{
					MDSU_free( pContext,
							   DbRecordAttributes[i].Value->Data );
				}
				MDSU_free( pContext,
						   DbRecordAttributes[i].Value );
			}
		}
	}

	/* Free the state structure */
	MDSU_free( pContext,
			   pAttrState );
	DbRecord->AttributeData = NULL;

	return CSSM_OK;
}
示例#3
0
文件: bsp_schema.c 项目: ozgend/hive
static BioAPI_RETURN BioAPI DestructBioAPIBspCapabiltiesPredicate(
							MDSU_CONTEXT *pContext,
							CSSM_QUERY *pQuery,
							void *pPredState )
{
	assert( pContext && pQuery );

	/* Free the attribute array */
	if ( pPredState != NULL )
	{
		MDSU_free( pContext, pPredState );
	}

	return CSSM_OK;
}
示例#4
0
static CSSM_RETURN __CleanMDS( MDSU_CONTEXT *pContext )
{
	CSSM_RETURN rv = CSSM_OK;
	MDSU_CDSA_COMMON_SCHEMA CommonTemplate;
	MDSU_CDSA_COMMON_SCHEMA CommonData;
	MDSU_CDSA_DL_PRIMARY_SCHEMA DLPrimaryTemplate;
	MDSU_CDSA_DL_PRIMARY_SCHEMA DLPrimaryData;
	MDSU_CDSA_DL_ENC_PRODUCT_SCHEMA DLEncProdTemplate;
	MDSU_CDSA_DL_ENC_PRODUCT_SCHEMA DLEncProdData;

	/* Execute a search on every DL record type to get a handle of all
	 * records and then delete them.
	 */
	/* Common Schema */
	CommonTemplate.ModuleID = MODULE_GUID;
	rv = MDSU_FindFirst( pContext,
						 &IfiMdsuCdsadirCommonSchema,
						 &CommonTemplate,
						 MDSU_COM_MODULE_ID,
						 &CommonData,
						 NULL );
	while ( rv == CSSM_OK )
	{
		if ( CommonData.Manifest.Data )
		{
			MDSU_free( pContext, CommonData.Manifest.Data );
		}

		rv = MDSU_FindNext( pContext,
							&CommonData,
							NULL );
	}
	if ( rv == CSSMERR_DL_ENDOFDATA )
	{
		/* DL Primary Schema */
		DLPrimaryTemplate.ModuleID = MODULE_GUID;
		rv = MDSU_FindFirst( pContext,
							 &IfiMdsuCdsadirDLPrimarySchema,
							 &DLPrimaryTemplate,
							 MDSU_DLP_MODULE_ID,
							 &DLPrimaryData,
							 NULL );
		while ( rv == CSSM_OK )
		{
			if ( DLPrimaryData.Manifest.Data )
			{
				MDSU_free( pContext, DLPrimaryData.Manifest.Data );
			}

			rv = MDSU_FindNext( pContext,
								&DLPrimaryData,
								NULL );
		}
		if ( rv == CSSMERR_DL_ENDOFDATA )
		{
			/* DL Encapsulated Product Schema */
			DLEncProdTemplate.ModuleID = MODULE_GUID;
			rv = MDSU_FindFirst( pContext,
								 &IfiMdsuCdsadirDLEncProductSchema,
								 &DLEncProdTemplate,
								 MDSU_DLEP_MODULE_ID,
								 &DLEncProdData,
								 NULL );
			while ( rv == CSSM_OK )
			{
				rv = MDSU_FindNext( pContext,
									&DLEncProdData,
									NULL );
			}
			if ( rv == CSSMERR_DL_ENDOFDATA )
			{
				/* Flush everything from the MDS */
				rv = MDSU_Revert( pContext );
			} /* CSP Encapsulated Product removed */
		} /* CSP Primary removed */
	} /* Common removed */

	/* Make sure nothing gets removed if there is an error */
	if ( ( rv != CSSMERR_DL_ENDOFDATA ) &&
		 ( rv != CSSM_OK ) )
	{
		MDSU_Commit( pContext );
	}

	return rv;
}
示例#5
0
文件: bsp_schema.c 项目: ozgend/hive
static BioAPI_RETURN BioAPI ConstructBioAPIBspCapabiltiesAttributes(
							MDSU_CONTEXT *pContext,
							const void *pSchemaData,
							CSSM_DB_RECORD_ATTRIBUTE_DATA *DbRecord,
							CSSM_BOOL bFillValues,
							void **ppAttrState )
{
	CSSM_RETURN rv = CSSM_OK;
	const BioAPI_BSP_SCHEMA *pBioAPIBspCap =
							(const BioAPI_BSP_SCHEMA*)pSchemaData;
	BIOAPI_BSP_ATTR_STATE *pState = NULL;
	CSSM_DB_ATTRIBUTE_DATA *DbRecordAttributes;
	uint32 i;

	assert( pContext && DbRecord && ppAttrState );
	assert( ( bFillValues == CSSM_FALSE ) ||
			( ( bFillValues == CSSM_TRUE ) && pSchemaData ) );

	/* Allocate the memory for the attributes */
	pState = MDSU_malloc( pContext, sizeof(BIOAPI_BSP_ATTR_STATE) );
	if ( pState == NULL )
	{
		ERR( rv = BioAPIERR_H_FRAMEWORK_MEMORY_ERROR );
	}
	else
	{
		/* Clear the structure */
		memset( pState, 0, sizeof(BIOAPI_BSP_ATTR_STATE) );
		DbRecordAttributes = pState->DbRecordAttributes;

		/* Fill in the record information */
		DbRecord->DataRecordType = BIOAPI_BSP_RECORDTYPE;
		DbRecord->SemanticInformation = 0;
		DbRecord->NumberOfAttributes = BIOAPI_BSP_NUM_ATTRIBUTES;
		DbRecord->AttributeData = DbRecordAttributes;

		/* Fill in attribute info */
		DbRecordAttributes[__ModuleId].Info = s_BioApiAttrInfo_ModuleId;
		DbRecordAttributes[__DeviceId].Info = s_BioApiAttrInfo_DeviceId;
		DbRecordAttributes[__BspName].Info = s_BioApiAttrInfo_BspName;
		DbRecordAttributes[__SpecVersion].Info = s_BioApiAttrInfo_SpecVersion;
		DbRecordAttributes[__ProductVersion].Info = s_BioApiAttrInfo_ProductVersion;
		DbRecordAttributes[__Vendor].Info = s_BioApiAttrInfo_Vendor;
		DbRecordAttributes[__BspSupportedFormats].Info = s_BioApiAttrInfo_BspSupportedFormats;
		DbRecordAttributes[__FactorsMask].Info = s_BioApiAttrInfo_FactorsMask;
		DbRecordAttributes[__Operations].Info = s_BioApiAttrInfo_Operations;
		DbRecordAttributes[__Options].Info = s_BioApiAttrInfo_Options;
		DbRecordAttributes[__PayloadPolicy].Info = s_BioApiAttrInfo_PayloadPolicy;
		DbRecordAttributes[__MaxPayloadSize].Info = s_BioApiAttrInfo_MaxPayloadSize;
		DbRecordAttributes[__DefaultVerifyTimeout].Info = s_BioApiAttrInfo_DefaultVerifyTimeout;
		DbRecordAttributes[__DefaultIdentifyTimeout].Info = s_BioApiAttrInfo_DefaultIdentifyTimeout;
		DbRecordAttributes[__DefaultCaptureTimeout].Info = s_BioApiAttrInfo_DefaultCaptureTimeout;
		DbRecordAttributes[__DefaultEnrollTimeout].Info = s_BioApiAttrInfo_DefaultEnrollTimeout;
		DbRecordAttributes[__MaxBspDbSize].Info = s_BioApiAttrInfo_MaxBspDbSize;
		DbRecordAttributes[__MaxIdentify].Info = s_BioApiAttrInfo_MaxIdentify;
		DbRecordAttributes[__Description].Info = s_BioApiAttrInfo_Description;
		DbRecordAttributes[__Path].Info = s_BioApiAttrInfo_Path;
		if ( bFillValues == CSSM_TRUE )
		{
			/* Connect the attribute value array to the attribute array */
			for ( i = 0; i < DbRecord->NumberOfAttributes; i++ )
			{
				DbRecordAttributes[i].Value = &pState->AttributeValues[i];
				DbRecordAttributes[i].NumberOfValues = 1;
			}

			/* Fill in the record contents */
			/* ModuleId */
			BioAPI_GetPrintableUUID( &pBioAPIBspCap->ModuleId,
									(char*)pState->PrintableUuid );
			DbRecordAttributes[__ModuleId].Value->Data =
													pState->PrintableUuid;
			DbRecordAttributes[__ModuleId].Value->Length =
								strlen( (char*)pState->PrintableUuid ) + 1;

			/* DeviceId */
			DbRecordAttributes[__DeviceId].Value->Length = sizeof(uint32);
			DbRecordAttributes[__DeviceId].Value->Data = (uint8*)&pBioAPIBspCap->DeviceId;

			/* BspName */
			DbRecordAttributes[__BspName].Value->Length =
										strlen( pBioAPIBspCap->BSPName ) + 1 ;
			DbRecordAttributes[__BspName].Value->Data =
												(uint8*)pBioAPIBspCap->BSPName;

			/* SpecVersion */
			BioAPI_GetPrintableVersion( &pBioAPIBspCap->SpecVersion,
									   (char*)pState->PrintableSpecVersion );
			DbRecordAttributes[__SpecVersion].Value->Data =
													pState->PrintableSpecVersion;
			DbRecordAttributes[__SpecVersion].Value->Length =
								strlen( (char*)pState->PrintableSpecVersion ) + 1;

			/* ProductVersion */
			BioAPI_GetPrintableVersion( &pBioAPIBspCap->ProductVersion,
									   (char*)pState->PrintableProductVersion );
			DbRecordAttributes[__ProductVersion].Value->Data =
													pState->PrintableProductVersion;
			DbRecordAttributes[__ProductVersion].Value->Length =
								strlen( (char*)pState->PrintableProductVersion ) + 1;

			/* Vendor */
			DbRecordAttributes[__Vendor].Value->Length =
										strlen( pBioAPIBspCap->Vendor ) + 1 ;
			DbRecordAttributes[__Vendor].Value->Data =
												(uint8*)pBioAPIBspCap->Vendor;

			/* SupportedFormats */
			DbRecordAttributes[__BspSupportedFormats].Value->Length =
											sizeof(uint32) * pBioAPIBspCap->NumSupportedFormats;
			DbRecordAttributes[__BspSupportedFormats].Value->Data = (uint8*)&pBioAPIBspCap->BspSupportedFormats;

			/* FactorsMask */
			DbRecordAttributes[__FactorsMask].Value->Length = sizeof(uint32);
			DbRecordAttributes[__FactorsMask].Value->Data = (uint8*)&pBioAPIBspCap->FactorsMask;

			/* Operations */
			DbRecordAttributes[__Operations].Value->Length = sizeof(uint32);
			DbRecordAttributes[__Operations].Value->Data = (uint8*)&pBioAPIBspCap->Operations;

			/* Options */
			DbRecordAttributes[__Options].Value->Length = sizeof(uint32);
			DbRecordAttributes[__Options].Value->Data = (uint8*)&pBioAPIBspCap->Options;

			/* PayLoadPolicy */
			DbRecordAttributes[__PayloadPolicy].Value->Length = sizeof(uint32);
			DbRecordAttributes[__PayloadPolicy].Value->Data = (uint8*)&pBioAPIBspCap->PayloadPolicy;

			/* MaxPayloadSize */
			DbRecordAttributes[__MaxPayloadSize].Value->Length = sizeof(uint32);
			DbRecordAttributes[__MaxPayloadSize].Value->Data = (uint8*)&pBioAPIBspCap->MaxPayloadSize;

			/* DefaultVerifyTimeout */
			DbRecordAttributes[__DefaultVerifyTimeout].Value->Length = sizeof(sint32);
			DbRecordAttributes[__DefaultVerifyTimeout].Value->Data = (uint8*)&pBioAPIBspCap->DefaultVerifyTimeout;

			/* DefaultIdentifyTimeout */
			DbRecordAttributes[__DefaultIdentifyTimeout].Value->Length = sizeof(sint32);
			DbRecordAttributes[__DefaultIdentifyTimeout].Value->Data = (uint8*)&pBioAPIBspCap->DefaultIdentifyTimeout;

			/* DefaultCaptureTimeout */
			DbRecordAttributes[__DefaultCaptureTimeout].Value->Length = sizeof(sint32);
			DbRecordAttributes[__DefaultCaptureTimeout].Value->Data = (uint8*)&pBioAPIBspCap->DefaultCaptureTimeout;

			/* DefaultEnrollTimeout */
			DbRecordAttributes[__DefaultEnrollTimeout].Value->Length = sizeof(sint32);
			DbRecordAttributes[__DefaultEnrollTimeout].Value->Data = (uint8*)&pBioAPIBspCap->DefaultEnrollTimeout;

			/* MaxBspDbSize */
			DbRecordAttributes[__MaxBspDbSize].Value->Length = sizeof(uint32);
			DbRecordAttributes[__MaxBspDbSize].Value->Data = (uint8*)&pBioAPIBspCap->MaxBspDbSize;

			/* Max Identify */
			DbRecordAttributes[__MaxIdentify].Value->Length = sizeof(uint32);
			DbRecordAttributes[__MaxIdentify].Value->Data = (uint8*)&pBioAPIBspCap->MaxIdentify;

			/* Description */
			DbRecordAttributes[__Description].Value->Length =
										strlen( pBioAPIBspCap->Description ) + 1 ;
			DbRecordAttributes[__Description].Value->Data =
												(uint8*)pBioAPIBspCap->Description;

			/* Path */
			DbRecordAttributes[__Path].Value->Length =
										strlen( pBioAPIBspCap->Path ) + 1 ;
			DbRecordAttributes[__Path].Value->Data =
												(uint8*)pBioAPIBspCap->Path;

		} /* bFillValues */
		else
		{
			for ( i = 0; i < DbRecord->NumberOfAttributes; i++ )
			{
				DbRecordAttributes[i].Value = NULL;
				DbRecordAttributes[i].NumberOfValues = 0;
			}
		}

		if ( rv != CSSM_OK )
		{
			/* Deallocate memory if there was an error */
			MDSU_free( pContext,
					   pState );
			pState = NULL;
		}
	} /* allocate DbRecordAttributes */

	*ppAttrState = (void*)pState;

	return rv;
}