In the following example, the source data for Hash Service Provider is read from a CSV file, the list of rows is created and sent to the Service Provider.
pRow = &rowSet.pRowDefine;
piRows = &rowSet.iCount;
fin = fopen(&SourceFilePath[0], "r");
iCnt = 0;
Loop through each line of the source CSV file creating the field data for each row.
Loop BEGIN
Here the rowSet is created as a List of rows and not as an Array. An application can also allocate a fixed size array of DP_ROW_DEF structures, fill it with data and pass it to Provider_Service.
if(NULL == (*pRow))
{
printf("Failed to allocate memory for the row");
goto CleanRowSet;
}
if(NULL == pData)
{
printf("Failed to allocate memory for pData");
goto CleanRowSet;
}
{
printf("Failed to allocate memory for source buffer");
goto CleanRowSet;
}
(*pRow)->pFldDataDefine = pData;
if(NULL == pData)
{
printf("Failed to allocate memory for pData");
goto CleanRowSet;
}
{
printf("Failed to allocate memory for source buffer");
goto CleanRowSet;
}
(*pRow)->pFldDataDefine->pNext = pData;
(*pRow)->sCount = 2;
iCnt++;
Loop END
After the rowSet has been created invoke the Provider to mask the source data
fclose(fin);
*piRows = iCnt;
if(ODPPSUCCESS != retVal)
{
printf("Provider service failed %d", retVal);
goto CleanRowSet;
}
Free the memory that has been allocated if an error occurred.
CleanRowSet:
pRowSet = &rowSet;
for(i = 0; ((i < pRowSet->
iCount) && (NULL != pCurRow)); i++)
{
pPrevRow = pCurRow;
for(j = 0; ((j < pCurRow->
sCount) && (NULL != pData)); j++)
{
pPrev = pData;
free(pPrev);
}
pCurRow = pCurRow->
pNext;
free(pPrevRow);
}
CleanSVCDef:
for(i = 0; i < OPERANDS_MAX_SIZE; i++)
{
if(NULL != Operands[i].PV.pWC->pParmVal)
{
free(Operands[i].PV.pWC->pParmVal);
Operands[i].PV.pWC->pParmVal = NULL;
}
}
for(i = 0; i < MAX_COLUMNS; i++)
{
if(NULL != FldDef[i].CN.pWC->pColName)
{
free(FldDef[i].CN.pWC->pColName);
FldDef[i].CN.pWC->pColName = NULL;
}
}
return retVal;