From b58c301e34c0976c0925547f8bf569ae9d74b9a1 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 9 May 2008 22:46:38 +0000 Subject: [PATCH] 2008-05-10 00:44 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/rddads/rddads.h * contrib/rddads/adsfunc.c * contrib/rddads/adsmgmnt.c * More cleanups, internal fixes. ! ADSTESTLOGIN() fixed to not write into the 7th param string buffer directly since this may cause HVM corruption. To solve this properly, this parameter must now be passed by reference. 8th parameter no longer needed. ! ADSBLOB2FILE(), ADSFILE2BLOB(), ADSGETTABLECHARTYPE() fixed to not GPF when selected workarea is not ADS. + ADSDDSETDATABASEPROPERTY() now able to clear the content of numeric properties. --- harbour/ChangeLog | 15 + harbour/contrib/rddads/adsfunc.c | 1448 ++++++++++++++++------------- harbour/contrib/rddads/adsmgmnt.c | 66 +- harbour/contrib/rddads/rddads.h | 18 +- 4 files changed, 855 insertions(+), 692 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e908e932b4..4569c89e75 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,21 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-05-10 00:44 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * contrib/rddads/rddads.h + * contrib/rddads/adsfunc.c + * contrib/rddads/adsmgmnt.c + * More cleanups, internal fixes. + ! ADSTESTLOGIN() fixed to not write into the 7th + param string buffer directly since this may cause + HVM corruption. To solve this properly, this parameter + must now be passed by reference. 8th parameter no + longer needed. + ! ADSBLOB2FILE(), ADSFILE2BLOB(), ADSGETTABLECHARTYPE() + fixed to not GPF when selected workarea is not ADS. + + ADSDDSETDATABASEPROPERTY() now able to clear the + content of numeric properties. + 2008-05-09 11:47 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/rddads/rddads.h * contrib/rddads/adsfunc.c diff --git a/harbour/contrib/rddads/adsfunc.c b/harbour/contrib/rddads/adsfunc.c index 6fda8cc8e3..fc37ac91f2 100644 --- a/harbour/contrib/rddads/adsfunc.c +++ b/harbour/contrib/rddads/adsfunc.c @@ -63,21 +63,22 @@ #include "rddads.h" #define HARBOUR_MAX_RDD_FILTER_LENGTH 256 -#define MAX_STR_LEN 255 -#define ADS_MAX_PARAMDEF_LEN 2048 - -int adsFileType = ADS_CDX; -int adsLockType = ADS_PROPRIETARY_LOCKING; -int adsRights = ADS_CHECKRIGHTS; -int adsCharType = ADS_ANSI; -BOOL bTestRecLocks = FALSE; /* Debug Implicit locks */ -ADSHANDLE adsConnectHandle = 0; +#define MAX_STR_LEN 255 +#define ADS_MAX_PARAMDEF_LEN 2048 #if !defined( ADS_LINUX ) static PHB_ITEM s_pItmCobCallBack = NULL; #endif +int adsFileType = ADS_CDX; +int adsLockType = ADS_PROPRIETARY_LOCKING; +int adsRights = ADS_CHECKRIGHTS; +int adsCharType = ADS_ANSI; +BOOL bTestRecLocks = FALSE; /* Debug Implicit locks */ +ADSHANDLE adsConnectHandle = 0; + #ifdef ADS_USE_OEM_TRANSLATION + BOOL adsOEM = FALSE; char * hb_adsOemToAnsi( char * pcString, ULONG ulLen ) @@ -146,12 +147,7 @@ HB_FUNC( ADSSETFILETYPE ) HB_FUNC( ADSSETSERVERTYPE ) { - UNSIGNED32 ulRetVal = 999999; - if( hb_pcount() > 0 ) - { - ulRetVal = AdsSetServerType( hb_parni( 1 ) /* servType */ ); - } - hb_retnl( ulRetVal ); + hb_retnl( hb_pcount() > 0 ? AdsSetServerType( ( UNSIGNED16 ) hb_parni( 1 ) /* servType */ ) : 999999 ); } HB_FUNC( ADSSETDATEFORMAT ) @@ -165,13 +161,13 @@ HB_FUNC( ADSSETDATEFORMAT ) if( ISCHAR( 1 ) ) { - AdsSetDateFormat( (UNSIGNED8*) hb_parcx( 1 ) ); + AdsSetDateFormat( ( UNSIGNED8 * ) hb_parcx( 1 ) ); } } HB_FUNC( ADSSETEPOCH ) { - UNSIGNED16 pusEpoch = 1900; + UNSIGNED16 pusEpoch = 0; if( AdsGetEpoch( &pusEpoch ) == AE_SUCCESS ) { @@ -180,7 +176,7 @@ HB_FUNC( ADSSETEPOCH ) if( ISNUM( 1 ) ) { - AdsSetEpoch( hb_parni( 1 ) ); + AdsSetEpoch( ( UNSIGNED16 ) hb_parni( 1 ) ); } } @@ -202,56 +198,61 @@ HB_FUNC( ADSISSERVERLOADED ) if( ISCHAR( 1 ) ) { - UNSIGNED32 ulRetVal = AdsIsServerLoaded( (UNSIGNED8*) hb_parcx( 1 ), &pbLoaded ); + UNSIGNED32 ulRetVal = AdsIsServerLoaded( ( UNSIGNED8 * ) hb_parcx( 1 ), + &pbLoaded ); + if( ulRetVal != AE_SUCCESS ) { pbLoaded = 0; } } - hb_retnl( pbLoaded ); + + hb_retni( pbLoaded ); } HB_FUNC( ADSGETCONNECTIONTYPE ) { - // WARNING: This does NOT return the Type of a connection Handle-- it returns whether - // connected to ADS_REMOTE_SERVER, ADS_AIS_SERVER, or ADS_LOCAL_SERVER - UNSIGNED16 pusConnectType = 0; - UNSIGNED32 ulRetVal; ADSHANDLE hConnToCheck = HB_ADS_PARCONNECTION( 1 ); - // caller can specify a connection. Otherwise use default handle. - // The global adsConnectHandle will continue to be 0 if no adsConnect60 (Data - // Dictionary) calls are made. Simple table access uses an implicit connection - // whose handle we don't see unless you get it from an opened table - // with ADSGETTABLECONTYPE + /* NOTE: Caller can specify a connection. Otherwise use default handle. + The global adsConnectHandle will continue to be 0 if no adsConnect60() (Data + Dictionary) calls are made. Simple table access uses an implicit connection + whose handle we don't see unless you get it from an opened table + with ADSGETTABLECONTYPE(). */ if( hConnToCheck ) { - ulRetVal = AdsGetConnectionType ( hConnToCheck, &pusConnectType ); + UNSIGNED32 ulRetVal; + + /* NOTE: This does NOT return the Type of a connection Handle-- it returns whether + connected to ADS_REMOTE_SERVER, ADS_AIS_SERVER, or ADS_LOCAL_SERVER. */ + + ulRetVal = AdsGetConnectionType( hConnToCheck, &pusConnectType ); + if( ulRetVal != AE_SUCCESS ) { - // it may have set an error value, or leave as 0. - pusConnectType = AE_INVALID_CONNECTION_HANDLE; + pusConnectType = AE_INVALID_CONNECTION_HANDLE; /* It may have set an error value, or leave as 0. */ } } else { - // pusConnectType = AE_INVALID_CONNECTION_HANDLE; - pusConnectType = AE_NO_CONNECTION; + pusConnectType = AE_NO_CONNECTION; /* AE_INVALID_CONNECTION_HANDLE; */ } - hb_retnl( pusConnectType ); + + hb_retni( pusConnectType ); } HB_FUNC( ADSUNLOCKRECORD ) { - ADSAREAP pArea; - - pArea = hb_rddGetADSWorkAreaPointer(); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - UNSIGNED32 ulRetVal = AdsUnlockRecord( pArea->hTable, hb_parnl(1) ); + UNSIGNED32 ulRetVal; + + ulRetVal = AdsUnlockRecord( pArea->hTable, ( UNSIGNED32 ) hb_parnl( 1 ) ); + hb_retl( ulRetVal == AE_SUCCESS ); } else @@ -263,18 +264,18 @@ HB_FUNC( ADSUNLOCKRECORD ) HB_FUNC( ADSGETTABLECONTYPE ) { UNSIGNED16 pusConnectType = 0; - UNSIGNED32 ulRetVal; - ADSAREAP pArea; - ADSHANDLE pTableConnectHandle = 0; - - pArea = hb_rddGetADSWorkAreaPointer(); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { + ADSHANDLE pTableConnectHandle = 0; + AdsGetTableConnection( pArea->hTable, &pTableConnectHandle ); if( pTableConnectHandle ) { + UNSIGNED32 ulRetVal; + ulRetVal = AdsGetConnectionType( pTableConnectHandle, &pusConnectType ); if( ulRetVal != AE_SUCCESS ) @@ -284,7 +285,7 @@ HB_FUNC( ADSGETTABLECONTYPE ) } } - hb_retnl( pusConnectType ); + hb_retni( pusConnectType ); } HB_FUNC( ADSGETSERVERTIME ) @@ -300,7 +301,12 @@ HB_FUNC( ADSGETSERVERTIME ) ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - ulRetVal = AdsGetServerTime( hConnect, pucDateBuf, &pusDateBufLen, &plTime, pucTimeBuf, &pusTimeBufLen ); + ulRetVal = AdsGetServerTime( hConnect, + pucDateBuf, + &pusDateBufLen, + &plTime, + pucTimeBuf, + &pusTimeBufLen ); if( ulRetVal == AE_SUCCESS ) { @@ -311,27 +317,33 @@ HB_FUNC( ADSGETSERVERTIME ) } else { - AdsShowError( (UNSIGNED8 *) "AdsGetServerTime error:" ); + AdsShowError( ( UNSIGNED8 * ) "AdsGetServerTime() error" ); } } -//----------------------------------------------------------------------------// +/* ---------------------------------------------------------------------------- */ HB_FUNC( ADSISTABLELOCKED ) { - UNSIGNED32 ulRetVal = ~AE_SUCCESS; - UNSIGNED16 pbLocked = 0; - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { + UNSIGNED32 ulRetVal; + UNSIGNED16 pbLocked = 0; + ulRetVal = AdsIsTableLocked( pArea->hTable, &pbLocked ); - hb_retl( pbLocked != 0 ); + if( ulRetVal == AE_SUCCESS ) + { + hb_retl( pbLocked != 0 ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISTABLELOCKED" ); + } } - - if( ulRetVal != AE_SUCCESS ) + else { hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISTABLELOCKED" ); } @@ -340,13 +352,13 @@ HB_FUNC( ADSISTABLELOCKED ) HB_FUNC( ADSISRECORDLOCKED ) { UNSIGNED32 ulRetVal = ~AE_SUCCESS; - UNSIGNED32 ulRec; - UNSIGNED16 pbLocked = 0; - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { + UNSIGNED32 ulRec; + UNSIGNED16 pbLocked = 0; + if( ISNUM( 1 ) ) { ulRec = hb_parnl( 1 ); @@ -355,6 +367,7 @@ HB_FUNC( ADSISRECORDLOCKED ) { SELF_RECNO( ( AREAP ) pArea, &ulRec ); } + ulRetVal = AdsIsRecordLocked( pArea->hTable, ulRec, &pbLocked ); hb_retl( pbLocked != 0 ); @@ -403,22 +416,33 @@ HB_FUNC( ADSSETCHARTYPE ) { adsCharType = charType; } + #ifdef ADS_USE_OEM_TRANSLATION if( ISLOG( 2 ) ) { - adsOEM = hb_parnl( 2 ); + adsOEM = hb_parl( 2 ); } #endif } } -// return whether the current table is opened with OEM or ANSI character set +/* Return whether the current table is opened with OEM or ANSI character set. */ HB_FUNC( ADSGETTABLECHARTYPE ) { - UNSIGNED16 usCharType; ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - AdsGetTableCharType( pArea->hTable, &usCharType ); - hb_retni( usCharType ); + + if( pArea ) + { + UNSIGNED16 usCharType = 0; + + AdsGetTableCharType( pArea->hTable, &usCharType ); + + hb_retni( usCharType ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSGETTABLECHARTYPE" ); + } } @@ -433,7 +457,7 @@ HB_FUNC( ADSSETDEFAULT ) if( ISCHAR( 1 ) ) { - AdsSetDefault( (UNSIGNED8*) hb_parcx( 1 ) ); + AdsSetDefault( ( UNSIGNED8 * ) hb_parcx( 1 ) ); } } @@ -445,20 +469,21 @@ HB_FUNC( ADSSETSEARCHPATH ) AdsGetSearchPath( pucPath, &pusLen ); - hb_retclen( ( char *) pucPath, pusLen ); + hb_retclen( ( char * ) pucPath, pusLen ); if( ISCHAR( 1 ) ) { - AdsSetSearchPath( (UNSIGNED8*) hb_parcx( 1 ) ); + AdsSetSearchPath( ( UNSIGNED8 * ) hb_parcx( 1 ) ); } } HB_FUNC( ADSSETDELETED ) { - UNSIGNED16 pbShowDeleted; + UNSIGNED16 pbShowDeleted = 0; AdsGetDeleted( &pbShowDeleted ); - hb_retl( ! pbShowDeleted ); + + hb_retl( pbShowDeleted == 0 ); if( ISLOG( 1 ) ) { @@ -471,11 +496,12 @@ HB_FUNC( ADSSETEXACT ) UNSIGNED16 pbExact = 0; AdsGetExact( &pbExact ); + hb_retl( pbExact != 0 ); if( ISLOG( 1 ) ) { - AdsSetExact( hb_parl( 1 ) /* usExact */ ); + AdsSetExact( ( UNSIGNED16 ) hb_parl( 1 ) /* usExact */ ); } } @@ -483,15 +509,26 @@ HB_FUNC( ADSBLOB2FILE ) { char * szFileName = hb_parcx( 1 ); char * szFieldName = hb_parcx( 2 ); - ADSAREAP pArea; - UNSIGNED32 ulRetVal; - if( szFileName && strlen( szFileName ) && - szFieldName && strlen( szFieldName ) ) + if( strlen( szFileName ) && + strlen( szFieldName ) ) { - pArea = hb_rddGetADSWorkAreaPointer(); - ulRetVal = AdsBinaryToFile( pArea->hTable, (UNSIGNED8*)szFieldName, (UNSIGNED8*)szFileName ); - hb_retl( ulRetVal == AE_SUCCESS ); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); + + if( pArea ) + { + UNSIGNED32 ulRetVal; + + ulRetVal = AdsBinaryToFile( pArea->hTable, + ( UNSIGNED8 * ) szFieldName, + ( UNSIGNED8 * ) szFileName ); + + hb_retl( ulRetVal == AE_SUCCESS ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSBLOB2FILE" ); + } } else { @@ -503,17 +540,27 @@ HB_FUNC( ADSFILE2BLOB ) { char * szFileName = hb_parcx( 1 ); char * szFieldName = hb_parcx( 2 ); - ADSAREAP pArea; - UNSIGNED32 ulRetVal; - if( szFileName && strlen( szFileName ) && - szFieldName && strlen( szFieldName ) ) + if( strlen( szFileName ) && + strlen( szFieldName ) ) { - UNSIGNED16 usBinaryType = hb_pcount() > 2 ? hb_parni( 3 ) : ADS_BINARY; - - pArea = hb_rddGetADSWorkAreaPointer(); - ulRetVal = AdsFileToBinary( pArea->hTable, (UNSIGNED8*)szFieldName, usBinaryType, (UNSIGNED8*)szFileName ); - hb_retl( ulRetVal == AE_SUCCESS ); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); + + if( pArea ) + { + UNSIGNED32 ulRetVal; + + ulRetVal = AdsFileToBinary( pArea->hTable, + ( UNSIGNED8 * ) szFieldName, + ( UNSIGNED16 ) ( hb_pcount() > 2 ? hb_parni( 3 ) : ADS_BINARY ) /* usBinaryType */, + ( UNSIGNED8 * ) szFileName ); + + hb_retl( ulRetVal == AE_SUCCESS ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSFILE2BLOB" ); + } } else { @@ -521,222 +568,239 @@ HB_FUNC( ADSFILE2BLOB ) } } +/* 2nd parameter: unsupported Bag Name. */ HB_FUNC( ADSKEYNO ) { - ADSAREAP pArea; - UNSIGNED8* ordName; - UNSIGNED8 ordNum; - UNSIGNED32 pulKey = 0L; - ADSHANDLE hIndex = 0; - UNSIGNED16 usFilterOption = ADS_IGNOREFILTERS; - - PHB_ITEM pxOrder = hb_param( 1, HB_IT_ANY ); - /* 2nd parameter: unsupported Bag Name. */ - PHB_ITEM pFilterOption = hb_param( 3, HB_IT_NUMERIC ); + PHB_ITEM pxOrder = hb_param( 1, HB_IT_ANY ); + PHB_ITEM pFilterOption = hb_param( 3, HB_IT_NUMERIC ); /* if arg 1 or 3 is bad, toss error */ - if( ( pxOrder != NULL && !HB_IS_STRING( pxOrder ) && !HB_IS_NUMBER( pxOrder ) && !HB_IS_NIL( pxOrder ) ) || - ( pFilterOption != NULL && !HB_IS_NUMBER( pFilterOption ) ) ) + if( ( pxOrder == NULL || HB_IS_STRING( pxOrder ) || HB_IS_NUMBER( pxOrder ) || HB_IS_NIL( pxOrder ) ) && + ( pFilterOption == NULL || HB_IS_NUMBER( pFilterOption ) ) ) { - hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSKEYNO" ); - return; - } + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); - if( pArea ) - { - if( pFilterOption ) + if( pArea ) { - usFilterOption = hb_itemGetNI( pFilterOption ); - } - - /* get an Index Handle */ - if( pxOrder == NULL || HB_IS_NIL( pxOrder ) ) /* didn't pass it in; use current */ - { - hIndex = pArea->hOrdCurrent; - } - else if( HB_IS_NUMBER( pxOrder ) ) - { - ordNum = (UNSIGNED8) hb_itemGetNI( pxOrder ); - if( ordNum > 0 ) /* otherwise leave hIndex at 0 */ + UNSIGNED32 pulKey = 0L; + ADSHANDLE hIndex = 0; + UNSIGNED16 usFilterOption = pFilterOption ? hb_itemGetNI( pFilterOption ) : ADS_IGNOREFILTERS; + + /* get an Index Handle */ + if( pxOrder == NULL || HB_IS_NIL( pxOrder ) ) /* didn't pass it in; use current */ { - AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex ); + hIndex = pArea->hOrdCurrent; } - } - else /* must be number or nil since checked above */ - { - if( hb_itemGetCLen( pxOrder ) == 0 ) /* passed "" */ + else if( HB_IS_NUMBER( pxOrder ) ) + { + UNSIGNED8 ordNum = ( UNSIGNED8 ) hb_itemGetNI( pxOrder ); + + if( ordNum > 0 ) /* otherwise leave hIndex at 0 */ + { + AdsGetIndexHandleByOrder( pArea->hTable, + ordNum, + &hIndex ); + } + } + else if( hb_itemGetCLen( pxOrder ) == 0 ) /* passed empty string */ { hIndex = pArea->hOrdCurrent; } else { - ordName = (UNSIGNED8*) hb_itemGetCPtr( pxOrder ); - AdsGetIndexHandle( pArea->hTable, ordName, &hIndex ); - } - } + UNSIGNED8 * ordName = ( UNSIGNED8 * ) hb_itemGetCPtr( pxOrder ); - if( hIndex == 0 ) /* no index selected */ - { - AdsGetRecordNum( pArea->hTable, usFilterOption, &pulKey ); + AdsGetIndexHandle( pArea->hTable, + ordName, + &hIndex ); + } + + if( hIndex == 0 ) /* no index selected */ + { + AdsGetRecordNum( pArea->hTable, + usFilterOption, + &pulKey ); + } + else + { + AdsGetKeyNum( hIndex, + usFilterOption, + &pulKey ); + } + + hb_retnl( pulKey ); } else { - AdsGetKeyNum( hIndex, usFilterOption, &pulKey ); + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSKEYNO" ); } - - hb_retnl( pulKey ); } else { - hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSKEYNO" ); + hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSKEYNO" ); } } + +/* 2nd parameter: unsupported Bag Name. */ HB_FUNC( ADSKEYCOUNT ) { - ADSAREAP pArea; - UNSIGNED8* ordName; - UNSIGNED8 ordNum; - UNSIGNED32 pulKey = 0L; - ADSHANDLE hIndex = 0; - UNSIGNED16 usFilterOption = ADS_IGNOREFILTERS; - UNSIGNED8 pucScope[ ADS_MAX_KEY_LENGTH + 1 ]; - UNSIGNED16 pusBufLen = ADS_MAX_KEY_LENGTH + 1; - UNSIGNED8 pucFilter[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; - - PHB_ITEM pxOrder = hb_param( 1, HB_IT_ANY ); - /* 2nd parameter: unsupported Bag Name. */ - PHB_ITEM pFilterOption = hb_param( 3, HB_IT_NUMERIC ); - - if( pxOrder != NULL && HB_IS_NIL( pxOrder ) ) - { - pxOrder = NULL; // simplifies arg checks below - } + PHB_ITEM pxOrder = hb_param( 1, HB_IT_ANY ); + PHB_ITEM pFilterOption = hb_param( 3, HB_IT_NUMERIC ); /* if arg 1 or 3 is bad, toss error */ - if( ( pxOrder != NULL && !HB_IS_STRING( pxOrder ) && !HB_IS_NUMBER( pxOrder ) ) || - ( pFilterOption != NULL && !HB_IS_NUMBER( pFilterOption ) ) ) + if( ( pxOrder == NULL || HB_IS_STRING( pxOrder ) || HB_IS_NUMBER( pxOrder ) || HB_IS_NIL( pxOrder ) ) && + ( pFilterOption == NULL || HB_IS_NUMBER( pFilterOption ) ) ) { - hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSKEYCOUNT" ); - return; - } + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); - if( pArea ) - { - if( pFilterOption != NULL ) + if( pArea ) { - usFilterOption = hb_itemGetNI( pFilterOption ); - } - /* get an Index Handle */ - if( pxOrder == NULL ) /* didn't pass it in; use current */ - { - hIndex = pArea->hOrdCurrent; - } - else if( HB_IS_NUMBER( pxOrder ) ) - { - ordNum = (UNSIGNED8) hb_itemGetNI( pxOrder ); - if( ordNum > 0 ) /* otherwise leave hIndex at 0 */ + UNSIGNED32 pulKey = 0L; + ADSHANDLE hIndex = 0; + UNSIGNED16 usFilterOption = pFilterOption ? hb_itemGetNI( pFilterOption ) : ADS_IGNOREFILTERS; + + /* get an Index Handle */ + if( pxOrder == NULL || HB_IS_NIL( pxOrder ) ) /* didn't pass it in; use current */ { - AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex ); + hIndex = pArea->hOrdCurrent; } - } - else /* must be String since checked above */ - { - if( hb_itemGetCLen( pxOrder ) == 0 ) /* passed "" */ + else if( HB_IS_NUMBER( pxOrder ) ) + { + UNSIGNED8 ordNum = ( UNSIGNED8 ) hb_itemGetNI( pxOrder ); + + if( ordNum > 0 ) /* otherwise leave hIndex at 0 */ + { + AdsGetIndexHandleByOrder( pArea->hTable, + ordNum, + &hIndex ); + } + } + else if( hb_itemGetCLen( pxOrder ) == 0 ) /* passed empty string */ { hIndex = pArea->hOrdCurrent; } else { - ordName = (UNSIGNED8*) hb_itemGetCPtr( pxOrder ); - AdsGetIndexHandle( pArea->hTable, ordName, &hIndex ); + UNSIGNED8 * ordName = ( UNSIGNED8 * ) hb_itemGetCPtr( pxOrder ); + + AdsGetIndexHandle( pArea->hTable, + ordName, + &hIndex ); } - } - - hIndex = ( hIndex == 0 ) ? pArea->hTable : hIndex; - - if( usFilterOption == ADS_IGNOREFILTERS ) - { - AdsGetRecordCount( hIndex, ADS_IGNOREFILTERS, &pulKey ); - } - else /* ads scope handling is flawed; do our own */ - { /* One more optimization would be to check if there's a fully optimized AOF available so don't walk ours */ - AdsGetScope( hIndex, ADS_BOTTOM, pucScope, &pusBufLen ); - if( pusBufLen ) /* had a scope */ + + if( hIndex == 0 ) /* no index selected */ { - AdsGetAOF( pArea->hTable, pucFilter, &pusBufLen ); - if( !pusBufLen ) /* had no AOF */ - { - AdsGetFilter( pArea->hTable, pucFilter, &pusBufLen ); - } - if( pusBufLen ) /* had a scope with AOF or filter, walk it. Skips obey filters */ - { - ULONG ulRecNo; - UNSIGNED16 u16eof; + hIndex = pArea->hTable; + } - SELF_RECNO( ( AREAP ) pArea, &ulRecNo ); - AdsGotoTop( hIndex ); + if( usFilterOption == ADS_IGNOREFILTERS ) + { + AdsGetRecordCount( hIndex, ADS_IGNOREFILTERS, &pulKey ); + } + else + { + /* ADS scope handling is flawed; do our own */ + /* One more optimization would be to check if there's a fully optimized AOF available so don't walk ours. */ - AdsAtEOF( pArea->hTable, &u16eof ); - while( AdsSkip ( hIndex, 1 ) != AE_NO_CURRENT_RECORD && !u16eof ) + UNSIGNED8 pucScope[ ADS_MAX_KEY_LENGTH + 1 ]; + UNSIGNED16 pusBufLen = ADS_MAX_KEY_LENGTH + 1; + UNSIGNED8 pucFilter[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; + + AdsGetScope( hIndex, + ADS_BOTTOM, + pucScope, + &pusBufLen ); + + if( pusBufLen ) /* had a scope */ + { + AdsGetAOF( pArea->hTable, + pucFilter, + &pusBufLen ); + + if( !pusBufLen ) /* had no AOF */ { - AdsAtEOF( pArea->hTable, &u16eof ); - pulKey++; + AdsGetFilter( pArea->hTable, + pucFilter, + &pusBufLen ); } - SELF_GOTO( ( AREAP ) pArea, ulRecNo ); - } - else - { - AdsGetRecordCount( hIndex, usFilterOption, &pulKey ); - } - } - else /* no scope set */ - { - AdsGetRecordCount( hIndex, usFilterOption, &pulKey ); - } - } - hb_retnl( pulKey ); + if( pusBufLen ) /* had a scope with AOF or filter, walk it. Skips obey filters */ + { + ULONG ulRecNo; + UNSIGNED16 u16eof; + + SELF_RECNO( ( AREAP ) pArea, &ulRecNo ); + AdsGotoTop( hIndex ); + + AdsAtEOF( pArea->hTable, &u16eof ); + + while( AdsSkip( hIndex, 1 ) != AE_NO_CURRENT_RECORD && !u16eof ) + { + AdsAtEOF( pArea->hTable, &u16eof ); + pulKey++; + } + SELF_GOTO( ( AREAP ) pArea, ulRecNo ); + } + else + { + AdsGetRecordCount( hIndex, + usFilterOption, + &pulKey ); + } + } + else /* no scope set */ + { + AdsGetRecordCount( hIndex, + usFilterOption, + &pulKey ); + } + } + + hb_retnl( pulKey ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSKEYCOUNT" ); + } } else { - hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSKEYCOUNT" ); + hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSKEYCOUNT" ); } } HB_FUNC( ADSADDCUSTOMKEY ) { - ADSAREAP pArea; - UNSIGNED8* ordName; - UNSIGNED8 ordNum; - ADSHANDLE hIndex; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { if( hb_pcount() > 0 ) { + ADSHANDLE hIndex; + if( ISNUM( 1 ) ) { - ordNum = hb_parni( 1 ); - AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex ); + AdsGetIndexHandleByOrder( pArea->hTable, + ( UNSIGNED16 ) hb_parni( 1 ) /* ordNum */, + &hIndex ); } else { - ordName = (UNSIGNED8*) hb_parcx( 1 ); - AdsGetIndexHandle( pArea->hTable, ordName, &hIndex ); + AdsGetIndexHandle( pArea->hTable, + ( UNSIGNED8 * ) hb_parcx( 1 ) /* ordName */, + &hIndex ); } - hb_retnl( (LONG) AdsAddCustomKey( hIndex ) ); + + hb_retnl( ( long ) AdsAddCustomKey( hIndex ) ); } else { if( pArea->hOrdCurrent != 0 ) { - hIndex = pArea->hOrdCurrent; - hb_retnl( (LONG) AdsAddCustomKey( hIndex ) ); + hb_retnl( ( long ) AdsAddCustomKey( pArea->hOrdCurrent ) ); } else { @@ -752,34 +816,33 @@ HB_FUNC( ADSADDCUSTOMKEY ) HB_FUNC( ADSDELETECUSTOMKEY ) { - ADSAREAP pArea; - UNSIGNED8* ordName; - UNSIGNED8 ordNum; - ADSHANDLE hIndex; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { if( hb_pcount() > 0 ) { + ADSHANDLE hIndex; + if( ISNUM( 1 ) ) { - ordNum = hb_parni( 1 ); - AdsGetIndexHandleByOrder( pArea->hTable, ordNum, &hIndex ); + AdsGetIndexHandleByOrder( pArea->hTable, + ( UNSIGNED16 ) hb_parni( 1 ) /* ordNum */, + &hIndex ); } else { - ordName = (UNSIGNED8*) hb_parcx( 1 ); - AdsGetIndexHandle( pArea->hTable, ordName, &hIndex ); + AdsGetIndexHandle( pArea->hTable, + ( UNSIGNED8 * ) hb_parcx( 1 ) /* ordName */, + &hIndex ); } - hb_retnl( (LONG) AdsDeleteCustomKey( hIndex ) ); + hb_retnl( ( long ) AdsDeleteCustomKey( hIndex ) ); } else { if( pArea->hOrdCurrent != 0 ) { - hIndex = pArea->hOrdCurrent; - hb_retnl( (LONG) AdsDeleteCustomKey( hIndex ) ); + hb_retnl( ( long ) AdsDeleteCustomKey( pArea->hOrdCurrent ) ); } else { @@ -795,9 +858,8 @@ HB_FUNC( ADSDELETECUSTOMKEY ) HB_FUNC( ADSCLEARAOF ) { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { AdsClearAOF( pArea->hTable ); @@ -811,16 +873,23 @@ HB_FUNC( ADSCLEARAOF ) HB_FUNC( ADSEVALAOF ) { - ADSAREAP pArea; - char * pucFilter; - UNSIGNED16 pusOptLevel; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); - if( pArea && ISCHAR( 1 ) ) + if( pArea ) { - pucFilter = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) ); - AdsEvalAOF( pArea->hTable, (UNSIGNED8*) pucFilter, &pusOptLevel ); - hb_adsOemAnsiFree( pucFilter ); + UNSIGNED16 pusOptLevel = 0; + + if( ISCHAR( 1 ) ) + { + char * pucFilter = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) ); + + AdsEvalAOF( pArea->hTable, + ( UNSIGNED8 * ) pucFilter, + &pusOptLevel ); + + hb_adsOemAnsiFree( pucFilter ); + } + hb_retni( pusOptLevel ); } else @@ -829,22 +898,23 @@ HB_FUNC( ADSEVALAOF ) } } - HB_FUNC( ADSGETTABLEALIAS ) { - ADSAREAP pArea; - UNSIGNED8 pucAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ]; - UNSIGNED16 pusLen = HARBOUR_MAX_RDD_ALIAS_LENGTH + 1; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsGetTableAlias( pArea->hTable, pucAlias, &pusLen ); + UNSIGNED8 pucAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ]; + UNSIGNED16 pusLen = HARBOUR_MAX_RDD_ALIAS_LENGTH + 1; + UNSIGNED32 ulRetVal; + + ulRetVal = AdsGetTableAlias( pArea->hTable, + pucAlias, + &pusLen ); if( ulRetVal == AE_SUCCESS ) { - hb_retclen ( ( char * ) pucAlias, pusLen ); + hb_retclen( ( char * ) pucAlias, pusLen ); } else { @@ -859,20 +929,25 @@ HB_FUNC( ADSGETTABLEALIAS ) HB_FUNC( ADSGETAOF ) { - ADSAREAP pArea; - UNSIGNED8 pucFilter[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; - UNSIGNED8 *pucFilter2 = NULL; - UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsGetAOF( pArea->hTable, pucFilter, &pusLen ); + UNSIGNED8 pucFilter[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; + UNSIGNED8 *pucFilter2 = NULL; + UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; + UNSIGNED32 ulRetVal; + + ulRetVal = AdsGetAOF( pArea->hTable, + pucFilter, + &pusLen ); + if( pusLen > HARBOUR_MAX_RDD_FILTER_LENGTH ) { - pucFilter2 = (UNSIGNED8*) hb_xgrab( pusLen + 1 ); - ulRetVal = AdsGetAOF( pArea->hTable, pucFilter2, &pusLen ); + pucFilter2 = ( UNSIGNED8 * ) hb_xgrab( pusLen + 1 ); + ulRetVal = AdsGetAOF( pArea->hTable, + pucFilter2, + &pusLen ); } if( ulRetVal == AE_SUCCESS ) @@ -900,14 +975,18 @@ HB_FUNC( ADSGETAOF ) HB_FUNC( ADSGETAOFOPTLEVEL ) { - ADSAREAP pArea; - UNSIGNED16 pusOptLevel = 0; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsGetAOFOptLevel( pArea->hTable, &pusOptLevel, NULL, NULL ); + UNSIGNED16 pusOptLevel = 0; + UNSIGNED32 ulRetVal; + + ulRetVal = AdsGetAOFOptLevel( pArea->hTable, + &pusOptLevel, + NULL, + NULL ); + hb_retni( ulRetVal == AE_SUCCESS ? pusOptLevel : ADS_OPTIMIZED_NONE ); } else @@ -918,39 +997,36 @@ HB_FUNC( ADSGETAOFOPTLEVEL ) HB_FUNC( ADSGETAOFNOOPT ) { - ADSAREAP pArea; - UNSIGNED16 pusOptLevel; - UNSIGNED8 pucNonOpt[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; - UNSIGNED8 *pucNonOpt2; - UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsGetAOFOptLevel( pArea->hTable, &pusOptLevel, pucNonOpt, &pusLen ); + UNSIGNED16 pusOptLevel; + UNSIGNED8 pucNonOpt[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; + UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; + UNSIGNED32 ulRetVal; + + ulRetVal = AdsGetAOFOptLevel( pArea->hTable, + &pusOptLevel, + pucNonOpt, + &pusLen ); if( pusLen > HARBOUR_MAX_RDD_FILTER_LENGTH ) { - pucNonOpt2 = (UNSIGNED8*) hb_xgrab( pusLen + 1 ); - ulRetVal = AdsGetAOFOptLevel( pArea->hTable, &pusOptLevel, pucNonOpt2, &pusLen ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retc( ( char * ) pucNonOpt2 ); - } - else - { - hb_retc( NULL ); - } + UNSIGNED8 * pucNonOpt2 = ( UNSIGNED8 * ) hb_xgrab( pusLen + 1 ); + + ulRetVal = AdsGetAOFOptLevel( pArea->hTable, + &pusOptLevel, + pucNonOpt2, + &pusLen ); + + hb_retc( ulRetVal == AE_SUCCESS ? ( char * ) pucNonOpt2 : NULL ); + hb_xfree( pucNonOpt2 ); } - else if( ulRetVal == AE_SUCCESS ) - { - hb_retc( ( char * ) pucNonOpt ); - } else { - hb_retc( NULL ); + hb_retc( ulRetVal == AE_SUCCESS ? ( char * ) pucNonOpt : NULL ); } } else @@ -961,18 +1037,19 @@ HB_FUNC( ADSGETAOFNOOPT ) HB_FUNC( ADSISRECORDINAOF ) { - ADSAREAP pArea; - UNSIGNED16 bIsInAOF = 0; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - UNSIGNED32 ulRecordNumber = hb_parnl( 1 ); /* 0 for current record */ + UNSIGNED32 ulRecordNumber = ( UNSIGNED32 ) hb_parnl( 1 ); /* 0 for current record */ + UNSIGNED16 bIsInAOF = 0; + UNSIGNED32 ulRetVal; - ulRetVal = AdsIsRecordInAOF( pArea->hTable, ulRecordNumber, &bIsInAOF ); + ulRetVal = AdsIsRecordInAOF( pArea->hTable, + ulRecordNumber, + &bIsInAOF ); - hb_retl( ulRetVal == AE_SUCCESS && bIsInAOF ); + hb_retl( ulRetVal == AE_SUCCESS && bIsInAOF != 0 ); } else { @@ -980,21 +1057,22 @@ HB_FUNC( ADSISRECORDINAOF ) } } -HB_FUNC( ADSISRECORDVALID ) // Does current record match any current filter? +/* Does current record match any current filter? */ +HB_FUNC( ADSISRECORDVALID ) { BOOL bReturn = FALSE; - AREAP pArea; + AREAP pArea = hb_rddGetCurrentWorkAreaPointer(); - pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer(); if( pArea ) { BOOL fEof = TRUE; - if( SELF_EOF( ( AREAP ) pArea , &fEof ) == SUCCESS && !fEof ) + if( SELF_EOF( ( AREAP ) pArea, &fEof ) == SUCCESS && !fEof ) { if( pArea->dbfi.itmCobExpr ) { PHB_ITEM pResult = hb_vmEvalBlock( pArea->dbfi.itmCobExpr ); + bReturn = HB_IS_LOGICAL( pResult ) && hb_itemGetL( pResult ); } else @@ -1009,9 +1087,8 @@ HB_FUNC( ADSISRECORDVALID ) // Does current record match any current HB_FUNC( ADSREFRESHAOF ) { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { AdsRefreshAOF( pArea->hTable ); @@ -1024,55 +1101,59 @@ HB_FUNC( ADSREFRESHAOF ) HB_FUNC( ADSSETAOF ) { - ADSAREAP pArea; - char * pucFilter; - UNSIGNED16 usResolve = ADS_RESOLVE_DYNAMIC ; /* ADS_RESOLVE_IMMEDIATE */ - UNSIGNED32 ulRetVal; + if( ISCHAR( 1 ) ) + { + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); - if( ! ISCHAR( 1 ) ) - { - hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSSETAOF" ); - } - else if( pArea ) - { - if( hb_pcount() > 1 ) + if( pArea ) { - usResolve = hb_parni( 2 ); + UNSIGNED32 ulRetVal; + UNSIGNED16 usResolve = ( UNSIGNED16 ) ( hb_pcount() > 1 ? hb_parni( 2 ) : ADS_RESOLVE_DYNAMIC ); /* ADS_RESOLVE_IMMEDIATE */ + char * pucFilter; + + pucFilter = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) ); + + ulRetVal = AdsSetAOF( pArea->hTable, + ( UNSIGNED8 * ) pucFilter, + usResolve ); + + hb_adsOemAnsiFree( pucFilter ); + + hb_retl( ulRetVal == AE_SUCCESS ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSSETAOF" ); } - - pucFilter = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) ); - - ulRetVal = AdsSetAOF( pArea->hTable, (UNSIGNED8*) pucFilter, usResolve ); - - hb_adsOemAnsiFree( pucFilter ); - - hb_retl( ulRetVal == AE_SUCCESS ); } else { - hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSSETAOF" ); + hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSSETAOF" ); } - } HB_FUNC( ADSGETFILTER ) { - ADSAREAP pArea; - UNSIGNED8 pucFilter[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; - UNSIGNED8 *pucFilter2 = NULL; - UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsGetFilter( pArea->hTable, pucFilter, &pusLen ); + UNSIGNED8 pucFilter[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; + UNSIGNED8 * pucFilter2 = NULL; + UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; + UNSIGNED32 ulRetVal; + + ulRetVal = AdsGetFilter( pArea->hTable, + pucFilter, + &pusLen ); if( pusLen > HARBOUR_MAX_RDD_FILTER_LENGTH ) { - pucFilter2 = (UNSIGNED8*) hb_xgrab( pusLen + 1 ); - ulRetVal = AdsGetFilter( pArea->hTable, pucFilter2, &pusLen ); + pucFilter2 = ( UNSIGNED8 * ) hb_xgrab( pusLen + 1 ); + + ulRetVal = AdsGetFilter( pArea->hTable, + pucFilter2, + &pusLen ); } if( ulRetVal == AE_SUCCESS ) @@ -1083,7 +1164,7 @@ HB_FUNC( ADSGETFILTER ) } else { - HB_TRACE(HB_TR_DEBUG, ("adsGetFilter Error %lu", ulRetVal)); + HB_TRACE(HB_TR_DEBUG, ("adsGetFilter() error %lu", ulRetVal)); hb_retc( NULL ); } @@ -1100,17 +1181,20 @@ HB_FUNC( ADSGETFILTER ) HB_FUNC( ADSENABLEENCRYPTION ) { - ADSAREAP pArea; - UNSIGNED32 ulRetVal; char * pucPassword = hb_parcx( 1 ); - if( pucPassword && strlen( pucPassword ) ) + if( strlen( pucPassword ) ) { - pArea = hb_rddGetADSWorkAreaPointer(); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); + if( pArea ) { - ulRetVal = AdsEnableEncryption( pArea->hTable, ( UNSIGNED8 * ) pucPassword ); - hb_retni( ulRetVal ); + UNSIGNED32 ulRetVal; + + ulRetVal = AdsEnableEncryption( pArea->hTable, + ( UNSIGNED8 * ) pucPassword ); + + hb_retnl( ulRetVal ); } else { @@ -1125,14 +1209,11 @@ HB_FUNC( ADSENABLEENCRYPTION ) HB_FUNC( ADSDISABLEENCRYPTION ) { - ADSAREAP pArea; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsDisableEncryption( pArea->hTable ); - hb_retni( ulRetVal ); + hb_retnl( AdsDisableEncryption( pArea->hTable ) ); } else { @@ -1142,14 +1223,11 @@ HB_FUNC( ADSDISABLEENCRYPTION ) HB_FUNC( ADSENCRYPTTABLE ) { - ADSAREAP pArea; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsEncryptTable( pArea->hTable ); - hb_retni( ulRetVal ); + hb_retnl( AdsEncryptTable( pArea->hTable ) ); } else { @@ -1159,14 +1237,11 @@ HB_FUNC( ADSENCRYPTTABLE ) HB_FUNC( ADSDECRYPTTABLE ) { - ADSAREAP pArea; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsDecryptTable( pArea->hTable ); - hb_retni( ulRetVal ); + hb_retnl( AdsDecryptTable( pArea->hTable ) ); } else { @@ -1176,14 +1251,11 @@ HB_FUNC( ADSDECRYPTTABLE ) HB_FUNC( ADSENCRYPTRECORD ) { - ADSAREAP pArea; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsEncryptRecord( pArea->hTable ); - hb_retni( ulRetVal ); + hb_retnl( AdsEncryptRecord( pArea->hTable ) ); } else { @@ -1193,14 +1265,11 @@ HB_FUNC( ADSENCRYPTRECORD ) HB_FUNC( ADSDECRYPTRECORD ) { - ADSAREAP pArea; - UNSIGNED32 ulRetVal; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsDecryptRecord( pArea->hTable ); - hb_retni( ulRetVal ); + hb_retnl( AdsDecryptRecord( pArea->hTable ) ); } else { @@ -1210,9 +1279,8 @@ HB_FUNC( ADSDECRYPTRECORD ) HB_FUNC( ADSISENCRYPTIONENABLED ) { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { UNSIGNED16 usIsEnabled = 0; @@ -1227,9 +1295,8 @@ HB_FUNC( ADSISENCRYPTIONENABLED ) HB_FUNC( ADSISRECORDENCRYPTED ) { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { UNSIGNED16 usIsEnabled = 0; @@ -1244,9 +1311,8 @@ HB_FUNC( ADSISRECORDENCRYPTED ) HB_FUNC( ADSISTABLEENCRYPTED ) { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { UNSIGNED16 usIsEnabled = 0; @@ -1265,7 +1331,10 @@ HB_FUNC( ADSCONNECT ) { ADSHANDLE hConnect = 0; UNSIGNED32 ulRetVal; - ulRetVal = AdsConnect( (UNSIGNED8*) hb_parcx( 1 ), &hConnect ); + + ulRetVal = AdsConnect( ( UNSIGNED8 * ) hb_parcx( 1 ), + &hConnect ); + if( ulRetVal == AE_SUCCESS ) { adsConnectHandle = hConnect; @@ -1284,33 +1353,42 @@ HB_FUNC( ADSCONNECT ) HB_FUNC( ADSDISCONNECT ) { - /* From ACE HLP: - * AdsDisconnect is used to disconnect a connection from the specified server. - * If tables are currently opened, all data is flushed, locks are released, - * and open tables are closed before the disconnect occurs. - * - * If zero is passed as the connection handle, all connections on the server - * associated with the user will be disconnected. If AdsDisconnect is called - * on a connection with a transaction active, the transaction will be rolled back. + /* NOTE: From ACE.HLP: * + * AdsDisconnect() is used to disconnect a connection from the specified server. + * If tables are currently opened, all data is flushed, locks are released, + * and open tables are closed before the disconnect occurs. + * + * If zero is passed as the connection handle, all connections on the server + * associated with the user will be disconnected. If AdsDisconnect() is called + * on a connection with a transaction active, the transaction will be rolled back. */ - UNSIGNED32 ulRetVal = ~AE_SUCCESS; + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - // Only allow disconnect of 0 if explicitly passed or adsConnectHandle is 0 - // (hConnect might be 0 if caller accidentally disconnects twice; this should not close all connections!) + /* NOTE: Only allow disconnect of 0 if explicitly passed or adsConnectHandle is 0 + (hConnect might be 0 if caller accidentally disconnects twice; + this should not close all connections! */ + if( hConnect != 0 || ISNUM( 1 ) ) { - ulRetVal = AdsDisconnect( hConnect ); - } + UNSIGNED32 ulRetVal; - if( ulRetVal == AE_SUCCESS ) - { - if( hConnect == adsConnectHandle ) + ulRetVal = AdsDisconnect( hConnect ); + + if( ulRetVal == AE_SUCCESS ) { - adsConnectHandle = 0; + if( hConnect == adsConnectHandle ) + { + adsConnectHandle = 0; + } + + hb_retl( TRUE ); + } + else + { + hb_retl( FALSE ); } - hb_retl( TRUE ); } else { @@ -1320,15 +1398,16 @@ HB_FUNC( ADSDISCONNECT ) HB_FUNC( ADSCREATESQLSTATEMENT ) { - UNSIGNED32 u32RetVal; - ADSAREAP pArea; - ADSHANDLE adsStatementHandle; BOOL fResult = FALSE; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); if( hConnect ) { + UNSIGNED32 u32RetVal; + ADSHANDLE adsStatementHandle; + u32RetVal = AdsCreateSQLStatement( hConnect, &adsStatementHandle ); + if( u32RetVal == AE_SUCCESS ) { if( hb_parni( 2 ) == ADS_CDX ) @@ -1348,7 +1427,8 @@ HB_FUNC( ADSCREATESQLSTATEMENT ) } else { - pArea = hb_rddGetADSWorkAreaPointer(); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); + if( pArea ) { char szAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ]; @@ -1372,30 +1452,31 @@ HB_FUNC( ADSCREATESQLSTATEMENT ) } } } + hb_retl( fResult ); } HB_FUNC( ADSEXECUTESQLDIRECT ) { - UNSIGNED32 ulRetVal; - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - /* -----------------10/9/2005 2:51PM----------------- -bh removed test for adsConnectHandle as it is not actually used; - the func was just trying to confirm a real connection existed - but we're trying to remove dependence on statics; - if we saved the nConnection to a WA, that would take care of it. - As is, it requires pArea->hStatement which we only allow created if - there's Connection so we should be OK. - * --------------------------------------------------*/ + /* NOTE: Removed test for adsConnectHandle as it is not actually used; + the func was just trying to confirm a real connection existed + but we're trying to remove dependence on statics; + if we saved the nConnection to a WA, that would take care of it. + As is, it requires pArea->hStatement which we only allow created if + there's Connection so we should be OK. [bh 10/9/2005 2:51PM] */ - if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) != 0 - && pArea->hStatement && ISCHAR( 1 ) ) + if( /* adsConnectHandle && */ pArea && pArea->hStatement && ISCHAR( 1 ) ) { + UNSIGNED32 ulRetVal; char * pucStmt = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) ); ADSHANDLE hCursor = 0; - ulRetVal = AdsExecuteSQLDirect( pArea->hStatement, (UNSIGNED8 *) pucStmt, &hCursor ); + ulRetVal = AdsExecuteSQLDirect( pArea->hStatement, + ( UNSIGNED8 * ) pucStmt, + &hCursor ); + hb_adsOemAnsiFree( pucStmt ); if( ulRetVal == AE_SUCCESS ) @@ -1418,7 +1499,7 @@ bh removed test for adsConnectHandle as it is not actually used; } else { - AdsShowError( (UNSIGNED8 *) "ExecuteSQL error:" ); + AdsShowError( ( UNSIGNED8 * ) "AdsExecuteSQLDirect() error" ); hb_retl( FALSE ); } } @@ -1430,23 +1511,23 @@ bh removed test for adsConnectHandle as it is not actually used; HB_FUNC( ADSPREPARESQL ) { - UNSIGNED32 ulRetVal; - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - /* -----------------10/9/2005 2:51PM----------------- -bh removed test for adsConnectHandle as it is not actually used; - the func was just trying to confirm a real connection existed - but we're trying to remove dependence on statics; - if we saved the nConnection to a WA, that would take care of it. - As is, it requires pArea->hStatement which we only allow created if - there's Connection so we should be OK. - * --------------------------------------------------*/ - if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) != 0 - && pArea->hStatement && ISCHAR( 1 ) ) + /* NOTE: Removed test for adsConnectHandle as it is not actually used; + the func was just trying to confirm a real connection existed + but we're trying to remove dependence on statics; + if we saved the nConnection to a WA, that would take care of it. + As is, it requires pArea->hStatement which we only allow created if + there's Connection so we should be OK. [bh 10/9/2005 2:51PM] */ + + if( /* adsConnectHandle && */ pArea && pArea->hStatement && ISCHAR( 1 ) ) { + UNSIGNED32 ulRetVal; char * pucStmt = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) ); - ulRetVal = AdsPrepareSQL( pArea->hStatement, (UNSIGNED8 *) pucStmt ); + ulRetVal = AdsPrepareSQL( pArea->hStatement, + ( UNSIGNED8 * ) pucStmt ); + hb_adsOemAnsiFree( pucStmt ); if( ulRetVal == AE_SUCCESS ) @@ -1455,7 +1536,7 @@ bh removed test for adsConnectHandle as it is not actually used; } else { - AdsShowError( (UNSIGNED8 *) "PrepareSQL error:" ); + AdsShowError( ( UNSIGNED8 * ) "AdsPrepareSQL() error" ); hb_retl( FALSE ); } } @@ -1467,24 +1548,22 @@ bh removed test for adsConnectHandle as it is not actually used; HB_FUNC( ADSEXECUTESQL ) { - UNSIGNED32 ulRetVal; - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - /* -----------------10/9/2005 2:51PM----------------- -bh removed test for adsConnectHandle as it is not actually used; - the func was just trying to confirm a real connection existed - but we're trying to remove dependence on statics; - if we saved the nConnection to a WA, that would take care of it. - As is, it requires pArea->hStatement which we only allow created if - there's Connection so we should be OK. - * --------------------------------------------------*/ + /* NOTE: Removed test for adsConnectHandle as it is not actually used; + the func was just trying to confirm a real connection existed + but we're trying to remove dependence on statics; + if we saved the nConnection to a WA, that would take care of it. + As is, it requires pArea->hStatement which we only allow created if + there's Connection so we should be OK. [bh 10/9/2005 2:51PM] */ - if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) != 0 - && pArea->hStatement ) + if( /* adsConnectHandle && */ pArea && pArea->hStatement ) { + UNSIGNED32 ulRetVal; ADSHANDLE hCursor = 0; ulRetVal = AdsExecuteSQL( pArea->hStatement, &hCursor ); + if( ulRetVal == AE_SUCCESS ) { if( hCursor ) @@ -1505,7 +1584,7 @@ bh removed test for adsConnectHandle as it is not actually used; } else { - AdsShowError( (UNSIGNED8 *) "ExecuteSQL error:" ); + AdsShowError( ( UNSIGNED8 * ) "AdsExecuteSQL error" ); hb_retl( FALSE ); } } @@ -1527,9 +1606,8 @@ HB_FUNC( ADSWRITEALLRECORDS ) HB_FUNC( ADSREFRESHRECORD ) { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { AdsRefreshRecord( pArea->hTable ); @@ -1540,24 +1618,22 @@ HB_FUNC( ADSREFRESHRECORD ) } } +/* lSuccess := AdsCopyTable( cTargetFile [, nAdsFilterOption ] ) */ HB_FUNC( ADSCOPYTABLE ) { - // lSuccess := AdsCopyTable( cTargetFile [, nAdsFilterOption ] ) + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - ADSAREAP pArea; - UNSIGNED32 ulRetVal; - ADSHANDLE hIndex; - - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { if( ISCHAR( 1 ) ) { - UNSIGNED16 usFilterOption = ISNUM( 2 ) ? (UNSIGNED16) hb_parni( 2 ) : ADS_RESPECTFILTERS; + UNSIGNED32 ulRetVal; + ADSHANDLE hIndex = ( pArea->hOrdCurrent ) ? pArea->hOrdCurrent : pArea->hTable; /* If an index is active copy table in indexed order. */ + UNSIGNED16 usFilterOption = ( UNSIGNED16 ) ( ISNUM( 2 ) ? hb_parni( 2 ) : ADS_RESPECTFILTERS ); - // If an index is active copy table in indexed order - hIndex = ( pArea->hOrdCurrent ) ? pArea->hOrdCurrent : pArea->hTable; - ulRetVal = AdsCopyTable( hIndex, usFilterOption, (UNSIGNED8 *) hb_parcx( 1 ) ); + ulRetVal = AdsCopyTable( hIndex, + usFilterOption, + ( UNSIGNED8 * ) hb_parcx( 1 ) /* pucFile */ ); hb_retl( ulRetVal == AE_SUCCESS ); } @@ -1574,16 +1650,21 @@ HB_FUNC( ADSCOPYTABLE ) HB_FUNC( ADSCONVERTTABLE ) { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { if( ISCHAR( 1 ) ) { - UNSIGNED16 usTableType = ISNUM( 2 ) ? hb_parni( 2 ) : ADS_ADT; + UNSIGNED32 ulRetVal; + UNSIGNED16 usTableType = ( UNSIGNED16 ) ( ISNUM( 2 ) ? hb_parni( 2 ) : ADS_ADT ); - AdsConvertTable( pArea->hTable, ADS_IGNOREFILTERS, (UNSIGNED8 *) hb_parcx( 1 ), usTableType ); + ulRetVal = AdsConvertTable( pArea->hTable, + ADS_IGNOREFILTERS, + ( UNSIGNED8 * ) hb_parcx( 1 /* pucFile */ ), + usTableType ); + + hb_retl( ulRetVal == AE_SUCCESS ); } else { @@ -1616,23 +1697,22 @@ UNSIGNED32 WINAPI ShowPercentage( UNSIGNED16 usPercentDone ) return 0; -} /* ShowPercentage */ +} /* ShowPercentage */ HB_FUNC( ADSREGCALLBACK ) { - UNSIGNED32 ulRetVal; - /* NOTE: current implementation is not thread safe. - ADS can register multiple callbacks, but one per thread/connection. - To be thread safe, we need multiple connections. - The registered function (and its codeblock s_pItmCobCallBack) should - NOT make any Advantage Client Engine calls. If it does, - it is possible to get error code 6619 "Communication Layer is busy". - */ + ADS can register multiple callbacks, but one per thread/connection. + To be thread safe, we need multiple connections. + The registered function (and its codeblock s_pItmCobCallBack) should + NOT make any Advantage Client Engine calls. If it does, + it is possible to get error code 6619 "Communication Layer is busy". */ if( ISBLOCK( 1 ) ) { + UNSIGNED32 ulRetVal; + if( s_pItmCobCallBack ) { hb_itemRelease( s_pItmCobCallBack ); @@ -1664,38 +1744,41 @@ HB_FUNC( ADSCLRCALLBACK ) hb_itemRelease( s_pItmCobCallBack ); s_pItmCobCallBack = NULL; } - hb_retni( AdsClearProgressCallback() ); + + hb_retnl( AdsClearProgressCallback() ); } #endif HB_FUNC( ADSISINDEXED ) { - ADSAREAP pArea; - pArea = hb_rddGetADSWorkAreaPointer(); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); + hb_retl( pArea && pArea->hOrdCurrent != 0 ); } +/* QUESTION: Shouldn't we generate a NOTABLE/NOARG RTEs like in similar functions? [vszakats] */ HB_FUNC( ADSISEXPRVALID ) /* cExpr */ { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); UNSIGNED16 bValidExpr = 0; - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea && ISCHAR( 1 ) ) { - AdsIsExprValid( pArea->hTable, (UNSIGNED8*) hb_parc( 1 ), &bValidExpr ); + AdsIsExprValid( pArea->hTable, + ( UNSIGNED8 * ) hb_parc( 1 ) /* pucExpr */, + &bValidExpr ); } - hb_retl( bValidExpr ); + hb_retl( bValidExpr != 0 ); } -HB_FUNC( ADSGETNUMINDEXES ) /* cExpr */ +/* QUESTION: Shouldn't we generate a NOTABLE RTE like in similar functions? [vszakats] */ +HB_FUNC( ADSGETNUMINDEXES ) { - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); UNSIGNED16 pusCnt = 0; - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { AdsGetNumIndexes( pArea->hTable, &pusCnt ); @@ -1704,39 +1787,37 @@ HB_FUNC( ADSGETNUMINDEXES ) /* cExpr */ hb_retni( pusCnt ); } -HB_FUNC( ADSCONNECTION ) // Get/Set func to switch between connections +HB_FUNC( ADSCONNECTION ) /* Get/Set func to switch between connections. */ { HB_ADS_RETCONNECTION( adsConnectHandle ); adsConnectHandle = HB_ADS_PARCONNECTION( 1 ); } -HB_FUNC( ADSGETHANDLETYPE ) // DD, admin, table +HB_FUNC( ADSGETHANDLETYPE ) /* DD, admin, table */ { UNSIGNED32 ulRetVal; UNSIGNED16 usType = AE_INVALID_HANDLE; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - ulRetVal = AdsGetHandleType( hConnect, &usType); - hb_retnl( ulRetVal == AE_SUCCESS ? usType : AE_INVALID_HANDLE ); + ulRetVal = AdsGetHandleType( hConnect, &usType ); + + hb_retni( ulRetVal == AE_SUCCESS ? usType : AE_INVALID_HANDLE ); } - +/* nLastErr := AdsGetLastError( [ @cLastErr ] ) */ HB_FUNC( ADSGETLASTERROR ) { - /* nLastErr := AdsGetLastError( [ @cLastErr ] ) */ - UNSIGNED32 ulLastErr = 0; UNSIGNED8 aucError[ ADS_MAX_ERROR_LEN + 1 ]; UNSIGNED16 usLength = ADS_MAX_ERROR_LEN + 1; - AdsGetLastError( &ulLastErr, aucError, &usLength ); + AdsGetLastError( &ulLastErr, + aucError, + &usLength ); - if( hb_pcount() > 0 ) - { - hb_storclen( ( char * ) aucError, usLength, 1 ); - } + hb_storclen( ( char * ) aucError, usLength, 1 ); hb_retnl( ulLastErr ); } @@ -1746,15 +1827,15 @@ HB_FUNC( ADSGETNUMOPENTABLES ) UNSIGNED16 pusNum = 0; AdsGetNumOpenTables( &pusNum ); - hb_retnl( pusNum ); + + hb_retni( pusNum ); } HB_FUNC( ADSSHOWERROR ) { - AdsShowError( (UNSIGNED8 *) hb_parc( 1 ) ); + AdsShowError( ( UNSIGNED8 * ) hb_parc( 1 ) ); } - HB_FUNC( ADSBEGINTRANSACTION ) { ADSHANDLE hConnect = hb_parnl( 1 ); @@ -1771,7 +1852,7 @@ HB_FUNC( ADSCOMMITTRANSACTION ) HB_FUNC( ADSFAILEDTRANSACTIONRECOVERY ) { - UNSIGNED8 *pucServer = ( UNSIGNED8 *) hb_parc( 1 ); + UNSIGNED8 * pucServer = ( UNSIGNED8 * ) hb_parc( 1 ); hb_retl( AdsFailedTransactionRecovery( pucServer ) == AE_SUCCESS ); } @@ -1809,12 +1890,13 @@ HB_FUNC( ADSROLLBACK ) HB_FUNC( ADSCACHERECORDS ) { UNSIGNED32 ulRetVal = ~AE_SUCCESS; - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsCacheRecords( pArea->hTable, hb_parni( 1 ) ); + ulRetVal = AdsCacheRecords( pArea->hTable, + ( UNSIGNED16 ) hb_parni( 1 ) ); + hb_retl( ulRetVal == AE_SUCCESS ); } @@ -1829,20 +1911,18 @@ HB_FUNC( ADSCACHERECORDS ) Returns true if successful, false if fails. Error code available by calling AdsGetLastError() */ - HB_FUNC( ADSREINDEX ) { UNSIGNED32 ulRetVal; - ADSAREAP pArea; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { ulRetVal = AdsReindex( pArea->hTable ); } else { - ulRetVal = AdsReindex( ( ADSHANDLE ) -1 ); // should return error! + ulRetVal = AdsReindex( ( ADSHANDLE ) -1 ); /* should return error! */ } hb_retl( ulRetVal == AE_SUCCESS ); @@ -1858,22 +1938,26 @@ HB_FUNC( ADSVERSION ) UNSIGNED16 usPos; char ucVersion[ 256 ]; - AdsGetVersion( &ulMajor, &ulMinor, &ucLetter, ucDesc, &usDescLen ); + AdsGetVersion( &ulMajor, + &ulMinor, + &ucLetter, + ucDesc, + &usDescLen ); switch( hb_parni( 1 ) /* iVersionType */ ) { - case 0: - snprintf( ucVersion, sizeof( ucVersion ), "%ld.%ld%c", ulMajor, ulMinor, ucLetter ); - break; - case 3: - snprintf( ucVersion, sizeof( ucVersion ), "%s, v%ld.%ld%c", ( char * ) ucDesc, ulMajor, ulMinor, ucLetter ); - break; - default: - ucVersion[ 0 ] = '\0'; + case 0: + snprintf( ucVersion, sizeof( ucVersion ), "%ld.%ld%c", ulMajor, ulMinor, ucLetter ); + break; + case 3: + snprintf( ucVersion, sizeof( ucVersion ), "%s, v%ld.%ld%c", ( char * ) ucDesc, ulMajor, ulMinor, ucLetter ); + break; + default: + ucVersion[ 0 ] = '\0'; } usPos = strlen( ucVersion ) - 1; - while( ucVersion[usPos] == ' ' && usPos > 0 ) // remove trailing spaces + while( ucVersion[usPos] == ' ' && usPos > 0 ) /* remove trailing spaces */ { ucVersion[ usPos-- ] = '\0'; } @@ -1883,35 +1967,31 @@ HB_FUNC( ADSVERSION ) HB_FUNC( ADSCACHEOPENTABLES ) { - UNSIGNED16 usOpen = hb_parni( 1 ); - UNSIGNED32 ulRetVal = AdsCacheOpenTables( usOpen ); - - hb_retnl( ulRetVal ); + hb_retnl( AdsCacheOpenTables( ( UNSIGNED16 ) hb_parni( 1 ) /* usOpen */ ) ); } HB_FUNC( ADSCACHEOPENCURSORS ) { - UNSIGNED16 usOpen = hb_parni( 1 ); - UNSIGNED32 ulRetVal = AdsCacheOpenCursors( usOpen ); - - hb_retnl( ulRetVal ); + hb_retnl( AdsCacheOpenCursors( ( UNSIGNED16 ) hb_parni( 1 ) /* usOpen */ ) ); } -// Use AdsIsEmpty() to determine if the indicated field is NULL for ADTs or empty for DBFs +/* Use AdsIsEmpty() to determine if the indicated field is NULL for ADTs or empty for DBFs. */ HB_FUNC( ADSISEMPTY ) { - UNSIGNED32 ulRetVal = ~AE_SUCCESS; - UNSIGNED16 pbEmpty = 0; - ADSAREAP pArea; - UNSIGNED8* pucFldName; + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); - pArea = hb_rddGetADSWorkAreaPointer(); if( ISCHAR( 1 ) || ISNUM( 1 ) ) { + UNSIGNED32 ulRetVal = ~AE_SUCCESS; + UNSIGNED16 pbEmpty = 0; + if( pArea ) { - pucFldName = ( ISCHAR( 1 ) ? ( UNSIGNED8* ) hb_parcx( 1 ) : ADSFIELD( hb_parni( 1 ) ) ); - ulRetVal = AdsIsEmpty( pArea->hTable, pucFldName, &pbEmpty ); + UNSIGNED8 * pucFldName = ( ISCHAR( 1 ) ? ( UNSIGNED8 * ) hb_parcx( 1 ) : ADSFIELD( hb_parni( 1 ) ) ); + + ulRetVal = AdsIsEmpty( pArea->hTable, + pucFldName, + &pbEmpty ); } if( pArea && ulRetVal == AE_SUCCESS ) @@ -1933,7 +2013,7 @@ HB_FUNC( ADSISEMPTY ) #if ADS_LIB_VERSION >= 620 -HB_FUNC( ADSGETNUMACTIVELINKS ) // Only valid for a DataDict +HB_FUNC( ADSGETNUMACTIVELINKS ) /* Only valid for a DataDict */ { UNSIGNED16 pusNumLinks = 0; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); @@ -1943,7 +2023,7 @@ HB_FUNC( ADSGETNUMACTIVELINKS ) // Only valid for a DataDict AdsGetNumActiveLinks( hConnect, &pusNumLinks ); } - hb_retnl( pusNumLinks ); + hb_retni( pusNumLinks ); } #endif @@ -1953,12 +2033,18 @@ HB_FUNC( ADSGETNUMACTIVELINKS ) // Only valid for a DataDict HB_FUNC( ADSDDADDTABLE ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pTableName = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED8 *pTableFileName = (UNSIGNED8 *) hb_parcx( 2 ); - UNSIGNED8 *pTableIndexFileName = (UNSIGNED8 *) hb_parcx( 3 ); + UNSIGNED8 * pTableName = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED8 * pTableFileName = ( UNSIGNED8 * ) hb_parcx( 2 ); + UNSIGNED8 * pTableIndexFileName = ( UNSIGNED8 * ) hb_parcx( 3 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 4 ); - ulRetVal = AdsDDAddTable( hConnect, pTableName, pTableFileName, adsFileType, adsCharType, pTableIndexFileName, NULL ); + ulRetVal = AdsDDAddTable( hConnect, + pTableName, + pTableFileName, + adsFileType, + adsCharType, + pTableIndexFileName, + NULL ); hb_retl( ulRetVal == AE_SUCCESS ); } @@ -1966,11 +2052,13 @@ HB_FUNC( ADSDDADDTABLE ) HB_FUNC( ADSDDREMOVETABLE ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pTableName = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED16 usDeleteFiles = (UNSIGNED16) ( ISNUM( 2 ) ? hb_parnl( 2 ) : ( ISLOG( 2 ) ? hb_parl( 2 ) : 0 ) ); + UNSIGNED8 * pTableName = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED16 usDeleteFiles = ( UNSIGNED16 ) ( ISNUM( 2 ) ? hb_parni( 2 ) : ( ISLOG( 2 ) ? hb_parl( 2 ) : 0 ) ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 4 ); - ulRetVal = AdsDDRemoveTable( hConnect, pTableName, usDeleteFiles ); + ulRetVal = AdsDDRemoveTable( hConnect, + pTableName, + usDeleteFiles ); hb_retl( ulRetVal == AE_SUCCESS ); } @@ -1978,12 +2066,15 @@ HB_FUNC( ADSDDREMOVETABLE ) HB_FUNC( ADSDDREMOVEINDEXFILE ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pTableName = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED8 *pIndexName = (UNSIGNED8 *) hb_parcx( 2 ); - UNSIGNED16 usDeleteFiles = (UNSIGNED16) ( ISNUM( 3 ) ? hb_parnl( 3 ) : ( ISLOG( 3 ) ? hb_parl( 3 ) : 0 ) ); + UNSIGNED8 *pTableName = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED8 *pIndexName = ( UNSIGNED8 * ) hb_parcx( 2 ); + UNSIGNED16 usDeleteFiles = ( UNSIGNED16 ) ( ISNUM( 3 ) ? hb_parni( 3 ) : ( ISLOG( 3 ) ? hb_parl( 3 ) : 0 ) ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 4 ); - ulRetVal = AdsDDRemoveIndexFile( hConnect, pTableName, pIndexName, usDeleteFiles ); + ulRetVal = AdsDDRemoveIndexFile( hConnect, + pTableName, + pIndexName, + usDeleteFiles ); hb_retl( ulRetVal == AE_SUCCESS ); } @@ -1991,11 +2082,13 @@ HB_FUNC( ADSDDREMOVEINDEXFILE ) HB_FUNC( ADSDDADDUSERTOGROUP ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pGroup = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED8 *pName = (UNSIGNED8 *) hb_parcx( 2 ); + UNSIGNED8 * pGroup = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED8 * pName = ( UNSIGNED8 * ) hb_parcx( 2 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); - ulRetVal = AdsDDAddUserToGroup( hConnect, pGroup, pName ); + ulRetVal = AdsDDAddUserToGroup( hConnect, + pGroup, + pName ); hb_retl( ulRetVal == AE_SUCCESS ); } @@ -2003,23 +2096,25 @@ HB_FUNC( ADSDDADDUSERTOGROUP ) HB_FUNC( ADSDDREMOVEUSERFROMGROUP ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pGroup = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED8 *pName = (UNSIGNED8 *) hb_parcx( 2 ); + UNSIGNED8 * pGroup = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED8 * pName = ( UNSIGNED8 * ) hb_parcx( 2 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); - ulRetVal = AdsDDRemoveUserFromGroup( hConnect, pGroup, pName ); + ulRetVal = AdsDDRemoveUserFromGroup( hConnect, + pGroup, + pName ); hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSCONNECT60 ) { - UNSIGNED32 ulRetVal ; - UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED16 usServerTypes = (UNSIGNED16) hb_parni( 2 ); - UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 3 ); - UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 4 ); - UNSIGNED32 ulOptions = ISNUM( 5 ) ? hb_parnl( 5 ) : ADS_DEFAULT ; + UNSIGNED32 ulRetVal; + UNSIGNED8 * pucServerPath = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED16 usServerTypes = ( UNSIGNED16 ) hb_parni( 2 ); + UNSIGNED8 * pucUserName = ( UNSIGNED8 * ) hb_parc( 3 ); + UNSIGNED8 * pucPassword = ( UNSIGNED8 * ) hb_parc( 4 ); + UNSIGNED32 ulOptions = ( UNSIGNED32 ) ( ISNUM( 5 ) ? hb_parnl( 5 ) : ADS_DEFAULT ); ADSHANDLE hConnect = 0; ulRetVal = AdsConnect60( pucServerPath, @@ -2033,10 +2128,7 @@ HB_FUNC( ADSCONNECT60 ) { adsConnectHandle = hConnect; /* set new default */ - if( ISBYREF( 6 ) ) - { - hb_stornl( hConnect, 6 ); - } + hb_stornl( hConnect, 6 ); hb_retl( TRUE ); } @@ -2049,14 +2141,14 @@ HB_FUNC( ADSCONNECT60 ) HB_FUNC( ADSDDCREATE ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pucDictionaryPath = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED16 usEncrypt = (UNSIGNED16) ( ISNUM( 2 ) ? hb_parnl( 2 ) : ( ISLOG( 2 ) ? hb_parl( 2 ) : 0 ) ); - UNSIGNED8 *pucDescription = (UNSIGNED8 *) hb_parc( 3 ); + UNSIGNED8 * pucDictionaryPath = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED16 usEncrypt = ( UNSIGNED16 ) hb_parl( 2 ); /* NOTE: Numeric (0, non-0) are also accepted by hb_parl(). */ + UNSIGNED8 * pucDescription = ( UNSIGNED8 * ) hb_parc( 3 ); ADSHANDLE hConnect = 0; - ulRetVal = AdsDDCreate( ( UNSIGNED8 *) pucDictionaryPath, + ulRetVal = AdsDDCreate( ( UNSIGNED8 * ) pucDictionaryPath, usEncrypt, - ( UNSIGNED8 *) pucDescription, + ( UNSIGNED8 * ) pucDescription, &hConnect ); if( ulRetVal == AE_SUCCESS ) @@ -2073,24 +2165,30 @@ HB_FUNC( ADSDDCREATE ) HB_FUNC( ADSDDCREATEUSER ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pucGroupName = (UNSIGNED8 *) hb_parc( 1 ); - UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 2 ); - UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 3 ); - UNSIGNED8 *pucDescription = (UNSIGNED8 *) hb_parc( 4 ); + UNSIGNED8 * pucGroupName = ( UNSIGNED8 * ) hb_parc( 1 ); + UNSIGNED8 * pucUserName = ( UNSIGNED8 * ) hb_parc( 2 ); + UNSIGNED8 * pucPassword = ( UNSIGNED8 * ) hb_parc( 3 ); + UNSIGNED8 * pucDescription = ( UNSIGNED8 * ) hb_parc( 4 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 5 ); - ulRetVal = AdsDDCreateUser( hConnect, pucGroupName, - pucUserName, pucPassword, pucDescription ); + ulRetVal = AdsDDCreateUser( hConnect, + pucGroupName, + pucUserName, + pucPassword, + pucDescription ); + hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSDDDELETEUSER ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 1 ); + UNSIGNED8 * pucUserName = ( UNSIGNED8 * ) hb_parc( 1 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); - ulRetVal = AdsDDDeleteUser( hConnect, pucUserName ); + ulRetVal = AdsDDDeleteUser( hConnect, + pucUserName ); + hb_retl( ulRetVal == AE_SUCCESS ); } @@ -2119,7 +2217,10 @@ HB_FUNC( ADSDDGETDATABASEPROPERTY ) char sBuffer[ ADS_MAX_PARAMDEF_LEN ]; UNSIGNED16 ulLength = sizeof( sBuffer ); - if( AdsDDGetDatabaseProperty( hConnect, ulProperty, &sBuffer, &ulLength ) != AE_SUCCESS ) + if( AdsDDGetDatabaseProperty( hConnect, + ulProperty, + &sBuffer, + &ulLength ) != AE_SUCCESS ) { /* TODO: Better error handling. */ sBuffer[ 0 ] = '\0'; @@ -2144,7 +2245,10 @@ HB_FUNC( ADSDDGETDATABASEPROPERTY ) UNSIGNED16 ulBuffer; UNSIGNED16 ulLength = sizeof( ulBuffer ); - AdsDDGetDatabaseProperty( hConnect, ulProperty, &ulBuffer, &ulLength ); + AdsDDGetDatabaseProperty( hConnect, + ulProperty, + &ulBuffer, + &ulLength ); hb_retl( ulBuffer != 0 ); break; } @@ -2156,8 +2260,11 @@ HB_FUNC( ADSDDGETDATABASEPROPERTY ) UNSIGNED16 ulBuffer; UNSIGNED16 ulLength = sizeof( ulBuffer ); - AdsDDGetDatabaseProperty( hConnect, ulProperty, &ulBuffer, &ulLength ); - hb_retnl( ulBuffer ); + AdsDDGetDatabaseProperty( hConnect, + ulProperty, + &ulBuffer, + &ulLength ); + hb_retni( ulBuffer ); break; } #endif @@ -2194,7 +2301,10 @@ HB_FUNC( ADSDDSETDATABASEPROPERTY ) case ADS_DD_FTS_CONDITIONAL_CHARS: case ADS_DD_LOGINS_DISABLED_ERRSTR: { - ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, hb_itemGetCPtr( pParam ), ( UNSIGNED16 ) hb_itemGetCLen( pParam ) + 1 ); + ulRetVal = AdsDDSetDatabaseProperty( hConnect, + ulProperty, + hb_itemGetCPtr( pParam ), + ( UNSIGNED16 ) hb_itemGetCLen( pParam ) + 1 ); break; } #endif @@ -2213,7 +2323,10 @@ HB_FUNC( ADSDDSETDATABASEPROPERTY ) #endif { ulBuffer = hb_itemGetL( pParam ); - ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, &ulBuffer, sizeof( ulBuffer ) ); + ulRetVal = AdsDDSetDatabaseProperty( hConnect, + ulProperty, + &ulBuffer, + sizeof( ulBuffer ) ); break; } /* Integer properties */ @@ -2224,8 +2337,21 @@ HB_FUNC( ADSDDSETDATABASEPROPERTY ) case ADS_DD_VERSION_MINOR: #endif { - ulBuffer = hb_itemGetNI( pParam ); - ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, &ulBuffer, sizeof( ulBuffer ) ); + if( HB_IS_NUMERIC( pParam ) ) + { + ulBuffer = hb_itemGetNI( pParam ); + ulRetVal = AdsDDSetDatabaseProperty( hConnect, + ulProperty, + &ulBuffer, + sizeof( ulBuffer ) ); + } + else + { + ulRetVal = AdsDDSetDatabaseProperty( hConnect, + ulProperty, + NULL, + 0 ); + } break; } default: @@ -2240,15 +2366,15 @@ HB_FUNC( ADSDDSETDATABASEPROPERTY ) HB_FUNC( ADSDDGETUSERPROPERTY ) { - UNSIGNED32 ulRetVal; - UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED16 usPropertyID = hb_parni( 2 ); - ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 4 ); - UNSIGNED8 pvProperty[ ADS_MAX_PARAMDEF_LEN ] = { 0 }; - UNSIGNED16 usPropertyLen = ADS_MAX_PARAMDEF_LEN; - if( ISBYREF( 3 ) /* fPropertyByRef */ ) { + UNSIGNED32 ulRetVal; + UNSIGNED8 * pucUserName = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED16 usPropertyID = ( UNSIGNED16 ) hb_parni( 2 ); + UNSIGNED8 pvProperty[ ADS_MAX_PARAMDEF_LEN ] = { 0 }; + UNSIGNED16 usPropertyLen = ADS_MAX_PARAMDEF_LEN; + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 4 ); + ulRetVal = AdsDDGetUserProperty( hConnect, pucUserName, usPropertyID, @@ -2268,8 +2394,8 @@ HB_FUNC( ADSDDGETUSERPROPERTY ) /* Verify if a username/password combination is valid for this database - Call : ADSTESTLOGIN( serverpath, servertypes, username, password, options, - [ userproperty, buffer, bufferlength ] ) + Call : ADSTESTLOGIN( cServerPath, nServerTypes, cUserName, cPassword, options, + [ nUserProperty, @cBuffer ] ) Returns : True if login succeeds Notes: This creates a temporary connection only during the execution of this @@ -2282,16 +2408,13 @@ HB_FUNC( ADSDDGETUSERPROPERTY ) HB_FUNC( ADSTESTLOGIN ) { - UNSIGNED32 ulRetVal ; - UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED16 usServerTypes = (UNSIGNED16) hb_parni( 2 ); - UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 3 ); - UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 4 ); - UNSIGNED32 ulOptions = ISNUM( 5 ) ? hb_parnl( 5 ) : ADS_DEFAULT; - UNSIGNED16 usPropertyID = hb_parni( 6 ); - UNSIGNED8 *pvProperty = (UNSIGNED8 *) hb_parc( 7 ); - UNSIGNED16 usPropertyLen = hb_parni( 8 ); - ADSHANDLE adsTestHandle; + UNSIGNED32 ulRetVal; + UNSIGNED8 * pucServerPath = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED16 usServerTypes = ( UNSIGNED16 ) hb_parni( 2 ); + UNSIGNED8 * pucUserName = ( UNSIGNED8 * ) hb_parc( 3 ); + UNSIGNED8 * pucPassword = ( UNSIGNED8 * ) hb_parc( 4 ); + UNSIGNED32 ulOptions = ( UNSIGNED32 ) ( ISNUM( 5 ) ? hb_parnl( 5 ) : ADS_DEFAULT ); + ADSHANDLE adsTestHandle; ulRetVal = AdsConnect60( pucServerPath, usServerTypes, @@ -2302,12 +2425,22 @@ HB_FUNC( ADSTESTLOGIN ) if( ulRetVal == AE_SUCCESS ) { - if( usPropertyLen ) + if( ISBYREF( 7 ) ) { - AdsDDGetUserProperty( adsTestHandle, pucUserName, usPropertyID, - pvProperty, &usPropertyLen ); + UNSIGNED8 pvProperty[ ADS_MAX_PARAMDEF_LEN ] = { 0 }; + UNSIGNED16 usPropertyLen = ADS_MAX_PARAMDEF_LEN; + + ulRetVal = AdsDDGetUserProperty( adsTestHandle, + pucUserName, + ( UNSIGNED16 ) hb_parni( 6 ) /* usPropertyID */, + pvProperty, + &usPropertyLen ); + + hb_storc( ulRetVal == AE_SUCCESS ? ( char * ) pvProperty : NULL, 7 ); } + AdsDisconnect( adsTestHandle ); + hb_retl( TRUE ); } else @@ -2319,10 +2452,10 @@ HB_FUNC( ADSTESTLOGIN ) HB_FUNC( ADSRESTRUCTURETABLE ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pTableName = (UNSIGNED8 *) hb_parcx( 1 ); - UNSIGNED8 *pucAddFields = (UNSIGNED8 *) hb_parcx( 2 ); - UNSIGNED8 *pucDeleteFields = (UNSIGNED8 *) hb_parcx( 3 ); - UNSIGNED8 *pucChangeFields = (UNSIGNED8 *) hb_parcx( 4 ); + UNSIGNED8 * pTableName = ( UNSIGNED8 * ) hb_parcx( 1 ); + UNSIGNED8 * pucAddFields = ( UNSIGNED8 * ) hb_parcx( 2 ); + UNSIGNED8 * pucDeleteFields = ( UNSIGNED8 * ) hb_parcx( 3 ); + UNSIGNED8 * pucChangeFields = ( UNSIGNED8 * ) hb_parcx( 4 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 5 ); ulRetVal = AdsRestructureTable( hConnect, @@ -2341,19 +2474,18 @@ HB_FUNC( ADSRESTRUCTURETABLE ) HB_FUNC( ADSCOPYTABLECONTENTS ) { - ADSAREAP pArea; - ADSAREAP pDest; - UNSIGNED32 ulRetVal; - char * szAlias = hb_parcx( 1 ); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); /* Source */ - pArea = hb_rddGetADSWorkAreaPointer(); // Source if( pArea ) { - if( hb_rddSelectWorkAreaAlias( szAlias ) == SUCCESS ) + if( hb_rddSelectWorkAreaAlias( hb_parcx( 1 ) /* szAliasDest */ ) == SUCCESS ) { - pDest = hb_rddGetADSWorkAreaPointer(); // Destination + ADSAREAP pDest = hb_rddGetADSWorkAreaPointer(); + if( pDest ) { + UNSIGNED32 ulRetVal; + ulRetVal = AdsCopyTableContents( pArea->hTable, pDest->hTable, ADS_IGNOREFILTERS ); @@ -2382,27 +2514,35 @@ HB_FUNC( ADSDIRECTORY ) SIGNED32 sHandle = 0; #endif PHB_ITEM pitmDir; - PHB_ITEM pitmFileName; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); pitmDir = hb_itemNew( NULL ); hb_arrayNew( pitmDir, 0 ); - ulRetVal = AdsFindFirstTable( hConnect, ( UNSIGNED8* ) hb_parcx( 1 ), ( UNSIGNED8* ) ucFileName, &usFileNameLen, &sHandle ); + ulRetVal = AdsFindFirstTable( hConnect, + ( UNSIGNED8 * ) hb_parcx( 1 ), + ( UNSIGNED8 * ) ucFileName, + &usFileNameLen, + &sHandle ); + if( ulRetVal == AE_SUCCESS || ulRetVal == AE_NO_FILE_FOUND ) { while( ulRetVal == AE_SUCCESS ) { - pitmFileName = hb_itemPutCL( NULL, ( char * ) ucFileName, usFileNameLen ); + PHB_ITEM pitmFileName = hb_itemPutCL( NULL, ( char * ) ucFileName, usFileNameLen ); hb_arrayAddForward( pitmDir, pitmFileName ); usFileNameLen = ADS_MAX_TABLE_NAME; - ulRetVal = AdsFindNextTable( hConnect, sHandle, ucFileName, &usFileNameLen ); + ulRetVal = AdsFindNextTable( hConnect, + sHandle, + ucFileName, + &usFileNameLen ); } AdsFindClose( hConnect, sHandle ); } + hb_itemReturnRelease( pitmDir ); } @@ -2411,34 +2551,38 @@ HB_FUNC( ADSCHECKEXISTENCE ) UNSIGNED16 usExist = 0; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); - hb_retl( AdsCheckExistence( hConnect, ( UNSIGNED8* ) hb_parcx( 1 ), &usExist ) == AE_SUCCESS && usExist ); + hb_retl( AdsCheckExistence( hConnect, ( UNSIGNED8 * ) hb_parcx( 1 ), &usExist ) == AE_SUCCESS && usExist != 0 ); } HB_FUNC( ADSDELETEFILE ) { ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); - hb_retl( AdsDeleteFile( hConnect, ( UNSIGNED8* ) hb_parcx( 1 ) ) == AE_SUCCESS ); + + hb_retl( AdsDeleteFile( hConnect, ( UNSIGNED8 * ) hb_parcx( 1 ) ) == AE_SUCCESS ); } HB_FUNC( ADSSTMTSETTABLEPASSWORD ) { - ADSAREAP pArea; - UNSIGNED32 ulRetVal; char * pucTableName = hb_parcx( 1 ); char * pucPassword = hb_parcx( 2 ); - ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); - if( pucTableName && strlen( pucTableName ) && - pucPassword && strlen( pucPassword ) ) + if( strlen( pucTableName ) && + strlen( pucPassword ) ) { + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); + if( hConnect ) { - pArea = hb_rddGetADSWorkAreaPointer(); + ADSAREAP pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsStmtSetTablePassword( pArea->hStatement, ( UNSIGNED8 * ) pucTableName, ( UNSIGNED8 * ) pucPassword ); - hb_retni( ulRetVal ); + UNSIGNED32 ulRetVal; + + ulRetVal = AdsStmtSetTablePassword( pArea->hStatement, + ( UNSIGNED8 * ) pucTableName, + ( UNSIGNED8 * ) pucPassword ); + hb_retnl( ulRetVal ); } else { @@ -2458,9 +2602,9 @@ HB_FUNC( ADSSTMTSETTABLEPASSWORD ) HB_FUNC( ADSGETSERVERNAME ) { - ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - UNSIGNED8 buf[ 256 ]; - UNSIGNED16 usLen = 256; + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); + UNSIGNED8 buf[ 256 ]; + UNSIGNED16 usLen = 256; if( AdsGetServerName( hConnect, buf, &usLen ) == AE_SUCCESS ) { @@ -2496,10 +2640,12 @@ HB_FUNC( ADSCLOSECACHEDTABLES ) HB_FUNC( ADSCREATESAVEPOINT ) { ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - char* pucSavepoint = hb_parc( 2 ); + char * pucSavepoint = hb_parc( 2 ); UNSIGNED32 ulOptions = ADS_DEFAULT; - hb_retnl( AdsCreateSavepoint( hConnect, (UNSIGNED8 *) pucSavepoint, ulOptions ) ); + hb_retnl( AdsCreateSavepoint( hConnect, + ( UNSIGNED8 * ) pucSavepoint, + ulOptions ) ); } HB_FUNC( ADSROLLBACKSAVEPOINT ) @@ -2508,22 +2654,24 @@ HB_FUNC( ADSROLLBACKSAVEPOINT ) char * pucSavepoint = hb_parc( 2 ); UNSIGNED32 ulOptions = ADS_DEFAULT; - hb_retnl( AdsRollbackTransaction80( hConnect, (UNSIGNED8 *) pucSavepoint, ulOptions ) ); + hb_retnl( AdsRollbackTransaction80( hConnect, + ( UNSIGNED8 * ) pucSavepoint, + ulOptions ) ); } -#endif +#endif /* ADS_LIB_VERSION >= 800 */ #if ADS_LIB_VERSION >= 900 HB_FUNC( ADSDDCREATELINK ) { UNSIGNED32 ulRetVal; - ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - UNSIGNED8 *pucLinkAlias = (UNSIGNED8 *) hb_parcx( 2 ); - UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 3 ); - UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 4 ); - UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 5 ); - UNSIGNED32 ulOptions = ISNUM( 6 ) ? hb_parnl( 6 ) : ADS_DEFAULT; + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); + UNSIGNED8 * pucLinkAlias = ( UNSIGNED8 * ) hb_parcx( 2 ); + UNSIGNED8 * pucServerPath = ( UNSIGNED8 * ) hb_parcx( 3 ); + UNSIGNED8 * pucUserName = ( UNSIGNED8 * ) hb_parc( 4 ); + UNSIGNED8 * pucPassword = ( UNSIGNED8 * ) hb_parc( 5 ); + UNSIGNED32 ulOptions = ( UNSIGNED32 ) ( ISNUM( 6 ) ? hb_parnl( 6 ) : ADS_DEFAULT ); ulRetVal = AdsDDCreateLink( hConnect , pucLinkAlias , @@ -2538,12 +2686,12 @@ HB_FUNC( ADSDDCREATELINK ) HB_FUNC( ADSDDMODIFYLINK ) { UNSIGNED32 ulRetVal; - ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - UNSIGNED8 *pucLinkAlias = (UNSIGNED8 *) hb_parcx( 2 ); - UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 3 ); - UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 4 ); - UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 5 ); - UNSIGNED32 ulOptions = ISNUM( 6 ) ? hb_parnl( 6 ) : ADS_DEFAULT; + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); + UNSIGNED8 * pucLinkAlias = ( UNSIGNED8 * ) hb_parcx( 2 ); + UNSIGNED8 * pucServerPath = ( UNSIGNED8 * ) hb_parcx( 3 ); + UNSIGNED8 * pucUserName = ( UNSIGNED8 * ) hb_parc( 4 ); + UNSIGNED8 * pucPassword = ( UNSIGNED8 * ) hb_parc( 5 ); + UNSIGNED32 ulOptions = ( UNSIGNED32 ) ( ISNUM( 6 ) ? hb_parnl( 6 ) : ADS_DEFAULT ); ulRetVal = AdsDDModifyLink( hConnect , pucLinkAlias , @@ -2558,15 +2706,15 @@ HB_FUNC( ADSDDMODIFYLINK ) HB_FUNC( ADSDDDROPLINK ) { UNSIGNED32 ulRetVal; - ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - UNSIGNED8 *pucLinkAlias = (UNSIGNED8 *) hb_parcx( 2 ); - UNSIGNED16 ulOptions = ISLOG( 3 ) ? hb_parl( 3 ) : FALSE; + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); + UNSIGNED8 * pucLinkAlias = ( UNSIGNED8 * ) hb_parcx( 2 ); + UNSIGNED16 usDropGlobal = ( UNSIGNED16 ) hb_parl( 3 ); /* NOTE: Defaults to 0/FALSE for non logical parameters. */ ulRetVal = AdsDDDropLink( hConnect, pucLinkAlias, - ulOptions ); + usDropGlobal ); hb_retl( ulRetVal == AE_SUCCESS ); } -#endif +#endif /* ADS_LIB_VERSION >= 900 */ diff --git a/harbour/contrib/rddads/adsmgmnt.c b/harbour/contrib/rddads/adsmgmnt.c index 1ce4e137c4..4190b1e80b 100644 --- a/harbour/contrib/rddads/adsmgmnt.c +++ b/harbour/contrib/rddads/adsmgmnt.c @@ -57,33 +57,33 @@ #include "hbapi.h" #include "hbapiitm.h" -ADSHANDLE ads_g_hMgmtHandle = 0; +static ADSHANDLE s_hMgmtHandle = 0; HB_FUNC( ADSMGCONNECT ) { hb_retnl( AdsMgConnect( ( UNSIGNED8 * ) hb_parcx( 1 ) /* pucServerName */, ( UNSIGNED8 * ) hb_parc( 2 ) /* pucUserName */, ( UNSIGNED8 * ) hb_parc( 3 ) /* pucPassword */, - &ads_g_hMgmtHandle ) ); + &s_hMgmtHandle ) ); } HB_FUNC( ADSMGDISCONNECT ) { - hb_retnl( AdsMgDisconnect( ads_g_hMgmtHandle ) ); + hb_retnl( AdsMgDisconnect( s_hMgmtHandle ) ); - ads_g_hMgmtHandle = 0; + s_hMgmtHandle = 0; } HB_FUNC( ADSMGGETHANDLE ) { - hb_retnl( ( long ) ads_g_hMgmtHandle ); + hb_retnl( ( long ) s_hMgmtHandle ); } HB_FUNC( ADSMGKILLUSER ) { - hb_retnl( ( UNSIGNED16 ) AdsMgKillUser( ads_g_hMgmtHandle, + hb_retnl( ( UNSIGNED16 ) AdsMgKillUser( s_hMgmtHandle, ( UNSIGNED8 * ) hb_parc( 1 ), - ( UNSIGNED16 ) hb_parnl( 2 ) ) ); + ( UNSIGNED16 ) hb_parni( 2 ) ) ); } /* Determine OS ADS is running on; see ADS_MGMT_* constants */ @@ -92,7 +92,7 @@ HB_FUNC( ADSMGGETSERVERTYPE ) UNSIGNED32 ulRetVal; UNSIGNED16 usServerType = 0; - ulRetVal = AdsMgGetServerType( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetServerType( s_hMgmtHandle, &usServerType ); hb_retnl( ulRetVal == AE_SUCCESS ? usServerType : 0 ); @@ -104,7 +104,7 @@ HB_FUNC( ADSMGGETINSTALLINFO ) ADS_MGMT_INSTALL_INFO stInstallInfo; UNSIGNED16 usStructSize = sizeof( ADS_MGMT_INSTALL_INFO ); - ulRetVal = AdsMgGetInstallInfo( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetInstallInfo( s_hMgmtHandle, &stInstallInfo, &usStructSize ); @@ -136,7 +136,7 @@ HB_FUNC( ADSMGGETACTIVITYINFO ) ADS_MGMT_ACTIVITY_INFO stActivityInfo; UNSIGNED16 usStructSize = sizeof( ADS_MGMT_ACTIVITY_INFO ); - ulRetVal = AdsMgGetActivityInfo( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetActivityInfo( s_hMgmtHandle, &stActivityInfo, &usStructSize ); @@ -247,7 +247,7 @@ HB_FUNC( ADSMGGETCOMMSTATS ) ADS_MGMT_COMM_STATS stCommStats; UNSIGNED16 usStructSize = sizeof( ADS_MGMT_COMM_STATS ); - ulRetVal = AdsMgGetCommStats( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetCommStats( s_hMgmtHandle, &stCommStats, &usStructSize ); @@ -278,7 +278,7 @@ HB_FUNC( ADSMGGETCOMMSTATS ) HB_FUNC( ADSMGRESETCOMMSTATS ) { - hb_retnl( ads_g_hMgmtHandle ? AdsMgResetCommStats( ads_g_hMgmtHandle ) : -1 ); + hb_retnl( s_hMgmtHandle ? AdsMgResetCommStats( s_hMgmtHandle ) : -1 ); } HB_FUNC( ADSMGGETCONFIGINFO ) @@ -289,7 +289,7 @@ HB_FUNC( ADSMGGETCONFIGINFO ) UNSIGNED16 usConfigValuesStructSize = sizeof( ADS_MGMT_CONFIG_PARAMS ); UNSIGNED16 usConfigMemoryStructSize = sizeof( ADS_MGMT_CONFIG_MEMORY ); - ulRetVal = AdsMgGetConfigInfo( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetConfigInfo( s_hMgmtHandle, &stConfigValues, &usConfigValuesStructSize, &stConfigMemory, @@ -382,13 +382,13 @@ HB_FUNC( ADSMGGETCONFIGINFO ) HB_FUNC( ADSMGGETUSERNAMES ) { UNSIGNED32 ulRetVal; - UNSIGNED16 ulMaxUsers = ISNUM( 2 ) ? ( UNSIGNED16 ) hb_parnl( 2 ) : 2000; /* needed for array memory allocation; caller can set with 2nd arg */ + UNSIGNED16 ulMaxUsers = ISNUM( 2 ) ? ( UNSIGNED16 ) hb_parni( 2 ) : 2000; /* needed for array memory allocation; caller can set with 2nd arg */ UNSIGNED16 usStructSize = sizeof( ADS_MGMT_USER_INFO ); ADS_MGMT_USER_INFO * pastUserInfo; pastUserInfo = ( ADS_MGMT_USER_INFO * ) hb_xgrab( sizeof( ADS_MGMT_USER_INFO ) * ulMaxUsers ); - ulRetVal = AdsMgGetUserNames( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetUserNames( s_hMgmtHandle, ( UNSIGNED8 * ) hb_parc( 1 ) /* pucFileName */, pastUserInfo, &ulMaxUsers, @@ -469,7 +469,7 @@ HB_FUNC( ADSMGGETLOCKOWNER ) pstUserInfo = ( ADS_MGMT_USER_INFO * ) hb_xgrab( sizeof( ADS_MGMT_USER_INFO ) ); - ulRetVal = AdsMgGetLockOwner( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetLockOwner( s_hMgmtHandle, ( UNSIGNED8 * ) hb_parcx( 1 ) /* pucTableName */, ( UNSIGNED32 ) hb_parnl( 2 ) /* ulRecordNumber */, pstUserInfo, @@ -506,16 +506,16 @@ HB_FUNC( ADSMGGETLOCKOWNER ) HB_FUNC( ADSMGGETOPENTABLES ) /* nMaxNumberOfFilesToReturn, cUserName, nConnection */ { UNSIGNED32 ulRetVal; - UNSIGNED16 pusArrayLen = ISNUM( 1 ) ? ( UNSIGNED16 ) hb_parnl( 1 ) : 300; + UNSIGNED16 pusArrayLen = ISNUM( 1 ) ? ( UNSIGNED16 ) hb_parni( 1 ) : 300; char * pucUserName = hb_parclen( 2 ) > 0 ? hb_parc( 2 ) : NULL; - UNSIGNED16 usConnNumber = ( UNSIGNED16 ) hb_parnl( 3 ); // = HB_ADS_PARCONNECTION( 3 ) >>> only valid for netware, - // so don't default to current, only take a passed value + UNSIGNED16 usConnNumber = ( UNSIGNED16 ) hb_parni( 3 ); /* = HB_ADS_PARCONNECTION( 3 ) >>> only valid for netware, + so don't default to current, only take a passed value */ UNSIGNED16 pusStructSize = sizeof( ADS_MGMT_TABLE_INFO ); ADS_MGMT_TABLE_INFO * astOpenTableInfo; astOpenTableInfo = ( ADS_MGMT_TABLE_INFO * ) hb_xgrab( sizeof( ADS_MGMT_TABLE_INFO ) * pusArrayLen ); - ulRetVal = AdsMgGetOpenTables( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetOpenTables( s_hMgmtHandle, ( UNSIGNED8 * ) pucUserName, usConnNumber, astOpenTableInfo, @@ -530,7 +530,7 @@ HB_FUNC( ADSMGGETOPENTABLES ) /* nMaxNumberOfFilesToReturn, cUserName, nConnecti for( ulCount = 1; ulCount <= pusArrayLen; ulCount++ ) { hb_itemPutC( hb_arrayGetItemPtr( pArray, ( ULONG ) ulCount ), ( char * ) astOpenTableInfo[ ulCount - 1 ].aucTableName ); - // UNSIGNED16 astOpenTableInfo[ ulCount - 1 ].usLockType; /* Advantage locking mode */ + /* UNSIGNED16 astOpenTableInfo[ ulCount - 1 ].usLockType; */ /* Advantage locking mode */ } hb_itemReturnRelease( pArray ); } @@ -545,17 +545,17 @@ HB_FUNC( ADSMGGETOPENTABLES ) /* nMaxNumberOfFilesToReturn, cUserName, nConnecti HB_FUNC( ADSMGGETOPENINDEXES ) /* nMaxNumberOfFilesToReturn, cTableName, cUserName, nConnection */ { UNSIGNED32 ulRetVal; - UNSIGNED16 pusArrayLen = ISNUM( 1 ) ? ( UNSIGNED16 ) hb_parnl( 1 ) : 300; - char * pucTableName = hb_parclen( 2 ) > 0 ? hb_parc( 2 ) : NULL; // fully qualified path to that table + UNSIGNED16 pusArrayLen = ISNUM( 1 ) ? ( UNSIGNED16 ) hb_parni( 1 ) : 300; + char * pucTableName = hb_parclen( 2 ) > 0 ? hb_parc( 2 ) : NULL; /* fully qualified path to that table */ char * pucUserName = hb_parclen( 3 ) > 0 ? hb_parc( 3 ) : NULL; - UNSIGNED16 usConnNumber = ( UNSIGNED16 ) hb_parnl( 4 ); // = HB_ADS_PARCONNECTION( 4 ) >>> only valid for netware, - // so don't default to current, only take a passed value + UNSIGNED16 usConnNumber = ( UNSIGNED16 ) hb_parni( 4 ); /* = HB_ADS_PARCONNECTION( 4 ) >>> only valid for netware, + so don't default to current, only take a passed value */ UNSIGNED16 pusStructSize = sizeof( ADS_MGMT_INDEX_INFO ); ADS_MGMT_INDEX_INFO * astOpenIndexInfo; astOpenIndexInfo = ( ADS_MGMT_INDEX_INFO * ) hb_xgrab( sizeof( ADS_MGMT_INDEX_INFO ) * pusArrayLen ); - ulRetVal = AdsMgGetOpenIndexes( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetOpenIndexes( s_hMgmtHandle, ( UNSIGNED8 * ) pucTableName, ( UNSIGNED8 * ) pucUserName, usConnNumber, @@ -585,17 +585,17 @@ HB_FUNC( ADSMGGETOPENINDEXES ) /* nMaxNumberOfFilesToReturn, cTableName, cUserNa HB_FUNC( ADSMGGETLOCKS ) { UNSIGNED32 ulRetVal; - UNSIGNED16 pusArrayLen = ISNUM( 1 ) ? ( UNSIGNED16 ) hb_parnl( 1 ) : 2000; - char * pucTableName = hb_parclen( 2 ) > 0 ? hb_parc( 2 ) : NULL; // fully qualified path to that table + UNSIGNED16 pusArrayLen = ISNUM( 1 ) ? ( UNSIGNED16 ) hb_parni( 1 ) : 2000; + char * pucTableName = hb_parclen( 2 ) > 0 ? hb_parc( 2 ) : NULL; /* fully qualified path to that table */ char * pucUserName = hb_parclen( 3 ) > 0 ? hb_parc( 3 ) : NULL; - UNSIGNED16 usConnNumber = ( UNSIGNED16 ) hb_parnl( 4 ); // = HB_ADS_PARCONNECTION( 4 ) >>> only valid for netware, - // so don't default to current, only take a passed value + UNSIGNED16 usConnNumber = ( UNSIGNED16 ) hb_parni( 4 ); /* = HB_ADS_PARCONNECTION( 4 ) >>> only valid for netware, + so don't default to current, only take a passed value */ UNSIGNED16 pusStructSize = sizeof( ADS_MGMT_RECORD_INFO ); ADS_MGMT_RECORD_INFO * astRecordInfo; astRecordInfo = ( ADS_MGMT_RECORD_INFO * ) hb_xgrab( sizeof( ADS_MGMT_RECORD_INFO ) * pusArrayLen ); - ulRetVal = AdsMgGetLocks( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetLocks( s_hMgmtHandle, ( UNSIGNED8 * ) pucTableName, ( UNSIGNED8 * ) pucUserName, usConnNumber, @@ -625,13 +625,13 @@ HB_FUNC( ADSMGGETLOCKS ) HB_FUNC( ADSMGGETWORKERTHREADACTIVITY ) { UNSIGNED32 ulRetVal; - UNSIGNED16 pusArrayLen = ISNUM( 1 ) ? ( UNSIGNED16 ) hb_parnl( 1 ) : 2000; + UNSIGNED16 pusArrayLen = ISNUM( 1 ) ? ( UNSIGNED16 ) hb_parni( 1 ) : 2000; UNSIGNED16 pusStructSize = sizeof( ADS_MGMT_THREAD_ACTIVITY ); ADS_MGMT_THREAD_ACTIVITY * astWorkerThreadActivity; astWorkerThreadActivity = ( ADS_MGMT_THREAD_ACTIVITY * ) hb_xgrab( sizeof( ADS_MGMT_THREAD_ACTIVITY ) * pusArrayLen ); - ulRetVal = AdsMgGetWorkerThreadActivity( ads_g_hMgmtHandle, + ulRetVal = AdsMgGetWorkerThreadActivity( s_hMgmtHandle, astWorkerThreadActivity, &pusArrayLen, &pusStructSize ); diff --git a/harbour/contrib/rddads/rddads.h b/harbour/contrib/rddads/rddads.h index 520e0f761b..fcbacecc01 100644 --- a/harbour/contrib/rddads/rddads.h +++ b/harbour/contrib/rddads/rddads.h @@ -74,25 +74,25 @@ #ifndef ADS_LIB_VERSION #if defined(ADS_NOTIFICATION_CONNECTION) - #define ADS_LIB_VERSION 900 // or upper + #define ADS_LIB_VERSION 900 /* or upper */ #elif defined(ADS_UDP_IP_CONNECTION) - #define ADS_LIB_VERSION 810 // or upper + #define ADS_LIB_VERSION 810 /* or upper */ #elif defined(ADS_REPLICATION_CONNECTION) - #define ADS_LIB_VERSION 800 // or upper + #define ADS_LIB_VERSION 800 /* or upper */ #elif defined(ADS_NOT_AUTO_OPEN) - #define ADS_LIB_VERSION 710 // or upper + #define ADS_LIB_VERSION 710 /* or upper */ #elif defined(ADS_FTS_INDEX_ORDER) - #define ADS_LIB_VERSION 700 // or upper + #define ADS_LIB_VERSION 700 /* or upper */ #elif defined(ADS_COMPRESS_ALWAYS) - #define ADS_LIB_VERSION 620 // or upper + #define ADS_LIB_VERSION 620 /* or upper */ #elif defined(ADS_USER_DEFINED) - #define ADS_LIB_VERSION 611 // or upper + #define ADS_LIB_VERSION 611 /* or upper */ #else - #define ADS_LIB_VERSION 500 // or lower + #define ADS_LIB_VERSION 500 /* or lower */ #endif #endif -/* QUESTION: Why do we redefine this? Normally it is 4082 in 7.10 or upper and 256 in lower versions. */ +/* QUESTION: Why do we redefine this? Normally it is 4082 in 7.10 or upper and 256 in lower versions. [vszakats] */ #undef ADS_MAX_KEY_LENGTH #if ADS_LIB_VERSION >= 800 #define ADS_MAX_KEY_LENGTH 4082 /* maximum key value length. This is the max key length */