2001-05-13 07:55 UTC-0800 Brian Hays <bhays@abacuslaw.com>

This commit is contained in:
Brian Hays
2001-05-14 02:54:55 +00:00
parent cb8fa099bd
commit 26cf690f08
7 changed files with 198 additions and 18 deletions

View File

@@ -1,3 +1,34 @@
2001-05-13 07:55 UTC-0800 Brian Hays <bhays@abacuslaw.com>
* source/rdd/dbcmd.c
* dbAppend: set NetErr to True if SELF_APPEND fails
* contrib/rdd_ads/ads.ch
* added SET EPOCH TO and SET DATE FORMAT
* contrib/rdd_ads/adsfunc.c
+ added AdsGetTableAlias() to confirm ADS's idea of the alias
+ added AdsSetEpoch() and AdsSetDateFormat()
Done as get/set functions (returns previous setting)
+ added AdsCloseAllTables()
* changed ShowPercentage for Indexing CallBacks to return
the value from the codeblock to the Server.
Pass 0 to continue, 1 (non-zero) to abort
* contrib/rdd_ads/ads1.c
* Fixed adsOpen() to pass along the correct alias to ADS
* added DumpArea() for debugging: call this to dump ads server
settings to HB_TRACE. Currently in a quick-and-dirty state...
* source/vm/arrayshb.c
* added HB_ArrayID()
Useful for debugging: returns the array's "address" so dual
references to same array can be seen */
* source/vm/arrays.c
* in hb_arrayFromStack added missing ";" needed for debug build
2001-05-13 22:10 UTC+1 JFL (mafact) <jfl@mafact.com>
* harbour/include/hboo.ch
+ added #define to allow a better control of __objGetMsgList()

View File

@@ -86,4 +86,11 @@
=> Set( _SET_DELETED, <(x)> ) ;
;AdsSetDeleted( if( upper( <(x)> ) == "ON", .t., .f. ) )
#command SET DELETED (<x>) ;
=> Set( _SET_DELETED, <x> ); AdsSetDeleted( <x> )
=> Set( _SET_DELE, <x> ); AdsSetDeleted( <x> )
#command SET EPOCH TO <year> ;
=> Set( _SET_EPOCH, <year> ); AdsSetEpoch( <year> )
#command SET DATE FORMAT [TO] <c> ;
=> Set( _SET_DATEFORMAT, <c> ); AdsSetDateFormat( <c> )

View File

