PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ DBFWriteAttributeDirectly()

int SHPAPI_CALL DBFWriteAttributeDirectly ( DBFHandle  psDBF,
int  hEntity,
int  iField,
void *  pValue 
)

Definition at line 1410 of file dbfopen.c.

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

Referenced by ShpLoaderGenerateShapeRow().

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