2065 int nOldRecordLength;
2072 if (iField < 0 || iField >= psDBF->
nFields)
2116 pszFInfo[16] =
STATIC_CAST(
unsigned char, nWidth % 256);
2117 pszFInfo[17] =
STATIC_CAST(
unsigned char, nWidth / 256);
2121 pszFInfo[16] =
STATIC_CAST(
unsigned char, nWidth);
2122 pszFInfo[17] =
STATIC_CAST(
unsigned char, nDecimals);
2128 if (nWidth != nOldWidth)
2130 for (i = iField + 1; i < psDBF->
nFields; i++)
2146 if (nWidth < nOldWidth || (nWidth == nOldWidth && chType != chOldType))
2149 char* pszOldField =
STATIC_CAST(
char *,
malloc(
sizeof(
char) * (nOldWidth + 1)));
2152 pszOldField[nOldWidth] = 0;
2155 for (iRecord = 0; iRecord < psDBF->
nRecords; iRecord++)
2162 psDBF->
sHooks.
FRead( pszRecord, nOldRecordLength, 1, psDBF->
fp );
2164 memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
2167 if (nWidth != nOldWidth)
2169 if ((chOldType ==
'N' || chOldType ==
'F' || chOldType ==
'D') && pszOldField[0] ==
' ')
2172 memmove( pszRecord + nOffset,
2173 pszRecord + nOffset + nOldWidth - nWidth,
2176 if (nOffset + nOldWidth < nOldRecordLength)
2178 memmove( pszRecord + nOffset + nWidth,
2179 pszRecord + nOffset + nOldWidth,
2180 nOldRecordLength - (nOffset + nOldWidth));
2187 memset( pszRecord + nOffset, chFieldFill, nWidth);
2213 else if (nWidth > nOldWidth)
2216 char* pszOldField =
STATIC_CAST(
char *,
malloc(
sizeof(
char) * (nOldWidth + 1)));
2219 pszOldField[nOldWidth] = 0;
2222 for (iRecord = psDBF->
nRecords - 1; iRecord >= 0; iRecord--)
2229 psDBF->
sHooks.
FRead( pszRecord, nOldRecordLength, 1, psDBF->
fp );
2231 memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
2234 if (nOffset + nOldWidth < nOldRecordLength)
2236 memmove( pszRecord + nOffset + nWidth,
2237 pszRecord + nOffset + nOldWidth,
2238 nOldRecordLength - (nOffset + nOldWidth));
2244 memset( pszRecord + nOffset, chFieldFill, nWidth);
2248 if ((chOldType ==
'N' || chOldType ==
'F'))
2251 memmove( pszRecord + nOffset + nWidth - nOldWidth,
2252 pszRecord + nOffset, nOldWidth );
2253 memset( pszRecord + nOffset,
' ', nWidth - nOldWidth );
2258 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)