From d8165bb1955276951d666dec612bc38a436d3427 Mon Sep 17 00:00:00 2001 From: "Alexander S.Kresin" Date: Fri, 30 Mar 2001 09:12:51 +0000 Subject: [PATCH] 2001-03-30 13:10 GMT+3 Alexander Kresin --- harbour/ChangeLog | 8 +++ harbour/include/hbrddntx.h | 6 +-- harbour/source/rdd/dbfntx/dbfntx1.c | 75 +++++++++++++++++++++++++++-- 3 files changed, 83 insertions(+), 6 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 14c4ef12c8..e89586911d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +2001-03-30 13:10 GMT+3 Alexander Kresin + * source/rdd/dbfntx/dbfntx1.c + * include/hbrddntx.h + + started ntxOrderListRebuild() + + added ntxPack() - will work properly after ntxOrderListRebuild() has + finished + + added ntxZap() + 2001-03-28 00:00 UTC-0800 Brian Hays * contrib/rdd_ads/ads1.c + added ADSSetRelKeyPos for quick scrollbar guesstimates diff --git a/harbour/include/hbrddntx.h b/harbour/include/hbrddntx.h index c89de82226..7b95dc1f59 100644 --- a/harbour/include/hbrddntx.h +++ b/harbour/include/hbrddntx.h @@ -338,12 +338,12 @@ static ERRCODE ntxClose( NTXAREAP pArea ); static ERRCODE ntxStructSize( NTXAREAP pArea, USHORT * uiSize ); #define ntxSysName NULL #define ntxEval NULL -#define ntxPack NULL +static ERRCODE ntxPack( NTXAREAP pArea ); #define ntPackRec NULL #define ntxSort NULL #define ntxTrans NULL #define ntxTransRec NULL -#define ntxZap NULL +static ERRCODE ntxZap( NTXAREAP pArea ); #define ntxchildEnd NULL #define ntxchildStart NULL #define ntxchildSync NULL @@ -360,7 +360,7 @@ static ERRCODE ntxOrderListClear( NTXAREAP pArea ); /* Close all indexes */ #define ntxOrderListDelete NULL static ERRCODE ntxOrderListFocus( NTXAREAP pArea, LPDBORDERINFO pOrderInfo ); -#define ntxOrderListRebuild NULL +static ERRCODE ntxOrderListRebuild( NTXAREAP pArea ); #define ntxOrderCondition NULL static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ); /* Create new Index */ diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 79e737ccf6..0d93a8af36 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -2167,6 +2167,59 @@ static ERRCODE ntxStructSize( NTXAREAP pArea, USHORT * uiSize ) return SUCCESS; } +static ERRCODE ntxPack( NTXAREAP pArea ) +{ + HB_TRACE(HB_TR_DEBUG, ("ntxPack(%p)", pArea )); + + if( SUPER_PACK( ( AREAP ) pArea ) == SUCCESS ) + return ntxOrderListRebuild( pArea ); + else + return FAILURE; +} + +static ERRCODE ntxZap( NTXAREAP pArea ) +{ + HB_TRACE(HB_TR_DEBUG, ("ntxZap(%p)", pArea )); + + if( SUPER_ZAP( ( AREAP ) pArea ) == SUCCESS ) + { + LPNTXINDEX lpIndex, lpIndexTmp; + LPTAGINFO pTag; + char* buffer; + USHORT i, maxKeys; + LPNTXBUFFER itemlist; + + buffer = (char*) hb_xgrab( NTXBLOCKSIZE ); + lpIndex = pArea->lpNtxIndex; + lpIndexTmp = pArea->lpCurIndex; + while( lpIndex ) + { + lpIndex->CompoundTag->RootBlock = NTXBLOCKSIZE; + hb_ntxHeaderSave( lpIndex ); + + pTag = lpIndex->CompoundTag; + maxKeys = pTag->MaxKeys*2/3; + memset( buffer, 0, NTXBLOCKSIZE ); + itemlist = ( LPNTXBUFFER ) buffer; + itemlist->item_count = 0; + for( i = 0; i < maxKeys + 1; i++ ) + itemlist->item_offset[i] = 2 + 2 * ( pTag->MaxKeys + 1 ) + + i * ( pTag->KeyLength + 8 ); + + hb_fsSeek( lpIndex->DiskFile, NTXBLOCKSIZE, FS_SET ); + hb_fsWrite( lpIndex->DiskFile, (BYTE *) buffer, NTXBLOCKSIZE ); + hb_fsWrite( lpIndex->DiskFile, NULL, 0 ); + + lpIndex = lpIndex->pNext; + } + pArea->lpCurIndex = lpIndexTmp; + hb_xfree( buffer ); + return SUCCESS; + } + else + return FAILURE; +} + static ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) { PHB_ITEM pExpr, pResult, pError; @@ -2592,6 +2645,22 @@ static ERRCODE ntxOrderListFocus( NTXAREAP pArea, LPDBORDERINFO pOrderInfo ) return SUCCESS; } +static ERRCODE ntxOrderListRebuild( NTXAREAP pArea ) +{ + LPNTXINDEX lpIndex, lpIndexTmp; + + HB_TRACE(HB_TR_DEBUG, ("ntxOrderListRebuild(%p)", pArea)); + + lpIndex = pArea->lpNtxIndex; + lpIndexTmp = pArea->lpCurIndex; + while( lpIndex ) + { + lpIndex = lpIndex->pNext; + } + pArea->lpCurIndex = lpIndexTmp; + return SUCCESS; +} + static ERRCODE ntxClose( NTXAREAP pArea ) { HB_TRACE(HB_TR_DEBUG, ("ntxClose(%p)", pArea)); @@ -2702,12 +2771,12 @@ static RDDFUNCS ntxTable = { ntxBof, ( DBENTRYP_SP ) ntxStructSize, ntxSysName, ntxEval, - ntxPack, + ( DBENTRYP_V ) ntxPack, ntPackRec, ntxSort, ntxTrans, ntxTransRec, - ntxZap, + ( DBENTRYP_V ) ntxZap, ntxchildEnd, ntxchildStart, ntxchildSync, @@ -2722,7 +2791,7 @@ static RDDFUNCS ntxTable = { ntxBof, ( DBENTRYP_V ) ntxOrderListClear, ntxOrderListDelete, ( DBENTRYP_OI ) ntxOrderListFocus, - ntxOrderListRebuild, + ( DBENTRYP_V ) ntxOrderListRebuild, ntxOrderCondition, ( DBENTRYP_VOC ) ntxOrderCreate, ntxOrderDestroy,