Optim Data Privacy Providers  11.3.0
 All Data Structures Files Functions Variables Macros Groups Pages
Example for Provider_FrmwInit()

The following example initializes the ODPP framework with the path of the error messages file.

RETVAL retVal; // return code
DP_FRMW_PARAMS_DEF FrmwParams; // Framework Operand
DP_INIT_OP_DEF FrmwParameter[OPERANDS_MAX_SIZE];// Array of framework initialization parameters
//Clear the Framework parameters memory
memset(&FrmwParameter, 0, sizeof(DP_INIT_OP_DEF) * OPERANDS_MAX_SIZE);
//Clear the Framework parameter definition
memset(&FrmwParams, 0, sizeof(DP_FRMW_PARAMS_DEF));
//Initialize the DP_FRMW_PARAM_DEF structure
//Parameter to set the error file path
FrmwParameter[0].usParameterID = ODPP_OPR_ERRORFILE_PATH;
//If USE_ODPP_MBCS_CHAR_CALLS is defined while building the code then mixed character(MBCS/SBCS) format will be used otherwise wide character(Unicode) format will be used
#ifndef USE_ODPP_MBCS_CHAR_CALLS
//For wide character (Unicode) format
//To indicate that Framework parameter ODPP_OPR_ERRORFILE_PATH will hold value in wide character(Unicode) format and DPPRM_VAL_WC_SS structure will be used to specify parameter value.
FrmwParameter[0].iValueSubType = PARAM_VAL_WC;
//Allocate the pWC structure
FrmwParameter[0].PV.pWC = (DPPRM_VAL_WC_SS *) malloc(sizeof(DPPRM_VAL_WC_SS));
if(NULL == FrmwParameter[0].PV.pWC)
{
printf("Failed to allocate memory for the error file path");
goto CleanFrmwParams;
}
//Clear the DPPRM_VAL_WC_SS structure
memset(FrmwParameter[0].PV.pWC, 0, sizeof(DPPRM_VAL_WC_SS));
//Set the size of the pParamVal buffer in bytes
FrmwParameter[0].iValueBufBytes = (ODPP_MAX_FILENAME_LEN + 1) * sizeof(ODPP_WCHAR);
//Allocate memory for the error file path
FrmwParameter[0].PV.pWC->pParamVal = (ODPP_WCHAR*) malloc( sizeof(ODPP_WCHAR) * ( FrmwParameter[0].iValueBufBytes / sizeof(ODPP_WCHAR)) );
if(NULL == FrmwParameter[0].PV.pWC->pParamVal)
{
printf("Failed to allocate memory for the error file path");
goto CleanFrmwParams;
}
//Set the path of the error file. make sure ODPPErrMsgs_EN.xml file is present in mentioned directory otherwise framework initialization will fail.
wcscpy(FrmwParameter[0].PV.pWC->pParamVal, L"..\\ErrorDirectory\\");
#else
//For mixed character(MBCS/SBCS) format
//To indicate that Framework parameter ODPP_OPR_ERRORFILE_PATH will hold value in mixed character(SBCS/MBCS) format and DPPRM_VAL_MC_SS structure will be used to specify parameter value.
FrmwParameter[0].iValueSubType = PARAM_VAL_MC;
//Allocate the pMC structure
FrmwParameter[0].PV.pMC = (DPPRM_VAL_MC_SS *) malloc(sizeof(DPPRM_VAL_MC_SS));
if(NULL == FrmwParameter[0].PV.pMC)
{
printf("Failed to allocate memory for the error file path");
goto CleanFrmwParams;
}
//Clear the DPPRM_VAL_MC_SS structure
memset(FrmwParameter[0].PV.pMC, 0, sizeof(DPPRM_VAL_MC_SS));
//Set the size of the pParamVal buffer in bytes
//Allocate memory for the error file path
FrmwParameter[0].PV.pMC->pParamVal = (char *) malloc( FrmwParameter[0].iValueBufBytes );
if(NULL == FrmwParameter[0].PV.pMC->pParamVal)
{
printf("Failed to allocate memory for the error file path");
goto CleanFrmwParams;;
}
//Set the path of the error file. make sure ODPPErrMsgs_EN.xml file is present in mentioned directory otherwise framework initialization will fail.
strcpy(FrmwParameter[0].PV.pMC->pParamVal, "..\\ErrorDirectory\\");
//For system default codepage
FrmwParameter[0].PV.pMC->iParamValCodePage = -1;
//DBMS type code
FrmwParameter[0].PV.pMC->cParamValDBMSType = RDB_NONE;
#endif
//Assign the parameter list to framework parameter
FrmwParams.pParams = &FrmwParameter[0];
//Set the number of framework parameter
FrmwParams.sParamCount = 1;
//Initialize the ODPP Framework
//Initialize the framework, if you do not supply any parameter then you can call Provider_FrmwInit by passing NULL.
//retVal = Provider_FrmwInit(NULL);
retVal = Provider_FrmwInit(&FrmwParams);
if(ODPPSUCCESS != retVal)
{
printf("\nFramework init failed Err=%#x\n", retVal);
goto CleanFrmwParams;
}

Free the memory allocated during Framework initialization

CleanFrmwParams:
//Free the memory allocated for framework parameter
for(sCnt=0; sCnt < FrmwParams.sParamCount; sCnt++)
{
if(NULL != (PrvDef.pPrvDetails + sCnt))
{
#ifndef USE_ODPP_MBCS_CHAR_CALLS
if(NULL != (FrmwParams.pParams + sCnt)->PV.pWC)
{
if(NULL != (FrmwParams.pParams + sCnt)->PV.pWC->pParamVal)
{
free((FrmwParams.pParams + sCnt)->PV.pWC->pParamVal);
(FrmwParams.pParams + sCnt)->PV.pWC->pParamVal = NULL;
}
free((FrmwParams.pParams + sCnt)->PV.pWC);
(FrmwParams.pParams + sCnt)->PV.pWC = NULL;
}
#else
if(NULL != (FrmwParams.pParams + sCnt)->PV.pMC)
{
if(NULL != (FrmwParams.pParams + sCnt)->PV.pMC->pParamVal)
{
free((FrmwParams.pParams + sCnt)->PV.pMC->pParamVal);
(FrmwParams.pParams + sCnt)->PV.pMC->pParamVal = NULL;
}
free((FrmwParams.pParams + sCnt)->PV.pMC);
(FrmwParams.pParams + sCnt)->PV.pMC = NULL;
}
#endif
}
}
free(FrmwParams.pParams);