2001-04-26 01:15 UTC-0800 Brian Hays <bhays@abacuslaw.com>
This commit is contained in:
@@ -1,3 +1,28 @@
|
||||
2001-04-26 01:15 UTC-0800 Brian Hays <bhays@abacuslaw.com>
|
||||
|
||||
* source/rdd/dbcmd.c
|
||||
* __dbLocate wasn't freeing mem blocks if dataset was empty
|
||||
* added ordKeyCount
|
||||
* formatted comments
|
||||
* removed HB_SYMBOL_UNUSED( bRest ); since it's used now
|
||||
* Fixed logic in __dbCopy for only having a For clause
|
||||
(it was failing to copy if first record failed test)
|
||||
Harrier - please review my change to bFor/pFor testing
|
||||
|
||||
* contrib/rdd_ads/adsfunc.c
|
||||
+ Added ADSGETFILTER() for retrieving what ADS thinks the
|
||||
filter is
|
||||
|
||||
* contrib/rdd_ads/ads1.c
|
||||
* fixed dbOrderInfo(DBOI_KEYCOUNT) when no scope was set
|
||||
(was returning 0)
|
||||
|
||||
* contrib/rdd_ads/adsmgmnt.c
|
||||
* removed unneeded headers
|
||||
|
||||
* source/rtl/dummy.prg
|
||||
* removed ordKeyCount
|
||||
|
||||
2001-04-25 17:51 GMT-3 Horacio Roldan <horacioroldan@usa.net>
|
||||
*source/rdd/workarea.c
|
||||
* patched GPF using valResult.
|
||||
|
||||
@@ -246,15 +246,20 @@ static ERRCODE hb_adsCheckBofEof( ADSAREAP pArea )
|
||||
|
||||
ERRCODE adsCloseCursor( ADSAREAP pArea )
|
||||
{
|
||||
UNSIGNED32 ulRetVal;
|
||||
ERRCODE uiError;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("adsCloseCursor(%p)", pArea));
|
||||
|
||||
if( pArea->hTable )
|
||||
{
|
||||
AdsCloseTable ( pArea->hTable );
|
||||
ulRetVal = AdsCloseTable ( pArea->hTable );
|
||||
if ( ulRetVal != AE_SUCCESS )
|
||||
HB_TRACE(HB_TR_ALWAYS, ("adsCloseTable failed (%lu, %s)", ulRetVal, pArea->szDataFileName));
|
||||
|
||||
pArea->hTable = 0;
|
||||
}
|
||||
|
||||
uiError = SUPER_CLOSE( (AREAP)pArea ); // dbCreate needs this even if
|
||||
|
||||
/* Free field offset array */
|
||||
@@ -540,7 +545,7 @@ static ERRCODE adsSkip( ADSAREAP pArea, LONG lToSkip )
|
||||
hb_adsCheckBofEof( pArea );
|
||||
lReturn = SUPER_SKIPFILTER( (AREAP)pArea, lUnit );
|
||||
|
||||
// now handle non-1 values
|
||||
/* now handle non-1 values */
|
||||
while( lCount > 1 && lReturn == SUCCESS && !pArea->fBof && !pArea->fEof)
|
||||
{
|
||||
AdsSkip ( (pArea->hOrdCurrent) ? pArea->hOrdCurrent : pArea->hTable, lUnit );
|
||||
@@ -662,7 +667,6 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
|
||||
{
|
||||
LPFIELD pField;
|
||||
BYTE * pBuffer = pArea->pRecord;
|
||||
// char szBuffer[ 21 ];
|
||||
UNSIGNED8 szName[ HARBOUR_MAX_RDD_FIELDNAME_LENGTH + 1 ];
|
||||
UNSIGNED16 pusBufLen = HARBOUR_MAX_RDD_FIELDNAME_LENGTH;
|
||||
UNSIGNED32 pulLength;
|
||||
@@ -803,7 +807,6 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
|
||||
return FAILURE;
|
||||
|
||||
pField = pArea->lpFields + uiIndex - 1;
|
||||
// szText = pArea->pRecord + pArea->pFieldOffset[ uiIndex - 1 ];
|
||||
szText = pArea->pRecord;
|
||||
bError = TRUE;
|
||||
AdsGetFieldName( pArea->hTable, uiIndex, szName, &pusBufLen );
|
||||
@@ -816,8 +819,6 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
|
||||
uiCount = ( USHORT ) hb_itemGetCLen( pItem );
|
||||
if( uiCount > pField->uiLen )
|
||||
uiCount = pField->uiLen;
|
||||
// memcpy( szText, hb_itemGetCPtr( pItem ), uiCount );
|
||||
// memset( szText + uiCount, ' ', pField->uiLen - uiCount );
|
||||
AdsSetString( pArea->hTable, szName, (UCHAR*)hb_itemGetCPtr( pItem ), uiCount );
|
||||
bError = FALSE;
|
||||
}
|
||||
@@ -1158,6 +1159,7 @@ static ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo )
|
||||
commonError( pArea, EG_OPEN, ( USHORT ) ulRetVal, ( char * ) pOpenInfo->abName );
|
||||
|
||||
}
|
||||
|
||||
pArea->hTable = hTable;
|
||||
pArea->fShared = pOpenInfo->fShared;
|
||||
pArea->fReadonly = pOpenInfo->fReadonly;
|
||||
@@ -1725,6 +1727,8 @@ static ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrde
|
||||
AdsGotoRecord( pArea->hTable, pArea->ulRecNo );
|
||||
AdsAtEOF( pArea->hTable, (UNSIGNED16 *)&(pArea->fEof) );
|
||||
}
|
||||
else /* no scope set */
|
||||
AdsGetRecordCount ( phIndex, ADS_RESPECTFILTERS, &pul32);
|
||||
}else
|
||||
AdsGetRecordCount( pArea->hTable, ADS_RESPECTFILTERS, &pul32);
|
||||
|
||||
@@ -1829,10 +1833,6 @@ static ERRCODE adsClearFilter( ADSAREAP pArea )
|
||||
We don't know if an AOF was used.
|
||||
Since a call to the server would need to be made to see if there's an AOF
|
||||
anyway, just always attempt to clear it.
|
||||
///
|
||||
///UNSIGNED8 aucAOF[64];
|
||||
///UNSIGNED16 usLength;
|
||||
/// if ( AdsGetAOF( pArea->hTable, aucAOF, &usLength ) == AE_SUCCESS && usLength > 0)
|
||||
*/
|
||||
AdsClearAOF ( pArea->hTable );
|
||||
AdsClearFilter ( pArea->hTable );
|
||||
|
||||
@@ -479,6 +479,34 @@ HB_FUNC( ADSSETAOF )
|
||||
|
||||
}
|
||||
|
||||
HB_FUNC( ADSGETFILTER )
|
||||
{
|
||||
ADSAREAP pArea;
|
||||
UNSIGNED8 pucFilter[HARBOUR_MAX_RDD_FILTER_LENGTH+1];
|
||||
UNSIGNED8 *pucFilter2;
|
||||
UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH;
|
||||
UNSIGNED32 ulRetVal;
|
||||
|
||||
hb_retc( "" );
|
||||
pArea = (ADSAREAP) hb_rddGetCurrentWorkAreaPointer();
|
||||
if( pArea )
|
||||
{
|
||||
ulRetVal = AdsGetFilter( pArea->hTable, pucFilter, &pusLen );
|
||||
if ( ulRetVal == AE_SUCCESS )
|
||||
{
|
||||
if ( pusLen > HARBOUR_MAX_RDD_FILTER_LENGTH )
|
||||
{
|
||||
pucFilter2 = (UNSIGNED8*) hb_xgrab(pusLen + 1);
|
||||
ulRetVal = AdsGetFilter( pArea->hTable, pucFilter2, &pusLen );
|
||||
if ( ulRetVal == AE_SUCCESS )
|
||||
hb_retc( pucFilter2 );
|
||||
hb_xfree( pucFilter2 );
|
||||
}
|
||||
else
|
||||
hb_retc( pucFilter );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( ADSENABLEENCRYPTION )
|
||||
{
|
||||
|
||||
@@ -53,14 +53,6 @@
|
||||
|
||||
#define HB_OS_WIN_32_USED
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbinit.h"
|
||||
#include "hbvm.h"
|
||||
#include "rddsys.ch"
|
||||
#include "hbapilng.h"
|
||||
#include "hbdate.h"
|
||||
#include "hbapierr.h"
|
||||
#include "rddads.h"
|
||||
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ static LPRDDNODE s_pRddList = NULL; /* Registered RDD's */
|
||||
static BOOL s_bNetError = FALSE; /* Error on Networked environments */
|
||||
|
||||
static LPAREANODE s_pWorkAreas = NULL; /* WorkAreas */
|
||||
static LPAREANODE s_pCurrArea = NULL; /* Pointer to a selectd and valid area */
|
||||
static LPAREANODE s_pCurrArea = NULL; /* Pointer to a selected and valid area */
|
||||
|
||||
/*
|
||||
* -- DEFAULT METHODS --
|
||||
@@ -244,7 +244,7 @@ static void hb_rddCloseAll( void )
|
||||
s_pCurrArea = pAreaNode;
|
||||
pAreaNode = pAreaNode->pNext;
|
||||
if( ( !nCycl && ( ( AREAP ) s_pCurrArea->pArea )->lpdbRelations ) ||
|
||||
( nCycl && s_pCurrArea->pArea ) )
|
||||
( nCycl && s_pCurrArea->pArea ) )
|
||||
{
|
||||
SELF_CLOSE( ( AREAP ) s_pCurrArea->pArea );
|
||||
SELF_RELEASE( ( AREAP ) s_pCurrArea->pArea );
|
||||
@@ -1416,7 +1416,7 @@ HB_FUNC( __DBLOCATE )
|
||||
{
|
||||
SELF_GOTOID( ( AREAP ) s_pCurrArea->pArea, pRecord );
|
||||
if( ( ( AREAP ) s_pCurrArea->pArea )->fEof )
|
||||
return;
|
||||
goto ExitLocate ;
|
||||
if( hb_itemType( pWhile ) == HB_IT_BLOCK )
|
||||
bWhile = hb_itemGetL( hb_vmEvalBlock( pWhile ) );
|
||||
else
|
||||
@@ -1433,7 +1433,7 @@ HB_FUNC( __DBLOCATE )
|
||||
{
|
||||
lNext = hb_parnl( 3 );
|
||||
if( ( ( AREAP ) s_pCurrArea->pArea )->fEof || lNext <= 0 )
|
||||
return;
|
||||
goto ExitLocate ;
|
||||
if( hb_itemType( pWhile ) == HB_IT_BLOCK )
|
||||
bWhile = hb_itemGetL( hb_vmEvalBlock( pWhile ) );
|
||||
else
|
||||
@@ -1459,7 +1459,7 @@ HB_FUNC( __DBLOCATE )
|
||||
else if( hb_itemGetL( pRest ) )
|
||||
{
|
||||
if( ( ( AREAP ) s_pCurrArea->pArea )->fEof )
|
||||
return;
|
||||
goto ExitLocate ;
|
||||
if( hb_itemType( pWhile ) == HB_IT_BLOCK )
|
||||
bWhile = hb_itemGetL( hb_vmEvalBlock( pWhile ) );
|
||||
else
|
||||
@@ -1486,7 +1486,7 @@ HB_FUNC( __DBLOCATE )
|
||||
{
|
||||
SELF_GOTOP( ( AREAP ) s_pCurrArea->pArea );
|
||||
if( ( ( AREAP ) s_pCurrArea->pArea )->fEof )
|
||||
return;
|
||||
goto ExitLocate ;
|
||||
if( hb_itemType( pNewFor ) == HB_IT_BLOCK )
|
||||
bFor = hb_itemGetL( hb_vmEvalBlock( pNewFor ) );
|
||||
else
|
||||
@@ -1502,6 +1502,7 @@ HB_FUNC( __DBLOCATE )
|
||||
( ( AREAP ) s_pCurrArea->pArea )->fFound = bFor;
|
||||
}
|
||||
|
||||
ExitLocate :
|
||||
/* Release items */
|
||||
hb_itemRelease( pNewFor );
|
||||
hb_itemRelease( pNewRest );
|
||||
@@ -2381,6 +2382,27 @@ HB_FUNC( ORDKEY )
|
||||
}
|
||||
|
||||
#ifdef HB_COMPAT_C53
|
||||
HB_FUNC( ORDKEYCOUNT )
|
||||
{
|
||||
DBORDERINFO pOrderInfo;
|
||||
|
||||
if( s_pCurrArea )
|
||||
{
|
||||
pOrderInfo.itmOrder = hb_param( 1, HB_IT_STRING );
|
||||
if( !pOrderInfo.itmOrder )
|
||||
pOrderInfo.itmOrder = hb_param( 1, HB_IT_NUMERIC );
|
||||
pOrderInfo.atomBagName = hb_param( 2, HB_IT_STRING );
|
||||
/* Either or both may be NIL */
|
||||
|
||||
pOrderInfo.itmResult = hb_itemPutNL( NULL, 0 );
|
||||
SELF_ORDINFO( ( AREAP ) s_pCurrArea->pArea, DBOI_KEYCOUNT, &pOrderInfo );
|
||||
hb_retnl( hb_itemGetNL( pOrderInfo.itmResult ) );
|
||||
hb_itemRelease( pOrderInfo.itmResult );
|
||||
}
|
||||
else
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "ORDKEYCOUNT" );
|
||||
|
||||
}
|
||||
|
||||
HB_FUNC( ORDKEYNO )
|
||||
{
|
||||
@@ -3393,7 +3415,7 @@ static LPAREANODE GetTheOtherArea( char *szDriver, char * szFileName, BOOL creat
|
||||
return pAreaNode;
|
||||
}
|
||||
|
||||
// move the Field Data between areas by name
|
||||
/* move the Field Data between areas by name */
|
||||
static void rddMoveFields( AREAP pAreaFrom, AREAP pAreaTo, PHB_ITEM pFields )
|
||||
{
|
||||
USHORT i, f=1;
|
||||
@@ -3402,7 +3424,7 @@ static void rddMoveFields( AREAP pAreaFrom, AREAP pAreaTo, PHB_ITEM pFields )
|
||||
fieldValue = hb_itemNew( NULL );
|
||||
for ( i=0 ; i<pAreaFrom->uiFieldCount; i++ )
|
||||
{
|
||||
// list or field in the list?
|
||||
/* list or field in the list?*/
|
||||
if ( !pFields || IsFieldIn( (( PHB_DYNS )(pAreaFrom->lpFields + i)->sym )->pSymbol->szName, pFields ))
|
||||
{
|
||||
SELF_GETVALUE( pAreaFrom, i+1, fieldValue );
|
||||
@@ -3412,7 +3434,7 @@ static void rddMoveFields( AREAP pAreaFrom, AREAP pAreaTo, PHB_ITEM pFields )
|
||||
hb_itemRelease( fieldValue );
|
||||
}
|
||||
|
||||
// move the records filtering if apropiate
|
||||
/*move the records, filtering if apropiate*/
|
||||
static ERRCODE rddMoveRecords( char *cAreaFrom, char *cAreaTo, PHB_ITEM pFields,
|
||||
PHB_ITEM pFor, PHB_ITEM pWhile, LONG lNext,
|
||||
ULONG lRec, BOOL bRest, char *cDriver )
|
||||
@@ -3427,32 +3449,31 @@ static ERRCODE rddMoveRecords( char *cAreaFrom, char *cAreaTo, PHB_ITEM pFields,
|
||||
LPAREANODE pAreaRelease=NULL;
|
||||
LPAREANODE s_pCurrAreaSaved=s_pCurrArea;
|
||||
|
||||
HB_SYMBOL_UNUSED( bRest );
|
||||
HB_TRACE(HB_TR_DEBUG, ("rddMoveRecords(%s, %s, %p, %p, %p, %d, %lu, %d, %s )",
|
||||
cAreaFrom, cAreaTo, pFields, pFor, pWhile, lNext, lRec, bRest, cDriver));
|
||||
|
||||
if ( !s_pCurrArea ) // We need a current Area to APPEND TO or FROM
|
||||
if ( !s_pCurrArea ) /*We need a current Area to APPEND TO or FROM*/
|
||||
{
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "DBAPP" );
|
||||
return EG_NOTABLE;
|
||||
}
|
||||
|
||||
// get the RDD Driver to use for the "other" Area
|
||||
/*get the RDD Driver to use for the "other" Area*/
|
||||
if( cDriver )
|
||||
szDriver = cDriver;
|
||||
else
|
||||
szDriver = s_szDefDriver;
|
||||
|
||||
if( !cAreaFrom && ! cAreaTo ) // File is needed
|
||||
if( !cAreaFrom && ! cAreaTo ) /*File is needed*/
|
||||
{
|
||||
hb_errRT_DBCMD( EG_ARG, EDBCMD_EVAL_BADPARAMETER, NULL, "DBAPP" );
|
||||
return EG_ARG;
|
||||
}
|
||||
|
||||
if ( pFields && hb_arrayLen( pFields ) == 0 ) // no field clause?
|
||||
if ( pFields && hb_arrayLen( pFields ) == 0 ) /*no field clause?*/
|
||||
pFields = NULL;
|
||||
|
||||
if ( cAreaTo ) // it's a COPY TO
|
||||
if ( cAreaTo ) /*it's a COPY TO*/
|
||||
{
|
||||
pAreaRelease = GetTheOtherArea( szDriver, cAreaTo, TRUE, pFields );
|
||||
pAreaTo = (AREAP) pAreaRelease->pArea;
|
||||
@@ -3461,34 +3482,34 @@ static ERRCODE rddMoveRecords( char *cAreaFrom, char *cAreaTo, PHB_ITEM pFields,
|
||||
pAreaTo = (AREAP) s_pCurrArea->pArea;
|
||||
|
||||
|
||||
if ( cAreaFrom ) // it's an APPEND FROM
|
||||
{ // make it current
|
||||
if ( cAreaFrom ) /*it's an APPEND FROM*/
|
||||
{ /*make it current*/
|
||||
pAreaRelease = s_pCurrArea = GetTheOtherArea( szDriver, cAreaFrom, FALSE, NULL );
|
||||
pAreaFrom = (AREAP) pAreaRelease->pArea;
|
||||
}
|
||||
else
|
||||
pAreaFrom = (AREAP) s_pCurrArea->pArea;
|
||||
|
||||
// or one or the other but necer none
|
||||
if ( !pAreaRelease ) // We need another Area to APPEND TO
|
||||
/* one or the other but never none*/
|
||||
if ( !pAreaRelease ) /*We need another Area to APPEND TO*/
|
||||
{
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "DBAPP" );
|
||||
return EG_NOTABLE;
|
||||
}
|
||||
|
||||
if ( lRec > 0 ) // only one record
|
||||
SELF_GOTO( pAreaFrom, lRec ); // go there
|
||||
if ( lRec > 0 ) /*only one record*/
|
||||
SELF_GOTO( pAreaFrom, lRec ); /*go there*/
|
||||
else
|
||||
{
|
||||
if( !pWhile && !bRest ) // this two stay current
|
||||
SELF_GOTOP( pAreaFrom ); // else start from the top
|
||||
if( !pWhile && !bRest ) /*this two stay current*/
|
||||
SELF_GOTOP( pAreaFrom ); /*else start from the top*/
|
||||
}
|
||||
|
||||
// move those records assuming we are positioned on one.
|
||||
/*move those records assuming we are positioned on one.*/
|
||||
while( keepGoing )
|
||||
{
|
||||
keepGoing = FALSE;
|
||||
if( !pAreaFrom->fEof ) // until eof or an evaluation failed
|
||||
if( !pAreaFrom->fEof ) /*until eof or an evaluation failed*/
|
||||
{
|
||||
if( pWhile )
|
||||
bWhile = hb_itemGetL( hb_vmEvalBlock( pWhile ) );
|
||||
@@ -3500,23 +3521,27 @@ static ERRCODE rddMoveRecords( char *cAreaFrom, char *cAreaTo, PHB_ITEM pFields,
|
||||
else
|
||||
bFor = TRUE;
|
||||
|
||||
if( bWhile && bFor && (!lNext || toGo > 0 )) // candidate?
|
||||
if( bWhile && (!lNext || toGo > 0 )) /*candidate?*/
|
||||
{
|
||||
SELF_APPEND( ( AREAP ) pAreaTo, FALSE ); // put a new one on TO Area
|
||||
rddMoveFields( pAreaFrom, pAreaTo, pFields ); // move the data
|
||||
if ( lRec == 0 ) // only one record?
|
||||
keepGoing = TRUE;
|
||||
else
|
||||
continue;
|
||||
if ( bFor )
|
||||
{
|
||||
SELF_APPEND( ( AREAP ) pAreaTo, FALSE ); /*put a new one on TO Area*/
|
||||
rddMoveFields( pAreaFrom, pAreaTo, pFields ); /*move the data*/
|
||||
}
|
||||
if ( lRec == 0 || pFor ) /*not only one record? Or there's a For clause?*/
|
||||
keepGoing = TRUE;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
toGo--; // one less to go
|
||||
SELF_SKIP( pAreaFrom, 1L ); // get the next one
|
||||
|
||||
toGo--; /*one less to go*/
|
||||
SELF_SKIP( pAreaFrom, 1L ); /*get the next one*/
|
||||
}
|
||||
}
|
||||
|
||||
s_pCurrArea = s_pCurrAreaSaved; // set current WorkArea to initial state
|
||||
s_pCurrArea = s_pCurrAreaSaved; /*set current WorkArea to initial state*/
|
||||
|
||||
// Close the File
|
||||
/*Close the File*/
|
||||
SELF_CLOSE( ( AREAP ) pAreaRelease->pArea );
|
||||
SELF_RELEASE( ( AREAP ) pAreaRelease->pArea );
|
||||
hb_xfree( pAreaRelease );
|
||||
|
||||
@@ -42,7 +42,6 @@ FUNCTION ordCond() ; RETURN NIL
|
||||
FUNCTION ordDescend() ; RETURN .F.
|
||||
FUNCTION ordIsUnique() ; RETURN .F.
|
||||
FUNCTION ordKeyAdd() ; RETURN .F.
|
||||
FUNCTION ordKeyCount() ; RETURN 0
|
||||
FUNCTION ordKeyDel() ; RETURN .F.
|
||||
FUNCTION ordKeyGoto() ; RETURN .F.
|
||||
FUNCTION ordKeyVal() ; RETURN NIL
|
||||
|
||||
Reference in New Issue
Block a user