PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ DBFWriteAttributeDirectly()

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

Definition at line 1437 of file dbfopen.c.

1440 {
1441  int i, j;
1442  unsigned char *pabyRec;
1443 
1444 /* -------------------------------------------------------------------- */
1445 /* Is this a valid record? */
1446 /* -------------------------------------------------------------------- */
1447  if( hEntity < 0 || hEntity > psDBF->nRecords )
1448  return( FALSE );
1449 
1450  if( psDBF->bNoHeader )
1451  DBFWriteHeader(psDBF);
1452 
1453 /* -------------------------------------------------------------------- */
1454 /* Is this a brand new record? */
1455 /* -------------------------------------------------------------------- */
1456  if( hEntity == psDBF->nRecords )
1457  {
1458  if( !DBFFlushRecord( psDBF ) )
1459  return FALSE;
1460 
1461  psDBF->nRecords++;
1462  for( i = 0; i < psDBF->nRecordLength; i++ )
1463  psDBF->pszCurrentRecord[i] = ' ';
1464 
1465  psDBF->nCurrentRecord = hEntity;
1466  }
1467 
1468 /* -------------------------------------------------------------------- */
1469 /* Is this an existing record, but different than the last one */
1470 /* we accessed? */
1471 /* -------------------------------------------------------------------- */
1472  if( !DBFLoadRecord( psDBF, hEntity ) )
1473  return FALSE;
1474 
1475  pabyRec = REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord);
1476 
1477 /* -------------------------------------------------------------------- */
1478 /* Assign all the record fields. */
1479 /* -------------------------------------------------------------------- */
1480  if( STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))) > psDBF->panFieldSize[iField] )
1481  j = psDBF->panFieldSize[iField];
1482  else
1483  {
1484  memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
1485  psDBF->panFieldSize[iField] );
1486  j = STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue)));
1487  }
1488 
1489  strncpy(REINTERPRET_CAST(char *, pabyRec+psDBF->panFieldOffset[iField]),
1490  STATIC_CAST(const char *, pValue), j );
1491 
1492  psDBF->bCurrentRecordModified = TRUE;
1493  psDBF->bUpdated = TRUE;
1494 
1495  return( TRUE );
1496 }
static int DBFLoadRecord(DBFHandle psDBF, int iRecord)
Definition: dbfopen.c:257
#define STATIC_CAST(type, x)
Definition: dbfopen.c:96
#define REINTERPRET_CAST(type, x)
Definition: dbfopen.c:97
static void DBFWriteHeader(DBFHandle psDBF)
Definition: dbfopen.c:127
#define TRUE
Definition: dbfopen.c:73
#define FALSE
Definition: dbfopen.c:72
static int DBFFlushRecord(DBFHandle psDBF)
Definition: dbfopen.c:195
int nRecordLength
Definition: shapefil.h:596
int * panFieldOffset
Definition: shapefil.h:601
int bUpdated
Definition: shapefil.h:616
int * panFieldSize
Definition: shapefil.h:602
char * pszCurrentRecord
Definition: shapefil.h:610
int bCurrentRecordModified
Definition: shapefil.h:609
int bNoHeader
Definition: shapefil.h:615
int nRecords
Definition: shapefil.h:594
int nCurrentRecord
Definition: shapefil.h:608

References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFFlushRecord(), DBFLoadRecord(), DBFWriteHeader(), FALSE, DBFInfo::nCurrentRecord, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCurrentRecord, REINTERPRET_CAST, STATIC_CAST, and TRUE.

Referenced by ShpLoaderGenerateShapeRow().

Here is the call graph for this function:
Here is the caller graph for this function: