From 89ea80830995c184150520b88543579efbe022b4 Mon Sep 17 00:00:00 2001 From: Luis Krause Date: Thu, 19 Feb 2004 20:52:07 +0000 Subject: [PATCH] 2004-02-19 12:48 UTC-0800 Luis Krause Mantilla --- harbour/ChangeLog | 13 ++++++++ harbour/contrib/rdd_ads/ads1.c | 47 ++++++++++++++++++++--------- harbour/contrib/rdd_ads/adsfunc.c | 6 ++-- harbour/source/rdd/dbfcdx/dbfcdx1.c | 8 ++--- harbour/source/rdd/dbfntx/dbfntx1.c | 2 +- 5 files changed, 53 insertions(+), 23 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0c8f0598bb..198271a316 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,19 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2004-02-19 12:48 UTC-0800 Luis Krause Mantilla + * contrib/rdd_ads/adsfunc.c + ! fixed casting in adsShowError() + * contrib/rdd_ads/ads1.c + ! adsSeek() now raises a runtime error 1201 if no index is active + ! adsOrderListAdd() sets order to 0 if an invalid or non-existent tag is provided + The above two were added to keep Clipper compatibility + + Added 5th param to commonError() in order to provide uiFlags, like other RDD's + * source/rdd/dbfcdx/dbfcdx1.c + * source/rdd/dbfntx/dbfntx1.c + ! Fixed error code returned by hb_cdxSeek() and ntxSeek() to 1201 (was 1020) + so it returns same error code as Clipper + 2004-02-17 9:22 UTC-0800 Luis Krause Mantilla * contrib/rdd_ads/adsfunc.c + Forgot to mention Brian Hays' implicit record locking fix/workaround is also diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index 6357409760..b81c3abb3c 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -150,7 +150,7 @@ void adsSetListener_callback( HB_set_enum setting, HB_set_listener_enum when ) } -static void commonError( ADSAREAP pArea, USHORT uiGenCode, USHORT uiSubCode, char* filename ) +static void commonError( ADSAREAP pArea, USHORT uiGenCode, USHORT uiSubCode, char * filename, USHORT uiFlags ) { PHB_ITEM pError; @@ -160,6 +160,8 @@ static void commonError( ADSAREAP pArea, USHORT uiGenCode, USHORT uiSubCode, cha hb_errPutDescription( pError, hb_langDGetErrorDesc( uiGenCode ) ); if( filename ) hb_errPutFileName( pError, filename ); + if ( uiFlags ) + hb_errPutFlags( pError, uiFlags ); SUPER_ERROR( ( AREAP ) pArea, pError ); hb_errRelease( pError ); return; @@ -528,7 +530,7 @@ static ERRCODE adsGoToId( ADSAREAP pArea, PHB_ITEM pItem ) } else { - commonError( pArea, EG_DATATYPE, 1020, NULL ); + commonError( pArea, EG_DATATYPE, 1020, NULL, 0 ); return FAILURE; } } @@ -553,6 +555,12 @@ static ERRCODE adsSeek( ADSAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin HB_TRACE(HB_TR_DEBUG, ("adsSeek(%p, %d, %p, %d)", pArea, bSoftSeek, pKey, bFindLast)); + if( ! pArea->hOrdCurrent ) + { + commonError( pArea, EG_NOORDER, 1201, NULL, EF_CANDEFAULT ); + return FAILURE; + } + if( bFindLast ) { if( hb_itemType( pKey ) == HB_IT_STRING ) @@ -1275,7 +1283,7 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( !pbLocked ) { - commonError( pArea, EG_UNLOCKED, EDBF_UNLOCKED, NULL ); + commonError( pArea, EG_UNLOCKED, EDBF_UNLOCKED, NULL, 0 ); //hb_errRT_DBCMD( EG_LOCK, EDBF_UNLOCKED, "Record not locked", "adsPutValue" ); } } @@ -1360,7 +1368,7 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( bTypeError ) { - commonError( pArea, EG_DATATYPE, 1020, NULL ); + commonError( pArea, EG_DATATYPE, 1020, NULL, 0 ); pArea->fRecordChanged = FALSE; /* bh: It seems wrong for this to be reset if OTHER fields have been @@ -1382,19 +1390,19 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { if( ulRetVal == AE_LOCK_FAILED || ulRetVal == AE_RECORD_NOT_LOCKED ) { - commonError( pArea, EG_UNLOCKED, EDBF_UNLOCKED, NULL ); + commonError( pArea, EG_UNLOCKED, EDBF_UNLOCKED, NULL, 0 ); } else if( ulRetVal == AE_TABLE_READONLY ) { - commonError( pArea, EG_READONLY, EDBF_READONLY, NULL ); + commonError( pArea, EG_READONLY, EDBF_READONLY, NULL, 0 ); } else if( ulRetVal == AE_DATA_TOO_LONG ) { - commonError( pArea, EG_WRITE, (USHORT) ulRetVal, NULL ); + commonError( pArea, EG_WRITE, (USHORT) ulRetVal, NULL, 0 ); } else { - commonError( pArea, EG_WRITE, (USHORT) ulRetVal, NULL ); + commonError( pArea, EG_WRITE, (USHORT) ulRetVal, NULL, 0 ); } return FAILURE; @@ -1772,7 +1780,7 @@ static ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) if( ulRetVal != AE_SUCCESS ) { if ( ulRetVal != 1001 ) /* && ulRetVal != 7008 ) */ /* 1001 and 7008 are standard ADS Open Errors that will usually be sharing issues */ - commonError( pArea, EG_OPEN, ( USHORT ) ulRetVal, ( char * ) pOpenInfo->abName ); + commonError( pArea, EG_OPEN, ( USHORT ) ulRetVal, ( char * ) pOpenInfo->abName, 0 ); return FAILURE; /* just set neterr */ } @@ -1928,7 +1936,7 @@ static ERRCODE adsPack( ADSAREAP pArea ) if( pArea->fShared ) { - commonError( pArea, EG_SHARED, 1023, NULL ); + commonError( pArea, EG_SHARED, 1023, NULL, 0 ); return FAILURE; } @@ -2035,7 +2043,7 @@ static ERRCODE adsOrderListFocus( ADSAREAP pArea, LPDBORDERINFO pOrderInfo ) UNSIGNED8 pucName[ADS_MAX_TAG_NAME]; UNSIGNED16 pusLen = ADS_MAX_TAG_NAME; UNSIGNED16 usOrder; - UNSIGNED32 ulRetVal; + UNSIGNED32 ulRetVal = AE_SUCCESS; HB_TRACE(HB_TR_DEBUG, ("adsOrderListFocus(%p, %p)", pArea, pOrderInfo)); if( !pArea->hOrdCurrent ) @@ -2043,7 +2051,7 @@ static ERRCODE adsOrderListFocus( ADSAREAP pArea, LPDBORDERINFO pOrderInfo ) else AdsGetIndexName( pArea->hOrdCurrent, pucName, &pusLen); - pOrderInfo->itmResult = hb_itemPutCL( pOrderInfo->itmResult, (char*)pucName, pusLen ); + pOrderInfo->itmResult = hb_itemPutCL( pOrderInfo->itmResult, ( char * ) pucName, pusLen ); if( pOrderInfo->itmOrder ) { @@ -2072,10 +2080,19 @@ static ERRCODE adsOrderListFocus( ADSAREAP pArea, LPDBORDERINFO pOrderInfo ) strncpy( ( char * ) pucTagName, pSrc, ulLen); pucTagName[ulLen] = '\0'; - ulRetVal = AdsGetIndexHandle( pArea->hTable, pucTagName, &phIndex ); + if ( ulLen ) + ulRetVal = AdsGetIndexHandle( pArea->hTable, pucTagName, &phIndex ); + else + { + pArea->hOrdCurrent = 0; + return SUCCESS; + } } if( ulRetVal != AE_SUCCESS ) + { + pArea->hOrdCurrent = 0; return FAILURE; + } pArea->hOrdCurrent = phIndex; } return SUCCESS; @@ -2085,7 +2102,7 @@ static ERRCODE adsOrderListRebuild( ADSAREAP pArea ) { HB_TRACE(HB_TR_DEBUG, ("adsOrderListRebuild(%p)", pArea)); - AdsReindex ( pArea->hTable ); + AdsReindex( pArea->hTable ); return SUCCESS; } @@ -2185,7 +2202,7 @@ static ERRCODE adsOrderCreate( ADSAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) if ( ulRetVal != AE_SUCCESS ) { - commonError( pArea, EG_CREATE, ( USHORT ) ulRetVal, (char*) pOrderInfo->abBagName ); + commonError( pArea, EG_CREATE, ( USHORT ) ulRetVal, ( char * ) pOrderInfo->abBagName, 0 ); return FAILURE; } else diff --git a/harbour/contrib/rdd_ads/adsfunc.c b/harbour/contrib/rdd_ads/adsfunc.c index 4c5683b6d4..5777876c29 100644 --- a/harbour/contrib/rdd_ads/adsfunc.c +++ b/harbour/contrib/rdd_ads/adsfunc.c @@ -1264,7 +1264,7 @@ UNSIGNED32 WINAPI ShowPercentage( UNSIGNED16 usPercentDone ) } /* ShowPercentage */ -HB_FUNC( ADSREGCALLBACK ) +HB_FUNC( ADSREGCALLBACK ) { UNSIGNED32 ulRetVal; @@ -1295,7 +1295,7 @@ HB_FUNC( ADSREGCALLBACK ) } -HB_FUNC( ADSCLRCALLBACK ) +HB_FUNC( ADSCLRCALLBACK ) { if ( itmCobCallBack ) { @@ -1375,7 +1375,7 @@ HB_FUNC( ADSGETNUMOPENTABLES ) HB_FUNC( ADSSHOWERROR ) { - char * pucTitle; + UNSIGNED8* pucTitle; if( ISCHAR( 1 ) ) { pucTitle = (UNSIGNED8*) hb_parc( 1 ); diff --git a/harbour/source/rdd/dbfcdx/dbfcdx1.c b/harbour/source/rdd/dbfcdx/dbfcdx1.c index 9769affc28..2a07316135 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/source/rdd/dbfcdx/dbfcdx1.c @@ -2407,7 +2407,7 @@ static int hb_cdxPageKeyLeafBalance( LPCDXPAGE pPage, SHORT iChildRet ) bMax = ( lpTmpPage->node.extNode.keyPool[ lpTmpPage->ReqByte - 2 ] >> ( 16 - lpTmpPage->TCBits ) ) & lpTmpPage->TCMask; bMax = iLen - 6 - HB_MAX( pPtr[ iKeys * iLen - 1 ], bMax ); - for ( j = 0; j < bMax && + for ( j = 0; j < bMax && pPtr[ ( iKeys - 1 ) * iLen + j ] == pbKey[ j ]; j++ ); iSize -= j; iMaxReq = lpTmpPage->ReqByte; @@ -2418,7 +2418,7 @@ static int hb_cdxPageKeyLeafBalance( LPCDXPAGE pPage, SHORT iChildRet ) ul = ( ul << 8 ) | 0xFF; } iSize += iKeys * iMaxReq; - iSize = lpTmpPage->iFree - iSize - + iSize = lpTmpPage->iFree - iSize - ( iMaxReq - lpTmpPage->ReqByte ) * lpTmpPage->iKeys; if ( iSize < 0 ) fIns = TRUE; @@ -2690,7 +2690,7 @@ static int hb_cdxPageKeyIntBalance( LPCDXPAGE pPage, SHORT iChildRet ) iMin = 1; if ( iMax > pPage->TagParent->MaxKeys ) iMax = pPage->TagParent->MaxKeys; - for ( i = iBlncKeys - 1; i >= 0 && + for ( i = iBlncKeys - 1; i >= 0 && childs[i]->iKeys >= iMin && childs[i]->iKeys <= iMax; i-- ) { iKeys -= childs[i]->iKeys; @@ -4673,7 +4673,7 @@ static ERRCODE hb_cdxSeek( CDXAREAP pArea, BOOL fSoftSeek, PHB_ITEM pKeyItm, BOO if ( ! pTag ) { - hb_cdxErrorRT( pArea, EG_NOORDER, 1020, NULL, EF_CANDEFAULT ); + hb_cdxErrorRT( pArea, EG_NOORDER, 1201, NULL, EF_CANDEFAULT ); return FAILURE; } else diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 44b59c22cc..ec5c05a46e 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -3066,7 +3066,7 @@ static ERRCODE ntxSeek( NTXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin return FAILURE; if ( ! pArea->lpCurTag ) { - commonError( pArea, EG_NOORDER, 1020, NULL, EF_CANDEFAULT ); + commonError( pArea, EG_NOORDER, 1201, NULL, EF_CANDEFAULT ); return FAILURE; } else