PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ DBFCloneEmpty()

DBFHandle SHPAPI_CALL DBFCloneEmpty ( DBFHandle  psDBF,
const char *  pszFilename 
)

Definition at line 1659 of file dbfopen.c.

1660 {
1661  DBFHandle newDBF;
1662 
1663  newDBF = DBFCreateEx ( pszFilename, psDBF->pszCodePage );
1664  if ( newDBF == SHPLIB_NULLPTR ) return SHPLIB_NULLPTR;
1665 
1666  newDBF->nFields = psDBF->nFields;
1667  newDBF->nRecordLength = psDBF->nRecordLength;
1668  newDBF->nHeaderLength = psDBF->nHeaderLength;
1669 
1670  if( psDBF->pszHeader )
1671  {
1672  newDBF->pszHeader = STATIC_CAST(char *, malloc ( XBASE_FLDHDR_SZ * psDBF->nFields ));
1673  memcpy ( newDBF->pszHeader, psDBF->pszHeader, XBASE_FLDHDR_SZ * psDBF->nFields );
1674  }
1675 
1676  newDBF->panFieldOffset = STATIC_CAST(int *, malloc ( sizeof(int) * psDBF->nFields ));
1677  memcpy ( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
1678  newDBF->panFieldSize = STATIC_CAST(int *, malloc ( sizeof(int) * psDBF->nFields ));
1679  memcpy ( newDBF->panFieldSize, psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
1680  newDBF->panFieldDecimals = STATIC_CAST(int *, malloc ( sizeof(int) * psDBF->nFields ));
1681  memcpy ( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
1682  newDBF->pachFieldType = STATIC_CAST(char *, malloc ( sizeof(char) * psDBF->nFields ));
1683  memcpy ( newDBF->pachFieldType, psDBF->pachFieldType, sizeof(char)*psDBF->nFields );
1684 
1685  newDBF->bNoHeader = TRUE;
1686  newDBF->bUpdated = TRUE;
1687  newDBF->bWriteEndOfFileChar = psDBF->bWriteEndOfFileChar;
1688 
1689  DBFWriteHeader ( newDBF );
1690  DBFClose ( newDBF );
1691 
1692  newDBF = DBFOpen ( pszFilename, "rb+" );
1693  newDBF->bWriteEndOfFileChar = psDBF->bWriteEndOfFileChar;
1694 
1695  return ( newDBF );
1696 }
DBFHandle SHPAPI_CALL DBFOpen(const char *pszFilename, const char *pszAccess)
Definition: dbfopen.c:351
#define STATIC_CAST(type, x)
Definition: dbfopen.c:96
DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszFilename, const char *pszCodePage)
Definition: dbfopen.c:669
void SHPAPI_CALL DBFClose(DBFHandle psDBF)
Definition: dbfopen.c:606
static void DBFWriteHeader(DBFHandle psDBF)
Definition: dbfopen.c:127
#define TRUE
Definition: dbfopen.c:73
#define SHPLIB_NULLPTR
Definition: dbfopen.c:99
void * malloc(YYSIZE_T)
#define XBASE_FLDHDR_SZ
Definition: shapefil.h:648
int bWriteEndOfFileChar
Definition: shapefil.h:631
int nRecordLength
Definition: shapefil.h:596
int * panFieldOffset
Definition: shapefil.h:601
int * panFieldDecimals
Definition: shapefil.h:603
char * pszCodePage
Definition: shapefil.h:625
int nFields
Definition: shapefil.h:600
int bUpdated
Definition: shapefil.h:616
int nHeaderLength
Definition: shapefil.h:597
int * panFieldSize
Definition: shapefil.h:602
char * pszHeader
Definition: shapefil.h:606
char * pachFieldType
Definition: shapefil.h:604
int bNoHeader
Definition: shapefil.h:615

References DBFInfo::bNoHeader, DBFInfo::bUpdated, DBFInfo::bWriteEndOfFileChar, DBFClose(), DBFCreateEx(), DBFOpen(), DBFWriteHeader(), malloc(), DBFInfo::nFields, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::pachFieldType, DBFInfo::panFieldDecimals, DBFInfo::panFieldOffset, DBFInfo::panFieldSize, DBFInfo::pszCodePage, DBFInfo::pszHeader, SHPLIB_NULLPTR, STATIC_CAST, TRUE, and XBASE_FLDHDR_SZ.

Here is the call graph for this function: