|
GRASS 8 Programmer's Manual 8.6.0dev(2026)-763b17e9a5
|
#include "shapefil_private.h"#include <assert.h>#include <errno.h>#include <math.h>#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include <string.h>#include <strings.h>
Go to the source code of this file.
Macros | |
| #define | STRCASECMP(a, b) (strcasecmp(a, b)) |
| #define | CPLsprintf sprintf |
| #define | CPLsnprintf snprintf |
| #define | FALSE 0 |
| #define | TRUE 1 |
| #define | XBASE_FILEHDR_SZ 32 |
| #define | HEADER_RECORD_TERMINATOR 0x0D |
| #define | END_OF_FILE_CHARACTER 0x1A |
| #define | CPL_IGNORE_RET_VAL_INT(x) x |
Functions | |
| void | DBFUpdateHeader (DBFHandle psDBF) |
| void | DBFSetLastModifiedDate (DBFHandle psDBF, int nYYSince1900, int nMM, int nDD) |
| DBFHandle | DBFOpen (const char *pszFilename, const char *pszAccess) |
| DBFHandle | DBFOpenLL (const char *pszFilename, const char *pszAccess, const SAHooks *psHooks) |
| void | DBFClose (DBFHandle psDBF) |
| DBFHandle | DBFCreate (const char *pszFilename) |
| DBFHandle | DBFCreateEx (const char *pszFilename, const char *pszCodePage) |
| DBFHandle | DBFCreateLL (const char *pszFilename, const char *pszCodePage, const SAHooks *psHooks) |
| int | DBFAddField (DBFHandle psDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals) |
| int | DBFAddNativeFieldType (DBFHandle psDBF, const char *pszFieldName, char chType, int nWidth, int nDecimals) |
| int | DBFReadIntegerAttribute (DBFHandle psDBF, int iRecord, int iField) |
| double | DBFReadDoubleAttribute (DBFHandle psDBF, int iRecord, int iField) |
| const char * | DBFReadStringAttribute (DBFHandle psDBF, int iRecord, int iField) |
| const char * | DBFReadLogicalAttribute (DBFHandle psDBF, int iRecord, int iField) |
| SHPDate | DBFReadDateAttribute (DBFHandle psDBF, int iRecord, int iField) |
| int | DBFIsAttributeNULL (const DBFHandle psDBF, int iRecord, int iField) |
| int | DBFGetFieldCount (const DBFHandle psDBF) |
| int | DBFGetRecordCount (const DBFHandle psDBF) |
| DBFFieldType | DBFGetFieldInfo (const DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals) |
| int | DBFWriteAttributeDirectly (DBFHandle psDBF, int hEntity, int iField, const void *pValue) |
| int | DBFWriteDoubleAttribute (DBFHandle psDBF, int iRecord, int iField, double dValue) |
| int | DBFWriteIntegerAttribute (DBFHandle psDBF, int iRecord, int iField, int nValue) |
| int | DBFWriteStringAttribute (DBFHandle psDBF, int iRecord, int iField, const char *pszValue) |
| int | DBFWriteNULLAttribute (DBFHandle psDBF, int iRecord, int iField) |
| int | DBFWriteLogicalAttribute (DBFHandle psDBF, int iRecord, int iField, const char lValue) |
| int | DBFWriteDateAttribute (DBFHandle psDBF, int iRecord, int iField, const SHPDate *lValue) |
| int | DBFWriteTuple (DBFHandle psDBF, int hEntity, const void *pRawTuple) |
| const char * | DBFReadTuple (DBFHandle psDBF, int hEntity) |
| DBFHandle | DBFCloneEmpty (const DBFHandle psDBF, const char *pszFilename) |
| char | DBFGetNativeFieldType (const DBFHandle psDBF, int iField) |
| int | DBFGetFieldIndex (const DBFHandle psDBF, const char *pszFieldName) |
| int | DBFIsRecordDeleted (const DBFHandle psDBF, int iShape) |
| int | DBFMarkRecordDeleted (DBFHandle psDBF, int iShape, int bIsDeleted) |
| const char * | DBFGetCodePage (const DBFHandle psDBF) |
| int | DBFDeleteField (DBFHandle psDBF, int iField) |
| int | DBFReorderFields (DBFHandle psDBF, const int *panMap) |
| int | DBFAlterFieldDefn (DBFHandle psDBF, int iField, const char *pszFieldName, char chType, int nWidth, int nDecimals) |
| void | DBFSetWriteEndOfFileChar (DBFHandle psDBF, int bWriteFlag) |
| int DBFAddField | ( | DBFHandle | psDBF, |
| const char * | pszFieldName, | ||
| DBFFieldType | eType, | ||
| int | nWidth, | ||
| int | nDecimals | ||
| ) |
| int DBFAddNativeFieldType | ( | DBFHandle | psDBF, |
| const char * | pszFieldName, | ||
| char | chType, | ||
| int | nWidth, | ||
| int | nDecimals | ||
| ) |
Definition at line 795 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFInfo::bWriteEndOfFileChar, DBFUpdateHeader(), END_OF_FILE_CHARACTER, SAHooks::Error, FALSE, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, DBFInfo::sHooks, SHPLIB_NULLPTR, STATIC_CAST, TRUE, XBASE_FLD_MAX_WIDTH, XBASE_FLDHDR_SZ, and XBASE_FLDNAME_LEN_WRITE.
Referenced by DBFAddField().
| int DBFAlterFieldDefn | ( | DBFHandle | psDBF, |
| int | iField, | ||
| const char * | pszFieldName, | ||
| char | chType, | ||
| int | nWidth, | ||
| int | nDecimals | ||
| ) |
Definition at line 2109 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFInfo::bWriteEndOfFileChar, DBFUpdateHeader(), END_OF_FILE_CHARACTER, FALSE, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, DBFInfo::sHooks, STATIC_CAST, TRUE, XBASE_FLD_MAX_WIDTH, XBASE_FLDHDR_SZ, and XBASE_FLDNAME_LEN_WRITE.
Definition at line 1680 of file dbfopen.c.
References DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFInfo::bWriteEndOfFileChar, DBFClose(), DBFCreateLL(), DBFOpen(), DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszHeader, DBFInfo::sHooks, SHPLIB_NULLPTR, STATIC_CAST, TRUE, and XBASE_FLDHDR_SZ.
| void DBFClose | ( | DBFHandle | psDBF | ) |
Definition at line 568 of file dbfopen.c.
References DBFInfo::bNoHeader, DBFInfo::bUpdated, CPL_IGNORE_RET_VAL_INT, DBFUpdateHeader(), SAHooks::FClose, DBFInfo::fp, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, DBFInfo::pszWorkField, DBFInfo::sHooks, and SHPLIB_NULLPTR.
Referenced by DBFCloneEmpty(), and DBFOpenLL().
| DBFHandle DBFCreate | ( | const char * | pszFilename | ) |
Definition at line 616 of file dbfopen.c.
References DBFCreateEx().
| DBFHandle DBFCreateEx | ( | const char * | pszFilename, |
| const char * | pszCodePage | ||
| ) |
Definition at line 627 of file dbfopen.c.
References DBFCreateLL(), and SASetupDefaultHooks().
Referenced by DBFCreate().
| DBFHandle DBFCreateLL | ( | const char * | pszFilename, |
| const char * | pszCodePage, | ||
| const SAHooks * | psHooks | ||
| ) |
Definition at line 643 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bRequireNextWriteSeek, CONST_CAST, DBFSetLastModifiedDate(), DBFSetWriteEndOfFileChar(), SAHooks::Error, FALSE, SAHooks::FClose, SAHooks::FOpen, DBFInfo::fp, SAHooks::FWrite, DBFInfo::iLanguageDriver, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, SAHooks::pvUserData, SAHooks::Remove, DBFInfo::sHooks, SHPLIB_NULLPTR, STATIC_CAST, strcpy, TRUE, and XBASE_FILEHDR_SZ.
Referenced by DBFCloneEmpty(), and DBFCreateEx().
| int DBFDeleteField | ( | DBFHandle | psDBF, |
| int | iField | ||
| ) |
Definition at line 1847 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFInfo::bWriteEndOfFileChar, DBFUpdateHeader(), END_OF_FILE_CHARACTER, FALSE, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, DBFInfo::sHooks, STATIC_CAST, TRUE, and XBASE_FLDHDR_SZ.
| const char * DBFGetCodePage | ( | const DBFHandle | psDBF | ) |
Definition at line 1834 of file dbfopen.c.
References SHPLIB_NULLPTR.
| int DBFGetFieldCount | ( | const DBFHandle | psDBF | ) |
Definition at line 1253 of file dbfopen.c.
References DBFInfo::nFields.
Referenced by DBFGetFieldIndex().
| int DBFGetFieldIndex | ( | const DBFHandle | psDBF, |
| const char * | pszFieldName | ||
| ) |
Definition at line 1756 of file dbfopen.c.
References DBFGetFieldCount(), DBFGetFieldInfo(), name, SHPLIB_NULLPTR, STRCASECMP, and XBASE_FLDNAME_LEN_READ.
| DBFFieldType DBFGetFieldInfo | ( | const DBFHandle | psDBF, |
| int | iField, | ||
| char * | pszFieldName, | ||
| int * | pnWidth, | ||
| int * | pnDecimals | ||
| ) |
Definition at line 1277 of file dbfopen.c.
References FTDate, FTDouble, FTInteger, FTInvalid, FTLogical, FTString, DBFInfo::nFields, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldSize, DBFInfo::pszHeader, SHPLIB_NULLPTR, STATIC_CAST, XBASE_FLDHDR_SZ, and XBASE_FLDNAME_LEN_READ.
Referenced by DBFGetFieldIndex().
| char DBFGetNativeFieldType | ( | const DBFHandle | psDBF, |
| int | iField | ||
| ) |
Definition at line 1740 of file dbfopen.c.
References DBFInfo::pachFieldType.
| int DBFGetRecordCount | ( | const DBFHandle | psDBF | ) |
Definition at line 1264 of file dbfopen.c.
References DBFInfo::nRecords.
| int DBFIsAttributeNULL | ( | const DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField | ||
| ) |
Definition at line 1235 of file dbfopen.c.
References DBFReadStringAttribute(), DBFInfo::pachFieldType, DBFInfo::panFieldSize, SHPLIB_NULLPTR, and TRUE.
| int DBFIsRecordDeleted | ( | const DBFHandle | psDBF, |
| int | iShape | ||
| ) |
Definition at line 1776 of file dbfopen.c.
References FALSE, DBFInfo::nRecords, DBFInfo::pszCurrentRecord, and TRUE.
| int DBFMarkRecordDeleted | ( | DBFHandle | psDBF, |
| int | iShape, | ||
| int | bIsDeleted | ||
| ) |
Definition at line 1800 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bUpdated, FALSE, DBFInfo::nRecords, DBFInfo::pszCurrentRecord, and TRUE.
| DBFHandle DBFOpen | ( | const char * | pszFilename, |
| const char * | pszAccess | ||
| ) |
Definition at line 300 of file dbfopen.c.
References DBFOpenLL(), and SASetupDefaultHooks().
Referenced by DBFCloneEmpty().
Definition at line 331 of file dbfopen.c.
References assert, DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bRequireNextWriteSeek, DBFClose(), DBFSetLastModifiedDate(), DBFSetWriteEndOfFileChar(), FALSE, SAHooks::FClose, SAHooks::FOpen, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, HEADER_RECORD_TERMINATOR, DBFInfo::iLanguageDriver, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszCurrentRecord, DBFInfo::pszHeader, SAHooks::pvUserData, REINTERPRET_CAST, DBFInfo::sHooks, SHPLIB_NULLPTR, STATIC_CAST, strcpy, TRUE, XBASE_FILEHDR_SZ, and XBASE_FLDHDR_SZ.
Referenced by DBFOpen().
Definition at line 1146 of file dbfopen.c.
References SHPDate::day, SHPDate::month, SHPLIB_NULLPTR, STATIC_CAST, and SHPDate::year.
| double DBFReadDoubleAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField | ||
| ) |
Definition at line 1102 of file dbfopen.c.
References SHPLIB_NULLPTR, and STATIC_CAST.
| int DBFReadIntegerAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField | ||
| ) |
Definition at line 1084 of file dbfopen.c.
References SHPLIB_NULLPTR, and STATIC_CAST.
| const char * DBFReadLogicalAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField | ||
| ) |
Definition at line 1134 of file dbfopen.c.
References STATIC_CAST.
| const char * DBFReadStringAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField | ||
| ) |
Definition at line 1121 of file dbfopen.c.
References STATIC_CAST.
Referenced by DBFIsAttributeNULL().
| const char * DBFReadTuple | ( | DBFHandle | psDBF, |
| int | hEntity | ||
| ) |
Definition at line 1662 of file dbfopen.c.
References SHPLIB_NULLPTR, and STATIC_CAST.
| int DBFReorderFields | ( | DBFHandle | psDBF, |
| const int * | panMap | ||
| ) |
Definition at line 1972 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFUpdateHeader(), SAHooks::Error, FALSE, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nCurrentRecord, DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszHeader, DBFInfo::sHooks, SHPLIB_NULLPTR, STATIC_CAST, TRUE, and XBASE_FLDHDR_SZ.
| void DBFSetLastModifiedDate | ( | DBFHandle | psDBF, |
| int | nYYSince1900, | ||
| int | nMM, | ||
| int | nDD | ||
| ) |
Definition at line 286 of file dbfopen.c.
References DBFInfo::nUpdateDay, DBFInfo::nUpdateMonth, and DBFInfo::nUpdateYearSince1900.
Referenced by DBFCreateLL(), and DBFOpenLL().
| void DBFSetWriteEndOfFileChar | ( | DBFHandle | psDBF, |
| int | bWriteFlag | ||
| ) |
Definition at line 2357 of file dbfopen.c.
References DBFInfo::bWriteEndOfFileChar.
Referenced by DBFCreateLL(), and DBFOpenLL().
| void DBFUpdateHeader | ( | DBFHandle | psDBF | ) |
Definition at line 252 of file dbfopen.c.
References DBFInfo::bNoHeader, SAHooks::FFlush, DBFInfo::fp, SAHooks::FRead, SAHooks::FSeek, SAHooks::FWrite, DBFInfo::nRecords, DBFInfo::nUpdateDay, DBFInfo::nUpdateMonth, DBFInfo::nUpdateYearSince1900, DBFInfo::sHooks, STATIC_CAST, and XBASE_FILEHDR_SZ.
Referenced by DBFAddNativeFieldType(), DBFAlterFieldDefn(), DBFClose(), DBFDeleteField(), and DBFReorderFields().
| int DBFWriteAttributeDirectly | ( | DBFHandle | psDBF, |
| int | hEntity, | ||
| int | iField, | ||
| const void * | pValue | ||
| ) |
Definition at line 1451 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, FALSE, DBFInfo::nCurrentRecord, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCurrentRecord, REINTERPRET_CAST, STATIC_CAST, and TRUE.
Referenced by DBFWriteDateAttribute().
Definition at line 1587 of file dbfopen.c.
References SHPDate::day, DBFWriteAttributeDirectly(), SHPDate::month, SHPLIB_NULLPTR, and SHPDate::year.
| int DBFWriteDoubleAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField, | ||
| double | dValue | ||
| ) |
Definition at line 1520 of file dbfopen.c.
References STATIC_CAST.
| int DBFWriteIntegerAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField, | ||
| int | nValue | ||
| ) |
Definition at line 1533 of file dbfopen.c.
References STATIC_CAST.
| int DBFWriteLogicalAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField, | ||
| const char | lValue | ||
| ) |
Definition at line 1573 of file dbfopen.c.
References CONST_CAST, and STATIC_CAST.
| int DBFWriteNULLAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField | ||
| ) |
Definition at line 1562 of file dbfopen.c.
References SHPLIB_NULLPTR.
| int DBFWriteStringAttribute | ( | DBFHandle | psDBF, |
| int | iRecord, | ||
| int | iField, | ||
| const char * | pszValue | ||
| ) |
Definition at line 1548 of file dbfopen.c.
References CONST_CAST, and STATIC_CAST.
| int DBFWriteTuple | ( | DBFHandle | psDBF, |
| int | hEntity, | ||
| const void * | pRawTuple | ||
| ) |
Definition at line 1611 of file dbfopen.c.
References DBFInfo::bCurrentRecordModified, DBFInfo::bNoHeader, DBFInfo::bUpdated, FALSE, DBFInfo::nCurrentRecord, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pszCurrentRecord, REINTERPRET_CAST, and TRUE.