PostGIS  2.1.10dev-r@@SVN_REVISION@@
int SHPAPI_CALL DBFWriteAttributeDirectly ( DBFHandle  psDBF,
int  hEntity,
int  iField,
void *  pValue 
)

Definition at line 1407 of file dbfopen.c.

References DBFFlushRecord(), DBFLoadRecord(), DBFWriteHeader(), and FALSE.

Referenced by ShpLoaderGenerateShapeRow().

1410 {
1411  int i, j;
1412  unsigned char *pabyRec;
1413 
1414 /* -------------------------------------------------------------------- */
1415 /* Is this a valid record? */
1416 /* -------------------------------------------------------------------- */
1417  if( hEntity < 0 || hEntity > psDBF->nRecords )
1418  return( FALSE );
1419 
1420  if( psDBF->bNoHeader )
1421  DBFWriteHeader(psDBF);
1422 
1423 /* -------------------------------------------------------------------- */
1424 /* Is this a brand new record? */
1425 /* -------------------------------------------------------------------- */
1426  if( hEntity == psDBF->nRecords )
1427  {
1428  if( !DBFFlushRecord( psDBF ) )
1429  return FALSE;
1430 
1431  psDBF->nRecords++;
1432  for( i = 0; i < psDBF->nRecordLength; i++ )
1433  psDBF->pszCurrentRecord[i] = ' ';
1434 
1435  psDBF->nCurrentRecord = hEntity;
1436  }
1437 
1438 /* -------------------------------------------------------------------- */
1439 /* Is this an existing record, but different than the last one */
1440 /* we accessed? */
1441 /* -------------------------------------------------------------------- */
1442  if( !DBFLoadRecord( psDBF, hEntity ) )
1443  return FALSE;
1444 
1445  pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
1446 
1447 /* -------------------------------------------------------------------- */
1448 /* Assign all the record fields. */
1449 /* -------------------------------------------------------------------- */
1450  if( (int)strlen((char *) pValue) > psDBF->panFieldSize[iField] )
1451  j = psDBF->panFieldSize[iField];
1452  else
1453  {
1454  memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
1455  psDBF->panFieldSize[iField] );
1456  j = strlen((char *) pValue);
1457  }
1458 
1459  strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
1460  (char *) pValue, j );
1461 
1462  psDBF->bCurrentRecordModified = TRUE;
1463  psDBF->bUpdated = TRUE;
1464 
1465  return( TRUE );
1466 }
static int DBFLoadRecord(DBFHandle psDBF, int iRecord)
Definition: dbfopen.c:292
static void DBFWriteHeader(DBFHandle psDBF)
Definition: dbfopen.c:198
static int DBFFlushRecord(DBFHandle psDBF)
Definition: dbfopen.c:259
#define FALSE
Definition: dbfopen.c:169
#define TRUE
Definition: dbfopen.c:170

Here is the call graph for this function:

Here is the caller graph for this function: