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

Definition at line 1406 of file dbfopen.c.

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

Referenced by ShpLoaderGenerateShapeRow().

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