GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d12eea5925
dbfopen.c File Reference
#include "shapefil_private.h"
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
Include dependency graph for dbfopen.c:

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 SHPAPI_CALL DBFUpdateHeader (DBFHandle psDBF)
 
void SHPAPI_CALL DBFSetLastModifiedDate (DBFHandle psDBF, int nYYSince1900, int nMM, int nDD)
 
DBFHandle SHPAPI_CALL DBFOpen (const char *pszFilename, const char *pszAccess)
 
DBFHandle SHPAPI_CALL DBFOpenLL (const char *pszFilename, const char *pszAccess, const SAHooks *psHooks)
 
void SHPAPI_CALL DBFClose (DBFHandle psDBF)
 
DBFHandle SHPAPI_CALL DBFCreate (const char *pszFilename)
 
DBFHandle SHPAPI_CALL DBFCreateEx (const char *pszFilename, const char *pszCodePage)
 
DBFHandle SHPAPI_CALL DBFCreateLL (const char *pszFilename, const char *pszCodePage, const SAHooks *psHooks)
 
int SHPAPI_CALL DBFAddField (DBFHandle psDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals)
 
int SHPAPI_CALL DBFAddNativeFieldType (DBFHandle psDBF, const char *pszFieldName, char chType, int nWidth, int nDecimals)
 
int SHPAPI_CALL DBFReadIntegerAttribute (DBFHandle psDBF, int iRecord, int iField)
 
double SHPAPI_CALL DBFReadDoubleAttribute (DBFHandle psDBF, int iRecord, int iField)
 
const char SHPAPI_CALL1DBFReadStringAttribute (DBFHandle psDBF, int iRecord, int iField){ return STATIC_CAST(const char *, DBFReadAttribute(psDBF, iRecord, iField, 'C')
 
const char SHPAPI_CALL1DBFReadLogicalAttribute (DBFHandle psDBF, int iRecord, int iField){ return STATIC_CAST(const char *, DBFReadAttribute(psDBF, iRecord, iField, 'L')
 
SHPDate SHPAPI_CALL DBFReadDateAttribute (DBFHandle psDBF, int iRecord, int iField)
 
int SHPAPI_CALL DBFIsAttributeNULL (const DBFHandle psDBF, int iRecord, int iField)
 
int SHPAPI_CALL DBFGetFieldCount (const DBFHandle psDBF)
 
int SHPAPI_CALL DBFGetRecordCount (const DBFHandle psDBF)
 
DBFFieldType SHPAPI_CALL DBFGetFieldInfo (const DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals)
 
int SHPAPI_CALL DBFWriteAttributeDirectly (DBFHandle psDBF, int hEntity, int iField, const void *pValue)
 
int SHPAPI_CALL DBFWriteDoubleAttribute (DBFHandle psDBF, int iRecord, int iField, double dValue)
 
int SHPAPI_CALL DBFWriteIntegerAttribute (DBFHandle psDBF, int iRecord, int iField, int nValue)
 
int SHPAPI_CALL DBFWriteStringAttribute (DBFHandle psDBF, int iRecord, int iField, const char *pszValue)
 
int SHPAPI_CALL DBFWriteNULLAttribute (DBFHandle psDBF, int iRecord, int iField)
 
int SHPAPI_CALL DBFWriteLogicalAttribute (DBFHandle psDBF, int iRecord, int iField, const char lValue)
 
int SHPAPI_CALL DBFWriteDateAttribute (DBFHandle psDBF, int iRecord, int iField, const SHPDate *lValue)
 
int SHPAPI_CALL DBFWriteTuple (DBFHandle psDBF, int hEntity, const void *pRawTuple)
 
const char SHPAPI_CALL1DBFReadTuple (DBFHandle psDBF, int hEntity){ if(hEntity< 0||hEntity >=psDBF->nRecords) return SHPLIB_NULLPTR;if(!DBFLoadRecord(psDBF, hEntity)) return SHPLIB_NULLPTR;return STATIC_CAST(const char *, psDBF->pszCurrentRecord
 
DBFHandle SHPAPI_CALL DBFCloneEmpty (const DBFHandle psDBF, const char *pszFilename)
 
char SHPAPI_CALL DBFGetNativeFieldType (const DBFHandle psDBF, int iField)
 
int SHPAPI_CALL DBFGetFieldIndex (const DBFHandle psDBF, const char *pszFieldName)
 
int SHPAPI_CALL DBFIsRecordDeleted (const DBFHandle psDBF, int iShape)
 
int SHPAPI_CALL DBFMarkRecordDeleted (DBFHandle psDBF, int iShape, int bIsDeleted)
 
const char SHPAPI_CALL1DBFGetCodePage (const DBFHandle psDBF){ if(psDBF==SHPLIB_NULLPTR) return SHPLIB_NULLPTR;return psDBF->pszCodePage;}int SHPAPI_CALL DBFDeleteField(DBFHandle psDBF, int iField
 
int SHPAPI_CALL DBFReorderFields (DBFHandle psDBF, const int *panMap)
 
int SHPAPI_CALL DBFAlterFieldDefn (DBFHandle psDBF, int iField, const char *pszFieldName, char chType, int nWidth, int nDecimals)
 
void SHPAPI_CALL DBFSetWriteEndOfFileChar (DBFHandle psDBF, int bWriteFlag)
 

Macro Definition Documentation

◆ CPL_IGNORE_RET_VAL_INT

#define CPL_IGNORE_RET_VAL_INT (   x)    x

Definition at line 68 of file dbfopen.c.

◆ CPLsnprintf

#define CPLsnprintf   snprintf

Definition at line 47 of file dbfopen.c.

◆ CPLsprintf

#define CPLsprintf   sprintf

Definition at line 46 of file dbfopen.c.

◆ END_OF_FILE_CHARACTER

#define END_OF_FILE_CHARACTER   0x1A

Definition at line 61 of file dbfopen.c.

◆ FALSE

#define FALSE   0

Definition at line 51 of file dbfopen.c.

◆ HEADER_RECORD_TERMINATOR

#define HEADER_RECORD_TERMINATOR   0x0D

Definition at line 58 of file dbfopen.c.

◆ STRCASECMP

#define STRCASECMP (   a,
  b 
)    (strcasecmp(a, b))

Definition at line 33 of file dbfopen.c.

◆ TRUE

#define TRUE   1

Definition at line 52 of file dbfopen.c.

◆ XBASE_FILEHDR_SZ

#define XBASE_FILEHDR_SZ   32

Definition at line 56 of file dbfopen.c.

Function Documentation

◆ DBFAddField()

int SHPAPI_CALL DBFAddField ( DBFHandle  psDBF,
const char *  pszFieldName,
DBFFieldType  eType,
int  nWidth,
int  nDecimals 
)

Definition at line 690 of file dbfopen.c.

References DBFAddNativeFieldType(), FTDate, FTLogical, and FTString.

◆ DBFAddNativeFieldType()

int SHPAPI_CALL DBFAddNativeFieldType ( DBFHandle  psDBF,
const char *  pszFieldName,
char  chType,
int  nWidth,
int  nDecimals 
)

Definition at line 734 of file dbfopen.c.

Referenced by DBFAddField().

◆ DBFAlterFieldDefn()

int SHPAPI_CALL DBFAlterFieldDefn ( DBFHandle  psDBF,
int  iField,
const char *  pszFieldName,
char  chType,
int  nWidth,
int  nDecimals 
)

Definition at line 1995 of file dbfopen.c.

References FALSE, and DBFInfo::nFields.

◆ DBFCloneEmpty()

◆ DBFClose()

void SHPAPI_CALL DBFClose ( DBFHandle  psDBF)

Definition at line 522 of file dbfopen.c.

References DBFInfo::bNoHeader, and SHPLIB_NULLPTR.

◆ DBFCreate()

DBFHandle SHPAPI_CALL DBFCreate ( const char *  pszFilename)

Definition at line 570 of file dbfopen.c.

References DBFCreateEx().

◆ DBFCreateEx()

DBFHandle SHPAPI_CALL DBFCreateEx ( const char *  pszFilename,
const char *  pszCodePage 
)

Definition at line 581 of file dbfopen.c.

References DBFCreateLL(), and SASetupDefaultHooks().

Referenced by DBFCreate().

◆ DBFCreateLL()

DBFHandle SHPAPI_CALL DBFCreateLL ( const char *  pszFilename,
const char *  pszCodePage,
const SAHooks psHooks 
)

Definition at line 597 of file dbfopen.c.

Referenced by DBFCloneEmpty(), and DBFCreateEx().

◆ DBFGetCodePage()

const char SHPAPI_CALL1* DBFGetCodePage ( const DBFHandle  psDBF)

Definition at line 1737 of file dbfopen.c.

References SHPLIB_NULLPTR.

◆ DBFGetFieldCount()

int SHPAPI_CALL DBFGetFieldCount ( const DBFHandle  psDBF)

Definition at line 1152 of file dbfopen.c.

References DBFInfo::nFields.

Referenced by DBFGetFieldIndex().

◆ DBFGetFieldIndex()

int SHPAPI_CALL DBFGetFieldIndex ( const DBFHandle  psDBF,
const char *  pszFieldName 
)

◆ DBFGetFieldInfo()

DBFFieldType SHPAPI_CALL DBFGetFieldInfo ( const DBFHandle  psDBF,
int  iField,
char *  pszFieldName,
int *  pnWidth,
int *  pnDecimals 
)

◆ DBFGetNativeFieldType()

char SHPAPI_CALL DBFGetNativeFieldType ( const DBFHandle  psDBF,
int  iField 
)

Definition at line 1639 of file dbfopen.c.

References DBFInfo::pachFieldType.

◆ DBFGetRecordCount()

int SHPAPI_CALL DBFGetRecordCount ( const DBFHandle  psDBF)

Definition at line 1163 of file dbfopen.c.

References DBFInfo::nRecords.

◆ DBFIsAttributeNULL()

int SHPAPI_CALL DBFIsAttributeNULL ( const DBFHandle  psDBF,
int  iRecord,
int  iField 
)

Definition at line 1135 of file dbfopen.c.

References DBFReadStringAttribute(), SHPLIB_NULLPTR, and TRUE.

◆ DBFIsRecordDeleted()

int SHPAPI_CALL DBFIsRecordDeleted ( const DBFHandle  psDBF,
int  iShape 
)

Definition at line 1675 of file dbfopen.c.

References DBFInfo::nRecords, and TRUE.

◆ DBFMarkRecordDeleted()

int SHPAPI_CALL DBFMarkRecordDeleted ( DBFHandle  psDBF,
int  iShape,
int  bIsDeleted 
)

Definition at line 1699 of file dbfopen.c.

References FALSE, and DBFInfo::nRecords.

◆ DBFOpen()

DBFHandle SHPAPI_CALL DBFOpen ( const char *  pszFilename,
const char *  pszAccess 
)

Definition at line 296 of file dbfopen.c.

References DBFOpenLL(), and SASetupDefaultHooks().

◆ DBFOpenLL()

DBFHandle SHPAPI_CALL DBFOpenLL ( const char *  pszFilename,
const char *  pszAccess,
const SAHooks psHooks 
)

Definition at line 327 of file dbfopen.c.

References SHPLIB_NULLPTR.

Referenced by DBFOpen().

◆ DBFReadDateAttribute()

SHPDate SHPAPI_CALL DBFReadDateAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField 
)

Definition at line 1053 of file dbfopen.c.

References STATIC_CAST.

◆ DBFReadDoubleAttribute()

double SHPAPI_CALL DBFReadDoubleAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField 
)

Definition at line 1009 of file dbfopen.c.

References STATIC_CAST.

◆ DBFReadIntegerAttribute()

int SHPAPI_CALL DBFReadIntegerAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField 
)

Definition at line 991 of file dbfopen.c.

References STATIC_CAST.

◆ DBFReadLogicalAttribute()

const char SHPAPI_CALL1* DBFReadLogicalAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField 
) const

References STATIC_CAST.

◆ DBFReadStringAttribute()

const char SHPAPI_CALL1* DBFReadStringAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField 
) const

References STATIC_CAST.

Referenced by DBFIsAttributeNULL().

◆ DBFReadTuple()

const char SHPAPI_CALL1* DBFReadTuple ( DBFHandle  psDBF,
int  hEntity 
) -> nRecords) return SHPLIB_NULLPTR;if(!DBFLoadRecord(psDBF, hEntity)) return SHPLIB_NULLPTR;return STATIC_CAST(const char *, psDBF->pszCurrentRecord

References SHPLIB_NULLPTR.

◆ DBFReorderFields()

int SHPAPI_CALL DBFReorderFields ( DBFHandle  psDBF,
const int *  panMap 
)

Definition at line 1875 of file dbfopen.c.

References DBFInfo::nFields, and TRUE.

◆ DBFSetLastModifiedDate()

void SHPAPI_CALL DBFSetLastModifiedDate ( DBFHandle  psDBF,
int  nYYSince1900,
int  nMM,
int  nDD 
)

◆ DBFSetWriteEndOfFileChar()

void SHPAPI_CALL DBFSetWriteEndOfFileChar ( DBFHandle  psDBF,
int  bWriteFlag 
)

Definition at line 2232 of file dbfopen.c.

References DBFInfo::bWriteEndOfFileChar.

◆ DBFUpdateHeader()

void SHPAPI_CALL DBFUpdateHeader ( DBFHandle  psDBF)

Definition at line 248 of file dbfopen.c.

References DBFInfo::bNoHeader.

◆ DBFWriteAttributeDirectly()

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

Definition at line 1350 of file dbfopen.c.

References DBFInfo::bNoHeader, FALSE, and DBFInfo::nRecords.

Referenced by DBFWriteDateAttribute().

◆ DBFWriteDateAttribute()

int SHPAPI_CALL DBFWriteDateAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField,
const SHPDate lValue 
)

