PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ DBFWriteAttributeDirectly()

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

Definition at line 1446 of file dbfopen.c.

1449 {
1450  int i, j;
1451  unsigned char *pabyRec;
1452 
1453 /* -------------------------------------------------------------------- */
1454 /* Is this a valid record? */
1455 /* -------------------------------------------------------------------- */
1456  if( hEntity < 0 || hEntity > psDBF->nRecords )
1457  return( FALSE );
1458 
1459  if( psDBF->bNoHeader )
1460  DBFWriteHeader(psDBF);
1461 
1462 /* -------------------------------------------------------------------- */
1463 /* Is this a brand new record? */
1464 /* -------------------------------------------------------------------- */
1465  if( hEntity == psDBF->nRecords )
1466  {
1467  if( !DBFFlushRecord( psDBF ) )
1468  return FALSE;
1469 
1470  psDBF->nRecords++;
1471  for( i = 0; i < psDBF->nRecordLength; i++ )
1472  psDBF->pszCurrentRecord[i] = ' ';
1473 
1474  psDBF->nCurrentRecord = hEntity;
1475  }
1476 
1477 /* -------------------------------------------------------------------- */
1478 /* Is this an existing record, but different than the last one */
1479 /* we accessed? */
1480 /* -------------------------------------------------------------------- */
1481  if( !DBFLoadRecord( psDBF, hEntity ) )
1482  return FALSE;
1483 
1484  pabyRec = REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord);
1485 
1486 /* -------------------------------------------------------------------- */
1487 /* Assign all the record fields. */
1488 /* -------------------------------------------------------------------- */
1489  if( STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))) > psDBF->panFieldSize[iField] )
1490  j = psDBF->panFieldSize[iField];
1491  else
1492  {
1493  memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
1494  psDBF->panFieldSize[iField] );
1495  j = STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue)));
1496  }
1497 
1498  strncpy(REINTERPRET_CAST(char *, pabyRec+psDBF->panFieldOffset[iField]),
1499  STATIC_CAST(const char *, pValue), j );
1500 
1501  psDBF->bCurrentRecordModified = TRUE;
1502  psDBF->bUpdated = TRUE;
1503 
1504  return( TRUE );
1505 }
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: