DWORD VmDirAttributeMetaDataToList( PVDIR_ATTRIBUTE pAttrAttrMetaData, PVDIR_LINKED_LIST* ppMetaDataList ) { DWORD dwError = 0; DWORD dwCnt = 0 ; PVDIR_LINKED_LIST pMetaDataList = NULL; PVMDIR_REPL_ATTRIBUTE_METADATA pReplMetaData = NULL; if (!pAttrAttrMetaData || !ppMetaDataList) { BAIL_WITH_VMDIR_ERROR(dwError, VMDIR_ERROR_INVALID_PARAMETER); } dwError = VmDirLinkedListCreate(&pMetaDataList); BAIL_ON_VMDIR_ERROR(dwError); for (dwCnt = 0; pAttrAttrMetaData->vals[dwCnt].lberbv.bv_val != NULL; dwCnt++) { dwError = VmDirReplMetaDataDeserialize( pAttrAttrMetaData->vals[dwCnt].lberbv.bv_val, &pReplMetaData); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirLinkedListInsertHead(pMetaDataList, pReplMetaData, NULL); BAIL_ON_VMDIR_ERROR(dwError); pReplMetaData = NULL; } *ppMetaDataList = pMetaDataList; cleanup: return dwError; error: VmDirFreeReplMetaData(pReplMetaData); VmDirFreeReplMetaDataList(pMetaDataList); VMDIR_LOG_ERROR(VMDIR_LOG_MASK_ALL, "failed, error (%d)", dwError); goto cleanup; }
DWORD VmDirIndexCfgRestoreProgress( PVDIR_BACKEND_CTX pBECtx, PVDIR_INDEX_CFG pIndexCfg, PBOOLEAN pbRestore ) { DWORD dwError = 0; PSTR pszStatusKey = NULL; PSTR pszStatusVal = NULL; PSTR pszInitOffsetKey = NULL; PSTR pszInitOffsetVal = NULL; PSTR pszScopesKey = NULL; PSTR pszScopesVal = NULL; PSTR pszNewScopesKey = NULL; PSTR pszNewScopesVal = NULL; PSTR pszDelScopesKey = NULL; PSTR pszDelScopesVal = NULL; PSTR pszScope = NULL; if (!pBECtx || !pIndexCfg || !pbRestore) { dwError = ERROR_INVALID_PARAMETER; BAIL_ON_VMDIR_ERROR(dwError); } dwError = _BuildAllKeyStrs( pIndexCfg, &pszStatusKey, &pszInitOffsetKey, &pszScopesKey, &pszNewScopesKey, &pszDelScopesKey); BAIL_ON_VMDIR_ERROR(dwError); if (gVdirIndexGlobals.bFirstboot) { pIndexCfg->status = VDIR_INDEXING_COMPLETE; } else { PSTR pszToken = NULL; char* save = NULL; dwError = pBECtx->pBE->pfnBEUniqKeyGetValue( pBECtx, pszStatusKey, &pszStatusVal); BAIL_ON_VMDIR_ERROR(dwError); pIndexCfg->status = VmDirStringToIA(pszStatusVal); dwError = pBECtx->pBE->pfnBEUniqKeyGetValue( pBECtx, pszInitOffsetKey, &pszInitOffsetVal); BAIL_ON_VMDIR_ERROR(dwError); pIndexCfg->initOffset = VmDirStringToIA(pszInitOffsetVal); dwError = pBECtx->pBE->pfnBEUniqKeyGetValue( pBECtx, pszScopesKey, &pszScopesVal); BAIL_ON_VMDIR_ERROR(dwError); if (!IsNullOrEmptyString(pszScopesVal)) { pszToken = VmDirStringTokA(pszScopesVal, INDEX_SEP, &save); while (pszToken) { dwError = VmDirAllocateStringA(pszToken, &pszScope); BAIL_ON_VMDIR_ERROR(dwError); dwError = LwRtlHashMapInsert( pIndexCfg->pUniqScopes, pszScope, NULL, NULL); BAIL_ON_VMDIR_ERROR(dwError); pszScope = NULL; pszToken = VmDirStringTokA(NULL, INDEX_SEP, &save); } } dwError = pBECtx->pBE->pfnBEUniqKeyGetValue( pBECtx, pszNewScopesKey, &pszNewScopesVal); BAIL_ON_VMDIR_ERROR(dwError); if (!IsNullOrEmptyString(pszNewScopesVal)) { pszToken = VmDirStringTokA(pszNewScopesVal, INDEX_SEP, &save); while (pszToken) { dwError = VmDirAllocateStringA(pszToken, &pszScope); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirLinkedListInsertHead( pIndexCfg->pNewUniqScopes, pszScope, NULL); BAIL_ON_VMDIR_ERROR(dwError); pszScope = NULL; pszToken = VmDirStringTokA(NULL, INDEX_SEP, &save); } } dwError = pBECtx->pBE->pfnBEUniqKeyGetValue( pBECtx, pszDelScopesKey, &pszDelScopesVal); BAIL_ON_VMDIR_ERROR(dwError); if (!IsNullOrEmptyString(pszDelScopesVal)) { pszToken = VmDirStringTokA(pszDelScopesVal, INDEX_SEP, &save); while (pszToken) { dwError = VmDirAllocateStringA(pszToken, &pszScope); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirLinkedListInsertHead( pIndexCfg->pDelUniqScopes, pszScope, NULL); BAIL_ON_VMDIR_ERROR(dwError); pszScope = NULL; pszToken = VmDirStringTokA(NULL, INDEX_SEP, &save); } } *pbRestore = TRUE; } cleanup: VMDIR_SAFE_FREE_MEMORY(pszStatusKey); VMDIR_SAFE_FREE_MEMORY(pszStatusVal); VMDIR_SAFE_FREE_MEMORY(pszInitOffsetKey); VMDIR_SAFE_FREE_MEMORY(pszInitOffsetVal); VMDIR_SAFE_FREE_MEMORY(pszScopesKey); VMDIR_SAFE_FREE_MEMORY(pszScopesVal); VMDIR_SAFE_FREE_MEMORY(pszNewScopesKey); VMDIR_SAFE_FREE_MEMORY(pszNewScopesVal); VMDIR_SAFE_FREE_MEMORY(pszDelScopesKey); VMDIR_SAFE_FREE_MEMORY(pszDelScopesVal); return dwError; error: VMDIR_LOG_ERROR( VMDIR_LOG_MASK_ALL, "%s failed, error (%d)", __FUNCTION__, dwError ); VMDIR_SAFE_FREE_MEMORY(pszScope); goto cleanup; }