// // Directory construction initializes MDS and opens the "CDSA" database // Directory::Directory() : mMemoryFunctions(Allocator::standard()) { StLock<Mutex> _(mInitLock); CssmError::check(MDS_Initialize(&mCallerGuid, &mMemoryFunctions, this, &mCDSA.DLHandle)); mCDSA.DBHandle = CSSM_INVALID_HANDLE; }
QMDS::QMDS(const CSSM_GUID *pCallerGuid) { m_memoryFunctions.malloc_func = QMdsUtil_malloc; m_memoryFunctions.free_func = QMdsUtil_free; m_memoryFunctions.realloc_func = QMdsUtil_realloc; m_memoryFunctions.calloc_func = QMdsUtil_calloc; m_memoryFunctions.AllocRef = &QMdsUtil_AllocRef; /* m_errorFuncs.SetError = QMdsUtil_SetError; m_errorFuncs.GetError = QMdsUtil_GetError; m_errorFuncs.ClearError = QMdsUtil_ClearError; */ BOOL bStatus = MDS_Initialize(pCallerGuid); if ( bStatus == FALSE ) { throw( "MDS_Initialize() failed" ); } }
BioAPI_RETURN BioAPI MDSU_Init( MDSU_CONTEXT *pContext, const BioAPI_MEMORY_FUNCS *pMemFuncs, const BioAPI_UUID *pUuid, const char *szDirectoryName, CSSM_DB_ACCESS_TYPE AccessType, uint32 CommitSize ) { BioAPI_RETURN rv = CSSM_OK; /* Parameter check */ if ( ( pContext == NULL ) || ( pMemFuncs == NULL ) || ( szDirectoryName == NULL ) ) { rv = CSSMERR_CSSM_INVALID_POINTER; } else { /* Set the default access value if one is not specified */ if ( AccessType == 0 ) { AccessType = CSSM_DB_ACCESS_READ; } /* Wipe the context clean */ memset( pContext, 0, sizeof(MDSU_CONTEXT) ); /* Set the memory functions */ pContext->MemFuncs = *pMemFuncs; /* Attempt to initialize the MDS and get an MDS handle */ if ( ( rv = MDS_Initialize( pUuid, NULL, &pContext->MemFuncs, &s_MDSUFuncs, &pContext->hMds ) ) == CSSM_OK ) { /* Open the requested MDS directory */ if ( ( rv = s_MDSUFuncs.DbOpen( pContext->hMds, szDirectoryName, NULL, AccessType, NULL, NULL, &pContext->hDb.DBHandle ) ) == CSSM_OK ) { pContext->hDb.DLHandle = pContext->hMds; /* Copy the proper values into the MDSU context */ if ( pUuid != NULL ) { BioAPI_CopyUuid (&pContext->ModuleUuid, pUuid); } else { BioAPI_ClearUuid (&pContext->ModuleUuid); } /* Allocate the commit cache */ pContext->pCommitCache = MDSU_calloc( pContext, sizeof(CSSM_DB_UNIQUE_RECORD_PTR), CommitSize ); pContext->CommitSize = CommitSize; pContext->CacheCount = 0; /* Close the database if there is an error condition */ if ( rv != CSSM_OK ) { s_MDSUFuncs.DbClose( pContext->hDb ); } } /* Terminate the MDS in an error condition */ if ( rv != CSSM_OK ) { MDS_Terminate( pContext->hMds ); memset( pContext, 0, sizeof(MDSU_CONTEXT) ); } } /* MDS_Initialize */ } /* Validation */ return rv; }