From 64d6e54bc6d307655d9fe30871ccd8df2136467b Mon Sep 17 00:00:00 2001 From: Bruno Cantero Date: Sun, 22 Aug 1999 11:03:28 +0000 Subject: [PATCH] ChangeLogTag:19990822-12:49 GMT+1 Bruno Cantero --- harbour/ChangeLog | 12 + harbour/include/rddapi.h | 51 +-- harbour/source/rdd/dbcmd.c | 626 ++++++++++++++-------------- harbour/source/rdd/dbf1.c | 249 +++++------ harbour/source/rdd/dbfntx/dbfntx1.c | 44 +- harbour/source/rdd/delim1.c | 56 +-- harbour/source/rdd/sdf1.c | 56 +-- harbour/source/vm/hvm.c | 12 +- 8 files changed, 457 insertions(+), 649 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f2f5e5e95f..f6b1ac97a6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,15 @@ +19990822-12:49 GMT+1 Bruno Cantero + * include/rddapi.h + source/vm/hvm.c + source/rdd/dbcmd.c + source/rdd/dbf1.c + source/rdd/sdf1.c + source/rdd/delim1.c + source/rdd/dbfntx/dbfntx1.c + * Renamed hb_GetCurrentWorkAreaNumber, hb_SelectWorkAreaNumber and + hb_SelectWorkAreaAlias to hb_rddGetCurrentWorkAreaNumber, + hb_rddSelectWorkAreaNumber and hb_rddSelectWorkAreaAlias. + 19990822-07:40 GMT+1 Victor Szel * source/rtl/strings.c diff --git a/harbour/include/rddapi.h b/harbour/include/rddapi.h index cf841266e5..d5d986b817 100644 --- a/harbour/include/rddapi.h +++ b/harbour/include/rddapi.h @@ -9,22 +9,26 @@ typedef USHORT ERRCODE; + /* RDD method return codes */ #define SUCCESS 0 #define FAILURE 1 + /* Flags for DBTRANSINFO */ #define DBTF_MATCH 0x0001 #define DBTF_PUTREC 0x0002 + /* Codes for Locking methods */ #define DBLM_EXCLUSIVE 1 #define DBLM_MULTIPLE 2 #define DBLM_FILE 3 + /* Codes for SELF_ORDINFO() */ #define DBOI_CONDITION 1 /* Get the order condition */ @@ -43,6 +47,7 @@ typedef USHORT ERRCODE; #define DBOI_ISDESC 12 /* Get the flag if the order is descending */ #define DBOI_UNIQUE 13 /* Get the flag if the order has the unique attribute set */ + /* Codes for SELF_INFO() */ #define DBI_ISDBF 1 /* Logical: RDD support DBF file format? */ @@ -81,6 +86,7 @@ typedef USHORT ERRCODE; #define DBI_USER 1000 /* Start of user definable DBI_ values */ + /* Codes for SELF_RECINFO() */ #define DBRI_DELETED 1 @@ -97,6 +103,7 @@ typedef USHORT ERRCODE; #define DBS_LEN 3 #define DBS_DEC 4 + /* Codes for RawLock types */ #define FILE_LOCK 1 @@ -118,6 +125,7 @@ typedef struct _FILEINFO typedef FILEINFO * LPFILEINFO; + /* * DBFIELDINFO * ----------- @@ -136,6 +144,7 @@ typedef struct typedef DBFIELDINFO * LPDBFIELDINFO; + /* * DBOPENINFO * ---------- @@ -156,6 +165,7 @@ typedef struct typedef DBOPENINFO * LPDBOPENINFO; + /* * DBEXTENDINFO * ------------ @@ -175,13 +185,13 @@ typedef struct typedef DBEXTENDINFO * LPDBEXTENDINFO; + /* * DBORDERCONDINFO * --------------- * The Create Order conditional Info structure */ -#if 0 typedef struct _DBORDERCONDINFO { BOOL fActive; @@ -207,7 +217,6 @@ typedef struct _DBORDERCONDINFO } DBORDERCONDINFO; typedef DBORDERCONDINFO * LPDBORDERCONDINFO; -#endif @@ -217,7 +226,6 @@ typedef DBORDERCONDINFO * LPDBORDERCONDINFO; * The Create Order Info structure */ -#if 0 typedef struct { LPDBORDERCONDINFO lpdbOrdCondInfo; /* Conditional information */ @@ -232,7 +240,6 @@ typedef struct } DBORDERCREATEINFO; typedef DBORDERCREATEINFO * LPDBORDERCREATEINFO; -#endif @@ -242,7 +249,6 @@ typedef DBORDERCREATEINFO * LPDBORDERCREATEINFO; * The Set Index Info structure */ -#if 0 typedef struct { PHB_ITEM atomBagName; /* Name of the Order Bag */ @@ -257,7 +263,6 @@ typedef struct } DBORDERINFO; typedef DBORDERINFO * LPDBORDERINFO; -#endif @@ -267,7 +272,6 @@ typedef DBORDERINFO * LPDBORDERINFO; * The Scope Info structure */ -#if 0 typedef struct { PHB_ITEM itmCobFor; /* Code Block representation of a FOR clause */ @@ -286,7 +290,6 @@ typedef struct } DBSCOPEINFO; typedef DBSCOPEINFO * LPDBSCOPEINFO; -#endif @@ -296,7 +299,6 @@ typedef DBSCOPEINFO * LPDBSCOPEINFO; * The Filter Info structure */ -#if 0 typedef struct { PHB_ITEM itmCobExpr; /* Block representation of the FILTER expression */ @@ -305,7 +307,6 @@ typedef struct } DBFILTERINFO; typedef DBFILTERINFO * LPDBFILTERINFO; -#endif @@ -315,7 +316,6 @@ typedef DBFILTERINFO * LPDBFILTERINFO; * The Relationship Info structure */ -#if 0 typedef struct _DBRELINFO { PHB_ITEM itmCobExpr; /* Block representation of the relational SEEK key */ @@ -329,7 +329,6 @@ typedef struct _DBRELINFO } DBRELINFO; typedef DBRELINFO * LPDBRELINFO; -#endif @@ -342,7 +341,6 @@ typedef DBRELINFO * LPDBRELINFO; * on each record of the workarea */ -#if 0 typedef struct { PHB_ITEM itmBlock; /* The block to be evaluated */ @@ -350,7 +348,7 @@ typedef struct } DBEVALINFO; typedef DBEVALINFO * LPDBEVALINFO; -#endif + /* @@ -362,7 +360,6 @@ typedef DBEVALINFO * LPDBEVALINFO; * one database to another; used by DBTRANSINFO */ -#if 0 typedef struct { USHORT uiSource; /* Field index number from the source */ @@ -370,7 +367,7 @@ typedef struct } DBTRANSITEM; typedef DBTRANSITEM * LPDBTRANSITEM; -#endif + /* @@ -382,7 +379,6 @@ typedef DBTRANSITEM * LPDBTRANSITEM; * to another */ -#if 0 typedef struct { struct _AREA *lpaSource; /* Pointer to source work area */ @@ -396,7 +392,7 @@ typedef struct } DBTRANSINFO; typedef DBTRANSINFO * LPDBTRANSINFO; -#endif + /* @@ -409,7 +405,6 @@ typedef DBTRANSINFO * LPDBTRANSINFO; * order of the sorting. */ -#if 0 typedef struct { USHORT uiField; /* Index into the workarea->fields structure */ @@ -417,7 +412,7 @@ typedef struct } DBSORTITEM; typedef DBSORTITEM * LPDBSORTITEM; -#endif + /* Flags for DBSORTITEM */ #define SF_ASCEND 1 @@ -437,7 +432,6 @@ typedef DBSORTITEM * LPDBSORTITEM; * Information for a physical sort on the workarea */ -#if 0 typedef struct { DBTRANSINFO dbtri; /* Destination workarea transfer information */ @@ -448,7 +442,7 @@ typedef struct } DBSORTINFO; typedef DBSORTINFO * LPDBSORTINFO; -#endif + /* @@ -459,7 +453,6 @@ typedef DBSORTINFO * LPDBSORTINFO; * Information for a record or file lock */ -#if 0 typedef struct { ULONG itmRecID; @@ -468,7 +461,6 @@ typedef struct } DBLOCKINFO; typedef DBLOCKINFO * LPDBLOCKINFO; -#endif @@ -519,19 +511,16 @@ typedef struct _AREA USHORT uiFieldCount; /* Total number of fields used */ LPFIELD lpFields; /* Pointer to an array of fields */ -#if 0 void * lpFieldExtents; /* Void ptr for additional field properties */ PHB_ITEM valResult; /* All purpose result holder */ BOOL fTop; /* TRUE if "top" */ BOOL fBottom; /* TRUE if "bottom" */ -#endif BOOL fBof; /* TRUE if "bof" */ BOOL fEof; /* TRUE if "eof" */ BOOL fFound; /* TRUE if "found" */ -#if 0 DBSCOPEINFO dbsi; /* Info regarding last LOCATE */ DBFILTERINFO dbfi; /* Filter in effect */ @@ -540,9 +529,8 @@ typedef struct _AREA LPDBRELINFO lpdbRelations; /* Parent/Child relationships used */ USHORT uiParents; /* Number of parents for this area */ - HANDLE heap; + USHORT heap; USHORT heapSize; -#endif USHORT rddID; @@ -602,10 +590,8 @@ typedef struct _RDDFUNCS DBENTRYP_SI seek; #endif DBENTRYP_L skip; -#if 0 DBENTRYP_L skipFilter; DBENTRYP_L skipRaw; -#endif /* Data management */ @@ -643,6 +629,7 @@ typedef struct _RDDFUNCS DBENTRYP_I recno; DBENTRYP_S setFieldExtent; + /* WorkArea/Database management */ #if 0 @@ -693,6 +680,7 @@ typedef struct _RDDFUNCS DBENTRYP_VP orderDestroy; DBENTRYP_SVP orderInfo; + /* Filters and Scope Settings */ DBENTRYP_V clearFilter; @@ -706,6 +694,7 @@ typedef struct _RDDFUNCS DBENTRYP_VP setScope; DBENTRYP_VPL skipScope; + /* Miscellaneous */ DBENTRYP_VP compile; diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index 3fa1f7f417..0eb20cb921 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -145,186 +145,10 @@ static USHORT uiNetError = 0; /* Error on Networked environments */ static LPAREANODE pWorkAreas = 0; /* WorkAreas */ static LPAREANODE pCurrArea = 0; /* Pointer to a selectd and valid area */ -static void hb_CheckRdd( void ) -{ - if( !szDefDriver ) - { - szDefDriver = ( char * ) hb_xgrab( 1 ); - szDefDriver[ 0 ] = '\0'; - /* Force link the built-in RDD's */ - HB_DBF(); - HB_SDF(); - HB_DELIM(); - HB_RDDSYS(); - } -} - -static void hb_CloseAll( void ) -{ - pCurrArea = pWorkAreas; - while( pWorkAreas ) - { - pCurrArea = pWorkAreas; - pWorkAreas = pWorkAreas->pNext; - SELF_CLOSE( ( AREAP ) pCurrArea->pArea ); - SELF_RELEASE( ( AREAP ) pCurrArea->pArea ); - hb_xfree( pCurrArea->pArea ); - hb_xfree( pCurrArea ); - } - uiCurrArea = 1; - pCurrArea = 0; - pWorkAreas = 0; -} - -static LPRDDNODE hb_FindRddNode( char * szDriver, USHORT * uiIndex ) -{ - LPRDDNODE pRddNode; - USHORT uiCount; - - uiCount = 0; - pRddNode = pRddList; - while( pRddNode ) - { - if( strcmp( pRddNode->szName, szDriver ) == 0 ) /* Matched RDD */ - { - if( uiIndex ) - * uiIndex = uiCount; - return pRddNode; - } - pRddNode = pRddNode->pNext; - uiCount++; - } - if( uiIndex ) - * uiIndex = 0; - return 0; -} - -static int hb_rddRegister( char * szDriver, USHORT uiType ) -{ - LPRDDNODE pRddNode, pRddNewNode; - PHB_DYNS pGetFuncTable; - char * szGetFuncTable; - - if( hb_FindRddNode( szDriver, 0 ) ) /* Duplicated RDD */ - return 1; - - szGetFuncTable = ( char * ) hb_xgrab( strlen( szDriver ) + 14 ); - strcpy( szGetFuncTable, szDriver ); - strcat( szGetFuncTable, "_GETFUNCTABLE" ); - pGetFuncTable = hb_dynsymFind( szGetFuncTable ); - hb_xfree( szGetFuncTable ); - if( !pGetFuncTable ) - return 2; /* Not valid RDD */ - - /* Create a new RDD node */ - pRddNewNode = ( LPRDDNODE ) hb_xgrab( sizeof( RDDNODE ) ); - memset( pRddNewNode, 0, sizeof( RDDNODE ) ); - - /* Fill the new RDD node */ - strncpy( pRddNewNode->szName, szDriver, HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ); - pRddNewNode->uiType = uiType; - - /* Call _GETFUNCTABLE() */ - hb_vmPushSymbol( pGetFuncTable->pSymbol ); - hb_vmPushNil(); - hb_vmPushLong( ( long ) &pRddNewNode->uiFunctions ); - hb_vmPushLong( ( long ) &pRddNewNode->pTable ); - hb_vmDo( 2 ); - if ( hb_parni( -1 ) != SUCCESS ) - { - hb_xfree( pRddNewNode ); /* Delete de new RDD node */ - return 3; /* Invalid FUNCTABLE */ - } - - if( !pRddList ) /* First RDD node */ - pRddList = pRddNewNode; - else - { - pRddNode = pRddList; - while( pRddNode->pNext ) - pRddNode = pRddNode->pNext; /* Locate the last RDD node */ - pRddNode->pNext = pRddNewNode; /* Add the new RDD node */ - } - return 0; /* Ok */ -} - -static USHORT hb_Select( char * szAlias ) -{ - PHB_DYNS pSymAlias; - - pSymAlias = hb_dynsymFind( szAlias ); - if( pSymAlias && pSymAlias->hArea ) - return pSymAlias->hArea; - else - return 0; -} - -static void hb_SelectFirstAvailable( void ) -{ - LPAREANODE pAreaNode; - - uiCurrArea = 1; - pAreaNode = pWorkAreas; - while( pAreaNode ) - { - if( ( ( AREAP ) pAreaNode->pArea )->uiArea > uiCurrArea ) - break; - else if( ( ( AREAP ) pAreaNode->pArea )->uiArea == uiCurrArea ) - uiCurrArea++; - pAreaNode = pAreaNode->pNext; - } - pCurrArea = 0; /* Selected WorkArea must be created */ -} - -static ERRCODE UnSupported_V( AREAP pArea ) -{ - HB_SYMBOL_UNUSED( pArea ); - printf( "Calling default: UnSupported()\n" ); - return SUCCESS; -} - -static ERRCODE UnSupported_L( AREAP pArea, LONG lLong ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( lLong ); - printf( "Calling default: UnSupported()\n" ); - return SUCCESS; -} - -static ERRCODE Bof( AREAP pArea, BOOL * pBof ) -{ - * pBof = pArea->fBof; - return SUCCESS; -} - -static ERRCODE Eof( AREAP pArea, BOOL * pEof ) -{ - * pEof = pArea->fEof; - return SUCCESS; -} - -static ERRCODE Found( AREAP pArea, BOOL * pFound ) -{ - * pFound = pArea->fFound; - return SUCCESS; -} - -static ERRCODE GoToId( AREAP pArea, PHB_ITEM pItem ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( pItem ); - printf( "Calling default: GoToId()\n" ); - return SUCCESS; -} - -static ERRCODE Skip( AREAP pArea, LONG lToSkip ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( lToSkip ); - printf( "Calling default: Skip()\n" ); - return SUCCESS; -} +/* + * -- BASIC RDD METHODS -- + */ static ERRCODE AddField( AREAP pArea, LPDBFIELDINFO pFieldInfo ) { @@ -346,6 +170,66 @@ static ERRCODE AddField( AREAP pArea, LPDBFIELDINFO pFieldInfo ) return SUCCESS; } +static ERRCODE Bof( AREAP pArea, BOOL * pBof ) +{ + * pBof = pArea->fBof; + return SUCCESS; +} + +static ERRCODE Close( AREAP pArea ) +{ + if( pArea->lpFileInfo->hFile != FS_ERROR ) + hb_fsClose( pArea->lpFileInfo->hFile ); + pArea->lpFileInfo->hFile = FS_ERROR; + ( ( PHB_DYNS ) pArea->atomAlias )->hArea = 0; + return SUCCESS; +} + +static ERRCODE Create( AREAP pArea, LPDBOPENINFO pCreateInfo ) +{ + pArea->lpFileInfo->hFile = hb_fsCreate( pCreateInfo->abName, FC_NORMAL ); + if( pArea->lpFileInfo->hFile == FS_ERROR ) + return FAILURE; + + if( SELF_WRITEDBHEADER( pArea ) == FAILURE ) + { + hb_fsClose( pArea->lpFileInfo->hFile ); + pArea->lpFileInfo->hFile = FS_ERROR; + return FAILURE; + } + + hb_fsClose( pArea->lpFileInfo->hFile ); + pArea->lpFileInfo->hFile = FS_ERROR; + return SUCCESS; +} + +static ERRCODE CreateFields( AREAP pArea, PHB_ITEM pStruct ) +{ + USHORT uiCount; + PHB_ITEM pFieldDesc; + DBFIELDINFO pFieldInfo; + + SELF_SETFIELDEXTENT( pArea, pStruct->item.asArray.value->ulLen ); + pFieldInfo.typeExtended = 0; + for( uiCount = 0; uiCount < pStruct->item.asArray.value->ulLen; uiCount++ ) + { + pFieldDesc = pStruct->item.asArray.value->pItems + uiCount; + pFieldInfo.uiType = toupper( hb_arrayGetString( pFieldDesc, 2 )[ 0 ] ); + pFieldInfo.atomName = ( BYTE * ) hb_arrayGetString( pFieldDesc, 1 ); + pFieldInfo.uiLen = ( USHORT ) hb_arrayGetDouble( pFieldDesc, 3 ); + pFieldInfo.uiDec = ( USHORT ) hb_arrayGetDouble( pFieldDesc, 4 ); + + SELF_ADDFIELD( pArea, &pFieldInfo ); + } + return SUCCESS; +} + +static ERRCODE Eof( AREAP pArea, BOOL * pEof ) +{ + * pEof = pArea->fEof; + return SUCCESS; +} + static ERRCODE FieldCount( AREAP pArea, USHORT * uiFields ) { * uiFields = pArea->uiFieldCount; @@ -375,106 +259,14 @@ static ERRCODE FieldName( AREAP pArea, USHORT uiIndex, void * szName ) static ERRCODE Flush( AREAP pArea ) { HB_SYMBOL_UNUSED( pArea ); + printf( "Calling default: Flush()\n" ); return SUCCESS; } -static ERRCODE CreateFields( AREAP pArea, PHB_ITEM pStruct ) +static ERRCODE Found( AREAP pArea, BOOL * pFound ) { - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( pStruct ); - printf( "Calling default: CreateFields()\n" ); - return SUCCESS; -} - -static ERRCODE DeleteRec( AREAP pArea ) -{ - HB_SYMBOL_UNUSED( pArea ); - printf( "Calling default: DeleteRec()\n" ); - return SUCCESS; -} - -static ERRCODE Deleted( AREAP pArea, BOOL * pDeleted ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( pDeleted ); - printf( "Calling default: Deleted()\n" ); - return SUCCESS; -} - -static ERRCODE GetValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( uiIndex ); - HB_SYMBOL_UNUSED( pItem ); - printf( "Calling default: GetValue()\n" ); - return SUCCESS; -} - -static ERRCODE PutValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( uiIndex ); - HB_SYMBOL_UNUSED( pItem ); - printf( "Calling default: PutValue()\n" ); - return SUCCESS; -} - -static ERRCODE Recall( AREAP pArea ) -{ - HB_SYMBOL_UNUSED( pArea ); - printf( "Calling default: Recall()\n" ); - return SUCCESS; -} - -static ERRCODE RecCount( AREAP pArea, LONG * pRecCount ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( pRecCount ); - printf( "Calling default: RecCount()\n" ); - return SUCCESS; -} - -static ERRCODE RecNo( AREAP pArea, PHB_ITEM pRecNo ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( pRecNo ); - return SUCCESS; -} - -static ERRCODE SetFieldExtent( AREAP pArea, USHORT uiFieldExtent ) -{ - pArea->uiFieldCount = 0; - pArea->uiFieldExtent = uiFieldExtent; - pArea->lpFields = ( LPFIELD ) hb_xgrab( uiFieldExtent * sizeof( FIELD ) ); - memset( pArea->lpFields, 0, uiFieldExtent * sizeof( FIELD ) ); - return SUCCESS; -} - -static ERRCODE Close( AREAP pArea ) -{ - if( pArea->lpFileInfo->hFile != FS_ERROR ) - hb_fsClose( pArea->lpFileInfo->hFile ); - pArea->lpFileInfo->hFile = FS_ERROR; - ( ( PHB_DYNS ) pArea->atomAlias )->hArea = 0; - return SUCCESS; -} - -static ERRCODE Create( AREAP pArea, LPDBOPENINFO pCreateInfo ) -{ - pArea->lpFileInfo->hFile = hb_fsCreate( pCreateInfo->abName, FC_NORMAL ); - if( pArea->lpFileInfo->hFile == FS_ERROR ) - return FAILURE; - - if( SELF_WRITEDBHEADER( pArea ) == FAILURE ) - { - hb_fsClose( pArea->lpFileInfo->hFile ); - pArea->lpFileInfo->hFile = FS_ERROR; - return FAILURE; - } - - hb_fsClose( pArea->lpFileInfo->hFile ); - pArea->lpFileInfo->hFile = FS_ERROR; + * pFound = pArea->fFound; return SUCCESS; } @@ -483,6 +275,7 @@ static ERRCODE Info( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) HB_SYMBOL_UNUSED( pArea ); HB_SYMBOL_UNUSED( uiIndex ); HB_SYMBOL_UNUSED( pItem ); + printf( "Calling default: Info()\n" ); return SUCCESS; } @@ -569,6 +362,31 @@ static ERRCODE Release( AREAP pArea ) return SUCCESS; } +static ERRCODE SetFieldExtent( AREAP pArea, USHORT uiFieldExtent ) +{ + pArea->uiFieldExtent = uiFieldExtent; + pArea->lpFields = ( LPFIELD ) hb_xgrab( uiFieldExtent * sizeof( FIELD ) ); + memset( pArea->lpFields, 0, uiFieldExtent * sizeof( FIELD ) ); + return SUCCESS; +} + +static ERRCODE Skip( AREAP pArea, LONG lToSkip ) +{ + if( pArea->dbfi.fFilter ) + return SELF_SKIPFILTER( pArea, lToSkip ); + else + return SELF_SKIPRAW( pArea, lToSkip ); +} + +static ERRCODE SkipFilter( AREAP pArea, LONG lToSkip ) +{ + HB_SYMBOL_UNUSED( pArea ); + HB_SYMBOL_UNUSED( lToSkip ); + + printf( "Calling default: SkipFilter()\n" ); + return SUCCESS; +} + static ERRCODE StructSize( AREAP pArea, USHORT * uiSize ) { HB_SYMBOL_UNUSED( pArea ); @@ -589,26 +407,36 @@ static ERRCODE SysName( AREAP pArea, BYTE * pBuffer ) return SUCCESS; } +static ERRCODE UnSupported( AREAP pArea ) +{ + HB_SYMBOL_UNUSED( pArea ); + + printf( "Calling default: UnSupported()\n" ); + return SUCCESS; +} + static RDDFUNCS defTable = { Bof, Eof, Found, - UnSupported_V, - UnSupported_L, - GoToId, - UnSupported_V, + UnSupported, + ( DBENTRYP_L ) UnSupported, + ( DBENTRYP_I ) UnSupported, + UnSupported, Skip, + SkipFilter, + ( DBENTRYP_L ) UnSupported, AddField, CreateFields, - DeleteRec, - Deleted, + UnSupported, + ( DBENTRYP_BP ) UnSupported, FieldCount, FieldName, Flush, - GetValue, - PutValue, - Recall, - RecCount, - RecNo, + ( DBENTRYP_SI ) UnSupported, + ( DBENTRYP_SI ) UnSupported, + UnSupported, + ( DBENTRYP_LP ) UnSupported, + ( DBENTRYP_I ) UnSupported, SetFieldExtent, Close, Create, @@ -618,10 +446,143 @@ static RDDFUNCS defTable = { Bof, Release, StructSize, SysName, - UnSupported_V, - UnSupported_V + UnSupported, + UnSupported }; + +static void hb_rddCheck( void ) +{ + if( !szDefDriver ) + { + szDefDriver = ( char * ) hb_xgrab( 1 ); + szDefDriver[ 0 ] = '\0'; + + /* Force link the built-in RDD's */ + HB_DBF(); + HB_SDF(); + HB_DELIM(); + HB_RDDSYS(); + } +} + +static void hb_rddCloseAll( void ) +{ + pCurrArea = pWorkAreas; + while( pWorkAreas ) + { + pCurrArea = pWorkAreas; + pWorkAreas = pWorkAreas->pNext; + SELF_CLOSE( ( AREAP ) pCurrArea->pArea ); + SELF_RELEASE( ( AREAP ) pCurrArea->pArea ); + hb_xfree( pCurrArea->pArea ); + hb_xfree( pCurrArea ); + } + uiCurrArea = 1; + pCurrArea = 0; + pWorkAreas = 0; +} + +static LPRDDNODE hb_rddFindNode( char * szDriver, USHORT * uiIndex ) +{ + LPRDDNODE pRddNode; + USHORT uiCount; + + uiCount = 0; + pRddNode = pRddList; + while( pRddNode ) + { + if( strcmp( pRddNode->szName, szDriver ) == 0 ) /* Matched RDD */ + { + if( uiIndex ) + * uiIndex = uiCount; + return pRddNode; + } + pRddNode = pRddNode->pNext; + uiCount++; + } + if( uiIndex ) + * uiIndex = 0; + return 0; +} + +static int hb_rddRegister( char * szDriver, USHORT uiType ) +{ + LPRDDNODE pRddNode, pRddNewNode; + PHB_DYNS pGetFuncTable; + char * szGetFuncTable; + + if( hb_rddFindNode( szDriver, 0 ) ) /* Duplicated RDD */ + return 1; + + szGetFuncTable = ( char * ) hb_xgrab( strlen( szDriver ) + 14 ); + strcpy( szGetFuncTable, szDriver ); + strcat( szGetFuncTable, "_GETFUNCTABLE" ); + pGetFuncTable = hb_dynsymFind( szGetFuncTable ); + hb_xfree( szGetFuncTable ); + if( !pGetFuncTable ) + return 2; /* Not valid RDD */ + + /* Create a new RDD node */ + pRddNewNode = ( LPRDDNODE ) hb_xgrab( sizeof( RDDNODE ) ); + memset( pRddNewNode, 0, sizeof( RDDNODE ) ); + + /* Fill the new RDD node */ + strncpy( pRddNewNode->szName, szDriver, HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ); + pRddNewNode->uiType = uiType; + + /* Call _GETFUNCTABLE() */ + hb_vmPushSymbol( pGetFuncTable->pSymbol ); + hb_vmPushNil(); + hb_vmPushLong( ( long ) &pRddNewNode->uiFunctions ); + hb_vmPushLong( ( long ) &pRddNewNode->pTable ); + hb_vmDo( 2 ); + if ( hb_parni( -1 ) != SUCCESS ) + { + hb_xfree( pRddNewNode ); /* Delete de new RDD node */ + return 3; /* Invalid FUNCTABLE */ + } + + if( !pRddList ) /* First RDD node */ + pRddList = pRddNewNode; + else + { + pRddNode = pRddList; + while( pRddNode->pNext ) + pRddNode = pRddNode->pNext; /* Locate the last RDD node */ + pRddNode->pNext = pRddNewNode; /* Add the new RDD node */ + } + return 0; /* Ok */ +} + +static USHORT hb_rddSelect( char * szAlias ) +{ + PHB_DYNS pSymAlias; + + pSymAlias = hb_dynsymFind( szAlias ); + if( pSymAlias && pSymAlias->hArea ) + return pSymAlias->hArea; + else + return 0; +} + +static void hb_rddSelectFirstAvailable( void ) +{ + LPAREANODE pAreaNode; + + uiCurrArea = 1; + pAreaNode = pWorkAreas; + while( pAreaNode ) + { + if( ( ( AREAP ) pAreaNode->pArea )->uiArea > uiCurrArea ) + break; + else if( ( ( AREAP ) pAreaNode->pArea )->uiArea == uiCurrArea ) + uiCurrArea++; + pAreaNode = pAreaNode->pNext; + } + pCurrArea = 0; /* Selected WorkArea must be created */ +} + ERRCODE hb_rddInherit( PRDDFUNCS pTable, PRDDFUNCS pSubTable, PRDDFUNCS pSuperTable, BYTE * szDrvName ) { char * szSuperName; @@ -641,8 +602,8 @@ ERRCODE hb_rddInherit( PRDDFUNCS pTable, PRDDFUNCS pSubTable, PRDDFUNCS pSuperTa { szSuperName = ( char * ) hb_xgrab( uiCount + 1 ); strcpy( szSuperName, ( char * ) szDrvName ); - szSuperName = hb_strUpper( szSuperName, uiCount ); - pRddNode = hb_FindRddNode( szSuperName, 0 ); + hb_strUpper( szSuperName, uiCount ); + pRddNode = hb_rddFindNode( szSuperName, 0 ); hb_xfree( szSuperName ); if( !pRddNode ) { @@ -664,12 +625,12 @@ ERRCODE hb_rddInherit( PRDDFUNCS pTable, PRDDFUNCS pSubTable, PRDDFUNCS pSuperTa return SUCCESS; } -int hb_GetCurrentWorkAreaNumber( void ) +int hb_rddGetCurrentWorkAreaNumber( void ) { return uiCurrArea; } -void hb_SelectWorkAreaNumber( int iArea ) +void hb_rddSelectWorkAreaNumber( int iArea ) { LPAREANODE pAreaNode; @@ -688,6 +649,25 @@ void hb_SelectWorkAreaNumber( int iArea ) pCurrArea = 0; /* Selected WorkArea is closed */ } +void hb_rddSelectWorkAreaAlias( char * szName ) +{ + PHB_DYNS pSymArea; + char * szAlias; + WORD wLen; + + wLen = strlen( szName ); + szAlias = ( char * ) hb_xgrab( wLen + 1 ); + strcpy( szAlias, szName ); + hb_strUpper( szAlias, wLen ); + pSymArea = hb_dynsymFind( szAlias ); + if( pSymArea && pSymArea->hArea ) + hb_rddSelectWorkAreaNumber( pSymArea->hArea ); + else + hb_errRT_BASE( EG_NOALIAS, 1002, 0, szAlias ); + + hb_xfree( szAlias ); +} + /* * -- HARBOUR FUNCTIONS -- */ @@ -728,7 +708,7 @@ HARBOUR HB_BOF( void ) HARBOUR HB_DBCLOSEALL( void ) { - hb_CloseAll(); + hb_rddCloseAll(); } HARBOUR HB_DBCLOSEAREA( void ) @@ -797,15 +777,15 @@ HARBOUR HB_DBCREATE( void ) } } - hb_CheckRdd(); + hb_rddCheck(); szDriver = hb_parc( 3 ); if( ( wLen = strlen( szDriver ) ) > 0 ) - szDriver = hb_strUpper( szDriver, wLen ); + hb_strUpper( szDriver, wLen ); else szDriver = szDefDriver; uiRddID = 0; - pRddNode = hb_FindRddNode( szDriver, &uiRddID ) ; + pRddNode = hb_rddFindNode( szDriver, &uiRddID ) ; if( !pRddNode ) { hb_errRT_DBCMD( EG_ARG, 1015, 0, "DBCREATE" ); @@ -904,9 +884,9 @@ HARBOUR HB_DBSELECTAREA( void ) if( ISCHAR( 1 ) ) { szAlias = hb_parc( 1 ); - szAlias = hb_strUpper( szAlias, strlen( szAlias ) ); + hb_strUpper( szAlias, strlen( szAlias ) ); - if( ( uiNewArea = hb_Select( szAlias ) ) == 0 ) + if( ( uiNewArea = hb_rddSelect( szAlias ) ) == 0 ) { hb_errRT_BASE( EG_NOALIAS, 1002, 0, szAlias ); return; @@ -916,7 +896,7 @@ HARBOUR HB_DBSELECTAREA( void ) uiNewArea = hb_parni( 1 ); if( uiNewArea == 0 ) - hb_SelectFirstAvailable(); + hb_rddSelectFirstAvailable(); else uiCurrArea = uiNewArea; @@ -968,9 +948,9 @@ HARBOUR HB_DBTABLEEXT( void ) if( !pCurrArea ) { - hb_CheckRdd(); + hb_rddCheck(); uiRddID = 0; - pRddNode = hb_FindRddNode( szDefDriver, &uiRddID ); + pRddNode = hb_rddFindNode( szDefDriver, &uiRddID ); if( !pRddNode ) { hb_retc( "" ); @@ -1023,7 +1003,7 @@ HARBOUR HB_DBUSEAREA( void ) uiNetError = 0; if( hb_parl( 1 ) ) - hb_SelectFirstAvailable(); + hb_rddSelectFirstAvailable(); else if( pCurrArea ) /* If current WorkArea is in use then close it */ { SELF_CLOSE( ( AREAP ) pCurrArea->pArea ); @@ -1044,15 +1024,15 @@ HARBOUR HB_DBUSEAREA( void ) pCurrArea = 0; } - hb_CheckRdd(); + hb_rddCheck(); szDriver = hb_parc( 2 ); if( ( wLen = strlen( szDriver ) ) > 0 ) - szDriver = hb_strUpper( szDriver, wLen ); + hb_strUpper( szDriver, wLen ); else szDriver = szDefDriver; uiRddID = 0; - pRddNode = hb_FindRddNode( szDriver, &uiRddID ); + pRddNode = hb_rddFindNode( szDriver, &uiRddID ); if( !pRddNode ) { hb_errRT_DBCMD( EG_ARG, 1015, 0, "DBUSEAREA" ); @@ -1232,7 +1212,7 @@ HARBOUR HB_FIELDPOS( void ) if( pCurrArea && ( ( AREAP ) pCurrArea->pArea )->lprfsHost ) { szName = hb_parc( 1 ); - szName = hb_strUpper( szName, strlen( szName ) ); + hb_strUpper( szName, strlen( szName ) ); uiCount = 0; pField = ( ( AREAP ) pCurrArea->pArea )->lpFields; while( pField ) @@ -1287,7 +1267,7 @@ HARBOUR HB_RDDLIST( void ) PHB_ITEM pName; LPRDDNODE pRddNode; - hb_CheckRdd(); + hb_rddCheck(); hb_arrayNew( &stack.Return, 0 ); pName = hb_itemNew( 0 ); pRddNode = pRddList; @@ -1325,11 +1305,11 @@ HARBOUR HB_RDDREGISTER( void ) char * szDriver; WORD wLen; - hb_CheckRdd(); + hb_rddCheck(); szDriver = hb_parc( 1 ); if( ( wLen = strlen( szDriver ) ) > 0 ) { - szDriver = hb_strUpper( szDriver, wLen ); + hb_strUpper( szDriver, wLen ); /* * hb_rddRegister returns: * @@ -1348,12 +1328,12 @@ HARBOUR HB_RDDSETDEFAULT( void ) char * szNewDriver; WORD wLen; - hb_CheckRdd(); + hb_rddCheck(); hb_retc( szDefDriver ); szNewDriver = hb_parc( 1 ); if( ( wLen = strlen( szNewDriver ) ) > 0 ) { - szNewDriver = hb_strUpper( szNewDriver, wLen ); + hb_strUpper( szNewDriver, wLen ); szDefDriver = ( char * ) hb_xrealloc( szDefDriver, wLen + 1 ); strcpy( szDefDriver, szNewDriver ); } @@ -1363,7 +1343,7 @@ HARBOUR HB_RDDSHUTDOWN( void ) { LPRDDNODE pRddNode; - hb_CloseAll(); + hb_rddCloseAll(); hb_xfree( szDefDriver ); while( pRddList ) { @@ -1373,18 +1353,6 @@ HARBOUR HB_RDDSHUTDOWN( void ) } } -HARBOUR HB_RECNO( void ) -{ - if( pCurrArea && ( ( AREAP ) pCurrArea->pArea )->lprfsHost ) - { - SELF_RECNO( ( AREAP ) pCurrArea->pArea, - ( ( AREAP ) pCurrArea->pArea )->lpExtendInfo->pRecNo ); - hb_itemReturn( ( ( AREAP ) pCurrArea->pArea )->lpExtendInfo->pRecNo ); - } - else - hb_retni( 0 ); -} - HARBOUR HB_RECCOUNT( void ) { LONG ulRecCount = 0; @@ -1394,13 +1362,23 @@ HARBOUR HB_RECCOUNT( void ) hb_retnl( ulRecCount ); } +HARBOUR HB_RECNO( void ) +{ + PHB_ITEM pRecNo; + + pRecNo = hb_itemPutNL( NULL, 0 ); + if( pCurrArea && ( ( AREAP ) pCurrArea->pArea )->lprfsHost ) + SELF_RECNO( ( AREAP ) pCurrArea->pArea, pRecNo ); + hb_itemReturn( pRecNo ); +} + HARBOUR HB_SELECT( void ) { char * szAlias; szAlias = hb_parc( 1 ); if( strlen( szAlias ) > 0 ) - hb_retni( hb_Select( szAlias ) ); + hb_retni( hb_rddSelect( szAlias ) ); else hb_retni( uiCurrArea ); } diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 00bca01098..d3fbaf38c2 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -74,17 +74,84 @@ HB_INIT_SYMBOLS_END( dbf1__InitSymbols ) #pragma startup dbf1__InitSymbols #endif -static ERRCODE ReadBuffer( AREAP pArea, LONG lRecNo ) +static ERRCODE ReadBuffer( AREAP pArea, LONG lRecNo ); + +/* + * -- DBF METHODS -- + */ + +static ERRCODE Deleted( AREAP pArea, BOOL * pDeleted ) { - hb_fsSeek( pArea->lpFileInfo->hFile, pArea->lpExtendInfo->uiHeaderLen + - ( lRecNo - 1 ) * pArea->lpExtendInfo->uiRecordLen, FS_SET ); - if( hb_fsRead( pArea->lpFileInfo->hFile, pArea->lpExtendInfo->bRecord, - pArea->lpExtendInfo->uiRecordLen ) != pArea->lpExtendInfo->uiRecordLen ) - { - memset( pArea->lpExtendInfo->bRecord, ' ', pArea->lpExtendInfo->uiRecordLen ); - pArea->lpExtendInfo->bRecord[ pArea->lpExtendInfo->uiRecordLen ] = 0; + if( pArea->lpExtendInfo->bRecord[ 0 ] == '*' ) + * pDeleted = TRUE; + else + * pDeleted = FALSE; + return SUCCESS; +} + +static ERRCODE DeleteRec( AREAP pArea ) +{ + HB_SYMBOL_UNUSED( pArea ); + + printf( "Calling DBF: DeleteRec()\n" ); + return SUCCESS; +} + +static ERRCODE GetValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) +{ + LPFIELD pField; + USHORT uiCount, uiOffset; + BYTE * szText, * szOldChar, szEndChar; + + if( uiIndex > pArea->uiFieldCount ) return FAILURE; + + pField = pArea->lpFields; + uiOffset = 1; + for( uiCount = 1; uiCount < uiIndex; uiCount++ ) + { + if( pField->uiType == 'C' ) + uiOffset += pField->uiLen + ( ( USHORT ) pField->uiDec << 8 ); + else + uiOffset += pField->uiLen; + pField = pField->lpfNext; } + + szText = pArea->lpExtendInfo->bRecord + uiOffset; + switch( pField->uiType ) + { + case 'C': + hb_itemPutCL( pItem, ( char * ) szText, + pField->uiLen + ( ( USHORT ) pField->uiDec << 8 ) ); + break; + + case 'N': + szOldChar = szText + pField->uiLen; + szEndChar = * szOldChar; + * szOldChar = 0; + if( pField->uiDec ) + hb_itemPutND( pItem, atof( ( char * ) szText ) ); + else + hb_itemPutNL( pItem, atof( ( char * ) szText ) ); + * szOldChar = szEndChar; + break; + + case 'D': + szOldChar = szText + pField->uiLen; + szEndChar = * szOldChar; + * szOldChar = 0; + hb_itemPutDS( pItem, ( char * ) szText ); + * szOldChar = szEndChar; + break; + + case 'L': + if( * szText == 'T' ) + hb_itemPutL( pItem, 1 ); + else + hb_itemPutL( pItem, 0 ); + break; + } + return SUCCESS; } @@ -144,118 +211,15 @@ static ERRCODE GoTop( AREAP pArea ) return SELF_GOTO( pArea, 1 ); } -static ERRCODE Skip( AREAP pArea, LONG lToSkip ) -{ - return SELF_GOTO( pArea, hb_itemGetNL( pArea->lpExtendInfo->pRecNo ) + lToSkip ); -} - -static ERRCODE CreateFields( AREAP pArea, PHB_ITEM pStruct ) -{ - USHORT uiCount; - PHB_ITEM pFieldDesc; - DBFIELDINFO pFieldInfo; - - SELF_SETFIELDEXTENT( pArea, pStruct->item.asArray.value->ulLen ); - pFieldInfo.typeExtended = 0; - for( uiCount = 0; uiCount < pStruct->item.asArray.value->ulLen; uiCount++ ) - { - pFieldDesc = pStruct->item.asArray.value->pItems + uiCount; - pFieldInfo.atomName = ( BYTE * ) hb_arrayGetString( pFieldDesc, 1 ); - pFieldInfo.uiLen = 0; - pFieldInfo.uiType = toupper( hb_arrayGetString( pFieldDesc, 2 )[ 0 ] ); - if( pFieldInfo.uiType == 'N' ) - { - pFieldInfo.uiLen = ( USHORT ) hb_arrayGetDouble( pFieldDesc, 3 ); - pFieldInfo.uiDec = ( USHORT ) hb_arrayGetDouble( pFieldDesc, 4 ); - } - else - { - if( pFieldInfo.uiType == 'L' || pFieldInfo.uiType == 'D' || - pFieldInfo.uiType == 'M' ) - pFieldInfo.uiLen = ( USHORT ) hb_arrayGetDouble( pFieldDesc, 3 ); - else if( pFieldInfo.uiType == 'C' ) - { - pFieldInfo.uiLen = ( USHORT ) hb_arrayGetDouble( pFieldDesc, 3 ) + - ( ( USHORT ) hb_arrayGetDouble( pFieldDesc, 4 ) << 8 ); - } - pFieldInfo.uiDec = 0; - } - SELF_ADDFIELD( pArea, &pFieldInfo ); - } - return SUCCESS; -} - -static ERRCODE DeleteRec( AREAP pArea ) +static ERRCODE Info( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { HB_SYMBOL_UNUSED( pArea ); - printf( "Calling DBF: DeleteRec()\n" ); - return SUCCESS; -} - -static ERRCODE Deleted( AREAP pArea, BOOL * pDeleted ) -{ - if( pArea->lpExtendInfo->bRecord[ 0 ] == '*' ) - * pDeleted = TRUE; - else - * pDeleted = FALSE; - return SUCCESS; -} - -static ERRCODE GetValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) -{ - LPFIELD pField; - USHORT uiCount, uiOffset; - BYTE * szText, * szOldChar, szEndChar; - - if( uiIndex > pArea->uiFieldCount ) - return FAILURE; - - pField = pArea->lpFields; - uiOffset = 1; - for( uiCount = 1; uiCount < uiIndex; uiCount++ ) + switch( uiIndex ) { - if( pField->uiType == 'C' ) - uiOffset += pField->uiLen + ( ( USHORT ) pField->uiDec << 8 ); - else - uiOffset += pField->uiLen; - pField = pField->lpfNext; - } - - szText = pArea->lpExtendInfo->bRecord + uiOffset; - switch( pField->uiType ) - { - case 'C': - hb_itemPutCL( pItem, ( char * ) szText, - pField->uiLen + ( ( USHORT ) pField->uiDec << 8 ) ); - break; - - case 'N': - szOldChar = szText + pField->uiLen; - szEndChar = * szOldChar; - * szOldChar = 0; - if( pField->uiDec ) - hb_itemPutND( pItem, atof( ( char * ) szText ) ); - else - hb_itemPutNL( pItem, atof( ( char * ) szText ) ); - * szOldChar = szEndChar; - break; - - case 'D': - szOldChar = szText + pField->uiLen; - szEndChar = * szOldChar; - * szOldChar = 0; - hb_itemPutDS( pItem, ( char * ) szText ); - * szOldChar = szEndChar; - break; - - case 'L': - if( * szText == 'T' ) - hb_itemPutL( pItem, 1 ); - else - hb_itemPutL( pItem, 0 ); + case DBI_TABLEEXT: + hb_itemPutC( pItem, ".DBF" ); break; } - return SUCCESS; } @@ -337,26 +301,16 @@ static ERRCODE PutValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) return SUCCESS; } -static ERRCODE RecCount( AREAP pArea, LONG * pRecCount ) +static ERRCODE ReadBuffer( AREAP pArea, LONG lRecNo ) { - DBFHEADER pHeader; - - hb_fsSeek( pArea->lpFileInfo->hFile, 0, FS_SET ); - if( hb_fsRead( pArea->lpFileInfo->hFile, ( BYTE * ) &pHeader, - sizeof( DBFHEADER ) ) != sizeof( DBFHEADER ) ) - return FAILURE; - * pRecCount = pHeader.ulRecords; - return SUCCESS; -} - -static ERRCODE Info( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) -{ - HB_SYMBOL_UNUSED( pArea ); - switch( uiIndex ) + hb_fsSeek( pArea->lpFileInfo->hFile, pArea->lpExtendInfo->uiHeaderLen + + ( lRecNo - 1 ) * pArea->lpExtendInfo->uiRecordLen, FS_SET ); + if( hb_fsRead( pArea->lpFileInfo->hFile, pArea->lpExtendInfo->bRecord, + pArea->lpExtendInfo->uiRecordLen ) != pArea->lpExtendInfo->uiRecordLen ) { - case DBI_TABLEEXT: - hb_itemPutC( pItem, ".DBF" ); - break; + memset( pArea->lpExtendInfo->bRecord, ' ', pArea->lpExtendInfo->uiRecordLen ); + pArea->lpExtendInfo->bRecord[ pArea->lpExtendInfo->uiRecordLen ] = 0; + return FAILURE; } return SUCCESS; } @@ -440,6 +394,29 @@ static ERRCODE ReadDBHeader( AREAP pArea ) return SUCCESS; } +static ERRCODE RecCount( AREAP pArea, LONG * pRecCount ) +{ + DBFHEADER pHeader; + + hb_fsSeek( pArea->lpFileInfo->hFile, 0, FS_SET ); + if( hb_fsRead( pArea->lpFileInfo->hFile, ( BYTE * ) &pHeader, + sizeof( DBFHEADER ) ) != sizeof( DBFHEADER ) ) + return FAILURE; + * pRecCount = pHeader.ulRecords; + return SUCCESS; +} + +static ERRCODE RecNo( AREAP pArea, PHB_ITEM pRecNo ) +{ + hb_itemCopy( pRecNo, pArea->lpExtendInfo->pRecNo ); + return SUCCESS; +} + +static ERRCODE SkipRaw( AREAP pArea, LONG lToSkip ) +{ + return SELF_GOTO( pArea, hb_itemGetNL( pArea->lpExtendInfo->pRecNo ) + lToSkip ); +} + static ERRCODE WriteDBHeader( AREAP pArea ) { DBFHEADER pHeader; @@ -543,9 +520,11 @@ static RDDFUNCS dbfTable = { 0, /* Super Bof */ GoTo, GoToId, GoTop, - Skip, + 0, /* Super Skip */ + 0, /* Super SkipFilter */ + SkipRaw, 0, /* Super AddField */ - CreateFields, + 0, /* Super CreateFields */ DeleteRec, Deleted, 0, /* Super FieldCount */ diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 80cb7e551e..293334c299 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -39,51 +39,9 @@ HB_INIT_SYMBOLS_END( dbfntx1__InitSymbols ) #pragma startup dbfntx1__InitSymbols #endif -static ERRCODE Info( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) -{ - HB_SYMBOL_UNUSED( pArea ); - switch( uiIndex ) - { - case DBI_TABLEEXT: - hb_itemPutC( pItem, ".DBF" ); - break; - } - return SUCCESS; -} - static RDDFUNCS ntxSuper = { 0 }; -static RDDFUNCS ntxTable = { 0, /* Super Bof */ - 0, /* Super Eof */ - 0, /* Super Found */ - 0, /* Super GoBottom */ - 0, /* Super GoTo */ - 0, /* Super GoToId */ - 0, /* Super GoTop */ - 0, /* Super Skip */ - 0, /* Super AddField */ - 0, /* Super CreateFields */ - 0, /* Super DeleteRec */ - 0, /* Super Deleted */ - 0, /* Super FieldCount */ - 0, /* Super FieldName */ - 0, /* Super Flush */ - 0, /* Super GetValue */ - 0, /* Super PutValue */ - 0, /* Super Recall */ - 0, /* Super RecCount */ - 0, /* Super SetFieldExtent */ - 0, /* Super RecNo */ - 0, /* Super Close */ - 0, /* Super Create */ - Info, - 0, /* Super NewArea */ - 0, /* Super Open */ - 0, /* Super Release */ - 0, /* Super StructSize */ - 0, /* Super SysName */ - 0 /* Super WriteDBHeader */ - }; +static RDDFUNCS ntxTable = { 0 }; HARBOUR HB__DBFNTX( void ) { diff --git a/harbour/source/rdd/delim1.c b/harbour/source/rdd/delim1.c index 3450ac0fb5..3cb3feee55 100644 --- a/harbour/source/rdd/delim1.c +++ b/harbour/source/rdd/delim1.c @@ -38,63 +38,9 @@ HB_INIT_SYMBOLS_END( delim1__InitSymbols ) #pragma startup delim1__InitSymbols #endif -static ERRCODE Info( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( uiIndex ); - HB_SYMBOL_UNUSED( pItem ); - printf( "Calling DELIM: Info()\n" ); - return SUCCESS; -} - -static ERRCODE ReadDBHeader( AREAP pArea ) -{ - HB_SYMBOL_UNUSED( pArea ); - printf( "Calling DELIM: ReadDBHeader()\n" ); - return SUCCESS; -} - -static ERRCODE WriteDBHeader( AREAP pArea ) -{ - HB_SYMBOL_UNUSED( pArea ); - printf( "Calling DELIM: WriteDBHeader()\n" ); - return SUCCESS; -} - static RDDFUNCS delimSuper = { 0 }; -static RDDFUNCS delimTable = { 0, /* Super Bof */ - 0, /* Super Eof */ - 0, /* Super Found */ - 0, /* Super GoBottom */ - 0, /* Super GoTo */ - 0, /* Super GoToId */ - 0, /* Super GoTop */ - 0, /* Super Skip */ - 0, /* Super AddField */ - 0, /* Super CreateFields */ - 0, /* Super DeleteRec */ - 0, /* Super Deleted */ - 0, /* Super FieldCount */ - 0, /* Super FieldName */ - 0, /* Super Flush */ - 0, /* Super GetValue */ - 0, /* Super PutValue */ - 0, /* Super Recall */ - 0, /* Super RecCount */ - 0, /* Super RecNo */ - 0, /* Super SetFieldExtent */ - 0, /* Super Close */ - 0, /* Super Create */ - Info, - 0, /* Super NewArea */ - 0, /* Super Open */ - 0, /* Super Release */ - 0, /* Super StructSize */ - 0, /* Super SysName */ - ReadDBHeader, - WriteDBHeader - }; +static RDDFUNCS delimTable = { 0 }; HARBOUR HB__DELIM( void ) { diff --git a/harbour/source/rdd/sdf1.c b/harbour/source/rdd/sdf1.c index a3dd4a954c..97b05f73a5 100644 --- a/harbour/source/rdd/sdf1.c +++ b/harbour/source/rdd/sdf1.c @@ -38,63 +38,9 @@ HB_INIT_SYMBOLS_END( sdf1__InitSymbols ) #pragma startup sdf1__InitSymbols #endif -static ERRCODE Info( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) -{ - HB_SYMBOL_UNUSED( pArea ); - HB_SYMBOL_UNUSED( uiIndex ); - HB_SYMBOL_UNUSED( pItem ); - printf( "Calling SDF: Info()\n" ); - return SUCCESS; -} - -static ERRCODE ReadDBHeader( AREAP pArea ) -{ - HB_SYMBOL_UNUSED( pArea ); - printf( "Calling SDF: ReadDBHeader()\n" ); - return SUCCESS; -} - -static ERRCODE WriteDBHeader( AREAP pArea ) -{ - HB_SYMBOL_UNUSED( pArea ); - printf( "Calling SDF: WriteDBHeader()\n" ); - return SUCCESS; -} - static RDDFUNCS sdfSuper = { 0 }; -static RDDFUNCS sdfTable = { 0, /* Super Bof */ - 0, /* Super Eof */ - 0, /* Super Found */ - 0, /* Super GoBottom */ - 0, /* Super GoTo */ - 0, /* Super GoToId */ - 0, /* Super GoTop */ - 0, /* Super Skip */ - 0, /* Super AddField */ - 0, /* Super CreateFields */ - 0, /* Super DeleteRec */ - 0, /* Super Deleted */ - 0, /* Super FieldCount */ - 0, /* Super FieldName */ - 0, /* Super Flush */ - 0, /* Super GetValue */ - 0, /* Super PutValue */ - 0, /* Super Recall */ - 0, /* Super RecCount */ - 0, /* Super RecNo */ - 0, /* Super SetFieldExtent */ - 0, /* Super Close */ - 0, /* Super Create */ - Info, - 0, /* Super NewArea */ - 0, /* Super Open */ - 0, /* Super Release */ - 0, /* Super StructSize */ - 0, /* Super SysName */ - ReadDBHeader, - WriteDBHeader - }; +static RDDFUNCS sdfTable = { 0 }; HARBOUR HB__SDF( void ) { diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index dbbcc2a1ef..de497f0bc3 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -44,8 +44,8 @@ extern void hb_consoleInitialize( void ); extern void hb_consoleRelease( void ); extern void InitSymbolTable( void ); /* initialization of runtime support symbols */ -extern int hb_GetCurrentWorkAreaNumber( void ); -extern void hb_SelectWorkAreaNumber( int iArea ); +extern int hb_rddGetCurrentWorkAreaNumber( void ); +extern void hb_rddSelectWorkAreaNumber( int iArea ); typedef struct _SYMBOLS { @@ -625,14 +625,14 @@ static void hb_vmAliasPop( void ) * or it was saved on the stack using hb_vmAliasPush() * or was evaluated from an expression, (nWorkArea)->field */ - hb_SelectWorkAreaNumber( pItem->item.asInteger.value ); + hb_rddSelectWorkAreaNumber( pItem->item.asInteger.value ); pItem->type = IT_NIL; break; case IT_SYMBOL: /* Alias was specified using alias identifier, for example: al->field */ - hb_SelectWorkAreaNumber( pItem->item.asSymbol.value->pDynSym->hArea ); + hb_rddSelectWorkAreaNumber( pItem->item.asSymbol.value->pDynSym->hArea ); pItem->type = IT_NIL; break; @@ -659,7 +659,7 @@ static void hb_vmAliasPop( void ) static void hb_vmAliasPush( void ) { stack.pPos->type = IT_INTEGER; - stack.pPos->item.asInteger.value = hb_GetCurrentWorkAreaNumber(); + stack.pPos->item.asInteger.value = hb_rddGetCurrentWorkAreaNumber(); stack.pPos->item.asInteger.length = 10; hb_stackPush(); HB_DEBUG( "hb_vmAliasPush\n" ); @@ -673,7 +673,7 @@ static void hb_vmAliasSwap( void ) HB_ITEM_PTR pItem = stack.pPos -1; HB_ITEM_PTR pWorkArea = stack.pPos -2; - hb_SelectWorkAreaNumber( pWorkArea->item.asInteger.value ); + hb_rddSelectWorkAreaNumber( pWorkArea->item.asInteger.value ); memcpy( pWorkArea, pItem, sizeof( HB_ITEM ) ); pItem->type =IT_NIL; hb_stackDec();