826 int nOldRecordLength, nOldHeaderLength;
844 nOldRecordLength = psDBF->nRecordLength;
845 nOldHeaderLength = psDBF->nHeaderLength;
853 psDBF->panFieldOffset = (
int *)
854 SfRealloc( psDBF->panFieldOffset,
sizeof(
int) * psDBF->nFields );
856 psDBF->panFieldSize = (
int *)
857 SfRealloc( psDBF->panFieldSize,
sizeof(
int) * psDBF->nFields );
859 psDBF->panFieldDecimals = (
int *)
860 SfRealloc( psDBF->panFieldDecimals,
sizeof(
int) * psDBF->nFields );
862 psDBF->pachFieldType = (
char *)
863 SfRealloc( psDBF->pachFieldType,
sizeof(
char) * psDBF->nFields );
868 psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength;
869 psDBF->nRecordLength += nWidth;
870 psDBF->panFieldSize[psDBF->nFields-1] = nWidth;
871 psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals;
872 psDBF->pachFieldType[psDBF->nFields-1] = chType;
877 psDBF->nHeaderLength += 32;
878 psDBF->bUpdated =
FALSE;
880 psDBF->pszHeader = (
char *)
SfRealloc(psDBF->pszHeader,psDBF->nFields*32);
882 pszFInfo = psDBF->pszHeader + 32 * (psDBF->nFields-1);
884 for( i = 0; i < 32; i++ )
887 if( (
int) strlen(pszFieldName) < 10 )
888 strncpy( pszFInfo, pszFieldName, strlen(pszFieldName));
890 strncpy( pszFInfo, pszFieldName, 10);
892 pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1];
896 pszFInfo[16] = (
unsigned char) (nWidth % 256);
897 pszFInfo[17] = (
unsigned char) (nWidth / 256);
901 pszFInfo[16] = (
unsigned char) nWidth;
902 pszFInfo[17] = (
unsigned char) nDecimals;
908 psDBF->pszCurrentRecord = (
char *)
SfRealloc(psDBF->pszCurrentRecord,
909 psDBF->nRecordLength);
912 if( psDBF->bNoHeader )
913 return( psDBF->nFields - 1 );
920 pszRecord = (
char *)
malloc(
sizeof(
char) * psDBF->nRecordLength);
924 for (i = psDBF->nRecords-1; i >= 0; --i)
926 nRecordOffset = nOldRecordLength * (
SAOffset) i + nOldHeaderLength;
929 psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
930 psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp );
933 memset(pszRecord + nOldRecordLength, chFieldFill, nWidth);
935 nRecordOffset = psDBF->nRecordLength * (
SAOffset) i + psDBF->nHeaderLength;
938 psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
939 psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
946 psDBF->bNoHeader =
TRUE;
949 psDBF->nCurrentRecord = -1;
950 psDBF->bCurrentRecordModified =
FALSE;
952 return( psDBF->nFields-1 );
static void * SfRealloc(void *pMem, int nNewSize)
static int DBFFlushRecord(DBFHandle psDBF)
static char DBFGetNullCharacter(char chType)
void SHPAPI_CALL DBFUpdateHeader(DBFHandle psDBF)