@@ -94,6 +94,57 @@ static void commonError( ADSAREAP pArea, USHORT uiGenCode, USHORT uiSubCode, cha
return;
}
static void DumpArea( ADSAREAP pArea ) /* For debugging: call this to dump ads server settings to HB_TRACE. Currently in a quick-and-dirty state... */
{
UNSIGNED8 pucTemp[1025];
UNSIGNED16 pusLen = 1024;
UNSIGNED32 ulRetVal = 0, ulRetAOF = 0, ulRetFilt = 0;
UNSIGNED8 pucFormat[16];
UNSIGNED8 pucFilter[1025];
UNSIGNED8 aucBuffer[MAX_STR_LEN + 1];
UNSIGNED8 pucIndexName[MAX_STR_LEN + 1];
UNSIGNED8 pucIndexExpr[MAX_STR_LEN + 1];
UNSIGNED8 pucIndexCond[MAX_STR_LEN + 1];
if( pArea )
{
pusLen = 15;
AdsGetDateFormat (pucFormat, &pusLen);
pusLen = 1024;
ulRetVal = AdsGetTableAlias( pArea->hTable, pucTemp, &pusLen );
AdsGetEpoch (&pusLen);
HB_TRACE(HB_TR_ALWAYS, ("DumpArea: \n pArea: %p hTable: %lu Alias: %s (RetVal %lu)\n Eof: %d DateFormat: %s Epoch: %d",
pArea, pArea->hTable, pucTemp, ulRetVal, pArea->fEof, pucFormat, pusLen));
pusLen = 1024;
ulRetAOF = AdsGetAOF( pArea->hTable, pucTemp, &pusLen );
pusLen = 1024;
ulRetFilt = AdsGetFilter( pArea->hTable, pucFilter, &pusLen );
HB_TRACE(HB_TR_ALWAYS, ("DumpArea AOF: (RetVal %lu) %s \n Filter: (RetVal %lu) %s", ulRetAOF, pucTemp, ulRetFilt, pucFilter));
if( pArea->hOrdCurrent )
{
pusLen = MAX_STR_LEN;
AdsGetIndexName( pArea->hOrdCurrent, pucIndexName, &pusLen);
pusLen = MAX_STR_LEN;
AdsGetIndexCondition( pArea->hOrdCurrent, pucIndexCond, &pusLen);
pusLen = MAX_STR_LEN;
AdsGetIndexExpr( pArea->hOrdCurrent, pucIndexExpr, &pusLen);
pusLen = 1024; /*ADS top/bottom are 1,2 instead of 0,1*/
ulRetVal = AdsGetScope( pArea->hOrdCurrent, 1, pucTemp, &pusLen );
pusLen = 1024;
ulRetFilt = AdsGetScope( pArea->hOrdCurrent, 2, pucFilter, &pusLen );
HB_TRACE(HB_TR_ALWAYS, ("DumpArea Index: %s Expr: %s Cond: %s\n Scope: (RetVal %lu) %s Bottom: (RetVal %lu) %s",
pucIndexName, pucIndexExpr, pucIndexCond, ulRetVal, pucTemp, ulRetFilt, pucFilter));
}
}
}
static BOOL hb_nltoa( LONG lValue, char * szBuffer, USHORT uiLen )
{
LONG lAbsNumber;
@@ -407,11 +458,13 @@ static ERRCODE adsGoToId( ADSAREAP pArea, PHB_ITEM pItem )
static ERRCODE adsGoTop( ADSAREAP pArea )
{
UNSIGNED32 ulRetVal = 0;
HB_TRACE(HB_TR_DEBUG, ("adsGoTop(%p)", pArea));
pArea->fTop = TRUE;
pArea->fBottom = FALSE;
AdsGotoTop ( (pArea->hOrdCurrent) ? pArea->hOrdCurrent : pArea->hTable );
ulRetVal = AdsGotoTop ( (pArea->hOrdCurrent) ? pArea->hOrdCurrent : pArea->hTable );
hb_adsCheckBofEof( pArea );
return SUPER_SKIPFILTER( (AREAP)pArea, 1 );
}
@@ -1144,8 +1197,7 @@ static ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo )
pArea->hStatement = 0;
pArea->hOrdCurrent = 0;
ulRetVal = AdsOpenTable ( 0, pOpenInfo->abName, NULL,
ulRetVal = AdsOpenTable ( 0, pOpenInfo->abName, pOpenInfo->atomAlias,
adsFileType, adsCharType, adsLockType, adsRights,
( (pOpenInfo->fShared) ? ADS_SHARED : ADS_EXCLUSIVE ) |
( (pOpenInfo->fReadonly) ? ADS_READONLY : ADS_DEFAULT ),
@@ -1881,15 +1933,20 @@ static ERRCODE adsSetFilter( ADSAREAP pArea, LPDBFILTERINFO pFilterInfo )
if (SUPER_SETFILTER( ( AREAP ) pArea, pFilterInfo ) == SUCCESS )
{
AdsIsExprValid( pArea->hTable, (UNSIGNED8*) hb_itemGetCPtr( pFilterInfo->abFilterText), (UNSIGNED16*) &bValidExpr );
if ( bValidExpr )
{
if ( hb_set.HB_SET_OPTIMIZE )
{
ulRetVal = AdsSetAOF( pArea->hTable, (UNSIGNED8*) hb_itemGetCPtr( pFilterInfo->abFilterText), usResolve );
}else
}
else
{
ulRetVal = AdsSetFilter( pArea->hTable, (UNSIGNED8*) hb_itemGetCPtr( pFilterInfo->abFilterText ) );
}
}
} /* else let SUPER handle filtering */
}
return ulRetVal == AE_SUCCESS ? SUCCESS : FAILURE ;
}

View File

@@ -44,6 +44,7 @@
#include "hbdate.h"
#include "hbapierr.h"
#include "rddads.h"
#include "hbstack.h"
#define HARBOUR_MAX_RDD_FILTER_LENGTH 256
extern ERRCODE adsCloseCursor( ADSAREAP pArea );
@@ -79,6 +80,35 @@ HB_FUNC( ADSSETSERVERTYPE )
}
}
HB_FUNC( ADSSETDATEFORMAT )
{
UNSIGNED8 pucFormat[16];
UNSIGNED16 pusLen = 15;
hb_retc( "");
AdsGetDateFormat (pucFormat, &pusLen);
if ( pusLen > 0 )
hb_retc( pucFormat );
if( ISCHAR( 1 ))
{
AdsSetDateFormat ( (UCHAR*) hb_parc(1) );
}
}
HB_FUNC( ADSSETEPOCH )
{
UNSIGNED16 pusEpoch = 1900;
if ( AdsGetEpoch ( &pusEpoch ) == AE_SUCCESS )
hb_retni( pusEpoch );
if( ISNUM( 1 ) )
{
AdsSetEpoch ( hb_parni(1) );
}
}
HB_FUNC( ADSAPPLICATIONEXIT )
{
AdsApplicationExit( );
@@ -290,7 +320,7 @@ HB_FUNC( ADSKEYCOUNT )
else
hIndex = (pArea->hOrdCurrent == 0) ? pArea->hTable : pArea->hOrdCurrent;
if( hb_pcount() > 2 )
if( hb_pcount() > 2 ) /* 2nd parameter: unsupported Bag Name */
{
if( ISNUM( 3 ) )
usFilterOption = hb_parni( 3 );
@@ -366,6 +396,26 @@ HB_FUNC( ADSEVALAOF )
}
HB_FUNC( ADSGETTABLEALIAS )
{
ADSAREAP pArea;
UNSIGNED8 pucAlias[HARBOUR_MAX_RDD_ALIAS_LENGTH +1];
UNSIGNED16 pusLen = HARBOUR_MAX_RDD_ALIAS_LENGTH;
UNSIGNED32 ulRetVal = FAILURE;
pArea = (ADSAREAP) hb_rddGetCurrentWorkAreaPointer();
if( pArea )
ulRetVal = AdsGetTableAlias( pArea->hTable, pucAlias, &pusLen );
else
hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSGETTABLEALIAS" );
if ( ulRetVal == AE_SUCCESS )
hb_retclen ( ( char * ) pucAlias, pusLen );
else
hb_retc( "" );
}
HB_FUNC( ADSGETAOF )
{
ADSAREAP pArea;
@@ -492,18 +542,29 @@ HB_FUNC( ADSGETFILTER )
if( pArea )
{
ulRetVal = AdsGetFilter( pArea->hTable, pucFilter, &pusLen );
if ( ulRetVal == AE_SUCCESS )
if ( pusLen > HARBOUR_MAX_RDD_FILTER_LENGTH )
{
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 );
}
pucFilter2 = (UNSIGNED8*) hb_xgrab(pusLen + 1);
ulRetVal = AdsGetFilter( pArea->hTable, pucFilter2, &pusLen );
if ( ulRetVal == AE_SUCCESS )
hb_retc( pucFilter2 );
else
hb_retc( pucFilter );
{
HB_TRACE(HB_TR_DEBUG, ("adsGetFilter Error %lu", ulRetVal));
}
hb_xfree( pucFilter2 );
}
else if ( ulRetVal == AE_SUCCESS )
{
hb_retc( pucFilter );
}
else
{
HB_TRACE(HB_TR_DEBUG, ("adsGetFilter Error %lu", ulRetVal));
/* sprintf((char*)pucFilter,"Error in AdsGetFilter: %lu", ulRetVal );
// hb_retc( pucFilter );
*/
}
}
}
@@ -804,6 +865,11 @@ HB_FUNC( ADSEXECUTESQL )
hb_retl( 0 );
}
HB_FUNC( ADSCLOSEALLTABLES )
{
hb_retnl( AdsCloseAllTables() );
}
HB_FUNC( ADSCOPYTABLE )
{
ADSAREAP pArea;
@@ -857,15 +923,18 @@ HB_FUNC( ADSCONVERTTABLE )
UNSIGNED32 WINAPI ShowPercentage( UNSIGNED16 usPercentDone )
{
UNSIGNED32 bRet = 0;
PHB_ITEM pPercentDone = hb_itemPutNI(NULL, usPercentDone);
if ( itmCobCallBack )
{
hb_vmEvalBlockV( itmCobCallBack, 1, pPercentDone ) ;
bRet = hb_itemGetL( &hb_stack.Return ) ;
}
else
{
HB_TRACE(HB_TR_DEBUG, ("ShowPercentage(%d) called with no codeblock set.\n", usPercentDone ));
/*bRet = 1;*/
}
hb_itemRelease( pPercentDone );
return 0;

View File

@@ -78,6 +78,11 @@
* ALL workareas. ADS does not have a "commit just this table" call.
* Use dbSkip(0) to commit changes to the current record.
* Be sure to use the command SET DEFAULT TO (cDir) and not its
* equivalent Set() function call. The Set() function will not make
* the call to ADS to change its internal setting, but the command
* will.
* For programmers who are already familiar with the
* ACE engine, this also means there are some differences
* between the RDDADS in Harbour and the parallel ACE documentation.

View File

@@ -833,7 +833,7 @@ PHB_ITEM hb_arrayFromStack( USHORT uiLen )
{
PHB_ITEM pArray = hb_itemNew( NULL );
PHB_BASEARRAY pBaseArray = ( PHB_BASEARRAY ) hb_gcAlloc( sizeof( HB_BASEARRAY ), hb_arrayReleaseGarbage );
USHORT uiPos
USHORT uiPos;
HB_TRACE(HB_TR_DEBUG, ("hb_arrayFromStack(%iu)", uiLen));

View File

@@ -126,6 +126,17 @@ HB_FUNC( AADD )
hb_errRT_BASE_SubstR( EG_ARG, 1123, NULL, "AADD", 2, hb_paramError(1), hb_paramError( 2 ) );
}
HB_FUNC( HB_ARRAYID ) /* for debugging: returns the array's "address" so dual references to same array can be seen */
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
if( HB_IS_ARRAY(pArray) )
hb_retnl( (long) pArray->item.asArray.value );
else
hb_retnl( -1 );
}
/* NOTE: CA-Cl*pper 5.3 and older will return NIL on bad parameter, 5.3a,b
will throw a runtime error. [vszakats] */