◆ DBFWriteDoubleAttribute()

int SHPAPI_CALL DBFWriteDoubleAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField,
double  dValue 
)

Definition at line 1419 of file dbfopen.c.

◆ DBFWriteIntegerAttribute()

int SHPAPI_CALL DBFWriteIntegerAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField,
int  nValue 
)

Definition at line 1432 of file dbfopen.c.

◆ DBFWriteLogicalAttribute()

int SHPAPI_CALL DBFWriteLogicalAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField,
const char  lValue 
)

Definition at line 1472 of file dbfopen.c.

◆ DBFWriteNULLAttribute()

int SHPAPI_CALL DBFWriteNULLAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField 
)

Definition at line 1461 of file dbfopen.c.

◆ DBFWriteStringAttribute()

int SHPAPI_CALL DBFWriteStringAttribute ( DBFHandle  psDBF,
int  iRecord,
int  iField,
const char *  pszValue 
)

Definition at line 1447 of file dbfopen.c.

◆ DBFWriteTuple()

int SHPAPI_CALL DBFWriteTuple ( DBFHandle  psDBF,
int  hEntity,
const void *  pRawTuple 
)

Definition at line 1510 of file dbfopen.c.

References DBFInfo::bNoHeader, FALSE, and DBFInfo::nRecords.