1275 int i, j, nRetResult =
TRUE;
1276 unsigned char *pabyRec;
1277 char szSField[400], szFormat[20];
1282 if( hEntity < 0 || hEntity > psDBF->nRecords )
1285 if( psDBF->bNoHeader )
1291 if( hEntity == psDBF->nRecords )
1297 for( i = 0; i < psDBF->nRecordLength; i++ )
1298 psDBF->pszCurrentRecord[i] =
' ';
1300 psDBF->nCurrentRecord = hEntity;
1310 pabyRec = (
unsigned char *) psDBF->pszCurrentRecord;
1312 psDBF->bCurrentRecordModified =
TRUE;
1313 psDBF->bUpdated =
TRUE;
1320 if( pValue == NULL )
1322 memset( (
char *) (pabyRec+psDBF->panFieldOffset[iField]),
1324 psDBF->panFieldSize[iField] );
1331 switch( psDBF->pachFieldType[iField] )
1336 if( psDBF->panFieldDecimals[iField] == 0 )
1338 int nWidth = psDBF->panFieldSize[iField];
1340 if( (
int)
sizeof(szSField)-2 < nWidth )
1341 nWidth =
sizeof(szSField)-2;
1343 sprintf( szFormat,
"%%%dd", nWidth );
1344 sprintf(szSField, szFormat, (
int) *((
double *) pValue) );
1345 if( (
int)strlen(szSField) > psDBF->panFieldSize[iField] )
1347 szSField[psDBF->panFieldSize[iField]] =
'\0';
1351 strncpy((
char *) (pabyRec+psDBF->panFieldOffset[iField]),
1352 szSField, strlen(szSField) );
1356 int nWidth = psDBF->panFieldSize[iField];
1358 if( (
int)
sizeof(szSField)-2 < nWidth )
1359 nWidth =
sizeof(szSField)-2;
1361 sprintf( szFormat,
"%%%d.%df",
1362 nWidth, psDBF->panFieldDecimals[iField] );
1363 sprintf(szSField, szFormat, *((
double *) pValue) );
1364 if( (
int) strlen(szSField) > psDBF->panFieldSize[iField] )
1366 szSField[psDBF->panFieldSize[iField]] =
'\0';
1369 strncpy((
char *) (pabyRec+psDBF->panFieldOffset[iField]),
1370 szSField, strlen(szSField) );
1375 if (psDBF->panFieldSize[iField] >= 1 &&
1376 (*(
char*)pValue ==
'F' || *(
char*)pValue ==
'T'))
1377 *(pabyRec+psDBF->panFieldOffset[iField]) = *(
char*)pValue;
1381 if( (
int) strlen((
char *) pValue) > psDBF->panFieldSize[iField] )
1383 j = psDBF->panFieldSize[iField];
1388 memset( pabyRec+psDBF->panFieldOffset[iField],
' ',
1389 psDBF->panFieldSize[iField] );
1390 j = strlen((
char *) pValue);
1393 strncpy((
char *) (pabyRec+psDBF->panFieldOffset[iField]),
1394 (
char *) pValue, j );
1398 return( nRetResult );
static int DBFLoadRecord(DBFHandle psDBF, int iRecord)
static void DBFWriteHeader(DBFHandle psDBF)
static char DBFGetNullCharacter(char chType)
static int DBFFlushRecord(DBFHandle psDBF)