PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void* DBFReadAttribute ( DBFHandle  psDBF,
int  hEntity,
int  iField,
char  chReqType 
)
static

Definition at line 958 of file dbfopen.c.

References DBFLoadRecord().

Referenced by DBFReadDoubleAttribute(), and DBFReadIntegerAttribute().

961 {
962  unsigned char *pabyRec;
963  void *pReturnField = NULL;
964 
965 /* -------------------------------------------------------------------- */
966 /* Verify selection. */
967 /* -------------------------------------------------------------------- */
968  if( hEntity < 0 || hEntity >= psDBF->nRecords )
969  return( NULL );
970 
971  if( iField < 0 || iField >= psDBF->nFields )
972  return( NULL );
973 
974 /* -------------------------------------------------------------------- */
975 /* Have we read the record? */
976 /* -------------------------------------------------------------------- */
977  if( !DBFLoadRecord( psDBF, hEntity ) )
978  return NULL;
979 
980  pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
981 
982 /* -------------------------------------------------------------------- */
983 /* Ensure we have room to extract the target field. */
984 /* -------------------------------------------------------------------- */
985  if( psDBF->panFieldSize[iField] >= psDBF->nWorkFieldLength )
986  {
987  psDBF->nWorkFieldLength = psDBF->panFieldSize[iField] + 100;
988  if( psDBF->pszWorkField == NULL )
989  psDBF->pszWorkField = (char *) malloc(psDBF->nWorkFieldLength);
990  else
991  psDBF->pszWorkField = (char *) realloc(psDBF->pszWorkField,
992  psDBF->nWorkFieldLength);
993  }
994 
995 /* -------------------------------------------------------------------- */
996 /* Extract the requested field. */
997 /* -------------------------------------------------------------------- */
998  strncpy( psDBF->pszWorkField,
999  ((const char *) pabyRec) + psDBF->panFieldOffset[iField],
1000  psDBF->panFieldSize[iField] );
1001  psDBF->pszWorkField[psDBF->panFieldSize[iField]] = '\0';
1002 
1003  pReturnField = psDBF->pszWorkField;
1004 
1005 /* -------------------------------------------------------------------- */
1006 /* Decode the field. */
1007 /* -------------------------------------------------------------------- */
1008  if( chReqType == 'N' )
1009  {
1010  psDBF->dfDoubleField = psDBF->sHooks.Atof(psDBF->pszWorkField);
1011 
1012  pReturnField = &(psDBF->dfDoubleField);
1013  }
1014 
1015 /* -------------------------------------------------------------------- */
1016 /* Should we trim white space off the string attribute value? */
1017 /* -------------------------------------------------------------------- */
1018 #ifdef TRIM_DBF_WHITESPACE
1019  else
1020  {
1021  char *pchSrc, *pchDst;
1022 
1023  pchDst = pchSrc = psDBF->pszWorkField;
1024  while( *pchSrc == ' ' )
1025  pchSrc++;
1026 
1027  while( *pchSrc != '\0' )
1028  *(pchDst++) = *(pchSrc++);
1029  *pchDst = '\0';
1030 
1031  while( pchDst != psDBF->pszWorkField && *(--pchDst) == ' ' )
1032  *pchDst = '\0';
1033  }
1034 #endif
1035 
1036  return( pReturnField );
1037 }
static int DBFLoadRecord(DBFHandle psDBF, int iRecord)
Definition: dbfopen.c:292

Here is the call graph for this function:

Here is the caller graph for this function: