In the following example, the user supplied replacement values are read from a CSV file, A Row is created containing these values and assign to pUserVal member of DP_INIT_OP_DEF.
fin = fopen(&SourceFilePath[0], "r");
Create a row and chain of replacement data fields. Assign the values read from CSV file to data fields and pass it to Provider_Init() using pUserVal member of DP_INIT_OP_DEF.
if(NULL == (*pRow))
{
printf("Failed to allocate memory for the row");
goto CleanRowDef;
}
if(NULL == pData)
{
printf("Failed to allocate memory for Data field");
goto CleanRowDef;
}
{
printf("Failed to allocate memory for source buffer");
goto CleanRowDef;
}
if(NULL == pData)
{
printf("Failed to allocate memory for pData");
goto CleanRowDef;
}
{
printf("Failed to allocate memory for source buffer");
goto CleanRowDef;
}
fclose(fin);
After the row containing replacement data values has been created, pass it to the Provider_Init() using pUserVal member of DP_INIT_OP_DEF. Assume all required operands for Lookup Service provider are provided to DP_INIT_OP_DEF, refer Provider_Init() example for more detail.
InitParameters[6].iValueSubType = 10;
InitParameters[6].pUserVal = pRow;
Free the memory that has been allocated if an error occurred.
CleanRowDef:
if(pRowDef != NULL)
{
pDpFldDataDef = pRowDef->pFldDataDefine;
while(pDpFldDataDef != NULL)
{
pPrevDataDef = pDpFldDataDef;
if(pPrevDataDef->pSrcBuf != NULL)
free(pPrevDataDef->pSrcBuf);
pDpFldDataDef = pDpFldDataDef->pNext;
free(pPrevDataDef);
}
pDpFldDataDef = NULL;
free(pRowDef);
pRowDefLkp = NULL;
}