From 8ee6ee64f9238ce9bbd3072b4f6c43e1f22a82cc Mon Sep 17 00:00:00 2001 From: Brian Hays Date: Tue, 21 Aug 2001 06:55:25 +0000 Subject: [PATCH] 2001-08-20 11:55 UTC-0800 Brian Hays --- harbour/ChangeLog | 49 ++++++- harbour/contrib/libgt/bitflags.c | 174 +++++++++++++++++++++++++ harbour/contrib/libgt/doc/en/ht_gt.txt | 151 +++++++++++++++++++++ harbour/contrib/rdd_ads/ads1.c | 127 +++++++++++++----- harbour/contrib/rdd_ads/adsfunc.c | 65 ++++++++- harbour/source/pp/pptable.c | 8 +- harbour/source/rdd/dbcmd.c | 15 ++- 7 files changed, 543 insertions(+), 46 deletions(-) create mode 100644 harbour/contrib/libgt/bitflags.c diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6eeb45886f..2c39c2c57d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,7 +1,52 @@ +2001-08-20 11:55 UTC-0800 Brian Hays + + * contrib/rdd_ads/ads1.c + * fixed subIndexing. + * optimized DBI_GETLOCKARRAY and fixed memory leak + * adsOrderListFocus() failed on space-padded strings + * adsGoTo: if on same record, refresh. Fixed issues that arose + from minor bugs in ADS when using relations in versions + prior to 6.1 + * adsAppend() added error handling + * fixed file lock/unlock, and record locking to support + dbrlock lock list maintenance (and memory leak when + no recno was passed to dbrlock()) + + * contrib/rdd_ads/adsfunc.c + * adssetServerType now returns any error numbers + + added AdsRefreshRecord, AdsIsTableLocked, AdsIsRecordLocked + + * source/rdd/dbcmd.c + * Set NetErr flag to True for failed dbAppend() + * fixed ordCondSet parameters. See pptable.c below. + + + contrib/libgt/bitflags.c + + Dave Pearson's bitflags.c, which I ported to Harbour. + Has functions to use a Harbour string for storing On/Off + bit flags. + + * contrib/libgt/doc/en/ht_gt.txt + + added docs from Dave Pearson's bitflags.c + + * source/pp/pptable.c + * Alexander Kresin's fix for 5.3 compatible parameters + for INDEX ON and ordCondSet(). + WARNING! IF you had hard-coded calls to this function, + and used any parameters after the 11th one, + you have to change your code! Or, if you have a header + that translates INDEX ON for clauses USECURRENT, ADDITIVE, + CUSTOM or NOOPTIMIZE, these parameters are shifted back + now. + The parameter list was incorrectly handled before because + of the 12th parameter that is always NIL. + See Harbour Archives, subject "XINDEX warning" for details + + + 2001-08-21 06:47 GMT Dave Pearson * source/rtl/gtcrs/gtcrs.c * Fixed incorrectly named variable (Row -> uRow) in hb_gt_VertLine(). - + 2001-08-21 23:35 UTC-0400 David G. Holm * include/hbapigt.h @@ -41,7 +86,7 @@ *source/compiler/exproptb.c *source/compiler/genc.c *source/compiler/hbpcode.c - * fixed bug in "¯o" and ¯o() syntax + * fixed bug in "¯o" and ¯o() syntax 2001-08-20 14:02 GMT Dave Pearson * config/test.cf diff --git a/harbour/contrib/libgt/bitflags.c b/harbour/contrib/libgt/bitflags.c new file mode 100644 index 0000000000..0f4cfe86f8 --- /dev/null +++ b/harbour/contrib/libgt/bitflags.c @@ -0,0 +1,174 @@ +/* + * File......: BITFLAGS.C + * Author....: Dave Pearson + * BBS.......: The Dark Knight Returns + * Net/Node..: 050/069 + * User Name.: Dave Pearson + * Date......: 31/03/93 + * Revision..: 1.0 + * + * This is an original work by Dave Pearson and is placed in the public + * domain. + * + * Modification history: + * --------------------- + * + * 8/19/2001 Modifications for Harbour by Brian Hays, also placed in + * the public domain. + + * + */ + + +#include "hbapi.h" + +#define _GT_MAX(x,y) (x > y ? x : y) + +HB_FUNC( GT_NEWFLAG ) +{ + char *FlagString; + unsigned ByteCount; + unsigned FlagCount = 1; + unsigned Byte; + + if (ISNUM(1)) + { + FlagCount = (unsigned) hb_parni(1); + } + if (FlagCount > 0) + { + ByteCount = (unsigned)((FlagCount / 8) + 1); + if (!(FlagCount % 8)) + { + --ByteCount; + } + FlagString = hb_xgrab(ByteCount); + for (Byte = 0; Byte < ByteCount; Byte++) + { + FlagString[Byte] = 0; + } + hb_retclen(FlagString, ByteCount); + hb_xfree(FlagString); + } + else + { + hb_retc(""); + } +} + +HB_FUNC( GT_SETFLAG ) +{ + char *FlagString; + unsigned StartBit = 1; + unsigned EndBit = 1; + unsigned BitCount; + unsigned BitPointer; + unsigned BytePointer; + + if ( ISCHAR(1) ) + { + FlagString = hb_parc(1); + if ( ISNUM(2) ) + { + StartBit = hb_parni(2); + } + if ( ISNUM(3) ) + { + EndBit = hb_parni(3); + } + EndBit = _GT_MAX(StartBit, EndBit); + if (StartBit > 0 && EndBit <= (hb_parclen(1) * 8)) + { + for (BitCount = StartBit; BitCount <= EndBit; BitCount++) + { + BitPointer = BitCount % 8; + BytePointer = (unsigned) (BitCount / 8); + if (!BitPointer) + { + BitPointer = 8; + --BytePointer; + } + FlagString[BytePointer] |= 1 << (BitPointer - 1); + } + } + hb_retclen(FlagString, hb_parclen(1)); + } + else + { + hb_retc(""); + } +} + +HB_FUNC( GT_CLRFLAG ) +{ + char *FlagString; + unsigned StartBit = 1; + unsigned EndBit = 1; + unsigned BitCount; + unsigned BitPointer; + unsigned BytePointer; + + if ( ISCHAR(1) ) + { + FlagString = hb_parc(1); + if ( ISNUM(2) ) + { + StartBit = hb_parni(2); + } + if ( ISNUM(3) ) + { + EndBit = hb_parni(3); + } + EndBit = _GT_MAX(StartBit, EndBit); + if (StartBit > 0 && EndBit <= (hb_parclen(1) * 8)) + { + for (BitCount = StartBit; BitCount <= EndBit; BitCount++) + { + BitPointer = BitCount % 8; + BytePointer = (unsigned) (BitCount / 8); + if (!BitPointer) + { + BitPointer = 8; + --BytePointer; + } + FlagString[BytePointer] &= 0xff - (1 << (BitPointer - 1)); + } + } + hb_retclen(FlagString, hb_parclen(1)); + } + else + { + hb_retc(""); + } +} + +HB_FUNC( GT_ISFLAG ) +{ + + BOOL FlagStatus = FALSE; + unsigned Bit = 1; + unsigned BitPointer; + unsigned BytePointer; + char *FlagString; + + if ( ISCHAR(1) ) + { + FlagString = hb_parc(1); + if ( ISNUM(2) ) + { + Bit = hb_parni(2); + } + if (Bit > 0 && Bit <= (hb_parclen(1) * 8)) + { + BitPointer = Bit % 8; + BytePointer = (unsigned) (Bit / 8); + if (!BitPointer) + { + BitPointer = 8; + --BytePointer; + } + FlagStatus = FlagString[BytePointer] & (1 << (BitPointer - 1)); + } + } + hb_retl(FlagStatus); +} diff --git a/harbour/contrib/libgt/doc/en/ht_gt.txt b/harbour/contrib/libgt/doc/en/ht_gt.txt index d1906468bc..61f9a7119f 100644 --- a/harbour/contrib/libgt/doc/en/ht_gt.txt +++ b/harbour/contrib/libgt/doc/en/ht_gt.txt @@ -9,6 +9,10 @@ * Copyright 1999 Andy M Leighton * Documentation * + * FlagString functions GT_NEWFLAG, GT_SETFLAG, GT_CLRFLAG, and + * GT_ISFLAG are an original work by Dave Pearson and + * are placed in the public domain. + * * See doc/license.txt for licensing terms. * */ @@ -564,3 +568,150 @@ * $END$ */ +/* $DOC$ + * $FUNCNAME$ + * GT_NEWFLAG() + * $CATEGORY$ + * General + * $ONELINER$ + * Create a new bit flag string. + * $SYNTAX$ + * GT_NewFlag() --> cFlagString + * $ARGUMENTS$ + * is the number of flags you wish to store. + * $RETURNS$ + * A string to hold the bit flags. All flags are set to FALSE. + * $DESCRIPTION$ + * GT_NewFlag() is used to construct a bit flag string. The bit flag + * functions can be used for storing a large number of logical values + * in a small space. + * + * To create a bit flag string you need to pass GT_NewFlag() a value + * that is equal to or greater than the number of flags required (you + * may want to allow for future expansion). Each character in the + * string returned from GT_NewFlag() will hold 8 logical values. + * $EXAMPLES$ + * cFlags := GT_NewFlag(20) // Create a bit flag string for 20 + * // logical values. + * $SEEALSO$ + * GT_SETFLAG() GT_CLRFLAG() GT_ISFLAG() + * $END$ + */ + +/* $DOC$ + * $FUNCNAME$ + * GT_SETFLAG() + * $CATEGORY$ + * General + * $ONELINER$ + * Set a number of flags to TRUE in a bit flag string. + * $SYNTAX$ + * GT_SetFlag(,[],[]) --> cFlagString + * $ARGUMENTS$ + * is a bit flag string created with GT_NewFlag() + * + * is the starting flag. This is an optional numeric value. + * If not supplied it defaults to 1. + * + * is the ending flag. This is an optional numeric value. If + * not supplied it defaults to . + * $RETURNS$ + * The bit map string with the new flag settings. + * $DESCRIPTION$ + * GT_SetFlag() is used to turn flags within the flag string on. + * $EXAMPLES$ + * cFlags := GT_NewFlag(20) // Create a bit flag string for 20 + * // logical values. + * + * // Now set flags 10 to 15 to true. + * + * cFlags := GT_SetFlag(cFlags,10,15) + * + * // And set flag 18 to true. + * + * cFlags := GT_SetFlag(cFlags,18) + * + * // And set flag 1 to true. + * + * cFlags := GT_SetFlag(cFlags) + * $SEEALSO$ + * GT_NEWFLAG() GT_CLRFLAG() GT_ISFLAG() + * $END$ + */ + +/* $DOC$ + * $FUNCNAME$ + * GT_CLRFLAG() + * $CATEGORY$ + * General + * $ONELINER$ + * Set a number of flags to FALSE in a bit flag string. + * $SYNTAX$ + * GT_ClrFlag(,[],[]) --> cFlagString + * $ARGUMENTS$ + * is a bit flag string created with GT_NewFlag() + * + * is the starting flag. This is an optional numeric value. + * If not supplied it defaults to 1. + * + * is the ending flag. This is an optional numeric value. If + * not supplied it defaults to . + * $RETURNS$ + * The bit map string with the new flag settings. + * $DESCRIPTION$ + * GT_ClrFlag() is used to turn flags within the flag string off. + * $EXAMPLES$ + * cFlags := GT_NewFlag(20) // Create a bit flag string for 20 + * // logical values. + * + * // Now, turn them all on. + * + * cFlags := GT_SetFlag(cFlags,1,20) + * + * // Now set flags 10 to 15 to false. + * + * cFlags := GT_ClrFlag(cFlags,10,15) + * + * // And set flag 18 to false. + * + * cFlags := GT_ClrFlag(cFlags,18) + * + * // And set flag 1 to false. + * + * cFlags := GT_ClrFlag(cFlags) + * $SEEALSO$ + * GT_NEWFLAG() GT_SETFLAG() GT_ISFLAG() + * $END$ + */ + +/* $DOC$ + * $FUNCNAME$ + * GT_ISFLAG() + * $CATEGORY$ + * General + * $ONELINER$ + * Test the setting of a flag in a bit flag string. + * $SYNTAX$ + * GT_IsFlag(,[]) --> lSetting + * $ARGUMENTS$ + * is a bit flag string created with GT_NewFlag() + * + * is the flag to be tested. + * $RETURNS$ + * A boolean value, TRUE if the flag is on, FALSE if it's off. + * $DESCRIPTION$ + * GT_IsFlag() is used to test the state of a flag with a bit flag + * string. + * $EXAMPLES$ + * + * // Print the setting of the flags in a flag string called ``cDave'' + * + * for nFlag := 1 to (len(cDave)*8) + * ? "Flag number ",nFlag," == ",GT_IsFlag(cDave,nFlag) + * next + * $SEEALSO$ + * GT_NEWFLAG() GT_SETFLAG() GT_CLRFLAG() + * $END$ + */ + + diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index 5fc16ccb31..489318189b 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -437,7 +437,21 @@ static ERRCODE adsGoTo( ADSAREAP pArea, ULONG ulRecNo ) pArea->fValidBuffer = FALSE; pArea->fFound = FALSE; - if( ulRecNo > 0 && ulRecNo <= pArea->ulRecCount ) + /* -----------------7/19/2001 3:04PM----------------- + The following call is a necessary workaround for ACE32.DLL + prior to 6.1. There were bugs where + AdsGotoRecord() can FAIL to move the record pointer + after some sequences of setting/clearing relations. + A call to AdsGetRecordNum() before it clears the problem. -BH + --------------------------------------------------*/ + AdsGetRecordNum( pArea->hTable, ADS_IGNOREFILTERS, + (UNSIGNED32 *)&(pArea->ulRecNo) ); + + if ( pArea->ulRecNo == ulRecNo && ulRecNo > 0 && !pArea->fEof) /* just refresh current record */ + { /* if it was at eof, and another station or handle added a record, it needs to GoTo or AtEof stays True. */ + AdsRefreshRecord(pArea->hTable); + } + else if( ulRecNo > 0 && ulRecNo <= pArea->ulRecCount ) { pArea->ulRecNo = ulRecNo; pArea->fBof = pArea->fEof = FALSE; @@ -468,8 +482,6 @@ static ERRCODE adsGoToId( ADSAREAP pArea, PHB_ITEM pItem ) if( HB_IS_NUMERIC( pItem ) ) { ulRecNo = hb_itemGetNL( pItem ); -// if( ulRecNo == 0 ) // bh: Go 0 must go to eof! -// ulRecNo = pArea->ulRecNo; return adsGoTo( pArea, ulRecNo ); } else @@ -481,12 +493,11 @@ static ERRCODE adsGoToId( ADSAREAP pArea, PHB_ITEM pItem ) static ERRCODE adsGoTop( ADSAREAP pArea ) { - UNSIGNED32 ulRetVal; HB_TRACE(HB_TR_DEBUG, ("adsGoTop(%p)", pArea)); pArea->fTop = TRUE; pArea->fBottom = FALSE; - ulRetVal = AdsGotoTop ( (pArea->hOrdCurrent) ? pArea->hOrdCurrent : pArea->hTable ); + AdsGotoTop ( (pArea->hOrdCurrent) ? pArea->hOrdCurrent : pArea->hTable ); hb_adsCheckBofEof( pArea ); return SUPER_SKIPFILTER( (AREAP)pArea, 1 ); @@ -662,13 +673,21 @@ static ERRCODE adsAddField( ADSAREAP pArea, LPDBFIELDINFO pFieldInfo ) static ERRCODE adsAppend( ADSAREAP pArea, BOOL bUnLockAll ) { + UNSIGNED32 ulRetVal; + HB_SYMBOL_UNUSED( bUnLockAll ); HB_TRACE(HB_TR_DEBUG, ("adsAppend(%p, %d)", pArea, (int) bUnLockAll)); - AdsAppendRecord ( pArea->hTable ); - pArea->ulRecCount++; - hb_adsCheckBofEof( pArea ); - return SUCCESS; + ulRetVal = AdsAppendRecord( pArea->hTable ); + if ( ulRetVal == AE_SUCCESS ) + { + pArea->ulRecCount++; + pArea->fBof = FALSE ; + pArea->fEof = FALSE ; + return SUCCESS; + } + else + return FAILURE; } #define adsCreateFields NULL @@ -1151,16 +1170,20 @@ static ERRCODE adsInfo( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) AdsGetNumLocks(pArea->hTable, &uiIndex); if(uiIndex) { - UNSIGNED32 *puLocks; - puLocks = (UNSIGNED32 *) hb_xgrab( (uiIndex + 1) * sizeof( UNSIGNED32 ) ); - AdsGetAllLocks(pArea->hTable, puLocks, &uiIndex); + UNSIGNED32 *puLocks; + puLocks = (UNSIGNED32 *) hb_xgrab( (uiIndex + 1) * sizeof( UNSIGNED32 ) ); + AdsGetAllLocks(pArea->hTable, puLocks, &uiIndex); - if(uiIndex) - for(uiCount=0; uiCount < uiIndex; uiCount++) - hb_arrayAdd( pItem, hb_itemPutNL( NULL, puLocks[ uiCount ] ) ); - - hb_xfree(puLocks); + if(uiIndex) + { + hb_arraySize( pItem, uiIndex ); + for(uiCount=0; uiCount < uiIndex; uiCount++) + hb_itemPutNL( hb_arrayGetItemPtr( pItem, (ULONG) uiCount+1 ), + puLocks[ uiCount ] ); + } + hb_xfree(puLocks); } + break; } @@ -1467,8 +1490,21 @@ static ERRCODE adsOrderListFocus( ADSAREAP pArea, LPDBORDERINFO pOrderInfo ) } else if( HB_IS_STRING( pOrderInfo->itmOrder ) ) { + /* ADS can't handle a space-padded string--we have to trim it */ + UNSIGNED8 pucTagName[ADS_MAX_TAG_NAME + 1]; + ULONG i; + char * pSrc = hb_itemGetCPtr( pOrderInfo->itmOrder ); + ULONG ulLen = hb_strRTrimLen( pSrc, + hb_itemGetCLen( pOrderInfo->itmOrder ), FALSE ); + + if( ulLen > ADS_MAX_TAG_NAME ) + ulLen = ADS_MAX_TAG_NAME; + + strncpy( pucTagName, pSrc, ulLen); + pucTagName[ulLen] = '\0'; + ulRetVal = AdsGetIndexHandle( pArea->hTable, - (UNSIGNED8*) hb_itemGetCPtr( pOrderInfo->itmOrder ), &phIndex ); + pucTagName, &phIndex ); } if( ulRetVal != AE_SUCCESS ) return FAILURE; @@ -2055,14 +2091,11 @@ static ERRCODE adsRawLock( ADSAREAP pArea, USHORT uiAction, ULONG lRecNo ) case FILE_UNLOCK: if( !pArea->fShared ) return TRUE; - hb_adsUnLockAllRecords( pArea ); - if( pArea->fFLocked ) - { - ulRetVal = AdsUnlockTable ( pArea->hTable ); - if ( ulRetVal != AE_SUCCESS ) - return FAILURE; + ulRetVal = AdsUnlockTable ( pArea->hTable ); + if ( ulRetVal == AE_SUCCESS || ulRetVal == AE_TABLE_NOT_LOCKED || ulRetVal == AE_TABLE_NOT_SHARED ) pArea->fFLocked = FALSE; - } + else + return FAILURE; break; } return SUCCESS; @@ -2070,18 +2103,51 @@ static ERRCODE adsRawLock( ADSAREAP pArea, USHORT uiAction, ULONG lRecNo ) static ERRCODE adsLock( ADSAREAP pArea, LPDBLOCKINFO pLockInfo ) { + USHORT uiAction ; + BOOL bUnlocked = FALSE; + ULONG ulRecNo; + HB_TRACE(HB_TR_DEBUG, ("adsLock(%p, %p)", pArea, pLockInfo)); if( pLockInfo->itmRecID == 0 ) { hb_adsUnLockAllRecords( pArea ); + bUnlocked = TRUE; /* Get current record */ AdsGetRecordNum( pArea->hTable, ADS_IGNOREFILTERS, - (UNSIGNED32 *)&(pArea->ulRecNo) ); - pLockInfo->itmRecID = hb_itemPutNL( NULL, pArea->ulRecNo ); + (UNSIGNED32 *)&(pArea->ulRecNo) ); + ulRecNo = pArea->ulRecNo; } - if( adsRawLock( pArea, pLockInfo->uiMethod, hb_itemGetNL( pLockInfo->itmRecID ) ) == SUCCESS ) + else + ulRecNo = (ULONG) hb_itemGetNL(pLockInfo->itmRecID) ; + + + switch ( pLockInfo->uiMethod ) + { + case DBLM_EXCLUSIVE : + if ( !bUnlocked ) + hb_adsUnLockAllRecords( pArea ); + + uiAction = REC_LOCK ; + break; + + case DBLM_MULTIPLE : + uiAction = REC_LOCK ; + break; + + case DBLM_FILE : + uiAction = FILE_LOCK ; + break; + + default : + /* This should probably throw a real error... */ + AdsShowError( (UNSIGNED8 *) "Error in pLockInfo->uiMethod" ); + pLockInfo->fResult = FALSE; + return FAILURE; + } + + if( adsRawLock( pArea, uiAction, ulRecNo ) == SUCCESS ) pLockInfo->fResult = TRUE; else pLockInfo->fResult = FALSE; @@ -2094,9 +2160,12 @@ static ERRCODE adsUnLock( ADSAREAP pArea, ULONG lRecNo ) HB_TRACE(HB_TR_DEBUG, ("adsUnLock(%p, %lu)", pArea, lRecNo)); if( lRecNo == 0 ) - hb_adsUnLockAllRecords( pArea ); + { + adsRawLock( pArea, FILE_UNLOCK, lRecNo ); + } else adsRawLock( pArea, REC_UNLOCK, lRecNo ); + return SUCCESS; } diff --git a/harbour/contrib/rdd_ads/adsfunc.c b/harbour/contrib/rdd_ads/adsfunc.c index e106ea901e..9c65de86a5 100644 --- a/harbour/contrib/rdd_ads/adsfunc.c +++ b/harbour/contrib/rdd_ads/adsfunc.c @@ -89,12 +89,13 @@ HB_FUNC( ADSSETFILETYPE ) HB_FUNC( ADSSETSERVERTYPE ) { int servType; + UNSIGNED32 ulRetVal = 999999; if( hb_pcount() > 0 ) { servType = hb_parni( 1 ); - if( servType>0 && servType<3 ) - AdsSetServerType( servType ); + ulRetVal = AdsSetServerType( servType ); } + hb_retnl( ulRetVal ); } HB_FUNC( ADSSETDATEFORMAT ) @@ -137,13 +138,13 @@ HB_FUNC( ADSISSERVERLOADED ) UNSIGNED16 pbLoaded = 0; UNSIGNED32 ulRetVal; - hb_retnl( 0 ); if( ISCHAR( 1 ) ) { ulRetVal = AdsIsServerLoaded( (UNSIGNED8*) hb_parc(1), &pbLoaded); - if ( ulRetVal == AE_SUCCESS ) - hb_retnl( pbLoaded ); + if ( ulRetVal != AE_SUCCESS ) + pbLoaded = 0; } + hb_retnl( pbLoaded ); } //HB_FUNC( ADSGETCONNECTIONTYPE ) @@ -169,6 +170,45 @@ HB_FUNC( ADSISSERVERLOADED ) //} +HB_FUNC( ADSISTABLELOCKED ) +{ + UNSIGNED32 ulRetVal ; + UNSIGNED16 pbLocked = FALSE; + ADSAREAP pArea; + + pArea = (ADSAREAP) hb_rddGetCurrentWorkAreaPointer(); + if( pArea ) + ulRetVal = AdsIsTableLocked( pArea->hTable, &pbLocked ); + + if( !pArea || ulRetVal != AE_SUCCESS ) + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISTABLELOCKED" ); + + hb_retl( pbLocked ); +} + +HB_FUNC( ADSISRECORDLOCKED ) +{ + UNSIGNED32 ulRetVal ; + UNSIGNED32 ulRec; + UNSIGNED16 pbLocked = FALSE; + ADSAREAP pArea; + + pArea = (ADSAREAP) hb_rddGetCurrentWorkAreaPointer(); + if( pArea ) + { + if ( ISNUM( 1 ) ) + ulRec = hb_parnl( 1 ); + else + ulRec = pArea->ulRecNo; + + ulRetVal = AdsIsRecordLocked( pArea->hTable, ulRec, &pbLocked ); + } + if( !pArea || ulRetVal != AE_SUCCESS ) + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISRECORDLOCKED" ); + + hb_retl( pbLocked ); +} + HB_FUNC( ADSLOCKING ) { int oldType = adsLockType; @@ -893,6 +933,17 @@ HB_FUNC( ADSWRITEALLRECORDS ) hb_retnl( AdsWriteAllRecords() ); } +HB_FUNC( ADSREFRESHRECORD ) +{ + ADSAREAP pArea; + + pArea = (ADSAREAP) hb_rddGetCurrentWorkAreaPointer(); + if( pArea ) + AdsRefreshRecord( pArea->hTable ); + else + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSREFRESHRECORD" ); +} + HB_FUNC( ADSCOPYTABLE ) { ADSAREAP pArea; @@ -1048,4 +1099,6 @@ HB_FUNC( ADSGETNUMINDEXES ) /* cExpr */ HB_FUNC( ADSGETCONNECTIONHANDLE ) { hb_retni( adsConnectHandle ); -} \ No newline at end of file +} + + diff --git a/harbour/source/pp/pptable.c b/harbour/source/pp/pptable.c index 163a078f94..d378a90e33 100644 --- a/harbour/source/pp/pptable.c +++ b/harbour/source/pp/pptable.c @@ -395,10 +395,10 @@ void hb_pp_Table( void ) static COMMANDS sC___228 = {0,"CLEAR","","CLEAR SCREEN ; CLEAR GETS",&sC___227 }; static COMMANDS sC___229 = {0,"CLEAR","ALL", "CLOSE DATABASES ; CLOSE FORMAT ; CLEAR MEMORY ; CLEAR GETS ; SET ALTERNATE OFF ; SET ALTERNATE TO",&sC___228 }; - static COMMANDS sC___230 = {0,"INDEX","ON \1A00 [TAG \1B40 ] TO \1C40 [FOR \1D00] [\1E20ALL>] [WHILE \1F00] [NEXT \1G00] [RECORD \1H00] [\1I20REST>] [EVAL \1J00] [EVERY \1K00] [\1L20 UNIQUE>] [\1M20 ASCENDING>] [\1N20 DESCENDING>]", - "ordCondSet( \1D20, \1D40, [\1E50], \1F40, \1J40, \1K00, RECNO(), \1G00, \1H00, [\1I50], [\1N50] ) ; ordCreate(\1C30, \1B30, \1A20, \1A40, [\1L50] )",&sC___229 }; - static COMMANDS sC___231 = {0,"INDEX","ON \1A00 TAG \1B40 [TO \1C40] [FOR \1D00] [\1E20ALL>] [WHILE \1F00] [NEXT \1G00] [RECORD \1H00] [\1I20REST>] [EVAL \1J00] [EVERY \1K00] [\1L20 UNIQUE>] [\1M20 ASCENDING>] [\1N20 DESCENDING>]", - "ordCondSet( \1D20, \1D40, [\1E50], \1F40, \1J40, \1K00, RECNO(), \1G00, \1H00, [\1I50], [\1N50] ) ; ordCreate(\1C30, \1B30, \1A20, \1A40, [\1L50] )",&sC___230 }; + static COMMANDS sC___230 = {0,"INDEX","ON \1A00 [TAG \1B40 ] TO \1C40 [FOR \1D00] [\1E20ALL>] [WHILE \1F00] [NEXT \1G00] [RECORD \1H00] [\1I20REST>] [EVAL \1J00] [EVERY \1K00] [\1L20 UNIQUE>] [\1M20 ASCENDING>] [\1N20 DESCENDING>] [\1O20 USECURRENT>] [\1P20 ADDITIVE>] [\1R20 CUSTOM>] [\1S20 NOOPTIMIZE>]", + "ordCondSet( \1D20, \1D40, [\1E50], \1F40, \1J40, \1K00, RECNO(), \1G00, \1H00, [\1I50], [\1N50],, [\1P50], [\1O50], [\1R50], [\1S50] ) ; ordCreate(\1C30, \1B30, \1A20, \1A40, [\1L50] )",&sC___229 }; + static COMMANDS sC___231 = {0,"INDEX","ON \1A00 TAG \1B40 [TO \1C40] [FOR \1D00] [\1E20ALL>] [WHILE \1F00] [NEXT \1G00] [RECORD \1H00] [\1I20REST>] [EVAL \1J00] [EVERY \1K00] [\1L20 UNIQUE>] [\1M20 ASCENDING>] [\1N20 DESCENDING>] [\1O20 USECURRENT>] [\1P20 ADDITIVE>] [\1R20 CUSTOM>] [\1S20 NOOPTIMIZE>]", + "ordCondSet( \1D20, \1D40, [\1E50], \1F40, \1J40, \1K00, RECNO(), \1G00, \1H00, [\1I50], [\1N50],, [\1P50], [\1O50], [\1R50], [\1S50] ) ; ordCreate(\1C30, \1B30, \1A20, \1A40, [\1L50] )",&sC___230 }; static COMMANDS sC___232 = {0,"INDEX","ON \1A00 TO \1B40 [\1C20 UNIQUE>]", "dbCreateIndex( \1B30, \1A20, \1A40, if( \1C50, .t., NIL ) )",&sC___231 }; static COMMANDS sC___233 = {0,"DELETE","TAG \1A40 [ IN \1B40 ] [, \1C40 [ IN \1D40 ] ]", diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index 8b1198b713..432c7dc8ce 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -1095,7 +1095,10 @@ HB_FUNC( DBAPPEND ) { bUnLockAll = ISLOG( 1 ) ? hb_parl( 1 ) : TRUE; s_bNetError = FALSE; - SELF_APPEND( ( AREAP ) s_pCurrArea->pArea, bUnLockAll ); + if( SELF_APPEND( ( AREAP ) s_pCurrArea->pArea, bUnLockAll ) == FAILURE ) + { + s_bNetError = TRUE; /* Temp fix! What about other types of errors? */ + } } else hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "DBAPPEND" ); @@ -1843,6 +1846,7 @@ HB_FUNC( DBTABLEEXT ) HB_FUNC( DBUNLOCK ) { + if( s_pCurrArea ) SELF_UNLOCK( ( AREAP ) s_pCurrArea->pArea, 0 ); else @@ -2295,10 +2299,11 @@ HB_FUNC( ORDCONDSET ) lpdbOrdCondInfo->lRecno = hb_parnl( 9 ); lpdbOrdCondInfo->fRest = hb_parl( 10 ); lpdbOrdCondInfo->fDescending = hb_parl( 11 ); - lpdbOrdCondInfo->fAdditive = hb_parl( 12 ); - lpdbOrdCondInfo->fUseCurrent = hb_parl( 13 ); - lpdbOrdCondInfo->fCustom = hb_parl( 14 ); - lpdbOrdCondInfo->fNoOptimize = hb_parl( 15 ); + /* 12th parameter is always nil */ + lpdbOrdCondInfo->fAdditive = hb_parl( 13 ); + lpdbOrdCondInfo->fUseCurrent = hb_parl( 14 ); + lpdbOrdCondInfo->fCustom = hb_parl( 15 ); + lpdbOrdCondInfo->fNoOptimize = hb_parl( 16 ); if( !lpdbOrdCondInfo->itmCobWhile ) lpdbOrdCondInfo->fRest = TRUE;