ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
dbfopen.c File Reference
#include "shapefil.h"
#include <math.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
 
#define STATIC_CAST(type, x)   ((type)(x))
 
#define REINTERPRET_CAST(type, x)   ((type)(x))
 
#define CONST_CAST(type, x)   ((type)(x))
 
#define SHPLIB_NULLPTR   NULL
 

Functions

static const char * cvsid_aw ()
 
static void * SfRealloc (void *pMem, int nNewSize)
 
static void DBFWriteHeader (DBFHandle psDBF)
 
static int DBFFlushRecord (DBFHandle psDBF)
 
static int DBFLoadRecord (DBFHandle psDBF, int iRecord)
 
void DBFUpdateHeader (DBFHandle psDBF)
 
void DBFSetLastModifiedDate (DBFHandle psDBF, int nYYSince1900, int nMM, int nDD)
 
DBFHandle DBFOpen (const char *pszFilename, const char *pszAccess)
 
static int DBFGetLenWithoutExtension (const char *pszBasename)
 
DBFHandle DBFOpenLL (const char *pszFilename, const char *pszAccess, 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, SAHooks *psHooks)
 
int DBFAddField (DBFHandle psDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals)
 
static char DBFGetNullCharacter (char chType)
 
int DBFAddNativeFieldType (DBFHandle psDBF, const char *pszFieldName, char chType, int nWidth, int nDecimals)
 
static void * DBFReadAttribute (DBFHandle psDBF, int hEntity, int iField, char chReqType)
 
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)
 
static int DBFIsValueNULL (char chType, const char *pszValue)
 
int DBFIsAttributeNULL (DBFHandle psDBF, int iRecord, int iField)
 
int DBFGetFieldCount (DBFHandle psDBF)
 
int DBFGetRecordCount (DBFHandle psDBF)
 
DBFFieldType DBFGetFieldInfo (DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals)
 
static int DBFWriteAttribute (DBFHandle psDBF, int hEntity, int iField, void *pValue)
 
int DBFWriteAttributeDirectly (DBFHandle psDBF, int hEntity, int iField, 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 DBFWriteTuple (DBFHandle psDBF, int hEntity, void *pRawTuple)
 
const char * DBFReadTuple (DBFHandle psDBF, int hEntity)
 
DBFHandle DBFCloneEmpty (DBFHandle psDBF, const char *pszFilename)
 
char DBFGetNativeFieldType (DBFHandle psDBF, int iField)
 
int DBFGetFieldIndex (DBFHandle psDBF, const char *pszFieldName)
 
int DBFIsRecordDeleted (DBFHandle psDBF, int iShape)
 
int DBFMarkRecordDeleted (DBFHandle psDBF, int iShape, int bIsDeleted)
 
const char * DBFGetCodePage (DBFHandle psDBF)
 
int DBFDeleteField (DBFHandle psDBF, int iField)
 
int DBFReorderFields (DBFHandle psDBF, int *panMap)
 
int DBFAlterFieldDefn (DBFHandle psDBF, int iField, const char *pszFieldName, char chType, int nWidth, int nDecimals)
 
void DBFSetWriteEndOfFileChar (DBFHandle psDBF, int bWriteFlag)
 

Variables

static const char cpl_cvsid [] = "$Id$"
 

Macro Definition Documentation

◆ CONST_CAST

#define CONST_CAST (   type,
  x 
)    ((type)(x))

Definition at line 261 of file dbfopen.c.

◆ CPL_IGNORE_RET_VAL_INT

#define CPL_IGNORE_RET_VAL_INT (   x)    x

Definition at line 250 of file dbfopen.c.

◆ CPLsnprintf

#define CPLsnprintf   snprintf

Definition at line 229 of file dbfopen.c.

◆ CPLsprintf

#define CPLsprintf   sprintf

Definition at line 228 of file dbfopen.c.

◆ END_OF_FILE_CHARACTER

#define END_OF_FILE_CHARACTER   0x1A

Definition at line 245 of file dbfopen.c.

◆ FALSE

#define FALSE   0

Definition at line 235 of file dbfopen.c.

◆ HEADER_RECORD_TERMINATOR

#define HEADER_RECORD_TERMINATOR   0x0D

Definition at line 242 of file dbfopen.c.

◆ REINTERPRET_CAST

#define REINTERPRET_CAST (   type,
  x 
)    ((type)(x))

Definition at line 260 of file dbfopen.c.

◆ SHPLIB_NULLPTR

#define SHPLIB_NULLPTR   NULL

Definition at line 262 of file dbfopen.c.

◆ STATIC_CAST

#define STATIC_CAST (   type,
  x 
)    ((type)(x))

Definition at line 259 of file dbfopen.c.

◆ STRCASECMP

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

Definition at line 215 of file dbfopen.c.

◆ TRUE

#define TRUE   1

Definition at line 236 of file dbfopen.c.

◆ XBASE_FILEHDR_SZ

#define XBASE_FILEHDR_SZ   32

Definition at line 240 of file dbfopen.c.

Function Documentation

◆ cvsid_aw()

static const char* cvsid_aw ( )
static

Definition at line 232 of file dbfopen.c.

◆ DBFAddField()

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

Definition at line 923 of file dbfopen.c.

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

◆ DBFAddNativeFieldType()

◆ DBFAlterFieldDefn()

◆ DBFCloneEmpty()

◆ DBFClose()

◆ DBFCreate()

DBFHandle DBFCreate ( const char *  pszFilename)

Definition at line 786 of file dbfopen.c.

References DBFCreateEx().

◆ DBFCreateEx()

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

Definition at line 799 of file dbfopen.c.

References DBFCreateLL(), and SASetupDefaultHooks().

Referenced by DBFCloneEmpty(), and DBFCreate().

◆ DBFCreateLL()

◆ DBFDeleteField()

◆ DBFFlushRecord()

◆ DBFGetCodePage()

const char* DBFGetCodePage ( DBFHandle  psDBF)

Definition at line 1943 of file dbfopen.c.

References SHPLIB_NULLPTR.

◆ DBFGetFieldCount()

int DBFGetFieldCount ( DBFHandle  psDBF)

Definition at line 1372 of file dbfopen.c.

References DBFInfo::nFields.

Referenced by DBFGetFieldIndex().

◆ DBFGetFieldIndex()

int DBFGetFieldIndex ( DBFHandle  psDBF,
const char *  pszFieldName 
)

◆ DBFGetFieldInfo()

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

◆ DBFGetLenWithoutExtension()

static int DBFGetLenWithoutExtension ( const char *  pszBasename)
static

Definition at line 504 of file dbfopen.c.

References STATIC_CAST.

Referenced by DBFCreateLL(), and DBFOpenLL().

◆ DBFGetNativeFieldType()

char DBFGetNativeFieldType ( DBFHandle  psDBF,
int  iField 
)

Definition at line 1836 of file dbfopen.c.

References DBFInfo::pachFieldType.

◆ DBFGetNullCharacter()

static char DBFGetNullCharacter ( char  chType)
static

Definition at line 946 of file dbfopen.c.

Referenced by DBFAddNativeFieldType(), DBFAlterFieldDefn(), and DBFWriteAttribute().

◆ DBFGetRecordCount()

int DBFGetRecordCount ( DBFHandle  psDBF)

Definition at line 1385 of file dbfopen.c.

References DBFInfo::nRecords.

◆ DBFIsAttributeNULL()

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

◆ DBFIsRecordDeleted()

int DBFIsRecordDeleted ( DBFHandle  psDBF,
int  iShape 
)

Definition at line 1876 of file dbfopen.c.

References DBFLoadRecord(), FALSE, DBFInfo::nRecords, DBFInfo::pszCurrentRecord, and TRUE.

