2066 int nOldRecordLength;
2073 if (iField < 0 || iField >= psDBF->
nFields)
2117 pszFInfo[16] =
STATIC_CAST(
unsigned char, nWidth % 256);
2118 pszFInfo[17] =
STATIC_CAST(
unsigned char, nWidth / 256);
2122 pszFInfo[16] =
STATIC_CAST(
unsigned char, nWidth);
2123 pszFInfo[17] =
STATIC_CAST(
unsigned char, nDecimals);
2129 if (nWidth != nOldWidth)
2131 for (i = iField + 1; i < psDBF->
nFields; i++)
2147 if (nWidth < nOldWidth || (nWidth == nOldWidth && chType != chOldType))
2150 char* pszOldField =
STATIC_CAST(
char *,
malloc(
sizeof(
char) * (nOldWidth + 1)));
2153 pszOldField[nOldWidth] = 0;
2156 for (iRecord = 0; iRecord < psDBF->
nRecords; iRecord++)
2163 psDBF->
sHooks.
FRead( pszRecord, nOldRecordLength, 1, psDBF->
fp );
2165 memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
2168 if (nWidth != nOldWidth)
2170 if ((chOldType ==
'N' || chOldType ==
'F' || chOldType ==
'D') && pszOldField[0] ==
' ')
2173 memmove( pszRecord + nOffset,
2174 pszRecord + nOffset + nOldWidth - nWidth,
2177 if (nOffset + nOldWidth < nOldRecordLength)
2179 memmove( pszRecord + nOffset + nWidth,
2180 pszRecord + nOffset + nOldWidth,
2181 nOldRecordLength - (nOffset + nOldWidth));
2188 memset( pszRecord + nOffset, chFieldFill, nWidth);
2214 else if (nWidth > nOldWidth)
2217 char* pszOldField =
STATIC_CAST(
char *,
malloc(
sizeof(
char) * (nOldWidth + 1)));
2220 pszOldField[nOldWidth] = 0;
2223 for (iRecord = psDBF->
nRecords - 1; iRecord >= 0; iRecord--)
2230 psDBF->
sHooks.
FRead( pszRecord, nOldRecordLength, 1, psDBF->
fp );
2232 memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
2235 if (nOffset + nOldWidth < nOldRecordLength)
2237 memmove( pszRecord + nOffset + nWidth,
2238 pszRecord + nOffset + nOldWidth,
2239 nOldRecordLength - (nOffset + nOldWidth));
2245 memset( pszRecord + nOffset, chFieldFill, nWidth);
2249 if ((chOldType ==
'N' || chOldType ==
'F'))
2252 memmove( pszRecord + nOffset + nWidth - nOldWidth,
2253 pszRecord + nOffset, nOldWidth );
2254 memset( pszRecord + nOffset,
' ', nWidth - nOldWidth );
2259 memset(pszRecord + nOffset + nOldWidth,
' ', nWidth - nOldWidth);
static int DBFIsValueNULL(char chType, const char *pszValue)
#define STATIC_CAST(type, x)
#define END_OF_FILE_CHARACTER
static void * SfRealloc(void *pMem, int nNewSize)
static char DBFGetNullCharacter(char chType)
static int DBFFlushRecord(DBFHandle psDBF)
void SHPAPI_CALL DBFUpdateHeader(DBFHandle psDBF)
#define XBASE_FLDNAME_LEN_WRITE
#define XBASE_FLD_MAX_WIDTH
int bCurrentRecordModified
SAOffset(* FWrite)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
SAOffset(* FRead)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
SAOffset(* FSeek)(SAFile file, SAOffset offset, int whence)