806 int nOldRecordLength, nOldHeaderLength;
824 nOldRecordLength = psDBF->nRecordLength;
825 nOldHeaderLength = psDBF->nHeaderLength;
833 psDBF->panFieldOffset = (
int *)
SfRealloc(psDBF->panFieldOffset,
sizeof(
int) * psDBF->nFields);
835 psDBF->panFieldSize = (
int *)
SfRealloc(psDBF->panFieldSize,
sizeof(
int) * psDBF->nFields);
837 psDBF->panFieldDecimals = (
int *)
SfRealloc(psDBF->panFieldDecimals,
sizeof(
int) * psDBF->nFields);
839 psDBF->pachFieldType = (
char *)
SfRealloc(psDBF->pachFieldType,
sizeof(
char) * psDBF->nFields);
844 psDBF->panFieldOffset[psDBF->nFields - 1] = psDBF->nRecordLength;
845 psDBF->nRecordLength += nWidth;
846 psDBF->panFieldSize[psDBF->nFields - 1] = nWidth;
847 psDBF->panFieldDecimals[psDBF->nFields - 1] = nDecimals;
848 psDBF->pachFieldType[psDBF->nFields - 1] = chType;
853 psDBF->nHeaderLength += 32;
854 psDBF->bUpdated =
FALSE;
856 psDBF->pszHeader = (
char *)
SfRealloc(psDBF->pszHeader, psDBF->nFields * 32);
858 pszFInfo = psDBF->pszHeader + 32 * (psDBF->nFields - 1);
860 for (i = 0; i < 32; i++)
863 memcpy(pszFInfo, pszFieldName, 10);
865 pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields - 1];
869 pszFInfo[16] = (
unsigned char)(nWidth % 256);
870 pszFInfo[17] = (
unsigned char)(nWidth / 256);
874 pszFInfo[16] = (
unsigned char)nWidth;
875 pszFInfo[17] = (
unsigned char)nDecimals;
881 psDBF->pszCurrentRecord = (
char *)
SfRealloc(psDBF->pszCurrentRecord, psDBF->nRecordLength);
884 if (psDBF->bNoHeader)
885 return (psDBF->nFields - 1);
892 pszRecord = (
char *)
malloc(
sizeof(
char) * psDBF->nRecordLength);
896 for (i = psDBF->nRecords - 1; i >= 0; --i)
898 nRecordOffset = nOldRecordLength * (
SAOffset)i + nOldHeaderLength;
901 psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0);
902 psDBF->sHooks.FRead(pszRecord, nOldRecordLength, 1, psDBF->fp);
905 memset(pszRecord + nOldRecordLength, chFieldFill, nWidth);
907 nRecordOffset = psDBF->nRecordLength * (
SAOffset)i + psDBF->nHeaderLength;
910 psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0);
911 psDBF->sHooks.FWrite(pszRecord, psDBF->nRecordLength, 1, psDBF->fp);
918 psDBF->bNoHeader =
TRUE;
921 psDBF->nCurrentRecord = -1;
922 psDBF->bCurrentRecordModified =
FALSE;
924 return (psDBF->nFields - 1);
static void * SfRealloc(void *pMem, int nNewSize)
static char DBFGetNullCharacter(char chType)
static int DBFFlushRecord(DBFHandle psDBF)
void SHPAPI_CALL DBFUpdateHeader(DBFHandle psDBF)