935{
936 unsigned char *pabyRec;
937 void *pReturnField = NULL;
938
939
940
941
942 if (hEntity < 0 || hEntity >= psDBF->nRecords)
943 return (NULL);
944
945 if (iField < 0 || iField >= psDBF->nFields)
946 return (NULL);
947
948
949
950
952 return NULL;
953
954 pabyRec = (unsigned char *)psDBF->pszCurrentRecord;
955
956
957
958
959 if (psDBF->panFieldSize[iField] >= psDBF->nWorkFieldLength)
960 {
961 psDBF->nWorkFieldLength = psDBF->panFieldSize[iField] + 100;
962 if (psDBF->pszWorkField == NULL)
963 psDBF->pszWorkField = (
char *)
malloc(psDBF->nWorkFieldLength);
964 else
965 psDBF->pszWorkField = (char *)realloc(psDBF->pszWorkField, psDBF->nWorkFieldLength);
966 }
967
968
969
970
971 strncpy(
972 psDBF->pszWorkField, ((const char *)pabyRec) + psDBF->panFieldOffset[iField], psDBF->panFieldSize[iField]);
973 psDBF->pszWorkField[psDBF->panFieldSize[iField]] = '\0';
974
975 pReturnField = psDBF->pszWorkField;
976
977
978
979
980 if (chReqType == 'N')
981 {
982 psDBF->dfDoubleField = psDBF->sHooks.Atof(psDBF->pszWorkField);
983
984 pReturnField = &(psDBF->dfDoubleField);
985 }
986
987
988
989
990#ifdef TRIM_DBF_WHITESPACE
991 else
992 {
993 char *pchSrc, *pchDst;
994
995 pchDst = pchSrc = psDBF->pszWorkField;
996 while (*pchSrc == ' ')
997 pchSrc++;
998
999 while (*pchSrc != '\0')
1000 *(pchDst++) = *(pchSrc++);
1001 *pchDst = '\0';
1002
1003 while (pchDst != psDBF->pszWorkField && *(--pchDst) == ' ')
1004 *pchDst = '\0';
1005 }
1006#endif
1007
1008 return (pReturnField);
1009}
static int DBFLoadRecord(DBFHandle psDBF, int iRecord)