◆ DBFIsValueNULL()

static int DBFIsValueNULL ( char  chType,
const char *  pszValue 
)
static

Definition at line 1303 of file dbfopen.c.

References FALSE, SHPLIB_NULLPTR, and TRUE.

Referenced by DBFAlterFieldDefn(), and DBFIsAttributeNULL().

◆ DBFLoadRecord()

◆ DBFMarkRecordDeleted()

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

◆ DBFOpen()

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

Definition at line 490 of file dbfopen.c.

References DBFOpenLL(), and SASetupDefaultHooks().

Referenced by DBFCloneEmpty().

◆ DBFOpenLL()

◆ DBFReadAttribute()

◆ DBFReadDoubleAttribute()

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

Definition at line 1257 of file dbfopen.c.

References DBFReadAttribute(), SHPLIB_NULLPTR, and STATIC_CAST.

◆ DBFReadIntegerAttribute()

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

Definition at line 1237 of file dbfopen.c.

References DBFReadAttribute(), SHPLIB_NULLPTR, and STATIC_CAST.

◆ DBFReadLogicalAttribute()

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

Definition at line 1290 of file dbfopen.c.

References DBFReadAttribute(), and STATIC_CAST.

◆ DBFReadStringAttribute()

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

Definition at line 1277 of file dbfopen.c.

References DBFReadAttribute(), and STATIC_CAST.

Referenced by DBFIsAttributeNULL().

◆ DBFReadTuple()

const char* DBFReadTuple ( DBFHandle  psDBF,
int  hEntity 
)

Definition at line 1766 of file dbfopen.c.

References DBFLoadRecord(), SHPLIB_NULLPTR, and STATIC_CAST.

◆ DBFReorderFields()

◆ DBFSetLastModifiedDate()

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

Definition at line 476 of file dbfopen.c.

References DBFInfo::nUpdateDay, DBFInfo::nUpdateMonth, and DBFInfo::nUpdateYearSince1900.

Referenced by DBFCreateLL(), and DBFOpenLL().

◆ DBFSetWriteEndOfFileChar()

void DBFSetWriteEndOfFileChar ( DBFHandle  psDBF,
int  bWriteFlag 
)

Definition at line 2432 of file dbfopen.c.

References DBFInfo::bWriteEndOfFileChar.

Referenced by DBFCreateLL(), and DBFOpenLL().

◆ DBFUpdateHeader()

◆ DBFWriteAttribute()

◆ DBFWriteAttributeDirectly()

◆ DBFWriteDoubleAttribute()

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

Definition at line 1640 of file dbfopen.c.

References DBFWriteAttribute(), and STATIC_CAST.

◆ DBFWriteHeader()

◆ DBFWriteIntegerAttribute()

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

Definition at line 1654 of file dbfopen.c.

References DBFWriteAttribute(), and STATIC_CAST.

◆ DBFWriteLogicalAttribute()

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

Definition at line 1697 of file dbfopen.c.

References CONST_CAST, DBFWriteAttribute(), and STATIC_CAST.

◆ DBFWriteNULLAttribute()

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

Definition at line 1684 of file dbfopen.c.

References DBFWriteAttribute(), and SHPLIB_NULLPTR.

◆ DBFWriteStringAttribute()

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

Definition at line 1670 of file dbfopen.c.

References CONST_CAST, DBFWriteAttribute(), and STATIC_CAST.

◆ DBFWriteTuple()

◆ SfRealloc()

static void* SfRealloc ( void *  pMem,
int  nNewSize 
)
static

Definition at line 272 of file dbfopen.c.

References SHPLIB_NULLPTR.

Referenced by DBFAddNativeFieldType(), DBFAlterFieldDefn(), DBFDeleteField(), and DBFOpenLL().

Variable Documentation

◆ cpl_cvsid

const char cpl_cvsid[] = "$Id$"
static

Definition at line 232 of file dbfopen.c.