PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ DBFWriteAttributeDirectly()

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

Definition at line 1366 of file dbfopen.c.

1367{
1368 int i, j;
1369 unsigned char *pabyRec;
1370
1371 /* -------------------------------------------------------------------- */
1372 /* Is this a valid record? */
1373 /* -------------------------------------------------------------------- */
1374 if (hEntity < 0 || hEntity > psDBF->nRecords)
1375 return (FALSE);
1376
1377 if (psDBF->bNoHeader)
1378 DBFWriteHeader(psDBF);
1379
1380 /* -------------------------------------------------------------------- */
1381 /* Is this a brand new record? */
1382 /* -------------------------------------------------------------------- */
1383 if (hEntity == psDBF->nRecords)
1384 {
1385 if (!DBFFlushRecord(psDBF))
1386 return FALSE;
1387
1388 psDBF->nRecords++;
1389 for (i = 0; i < psDBF->nRecordLength; i++)
1390 psDBF->pszCurrentRecord[i] = ' ';
1391
1392 psDBF->nCurrentRecord = hEntity;
1393 }
1394
1395 /* -------------------------------------------------------------------- */
1396 /* Is this an existing record, but different than the last one */
1397 /* we accessed? */
1398 /* -------------------------------------------------------------------- */
1399 if (!DBFLoadRecord(psDBF, hEntity))
1400 return FALSE;
1401
1402 pabyRec = (unsigned char *)psDBF->pszCurrentRecord;
1403
1404 /* -------------------------------------------------------------------- */
1405 /* Assign all the record fields. */
1406 /* -------------------------------------------------------------------- */
1407 if ((int)strlen((char *)pValue) > psDBF->panFieldSize[iField])
1408 j = psDBF->panFieldSize[iField];
1409 else
1410 {
1411 memset(pabyRec + psDBF->panFieldOffset[iField], ' ', psDBF->panFieldSize[iField]);
1412 j = strlen((char *)pValue);
1413 }
1414
1415 memcpy((char *)(pabyRec + psDBF->panFieldOffset[iField]), (char *)pValue, j);
1416
1417 psDBF->bCurrentRecordModified = TRUE;
1418 psDBF->bUpdated = TRUE;
1419
1420 return TRUE;
1421}
static int DBFLoadRecord(DBFHandle psDBF, int iRecord)
Definition dbfopen.c:286
static void DBFWriteHeader(DBFHandle psDBF)
Definition dbfopen.c:198
#define TRUE
Definition dbfopen.c:169
#define FALSE
Definition dbfopen.c:168
static int DBFFlushRecord(DBFHandle psDBF)
Definition dbfopen.c:258

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

Referenced by ShpLoaderGenerateShapeRow().

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