diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8fbddad0b1..778d2b4593 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,81 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-05-08 21:14 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * contrib/rddads/ads.ch + * contrib/rddads/rddads.h + * contrib/rddads/adsfunc.c + * contrib/rddads/ads1.c + * contrib/rddads/adsmgmnt.c + * Lots of minor code cleanups, formatting fixes, optimizations, + and several minor fixes. + ! Lib version related fixes. (some features were not updated + for newer ACE versions). + + Automatic version detection extended with 6.20 and 5.00. + 6.00 is still missing, if someone has it, pls send it to + me. Even 6.11-8.00 versions disappeared from the vendor's + site lately. + + Added support for all possible properties in + ADSDDGETDATABASEPROPERTY() + ADSDDSETDATABASEPROPERTY() + * ADSMGGETUSERNAMES() will now always return an array of + users with 6 elements in each item, all data which + is not available for the compiled version of the lib, + will be filled with empty strings. Previously the + number of elements depended on the compiled version. + ; Besides the above, no functionality change should be + experienced. + ; Please test. + + * contrib/rddads/make_b32.bat + * contrib/rddads/make_vc.bat + ! Changed to never look for ace32.dll in system32 dir + to generate the ace32.lib. + ! Some other fixes to prev change where ADS_VER + was obsoleted. + + * contrib/hbct/ctwfunc.c + * contrib/hbct/ctextern.ch + + Added hbct_MaxRow()/hbct_MaxCol() emulating + the original overloaded MaxRow()/MaxCol() + functions of CT3 lib. + + * source/rtl/maxrow.c + * Reverted previous change on request, thus introducing + a 3rd party lib specific function parameter extension. + Users of CT3 lib's overloaded MaxRow(.T.)/MaxCol(.T.) + functions are encouraged to change the app code + to rather use hbct_MaxRow()/hbct_MaxCol() + or hb_ScrMaxRow()/hbScrMaxCol(). These functions are + easy to implement in CA-Cl*pper too (simple wrappers + to Max*()). + + * source/compiler/hbmain.c + * Reverted previous change on request. Some outputs + are not exactly CA-Cl*pper compatible this way, but + functionally it probably doesn't matter for most ppl. + + * contrib/xhb/hbcompat.ch + ! Corrected MaxRow()/MaxCol()/hb_ScrMaxRow()/hb_ScrMaxCol() + translations. (hopefully, someone using xhb please test) + + - tests/ctwtest.prg + + contrib/hbct/tests/ctwtest.prg + * Moved CT lib specific test to contrib local test + directory (containing lots of other CT tests + already). Building these is yet to be solved. + + * contrib/hbct/tests/math.prg + * contrib/hbct/tests/trig.prg + * contrib/hbct/tests/num1.prg + ! Added SVN header. + + * include/hbgtinfo.ch + * Minor comment. + + * contrib/rddads/make_gcc.sh + * Help text sync with *.bat. + 2008-05-08 14:31 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/tbrowse.prg ! fixed positioning when cursor is moved by :rowpos assignment and diff --git a/harbour/contrib/hbct/ctextern.ch b/harbour/contrib/hbct/ctextern.ch index afadbdc2e5..2852e7f5e8 100644 --- a/harbour/contrib/hbct/ctextern.ch +++ b/harbour/contrib/hbct/ctextern.ch @@ -362,4 +362,7 @@ EXTERNAL WSETSHADOW EXTERNAL WSTEP EXTERNAL XTOC +EXTERNAL HBCT_MAXROW +EXTERNAL HBCT_MAXCOL + #endif /* HB_CTEXTERN_CH_ */ diff --git a/harbour/contrib/hbct/ctwfunc.c b/harbour/contrib/hbct/ctwfunc.c index 24684e269e..c3c5a9656a 100644 --- a/harbour/contrib/hbct/ctwfunc.c +++ b/harbour/contrib/hbct/ctwfunc.c @@ -329,3 +329,30 @@ HB_FUNC( CTWLASTKEY ) { hb_retni( hb_ctwLastKey() ); } + +/* NOTE: These two functions are emulating the MaxRow()/MaxCol() core functions + "overloaded" by the CT3 library. */ + +HB_FUNC( HBCT_MAXROW ) /* Return the maximum screen/window row number (zero origin) */ +{ + if( ISLOG( 1 ) && hb_parl( 1 ) ) + { + USHORT uiRows, uiCols; + hb_gtScrDim( &uiRows, &uiCols ); + hb_retni( uiRows - 1 ); + } + else + hb_retni( hb_gtMaxRow() ); +} + +HB_FUNC( HBCT_MAXCOL ) /* Return the maximum screen/window column number (zero origin) */ +{ + if( ISLOG( 1 ) && hb_parl( 1 ) ) + { + USHORT uiRows, uiCols; + hb_gtScrDim( &uiRows, &uiCols ); + hb_retni( uiCols - 1 ); + } + else + hb_retni( hb_gtMaxCol() ); +} diff --git a/harbour/tests/ctwtest.prg b/harbour/contrib/hbct/tests/ctwtest.prg similarity index 100% rename from harbour/tests/ctwtest.prg rename to harbour/contrib/hbct/tests/ctwtest.prg diff --git a/harbour/contrib/hbct/tests/math.prg b/harbour/contrib/hbct/tests/math.prg index 38fecefab0..6ce29700d0 100644 --- a/harbour/contrib/hbct/tests/math.prg +++ b/harbour/contrib/hbct/tests/math.prg @@ -1,3 +1,7 @@ +/* + * $Id$ + */ + /* * Harbour Project source code: * diff --git a/harbour/contrib/hbct/tests/num1.prg b/harbour/contrib/hbct/tests/num1.prg index 46e6191099..5a8039c8c5 100644 --- a/harbour/contrib/hbct/tests/num1.prg +++ b/harbour/contrib/hbct/tests/num1.prg @@ -1,3 +1,7 @@ +/* + * $Id$ + */ + /* * Harbour Project source code: * diff --git a/harbour/contrib/hbct/tests/trig.prg b/harbour/contrib/hbct/tests/trig.prg index 2b32f1a581..65b2752c84 100644 --- a/harbour/contrib/hbct/tests/trig.prg +++ b/harbour/contrib/hbct/tests/trig.prg @@ -1,3 +1,7 @@ +/* + * $Id$ + */ + /* * Harbour Project source code: * diff --git a/harbour/contrib/rddads/ads.ch b/harbour/contrib/rddads/ads.ch index dc8ea82974..f147edecbc 100644 --- a/harbour/contrib/rddads/ads.ch +++ b/harbour/contrib/rddads/ads.ch @@ -50,6 +50,26 @@ * */ +/* + If you want to limit your app to use an ADS version + earlier than the current one, you must set this constant + ADS_LIB_VERSION + to the *latest* version you want to allow/require, as in + -DADS_LIB_VERSION=500 + + As of 6/7/2004, the default supports linking to v6 and v7, + as there are no v7-specific features yet. + It does cover v6 data dictionary support, built-in + Internet Server capabilities, etc. + + So to link to v5, do this: + 1) Link with an ACE32.LIB created from the version 5 + dll that imports these functions, and + + 2) Set this "define" when compiling rddads: + -DADS_LIB_VERSION=500 +*/ + /* Supported file types */ #define ADS_NTX 1 #define ADS_CDX 2 @@ -82,21 +102,64 @@ #define ADS_IGNOREFILTERS 2 #define ADS_RESPECTSCOPES 3 -#command SET FILETYPE TO ; - => AdsSetFileType( if( upper( <(x)> ) == "NTX", 1, ; - if( upper( <(x)> ) == "CDX", 2, 3 ) ) ) - -#command SET SERVER LOCAL => AdsSetServerType( 1 ) -#command SET SERVER REMOTE => AdsSetServerType( 2 ) +#command SET FILETYPE TO ; + => AdsSetFileType( iif( Upper( <(x)> ) == "NTX", ADS_NTX, ; + iif( Upper( <(x)> ) == "CDX", ADS_CDX, ; + iif( Upper( <(x)> ) == "VFP", ADS_VFP, ADS_ADT ) ) ) ) /* Server type constants for ORing with AdsSetServerType() */ #define ADS_LOCAL_SERVER 1 #define ADS_REMOTE_SERVER 2 #define ADS_AIS_SERVER 4 +#command SET SERVER LOCAL => AdsSetServerType( ADS_LOCAL_SERVER ) +#command SET SERVER REMOTE => AdsSetServerType( ADS_REMOTE_SERVER ) + +#command SET AXS LOCKING ; + => AdsLocking( Upper( <(x)> ) == "ON" ) + +#command SET RIGHTS CHECKING ; + => AdsRightsCheck( Upper( <(x)> ) == "ON" ) + +/* character set types */ +#define ADS_ANSI 1 +#define ADS_OEM 2 + +#command SET CHARTYPE TO ; + => AdsSetCharType( iif( Upper( <(x)> ) == "OEM", ADS_OEM, ADS_ANSI ) ) + +#command COMMIT => AdsWriteAllRecords() +#command BEGIN TRANSACTION => AdsBeginTransaction() +#command COMMIT TRANSACTION => AdsCommitTransaction() +#command ROLLBACK TRANSACTION => AdsRollback() + +#command AUTOUSE <(db)> VIA ALTERNATE ; + [ALIAS ] ; + [] ; + [] ; + [] ; + [] ; + [INDEX <(index1)> [, <(indexn)>]] ; + ; + => IF AdsIsServerLoaded( <(db)> ) > 0 ; + ; dbUseArea( ; + <.new.>, , <(db)>, <(a)>, ; + iif( <.sh.> .OR. <.ex.>, !<.ex.>, NIL ), <.ro.> ; + ) ; + [; dbSetIndex( <(index1)> )] ; + [; dbSetIndex( <(indexn)> )] ; + ; ELSE ; + ; dbUseArea( ; + <.new.>, , <(db)>, <(a)>, ; + iif( <.sh.> .OR. <.ex.>, !<.ex.>, NIL ), <.ro.> ; + ) ; + [; dbSetIndex( <(index1)> )] ; + [; dbSetIndex( <(indexn)> )] ; + ; ENDIF + /* - * Constants for AdsMgGetServerType - * Note ADS_MGMT_NETWARE_SERVER remains for backwards compatibility only + * Constants for AdsMgGetServerType() + * Note ADS_MGMT_NETWARE_SERVER remains for backwards compatibility only. */ #define ADS_MGMT_NETWARE_SERVER 1 #define ADS_MGMT_NETWARE4_OR_OLDER_SERVER 1 @@ -106,35 +169,6 @@ #define ADS_MGMT_NETWARE5_OR_NEWER_SERVER 5 #define ADS_MGMT_LINUX_SERVER 6 -/* - If you want to limit your app to use an ADS version - earlier than the current one, you must set this constant - ADS_LIB_VERSION - to the *latest* version you want to allow/require, as in - -DADS_LIB_VERSION=500 - - As of 6/7/2004, the default supports linking to v6 and v7, - as there are no v7-specific features yet. - It does cover v6 data dictionary support, built-in - Internet Server capabilities, etc. - - So to link to v5, do this: - 1) Link with an ACE32.LIB created from the version 5 - dll that imports these functions, and - - 2) Set this "define" when compiling rddads: - -DADS_LIB_VERSION=500 - -*/ - -#command SET AXS LOCKING ; - => AdsLocking( if( upper( <(x)> ) == "ON", .t., .f. ) ) - -#command SET CHARTYPE TO ; - => AdsSetCharType( if( upper( <(x)> ) == "OEM", 2, 1 ) ) - -#command COMMIT => AdsWriteAllRecords() - /* ACE Handle types */ #define ADS_CONNECTION 1 #define ADS_TABLE 2 @@ -147,13 +181,6 @@ #define AE_NO_CONNECTION 5036 - -#command BEGIN TRANSACTION => AdsBeginTransaction() - -#command COMMIT TRANSACTION => AdsCommitTransaction() - -#command ROLLBACK TRANSACTION => AdsRollback() - #define ADS_DD_TABLE_OBJECT 1 #define ADS_DD_RELATION_OBJECT 2 #define ADS_DD_INDEX_FILE_OBJECT 3 @@ -169,13 +196,11 @@ #define ADS_DD_LINK_OBJECT 12 #define ADS_DD_TABLE_VIEW_OR_LINK_OBJECT 13 /* Used in v6.2 AdsFindFirst/NextTable */ - /* Common properties numbers < 100 */ #define ADS_DD_COMMENT 1 #define ADS_DD_VERSION 2 #define ADS_DD_USER_DEFINED_PROP 3 - /* Database properties between 100 and 199 */ #define ADS_DD_DEFAULT_TABLE_PATH 100 #define ADS_DD_ADMIN_PASSWORD 101 @@ -281,7 +306,6 @@ #define ADS_DD_LINK_OPTIONS 1301 #define ADS_DD_LINK_USERNAME 1302 - #define ADS_DD_LEVEL_0 0 #define ADS_DD_LEVEL_1 1 #define ADS_DD_LEVEL_2 2 @@ -296,30 +320,3 @@ #define ADS_DD_DFV_UNKNOWN 1 #define ADS_DD_DFV_NONE 2 #define ADS_DD_DFV_VALUES_STORED 3 - -#command AUTOUSE <(db)> VIA ALTERNATE ; - [ALIAS ] ; - [] ; - [] ; - [] ; - [] ; - [INDEX <(index1)> [, <(indexn)>]] ; - ; - => if ADSISSERVERLOADED( <(db)> ) >0 ; - ; dbUseArea( ; - <.new.>, , <(db)>, <(a)>, ; - if (<.sh.> .or. <.ex.>, !<.ex.>, NIL), <.ro.> ; - ) ; - [; dbSetIndex( <(index1)> )] ; - [; dbSetIndex( <(indexn)> )] ; - ; else ; - ; dbUseArea( ; - <.new.>, , <(db)>, <(a)>, ; - if (<.sh.> .or. <.ex.>, !<.ex.>, NIL), <.ro.> ; - ) ; - [; dbSetIndex( <(index1)> )] ; - [; dbSetIndex( <(indexn)> )] ; - ; endif - -#command SET RIGHTS CHECKING ; - => ADSRIGHTSCHECK ( if( upper( <(x)> ) == "ON", 1,0) ) diff --git a/harbour/contrib/rddads/ads1.c b/harbour/contrib/rddads/ads1.c index a3fb5e1639..1d8c7f8a4f 100644 --- a/harbour/contrib/rddads/ads1.c +++ b/harbour/contrib/rddads/ads1.c @@ -189,15 +189,15 @@ static ERRCODE commonError( ADSAREAP pArea, USHORT uiGenCode, USHORT uiSubCode, #if 0 static void DumpArea( ADSAREAP pArea ) /* For debugging: call this to dump ads server settings to HB_TRACE. Currently in a quick-and-dirty state... */ { - UNSIGNED8 pucTemp[1025]; + UNSIGNED8 pucTemp[ 1025 ]; UNSIGNED16 pusLen = 1024; UNSIGNED32 ulRetVal, ulRetAOF, ulRetFilt; - UNSIGNED8 pucFormat[16]; - UNSIGNED8 pucFilter[1025]; - /*UNSIGNED8 aucBuffer[MAX_STR_LEN + 1];*/ - UNSIGNED8 pucIndexName[MAX_STR_LEN + 1]; - UNSIGNED8 pucIndexExpr[MAX_STR_LEN + 1]; - UNSIGNED8 pucIndexCond[MAX_STR_LEN + 1]; + UNSIGNED8 pucFormat[ 16 ]; + UNSIGNED8 pucFilter[ 1025 ]; +/* UNSIGNED8 aucBuffer[ MAX_STR_LEN + 1 ]; */ + UNSIGNED8 pucIndexName[ MAX_STR_LEN + 1 ]; + UNSIGNED8 pucIndexExpr[ MAX_STR_LEN + 1 ]; + UNSIGNED8 pucIndexCond[ MAX_STR_LEN + 1 ]; if( pArea ) { @@ -225,13 +225,12 @@ static void DumpArea( ADSAREAP pArea ) /* For debugging: call this to dump ads AdsGetIndexExpr( pArea->hOrdCurrent, pucIndexExpr, &pusLen ); pusLen = 1024; /*ADS top/bottom are 1,2 instead of 0,1*/ - ulRetVal = AdsGetScope( pArea->hOrdCurrent, 1, pucTemp, &pusLen ); + ulRetVal = AdsGetScope( pArea->hOrdCurrent, ADS_TOP, pucTemp, &pusLen ); pusLen = 1024; - ulRetFilt = AdsGetScope( pArea->hOrdCurrent, 2, pucFilter, &pusLen ); + ulRetFilt = AdsGetScope( pArea->hOrdCurrent, ADS_BOTTOM, pucFilter, &pusLen ); HB_TRACE(HB_TR_ALWAYS, ("DumpArea Index: %s Expr: %s Cond: %s\n Scope: (RetVal %lu) %s Bottom: (RetVal %lu) %s", pucIndexName, pucIndexExpr, pucIndexCond, ulRetVal, pucTemp, ulRetFilt, pucFilter)); - } } } @@ -241,8 +240,8 @@ static BOOL adsIndexKeyCmp( ADSHANDLE hIndex, UNSIGNED8 * pszKey, UNSIGNED16 u16 { UNSIGNED32 u32RetVal; UNSIGNED16 u16Found = FALSE; + UNSIGNED8 pucCurKey[ ADS_MAX_KEY_LENGTH + 1 ]; UNSIGNED16 u16CurKeyLen = ADS_MAX_KEY_LENGTH; - UNSIGNED8 pucCurKey[ADS_MAX_KEY_LENGTH + 1]; /* * test if current record has fields that match the given key expression. @@ -462,7 +461,7 @@ static void adsGetKeyItem( ADSAREAP pArea, PHB_ITEM pItem, int iKeyType, { hb_itemPutDS( pItem, pKeyBuf ); } - else /* ADS_CDX, ADS_ADT */ + else /* ADS_CDX, ADS_ADT, ADS_VFP */ { HB_ORD2DBL( pKeyBuf, &dValue ); hb_itemPutDL( pItem, ( LONG ) dValue ); @@ -481,7 +480,7 @@ static void adsGetKeyItem( ADSAREAP pArea, PHB_ITEM pItem, int iKeyType, static void adsScopeGet( ADSAREAP pArea, ADSHANDLE hOrder, USHORT nScope, PHB_ITEM pItem ) { - UNSIGNED8 pucScope[ ADS_MAX_KEY_LENGTH+1 ]; + UNSIGNED8 pucScope[ ADS_MAX_KEY_LENGTH + 1 ]; UNSIGNED16 u16Len = ADS_MAX_KEY_LENGTH; UNSIGNED32 u32RetVal; UNSIGNED16 u16KeyType = 0; @@ -2818,8 +2817,8 @@ static ERRCODE adsInfo( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) case DBI_FULLPATH : { - UNSIGNED8 aucBuffer[MAX_STR_LEN + 1]; - UNSIGNED16 pusLen = MAX_STR_LEN; + UNSIGNED8 aucBuffer[ MAX_STR_LEN + 1 ]; + UNSIGNED16 pusLen = MAX_STR_LEN; AdsGetTableFilename( pArea->hTable, ADS_FULLPATHNAME, aucBuffer, &pusLen ); hb_itemPutCL( pItem, (char*)aucBuffer, pusLen ); break; @@ -2863,9 +2862,9 @@ static ERRCODE adsInfo( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) UNSIGNED32 ulMajor; UNSIGNED32 ulMinor; UNSIGNED8 ucLetter; - UNSIGNED8 ucDesc[128]; + UNSIGNED8 ucDesc[ 128 ]; UNSIGNED16 usDescLen = sizeof( ucDesc ) - 1; - UNSIGNED8 ucVersion[256]; + UNSIGNED8 ucVersion[ 256 ]; AdsGetVersion( &ulMajor, &ulMinor, &ucLetter, ucDesc, &usDescLen); @@ -2954,11 +2953,13 @@ static ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) u32RetVal = AdsGetHandleType( hConnection, &pusType); if( u32RetVal == AE_SUCCESS ) { -#ifdef ADS_SYS_ADMIN_CONNECTION /* Defined below 9.00 */ +#if ADS_LIB_VERSION >= 600 /* ADS_*_CONNECTION was added in >= 6.00 */ +#if ADS_LIB_VERSION < 900 /* ADS_SYS_ADMIN_CONNECTION was removed in >= 9.00 */ fDictionary = ( pusType == ADS_DATABASE_CONNECTION || pusType == ADS_SYS_ADMIN_CONNECTION ); #else fDictionary = ( pusType == ADS_DATABASE_CONNECTION ); +#endif #endif } szFile = ( char * ) pOpenInfo->abName; @@ -3077,7 +3078,7 @@ static ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) dbFieldInfo.uiFlags = 0; if( u32Length > pArea->maxFieldLen ) { - pArea->maxFieldLen = u32Length; + pArea->maxFieldLen = u32Length; } dbFieldInfo.uiTypeExtended = pusType; @@ -3093,9 +3094,11 @@ static ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) dbFieldInfo.uiFlags = HB_FF_BINARY; break; +#ifdef ADS_CISTRING /* Not defined below 7.10 */ case ADS_CISTRING: dbFieldInfo.uiType = HB_FT_STRING; break; +#endif case ADS_NUMERIC: dbFieldInfo.uiTypeExtended = 0; @@ -3418,7 +3421,7 @@ static ERRCODE adsSetRel( ADSAREAP pArea, LPDBRELINFO lpdbRelations ) static ERRCODE adsOrderListAdd( ADSAREAP pArea, LPDBORDERINFO pOrderInfo ) { - ADSHANDLE ahIndex[50]; + ADSHANDLE ahIndex[ 50 ]; UNSIGNED16 u16ArrayLen = 50; UNSIGNED32 u32RetVal; @@ -3695,7 +3698,7 @@ static ERRCODE adsOrderCreate( ADSAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) if( fClose ) { - ADSHANDLE ahIndex[50]; + ADSHANDLE ahIndex[ 50 ]; UNSIGNED16 pusArrayLen = 50; u32RetVal = AdsOpenIndex( pArea->hTable, @@ -3750,7 +3753,7 @@ static ERRCODE adsOrderDestroy( ADSAREAP pArea, LPDBORDERINFO pOrderInfo ) static ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrderInfo ) { ADSHANDLE hIndex; - UNSIGNED8 aucBuffer[MAX_STR_LEN + 1]; + UNSIGNED8 aucBuffer[ MAX_STR_LEN + 1 ]; UNSIGNED16 u16len = MAX_STR_LEN; UNSIGNED16 u16 = 0; UNSIGNED32 u32 = 0; diff --git a/harbour/contrib/rddads/adsfunc.c b/harbour/contrib/rddads/adsfunc.c index 51a60500ad..8a7c7f3754 100644 --- a/harbour/contrib/rddads/adsfunc.c +++ b/harbour/contrib/rddads/adsfunc.c @@ -4,9 +4,9 @@ /* * Harbour Project source code: - * Advantage Database Server RDD ( additional functions ) + * Advantage Database Server RDD (additional functions) * - * Copyright 2000 Alexander Kresin + * Copyright 2000 Alexander Kresin * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -72,6 +72,7 @@ int adsRights = ADS_CHECKRIGHTS; int adsCharType = ADS_ANSI; BOOL bTestRecLocks = FALSE; /* Debug Implicit locks */ ADSHANDLE adsConnectHandle = 0; + #if !defined( ADS_LINUX ) static PHB_ITEM s_pItmCobCallBack = NULL; #endif @@ -110,56 +111,57 @@ void hb_adsOemAnsiFree( char * pcString ) hb_xfree( pcString ); } } + #endif HB_FUNC( ADSTESTRECLOCKS ) /* Debug Implicit locks Set/Get call */ { - BOOL oldSetting = bTestRecLocks; + hb_retl( bTestRecLocks ); if( ISLOG( 1 ) ) + { bTestRecLocks = hb_parl( 1 ); - - hb_retl( oldSetting ); + } } - HB_FUNC( ADSSETFILETYPE ) { - int fileType, oldType = adsFileType; + hb_retni( adsFileType ); + if( hb_pcount() > 0 ) { - fileType = hb_parni( 1 ); - if( fileType > 0 && fileType < 4 ) + int fileType = hb_parni( 1 ); + + if( fileType >= ADS_NTX && +#if ADS_LIB_VERSION >= 900 + fileType <= ADS_VFP ) +#else + fileType <= ADS_ADT ) +#endif { adsFileType = fileType; } } - hb_retni( oldType ); } HB_FUNC( ADSSETSERVERTYPE ) { - int servType; UNSIGNED32 ulRetVal = 999999; if( hb_pcount() > 0 ) { - servType = hb_parni( 1 ); - ulRetVal = AdsSetServerType( servType ); + ulRetVal = AdsSetServerType( hb_parni( 1 ) /* servType */ ); } hb_retnl( ulRetVal ); } HB_FUNC( ADSSETDATEFORMAT ) { - UNSIGNED8 pucFormat[16]; + UNSIGNED8 pucFormat[ 16 ]; UNSIGNED16 pusLen = 16; - hb_retc( ""); AdsGetDateFormat( pucFormat, &pusLen ); - if( pusLen > 0 ) - { - hb_retc( (char *) pucFormat ); - } + + hb_retc( pusLen > 0 ? ( char * ) pucFormat : NULL ); if( ISCHAR( 1 ) ) { @@ -171,14 +173,14 @@ HB_FUNC( ADSSETEPOCH ) { UNSIGNED16 pusEpoch = 1900; - if( AdsGetEpoch ( &pusEpoch ) == AE_SUCCESS ) + if( AdsGetEpoch( &pusEpoch ) == AE_SUCCESS ) { hb_retni( pusEpoch ); } if( ISNUM( 1 ) ) { - AdsSetEpoch ( hb_parni( 1 ) ); + AdsSetEpoch( hb_parni( 1 ) ); } } @@ -197,11 +199,10 @@ HB_FUNC( ADSAPPLICATIONEXIT ) HB_FUNC( ADSISSERVERLOADED ) { UNSIGNED16 pbLoaded = 0; - UNSIGNED32 ulRetVal; if( ISCHAR( 1 ) ) { - ulRetVal = AdsIsServerLoaded( (UNSIGNED8*) hb_parcx( 1 ), &pbLoaded ); + UNSIGNED32 ulRetVal = AdsIsServerLoaded( (UNSIGNED8*) hb_parcx( 1 ), &pbLoaded ); if( ulRetVal != AE_SUCCESS ) { pbLoaded = 0; @@ -244,21 +245,19 @@ HB_FUNC( ADSGETCONNECTIONTYPE ) HB_FUNC( ADSUNLOCKRECORD ) { - UNSIGNED32 ulRetVal; ADSAREAP pArea; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - ulRetVal = AdsUnlockRecord( pArea->hTable, hb_parnl(1) ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - return; - } + UNSIGNED32 ulRetVal = AdsUnlockRecord( pArea->hTable, hb_parnl(1) ); + hb_retl( ulRetVal == AE_SUCCESS ); + } + else + { + hb_retl( FALSE ); } - hb_retl( FALSE ); } HB_FUNC( ADSGETTABLECONTYPE ) @@ -290,7 +289,6 @@ HB_FUNC( ADSGETTABLECONTYPE ) HB_FUNC( ADSGETSERVERTIME ) { - UNSIGNED32 ulRetVal; UNSIGNED8 pucDateBuf[ 16 ]; UNSIGNED8 pucTimeBuf[ 16 ]; @@ -307,8 +305,8 @@ HB_FUNC( ADSGETSERVERTIME ) if( ulRetVal == AE_SUCCESS ) { hb_reta( 3 ); - hb_storc( (char * )pucDateBuf, -1, 1 ); - hb_storc( (char *) pucTimeBuf, -1, 2 ); + hb_storc( ( char * ) pucDateBuf, -1, 1 ); + hb_storc( ( char * ) pucTimeBuf, -1, 2 ); hb_stornl( plTime, -1, 3 ); } else @@ -322,28 +320,28 @@ HB_FUNC( ADSGETSERVERTIME ) HB_FUNC( ADSISTABLELOCKED ) { UNSIGNED32 ulRetVal = ~AE_SUCCESS; - UNSIGNED16 pbLocked = FALSE; + UNSIGNED16 pbLocked = 0; ADSAREAP pArea; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { ulRetVal = AdsIsTableLocked( pArea->hTable, &pbLocked ); + + hb_retl( pbLocked ); } if( ulRetVal != AE_SUCCESS ) { hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISTABLELOCKED" ); } - - hb_retl( pbLocked ); } HB_FUNC( ADSISRECORDLOCKED ) { UNSIGNED32 ulRetVal = ~AE_SUCCESS; UNSIGNED32 ulRec; - UNSIGNED16 pbLocked = FALSE; + UNSIGNED16 pbLocked = 0; ADSAREAP pArea; pArea = hb_rddGetADSWorkAreaPointer(); @@ -358,46 +356,50 @@ HB_FUNC( ADSISRECORDLOCKED ) SELF_RECNO( ( AREAP ) pArea, &ulRec ); } ulRetVal = AdsIsRecordLocked( pArea->hTable, ulRec, &pbLocked ); + + hb_retl( pbLocked ); } + if( ulRetVal != AE_SUCCESS ) { hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISRECORDLOCKED" ); } - - hb_retl( pbLocked ); } HB_FUNC( ADSLOCKING ) { - int oldType = adsLockType; + hb_retl( adsLockType ); if( hb_pcount() > 0 ) { adsLockType = hb_parl( 1 ); } - - hb_retl( oldType ); } HB_FUNC( ADSRIGHTSCHECK ) { - int oldType = ( adsRights == ADS_CHECKRIGHTS ) ? 1 : 0; + hb_retl( adsRights == ADS_CHECKRIGHTS ); if( hb_pcount() > 0 ) { - adsRights = ( hb_parl( 1 ) ) ? ADS_CHECKRIGHTS : ADS_IGNORERIGHTS; + adsRights = hb_parl( 1 ) ? ADS_CHECKRIGHTS : ADS_IGNORERIGHTS; } - - hb_retl( oldType ); } HB_FUNC( ADSSETCHARTYPE ) { - int charType, oldType = adsCharType; + hb_retni( adsCharType ); + if( hb_pcount() > 0 ) { - charType = hb_parni( 1 ); - if( charType > 0 && charType < 3 ) + int charType = hb_parni( 1 ); + + if( charType >= ADS_ANSI && +#if ADS_LIB_VERSION >= 900 + charType <= ADS_MAX_CHAR_SETS ) +#else + charType <= ADS_OEM ) +#endif { adsCharType = charType; } @@ -408,7 +410,6 @@ HB_FUNC( ADSSETCHARTYPE ) } #endif } - hb_retni( oldType ); } // return whether the current table is opened with OEM or ANSI character set @@ -423,7 +424,7 @@ HB_FUNC( ADSGETTABLECHARTYPE ) HB_FUNC( ADSSETDEFAULT ) { - UNSIGNED8 pucDefault[ MAX_STR_LEN + 1]; + UNSIGNED8 pucDefault[ MAX_STR_LEN + 1 ]; UNSIGNED16 pusLen = MAX_STR_LEN + 1; AdsGetDefault( pucDefault, &pusLen ); @@ -434,13 +435,12 @@ HB_FUNC( ADSSETDEFAULT ) { AdsSetDefault( (UNSIGNED8*) hb_parcx( 1 ) ); } - } HB_FUNC( ADSSETSEARCHPATH ) { - UNSIGNED8 pucPath[ MAX_STR_LEN + 1]; + UNSIGNED8 pucPath[ MAX_STR_LEN + 1 ]; UNSIGNED16 pusLen = MAX_STR_LEN + 1; AdsGetSearchPath( pucPath, &pusLen ); @@ -455,93 +455,69 @@ HB_FUNC( ADSSETSEARCHPATH ) HB_FUNC( ADSSETDELETED ) { - UNSIGNED16 usShowDeleted = hb_parl( 1 ); - UNSIGNED16 pbShowDeleted ; + UNSIGNED16 pbShowDeleted; AdsGetDeleted( &pbShowDeleted ); hb_retl( ! pbShowDeleted ); if( ISLOG( 1 ) ) { - AdsShowDeleted( !usShowDeleted ); + AdsShowDeleted( !hb_parl( 1 ) /* usShowDeleted */ ); } } HB_FUNC( ADSSETEXACT ) { - UNSIGNED16 usExact = hb_parl( 1 ); - UNSIGNED16 pbExact ; + UNSIGNED16 pbExact; AdsGetExact( &pbExact ); hb_retl( pbExact ); if( ISLOG( 1 ) ) { - AdsSetExact( usExact ); + AdsSetExact( hb_parl( 1 ) /* usExact */ ); } } HB_FUNC( ADSBLOB2FILE ) { - char * szFileName, *szFieldName; + char * szFileName = hb_parcx( 1 ); + char * szFieldName = hb_parcx( 2 ); ADSAREAP pArea; UNSIGNED32 ulRetVal; - szFileName = hb_parcx( 1 ); - szFieldName = hb_parcx( 2 ); - if( !szFileName || !szFieldName || ( strlen( szFileName ) == 0 ) || - ( strlen( szFieldName ) == 0 ) ) + if( szFileName && strlen( szFileName ) && + szFieldName && strlen( szFieldName ) ) { - hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSBLOB2FILE" ); - return; - } - - pArea = hb_rddGetADSWorkAreaPointer(); - ulRetVal = AdsBinaryToFile( pArea->hTable, (UNSIGNED8*)szFieldName, (UNSIGNED8*)szFileName ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); + pArea = hb_rddGetADSWorkAreaPointer(); + ulRetVal = AdsBinaryToFile( pArea->hTable, (UNSIGNED8*)szFieldName, (UNSIGNED8*)szFileName ); + hb_retl( ulRetVal == AE_SUCCESS ); } else { - hb_retl( FALSE ); + hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSBLOB2FILE" ); } } HB_FUNC( ADSFILE2BLOB ) { - char * szFileName, *szFieldName; - UNSIGNED16 usBinaryType; + char * szFileName = hb_parcx( 1 ); + char * szFieldName = hb_parcx( 2 ); ADSAREAP pArea; UNSIGNED32 ulRetVal; - szFileName = hb_parcx( 1 ); - szFieldName = hb_parcx( 2 ); - if( !szFileName || !szFieldName || ( strlen( szFileName ) == 0 ) || - ( strlen( szFieldName ) == 0 ) ) + if( szFileName && strlen( szFileName ) && + szFieldName && 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 ); + } + else { hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSFILE2BLOB" ); - return; - } - - if( hb_pcount() > 2 ) - { - usBinaryType = hb_parni( 3 ); - } - else - { - usBinaryType = ADS_BINARY; - } - - pArea = hb_rddGetADSWorkAreaPointer(); - ulRetVal = AdsFileToBinary( pArea->hTable, (UNSIGNED8*)szFieldName, usBinaryType, (UNSIGNED8*)szFileName ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); } } @@ -625,9 +601,9 @@ HB_FUNC( ADSKEYCOUNT ) UNSIGNED32 pulKey = 0L; ADSHANDLE hIndex = 0; UNSIGNED16 usFilterOption = ADS_IGNOREFILTERS; - UNSIGNED8 pucScope[ADS_MAX_KEY_LENGTH + 1]; - UNSIGNED8 pucFilter[HARBOUR_MAX_RDD_FILTER_LENGTH + 1]; + 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. */ @@ -851,41 +827,40 @@ HB_FUNC( ADSEVALAOF ) { hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSEVALAOF" ); } - } HB_FUNC( ADSGETTABLEALIAS ) { ADSAREAP pArea; - UNSIGNED8 pucAlias[HARBOUR_MAX_RDD_ALIAS_LENGTH + 1]; + UNSIGNED8 pucAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ]; UNSIGNED16 pusLen = HARBOUR_MAX_RDD_ALIAS_LENGTH + 1; - UNSIGNED32 ulRetVal = FAILURE; + UNSIGNED32 ulRetVal; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { ulRetVal = AdsGetTableAlias( pArea->hTable, pucAlias, &pusLen ); + + if( ulRetVal == AE_SUCCESS ) + { + hb_retclen ( ( char * ) pucAlias, pusLen ); + } + else + { + hb_retc( NULL ); + } } else { hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSGETTABLEALIAS" ); } - - if( ulRetVal == AE_SUCCESS ) - { - hb_retclen ( ( char * ) pucAlias, pusLen ); - } - else - { - hb_retc( "" ); - } } HB_FUNC( ADSGETAOF ) { ADSAREAP pArea; - UNSIGNED8 pucFilter[HARBOUR_MAX_RDD_FILTER_LENGTH + 1]; + UNSIGNED8 pucFilter[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; UNSIGNED8 *pucFilter2 = NULL; UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; UNSIGNED32 ulRetVal; @@ -909,7 +884,7 @@ HB_FUNC( ADSGETAOF ) } else { - hb_retc( "" ); + hb_retc( NULL ); } if( pucFilter2 ) @@ -926,7 +901,7 @@ HB_FUNC( ADSGETAOF ) HB_FUNC( ADSGETAOFOPTLEVEL ) { ADSAREAP pArea; - UNSIGNED16 pusOptLevel; + UNSIGNED16 pusOptLevel = 0; UNSIGNED32 ulRetVal; pArea = hb_rddGetADSWorkAreaPointer(); @@ -945,7 +920,7 @@ HB_FUNC( ADSGETAOFNOOPT ) { ADSAREAP pArea; UNSIGNED16 pusOptLevel; - UNSIGNED8 pucNonOpt[HARBOUR_MAX_RDD_FILTER_LENGTH + 1]; + UNSIGNED8 pucNonOpt[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; UNSIGNED8 *pucNonOpt2; UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; UNSIGNED32 ulRetVal; @@ -961,11 +936,11 @@ HB_FUNC( ADSGETAOFNOOPT ) ulRetVal = AdsGetAOFOptLevel( pArea->hTable, &pusOptLevel, pucNonOpt2, &pusLen ); if( ulRetVal == AE_SUCCESS ) { - hb_retc( (char *) pucNonOpt2 ); + hb_retc( ( char * ) pucNonOpt2 ); } else { - hb_retc( "" ); + hb_retc( NULL ); } hb_xfree( pucNonOpt2 ); } @@ -975,9 +950,8 @@ HB_FUNC( ADSGETAOFNOOPT ) } else { - hb_retc( "" ); + hb_retc( NULL ); } - } else { @@ -988,27 +962,17 @@ HB_FUNC( ADSGETAOFNOOPT ) HB_FUNC( ADSISRECORDINAOF ) { ADSAREAP pArea; - UNSIGNED32 ulRecordNumber = 0; /* 0 for current record */ - UNSIGNED16 bIsInAOF; + UNSIGNED16 bIsInAOF = 0; UNSIGNED32 ulRetVal; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { - if( hb_pcount() > 0 ) - { - ulRecordNumber = hb_parnl( 1 ); - } + UNSIGNED32 ulRecordNumber = hb_parnl( 1 ); /* 0 for current record */ + ulRetVal = AdsIsRecordInAOF( pArea->hTable, ulRecordNumber, &bIsInAOF ); - if( ulRetVal == AE_SUCCESS && bIsInAOF ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( ulRetVal == AE_SUCCESS && bIsInAOF ); } else { @@ -1018,34 +982,28 @@ HB_FUNC( ADSISRECORDINAOF ) HB_FUNC( ADSISRECORDVALID ) // Does current record match any current filter? { - AREAP pArea; BOOL bReturn = FALSE; - PHB_ITEM pResult; + AREAP pArea; pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer(); if( pArea ) { - BOOL fEof; + BOOL fEof = TRUE; if( SELF_EOF( ( AREAP ) pArea , &fEof ) == SUCCESS && !fEof ) { - if( ! pArea->dbfi.itmCobExpr ) + if( pArea->dbfi.itmCobExpr ) { - bReturn = TRUE; + PHB_ITEM pResult = hb_vmEvalBlock( pArea->dbfi.itmCobExpr ); + bReturn = HB_IS_LOGICAL( pResult ) && hb_itemGetL( pResult ); } else { - pResult = hb_vmEvalBlock( pArea->dbfi.itmCobExpr ); - bReturn = HB_IS_LOGICAL( pResult ) && hb_itemGetL( pResult ); + bReturn = TRUE; } } } -/* - else - { - hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISRECORDVALID" ); - } -*/ + hb_retl( bReturn ); } @@ -1101,7 +1059,7 @@ HB_FUNC( ADSSETAOF ) HB_FUNC( ADSGETFILTER ) { ADSAREAP pArea; - UNSIGNED8 pucFilter[HARBOUR_MAX_RDD_FILTER_LENGTH + 1]; + UNSIGNED8 pucFilter[ HARBOUR_MAX_RDD_FILTER_LENGTH + 1 ]; UNSIGNED8 *pucFilter2 = NULL; UNSIGNED16 pusLen = HARBOUR_MAX_RDD_FILTER_LENGTH + 1; UNSIGNED32 ulRetVal; @@ -1119,15 +1077,14 @@ HB_FUNC( ADSGETFILTER ) if( ulRetVal == AE_SUCCESS ) { - char * szRet; - szRet = hb_adsAnsiToOem( ( char * ) ( pucFilter2 ? pucFilter2 : pucFilter ), pusLen ); + char * szRet = hb_adsAnsiToOem( ( char * ) ( pucFilter2 ? pucFilter2 : pucFilter ), pusLen ); hb_retc( szRet ); hb_adsOemAnsiFree( szRet ); } else { HB_TRACE(HB_TR_DEBUG, ("adsGetFilter Error %lu", ulRetVal)); - hb_retc( "" ); + hb_retc( NULL ); } if( pucFilter2 ) @@ -1137,7 +1094,7 @@ HB_FUNC( ADSGETFILTER ) } else { - hb_retc( "" ); + hb_retc( NULL ); } } @@ -1147,20 +1104,22 @@ HB_FUNC( ADSENABLEENCRYPTION ) UNSIGNED32 ulRetVal; char * pucPassword = hb_parcx( 1 ); - if( !pucPassword || ( strlen( pucPassword ) == 0 ) ) + if( pucPassword && strlen( pucPassword ) ) { - hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSENABLEENCRYPTION" ); - return; - } - pArea = hb_rddGetADSWorkAreaPointer(); - if( pArea ) - { - ulRetVal = AdsEnableEncryption( pArea->hTable, ( UNSIGNED8 * ) pucPassword ); - hb_retni( ulRetVal ); + pArea = hb_rddGetADSWorkAreaPointer(); + if( pArea ) + { + ulRetVal = AdsEnableEncryption( pArea->hTable, ( UNSIGNED8 * ) pucPassword ); + hb_retni( ulRetVal ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSENABLEENCRYPTION" ); + } } else { - hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSENABLEENCRYPTION" ); + hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSENABLEENCRYPTION" ); } } @@ -1252,13 +1211,13 @@ HB_FUNC( ADSDECRYPTRECORD ) HB_FUNC( ADSISENCRYPTIONENABLED ) { ADSAREAP pArea; - UNSIGNED16 usIsEnabled; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { + UNSIGNED16 usIsEnabled = 0; AdsIsEncryptionEnabled( pArea->hTable, &usIsEnabled ); - hb_retl( usIsEnabled ); + hb_retl( usIsEnabled != 0 ); } else { @@ -1269,13 +1228,13 @@ HB_FUNC( ADSISENCRYPTIONENABLED ) HB_FUNC( ADSISRECORDENCRYPTED ) { ADSAREAP pArea; - UNSIGNED16 usIsEnabled; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { + UNSIGNED16 usIsEnabled = 0; AdsIsRecordEncrypted( pArea->hTable, &usIsEnabled ); - hb_retl( usIsEnabled ); + hb_retl( usIsEnabled != 0 ); } else { @@ -1286,13 +1245,13 @@ HB_FUNC( ADSISRECORDENCRYPTED ) HB_FUNC( ADSISTABLEENCRYPTED ) { ADSAREAP pArea; - UNSIGNED16 usIsEnabled; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { + UNSIGNED16 usIsEnabled = 0; AdsIsTableEncrypted( pArea->hTable, &usIsEnabled ); - hb_retl( usIsEnabled ); + hb_retl( usIsEnabled != 0 ); } else { @@ -1302,11 +1261,10 @@ HB_FUNC( ADSISTABLEENCRYPTED ) HB_FUNC( ADSCONNECT ) { - UNSIGNED32 ulRetVal; - ADSHANDLE hConnect = 0; - - if( hb_pcount() > 0 && ISCHAR( 1 ) ) + if( ISCHAR( 1 ) ) { + ADSHANDLE hConnect = 0; + UNSIGNED32 ulRetVal; ulRetVal = AdsConnect( (UNSIGNED8*) hb_parcx( 1 ), &hConnect ); if( ulRetVal == AE_SUCCESS ) { @@ -1365,7 +1323,6 @@ HB_FUNC( ADSCREATESQLSTATEMENT ) UNSIGNED32 u32RetVal; ADSAREAP pArea; ADSHANDLE adsStatementHandle; - char szAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ]; BOOL fResult = FALSE; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); @@ -1379,7 +1336,7 @@ HB_FUNC( ADSCREATESQLSTATEMENT ) AdsStmtSetTableType( adsStatementHandle, ADS_CDX ); } #ifdef ADS_VFP /* Not defined below 9.00 */ - if( hb_parni( 2 ) == ADS_VFP ) + else if( hb_parni( 2 ) == ADS_VFP ) { AdsStmtSetTableType( adsStatementHandle, ADS_VFP ); } @@ -1394,6 +1351,8 @@ HB_FUNC( ADSCREATESQLSTATEMENT ) pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { + char szAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ]; + hb_strncpy( szAlias, ISCHAR( 1 ) ? hb_parc( 1 ) : "ADSSQL", HARBOUR_MAX_RDD_ALIAS_LENGTH ); pArea->atomAlias = hb_rddAllocWorkAreaAlias( szAlias, @@ -1419,7 +1378,6 @@ HB_FUNC( ADSCREATESQLSTATEMENT ) HB_FUNC( ADSEXECUTESQLDIRECT ) { UNSIGNED32 ulRetVal; - ADSHANDLE hCursor = 0; ADSAREAP pArea; /* -----------------10/9/2005 2:51PM----------------- @@ -1435,6 +1393,7 @@ bh removed test for adsConnectHandle as it is not actually used; && pArea->hStatement && ISCHAR( 1 ) ) { char * pucStmt = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) ); + ADSHANDLE hCursor = 0; ulRetVal = AdsExecuteSQLDirect( pArea->hStatement, (UNSIGNED8 *) pucStmt, &hCursor ); hb_adsOemAnsiFree( pucStmt ); @@ -1509,7 +1468,6 @@ bh removed test for adsConnectHandle as it is not actually used; HB_FUNC( ADSEXECUTESQL ) { UNSIGNED32 ulRetVal; - ADSHANDLE hCursor = 0; ADSAREAP pArea; /* -----------------10/9/2005 2:51PM----------------- @@ -1524,6 +1482,8 @@ bh removed test for adsConnectHandle as it is not actually used; if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) != 0 && pArea->hStatement ) { + ADSHANDLE hCursor = 0; + ulRetVal = AdsExecuteSQL( pArea->hStatement, &hCursor ); if( ulRetVal == AE_SUCCESS ) { @@ -1586,65 +1546,48 @@ HB_FUNC( ADSCOPYTABLE ) ADSAREAP pArea; UNSIGNED32 ulRetVal; - UNSIGNED16 usFilterOption = ADS_RESPECTFILTERS; - ADSHANDLE hIndex ; + ADSHANDLE hIndex; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { if( ISCHAR( 1 ) ) { - if( ISNUM( 2 ) ) - { - usFilterOption = (UNSIGNED16) hb_parni( 2 ); - } + UNSIGNED16 usFilterOption = ISNUM( 2 ) ? (UNSIGNED16) 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 ) ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - return; - } + hb_retl( ulRetVal == AE_SUCCESS ); } else { hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSCOPYTABLE" ); - return; } } else { hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCOPYTABLE" ); } - hb_retl( FALSE ); - } HB_FUNC( ADSCONVERTTABLE ) { ADSAREAP pArea; - UNSIGNED16 usTableType = ADS_ADT; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { if( ISCHAR( 1 ) ) { - if( ISNUM( 2 ) ) - { - usTableType = hb_parni( 2 ); - if( usTableType < 1 || usTableType > 3 ) - usTableType = ADS_ADT; - } + UNSIGNED16 usTableType = ISNUM( 2 ) ? hb_parni( 2 ) : ADS_ADT; + AdsConvertTable( pArea->hTable, ADS_IGNOREFILTERS, (UNSIGNED8 *) hb_parcx( 1 ), usTableType ); } else { hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSCONVERTTABLE" ); - return; } } else @@ -1680,13 +1623,12 @@ HB_FUNC( ADSREGCALLBACK ) { UNSIGNED32 ulRetVal; - /* Note: current implementation is not thread safe. + /* 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". - */ if( ISBLOCK( 1 ) ) @@ -1731,20 +1673,13 @@ HB_FUNC( ADSISINDEXED ) { ADSAREAP pArea; pArea = hb_rddGetADSWorkAreaPointer(); - if( pArea ) - { - hb_retl( pArea->hOrdCurrent ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( pArea && pArea->hOrdCurrent != 0 ); } HB_FUNC( ADSISEXPRVALID ) /* cExpr */ { ADSAREAP pArea; - UNSIGNED16 bValidExpr = FALSE; + UNSIGNED16 bValidExpr = 0; pArea = hb_rddGetADSWorkAreaPointer(); if( pArea && ISCHAR( 1 ) ) @@ -1752,7 +1687,7 @@ HB_FUNC( ADSISEXPRVALID ) /* cExpr */ AdsIsExprValid( pArea->hTable, (UNSIGNED8*) hb_parc( 1 ), &bValidExpr ); } - hb_retl( bValidExpr != FALSE ); + hb_retl( bValidExpr ); } HB_FUNC( ADSGETNUMINDEXES ) /* cExpr */ @@ -1771,26 +1706,19 @@ HB_FUNC( ADSGETNUMINDEXES ) /* cExpr */ HB_FUNC( ADSCONNECTION ) // Get/Set func to switch between connections { - ADSHANDLE hOldHandle = adsConnectHandle; + HB_ADS_RETCONNECTION( adsConnectHandle ); adsConnectHandle = HB_ADS_PARCONNECTION( 1 ); - HB_ADS_RETCONNECTION( hOldHandle ); } HB_FUNC( ADSGETHANDLETYPE ) // DD, admin, table { - UNSIGNED32 ulRetVal ; - UNSIGNED16 usType; + UNSIGNED32 ulRetVal; + UNSIGNED16 usType = AE_INVALID_HANDLE; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); ulRetVal = AdsGetHandleType( hConnect, &usType); - if( ulRetVal == AE_SUCCESS ) - { - hb_retnl( usType ); - }else - { - hb_retnl( AE_INVALID_HANDLE ); - } + hb_retnl( ulRetVal == AE_SUCCESS ? usType : AE_INVALID_HANDLE ); } @@ -1799,9 +1727,9 @@ HB_FUNC( ADSGETLASTERROR ) { /* nLastErr := AdsGetLastError( [ @cLastErr ] ) */ - UNSIGNED32 ulLastErr; - UNSIGNED16 usLength = ADS_MAX_ERROR_LEN + 1; + UNSIGNED32 ulLastErr = 0; UNSIGNED8 aucError[ ADS_MAX_ERROR_LEN + 1 ]; + UNSIGNED16 usLength = ADS_MAX_ERROR_LEN + 1; AdsGetLastError( &ulLastErr, aucError, &usLength ); @@ -1829,53 +1757,33 @@ HB_FUNC( ADSSHOWERROR ) HB_FUNC( ADSBEGINTRANSACTION ) { - ADSHANDLE hConnect = ISNUM( 1 ) ? hb_parnl( 1 ) : 0; + ADSHANDLE hConnect = hb_parnl( 1 ); - if( AdsBeginTransaction( hConnect ) == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( AdsBeginTransaction( hConnect ) == AE_SUCCESS ); } HB_FUNC( ADSCOMMITTRANSACTION ) { - ADSHANDLE hConnect = ISNUM( 1 ) ? hb_parnl( 1 ) : 0; + ADSHANDLE hConnect = hb_parnl( 1 ); - if( AdsCommitTransaction( hConnect ) == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( AdsCommitTransaction( hConnect ) == AE_SUCCESS ); } HB_FUNC( ADSFAILEDTRANSACTIONRECOVERY ) { - UNSIGNED8 *pucServer = ( UNSIGNED8 *) ( ISCHAR( 1 ) ? hb_parcx( 1 ) : NULL ); + UNSIGNED8 *pucServer = ( UNSIGNED8 *) hb_parc( 1 ); - if( AdsFailedTransactionRecovery( pucServer ) == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( AdsFailedTransactionRecovery( pucServer ) == AE_SUCCESS ); } HB_FUNC( ADSINTRANSACTION ) { - ADSHANDLE hConnect = ISNUM( 1 ) ? hb_parnl( 1 ) : 0; - UNSIGNED16 pbInTrans; + ADSHANDLE hConnect = hb_parnl( 1 ); + UNSIGNED16 pbInTrans = 0; - if( AdsInTransaction( hConnect, &pbInTrans ) == AE_SUCCESS ) + if( AdsInTransaction( hConnect, + &pbInTrans ) == AE_SUCCESS ) { hb_retl( pbInTrans ); } @@ -1888,16 +1796,9 @@ HB_FUNC( ADSINTRANSACTION ) HB_FUNC( ADSROLLBACK ) { - ADSHANDLE hConnect = ISNUM( 1 ) ? hb_parnl( 1 ) : 0; + ADSHANDLE hConnect = hb_parnl( 1 ); - if( AdsRollbackTransaction( hConnect ) == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( AdsRollbackTransaction( hConnect ) == AE_SUCCESS ); } /* @@ -1907,23 +1808,20 @@ HB_FUNC( ADSROLLBACK ) */ HB_FUNC( ADSCACHERECORDS ) { - UNSIGNED32 ulRetVal ; + UNSIGNED32 ulRetVal = ~AE_SUCCESS; ADSAREAP pArea; - ulRetVal = FALSE; - pArea = hb_rddGetADSWorkAreaPointer(); if( pArea ) { ulRetVal = AdsCacheRecords( pArea->hTable, hb_parni( 1 ) ); + hb_retl( ulRetVal == AE_SUCCESS ); } if( !pArea || ulRetVal != AE_SUCCESS ) { - hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCACHERECORDS" ); + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSCACHERECORDS" ); } - - hb_retl( ulRetVal ); } /* @@ -1947,44 +1845,37 @@ HB_FUNC( ADSREINDEX ) ulRetVal = AdsReindex( ( ADSHANDLE ) -1 ); // should return error! } - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSVERSION ) { - int iVersionType = ISNUM( 1 ) ? hb_parni( 1 ) : 0; UNSIGNED32 ulMajor; UNSIGNED32 ulMinor; UNSIGNED8 ucLetter; - UNSIGNED8 ucDesc[128]; - UNSIGNED16 usDescLen = sizeof( ucDesc ) - 1, usPos; - char ucVersion[256]; + UNSIGNED8 ucDesc[ 128 ]; + UNSIGNED16 usDescLen = sizeof( ucDesc ) - 1; + UNSIGNED16 usPos; + char ucVersion[ 256 ]; AdsGetVersion( &ulMajor, &ulMinor, &ucLetter, ucDesc, &usDescLen ); - switch( iVersionType ) + 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 ); + snprintf( ucVersion, sizeof( ucVersion ), "%s, v%ld.%ld%c", ( char * ) ucDesc, ulMajor, ulMinor, ucLetter ); break; default: - ucVersion[0] = 0; + ucVersion[ 0 ] = '\0'; } usPos = strlen( ucVersion ) - 1; - while( ucVersion[usPos] == 0x20 && usPos > 0 ) // remove trailing spaces + while( ucVersion[usPos] == ' ' && usPos > 0 ) // remove trailing spaces { - ucVersion[usPos--] = 0; + ucVersion[ usPos-- ] = '\0'; } hb_retc( ucVersion ); @@ -2010,31 +1901,36 @@ HB_FUNC( ADSCACHEOPENCURSORS ) HB_FUNC( ADSISEMPTY ) { UNSIGNED32 ulRetVal = ~AE_SUCCESS; - UNSIGNED16 pbEmpty = FALSE; + UNSIGNED16 pbEmpty = 0; ADSAREAP pArea; UNSIGNED8* pucFldName; pArea = hb_rddGetADSWorkAreaPointer(); - if( ! ISCHAR( 1 ) && ! ISNUM( 1 ) ) + if( ISCHAR( 1 ) || ISNUM( 1 ) ) + { + if( pArea ) + { + pucFldName = ( ISCHAR( 1 ) ? ( UNSIGNED8* ) hb_parcx( 1 ) : ADSFIELD( hb_parni( 1 ) ) ); + ulRetVal = AdsIsEmpty( pArea->hTable, pucFldName, &pbEmpty ); + } + + if( pArea && ulRetVal == AE_SUCCESS ) + { + hb_retl( pbEmpty ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISEMPTY" ); + } + } + else { hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSISEMPTY" ); - return; } - else if( pArea ) - { - pucFldName = ( ISCHAR( 1 ) ? ( UNSIGNED8* ) hb_parcx( 1 ) : ADSFIELD( hb_parni( 1 ) ) ); - ulRetVal = AdsIsEmpty( pArea->hTable, pucFldName, &pbEmpty ); - } - - if( ! pArea || ulRetVal != AE_SUCCESS ) - { - hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSISEMPTY" ); - return; - } - - hb_retl( pbEmpty ); } +/* Please add all-version functions above this block */ + #if ADS_LIB_VERSION >= 620 HB_FUNC( ADSGETNUMACTIVELINKS ) // Only valid for a DataDict @@ -2046,6 +1942,7 @@ HB_FUNC( ADSGETNUMACTIVELINKS ) // Only valid for a DataDict { AdsGetNumActiveLinks( hConnect, &pusNumLinks ); } + hb_retnl( pusNumLinks ); } @@ -2063,14 +1960,7 @@ HB_FUNC( ADSDDADDTABLE ) ulRetVal = AdsDDAddTable( hConnect, pTableName, pTableFileName, adsFileType, adsCharType, pTableIndexFileName, NULL ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSDDREMOVETABLE ) @@ -2082,14 +1972,7 @@ HB_FUNC( ADSDDREMOVETABLE ) ulRetVal = AdsDDRemoveTable( hConnect, pTableName, usDeleteFiles ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSDDREMOVEINDEXFILE ) @@ -2102,14 +1985,7 @@ HB_FUNC( ADSDDREMOVEINDEXFILE ) ulRetVal = AdsDDRemoveIndexFile( hConnect, pTableName, pIndexName, usDeleteFiles ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSDDADDUSERTOGROUP ) @@ -2121,15 +1997,7 @@ HB_FUNC( ADSDDADDUSERTOGROUP ) ulRetVal = AdsDDAddUserToGroup( hConnect, pGroup, pName ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } - + hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSDDREMOVEUSERFROMGROUP ) @@ -2141,15 +2009,7 @@ HB_FUNC( ADSDDREMOVEUSERFROMGROUP ) ulRetVal = AdsDDRemoveUserFromGroup( hConnect, pGroup, pName ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } - + hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSCONNECT60 ) @@ -2157,8 +2017,8 @@ HB_FUNC( ADSCONNECT60 ) UNSIGNED32 ulRetVal ; UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 1 ); UNSIGNED16 usServerTypes = (UNSIGNED16) hb_parni( 2 ); - UNSIGNED8 *pucUserName = ISCHAR( 3 ) ? (UNSIGNED8 *) hb_parcx( 3 ) : NULL ; - UNSIGNED8 *pucPassword = ISCHAR( 4 ) ? (UNSIGNED8 *) hb_parcx( 4 ) : NULL ; + UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 3 ); + UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 4 ); UNSIGNED32 ulOptions = ISNUM( 5 ) ? hb_parnl( 5 ) : ADS_DEFAULT ; ADSHANDLE hConnect = 0; @@ -2177,6 +2037,7 @@ HB_FUNC( ADSCONNECT60 ) { hb_stornl( hConnect, 6 ); } + hb_retl( TRUE ); } else @@ -2190,12 +2051,12 @@ 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 = ISCHAR( 3 ) ? (UNSIGNED8 *) hb_parcx( 3 ) : NULL; + 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 ) @@ -2212,10 +2073,10 @@ HB_FUNC( ADSDDCREATE ) HB_FUNC( ADSDDCREATEUSER ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pucGroupName = ISCHAR( 1 ) ? (UNSIGNED8 *) hb_parcx( 1 ) : NULL; - UNSIGNED8 *pucUserName = ISCHAR( 2 ) ? (UNSIGNED8 *) hb_parcx( 2 ) : NULL; - UNSIGNED8 *pucPassword = ISCHAR( 3 ) ? (UNSIGNED8 *) hb_parcx( 3 ) : NULL; - UNSIGNED8 *pucDescription = ISCHAR( 4 ) ? (UNSIGNED8 *) hb_parcx( 4 ) : NULL; + 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, @@ -2226,7 +2087,7 @@ HB_FUNC( ADSDDCREATEUSER ) HB_FUNC( ADSDDDELETEUSER ) { UNSIGNED32 ulRetVal; - UNSIGNED8 *pucUserName = ISCHAR( 1 ) ? (UNSIGNED8 *) hb_parcx( 1 ) : NULL; + UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 1 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); ulRetVal = AdsDDDeleteUser( hConnect, pucUserName ); @@ -2236,66 +2097,76 @@ HB_FUNC( ADSDDDELETEUSER ) HB_FUNC( ADSDDGETDATABASEPROPERTY ) { UNSIGNED16 ulProperty = ( UNSIGNED16 ) hb_parni( 1 ); - char sBuffer[ ADS_MAX_PARAMDEF_LEN ]; - UNSIGNED16 ulLength; - UNSIGNED16 ulBuffer; - UNSIGNED32 ulRetVal; - BOOL bChar = FALSE; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); switch( ulProperty ) { + /* String properties */ case ADS_DD_COMMENT: case ADS_DD_DEFAULT_TABLE_PATH: case ADS_DD_USER_DEFINED_PROP: case ADS_DD_TEMP_TABLE_PATH: - /*case ADS_DD_ADMIN_PASSWORD: not valid to retrieve */ case ADS_DD_VERSION: + case ADS_DD_ENCRYPT_TABLE_PASSWORD: +#if ADS_LIB_VERSION >= 710 + case ADS_DD_FTS_DELIMITERS: + case ADS_DD_FTS_NOISE: + case ADS_DD_FTS_DROP_CHARS: + case ADS_DD_FTS_CONDITIONAL_CHARS: + case ADS_DD_LOGINS_DISABLED_ERRSTR: +#endif { - ulLength = ADS_MAX_PARAMDEF_LEN ; - bChar = TRUE ; - ulRetVal = AdsDDGetDatabaseProperty( hConnect, ulProperty, &sBuffer, &ulLength ); - if( ulRetVal != AE_SUCCESS ) - { - sBuffer[0] = 0; - ulLength = 0; /* Current structure of this func doesn't give a good way to handle errors */ - } - else + char sBuffer[ ADS_MAX_PARAMDEF_LEN ]; + UNSIGNED16 ulLength = sizeof( sBuffer ); + + if( AdsDDGetDatabaseProperty( hConnect, ulProperty, &sBuffer, &ulLength ) != AE_SUCCESS ) { + /* TODO: Better error handling. */ + sBuffer[ 0 ] = '\0'; + ulLength = 0; } + hb_retclen( sBuffer, ulLength ); break; } + /* Boolean properties */ case ADS_DD_LOG_IN_REQUIRED: case ADS_DD_VERIFY_ACCESS_RIGHTS: - case ADS_DD_ENCRYPT_TABLE_PASSWORD: case ADS_DD_ENCRYPT_NEW_TABLE: +#if ADS_LIB_VERSION >= 710 + case ADS_DD_ENCRYPTED: + case ADS_DD_LOGINS_DISABLED: +#endif +#if ADS_LIB_VERSION >= 800 + case ADS_DD_ENCRYPT_INDEXES: + case ADS_DD_ENCRYPT_COMMUNICATION: +#endif { - ulLength = sizeof( UNSIGNED16 ); + UNSIGNED16 ulBuffer; + UNSIGNED16 ulLength = sizeof( ulBuffer ); + AdsDDGetDatabaseProperty( hConnect, ulProperty, &ulBuffer, &ulLength ); + hb_retl( ulBuffer != 0 ); break; } - } + /* Integer properties */ +#if ADS_LIB_VERSION >= 620 + case ADS_DD_VERSION_MAJOR: + case ADS_DD_VERSION_MINOR: + { + UNSIGNED16 ulBuffer; + UNSIGNED16 ulLength = sizeof( ulBuffer ); - if( ulProperty == ADS_DD_LOG_IN_REQUIRED || ulProperty == ADS_DD_VERIFY_ACCESS_RIGHTS || ulProperty == ADS_DD_ENCRYPT_NEW_TABLE ) - { - hb_retl( ulBuffer ); - } - else if( bChar ) - { - hb_retclen( sBuffer, ulLength ); - } - else - { - hb_retnl( ulBuffer ); + AdsDDGetDatabaseProperty( hConnect, ulProperty, &ulBuffer, &ulLength ); + hb_retnl( ulBuffer ); + break; + } +#endif } } HB_FUNC( ADSDDSETDATABASEPROPERTY ) { - - // char * szProperty; - // UNSIGNED16 ulLength; UNSIGNED32 ulRetVal; UNSIGNED16 ulBuffer; UNSIGNED16 ulProperty = ( UNSIGNED16 ) hb_parni( 1 ); @@ -2304,6 +2175,7 @@ HB_FUNC( ADSDDSETDATABASEPROPERTY ) switch( ulProperty ) { + /* String properties (NULL accepted) */ case ADS_DD_COMMENT: case ADS_DD_DEFAULT_TABLE_PATH: case ADS_DD_USER_DEFINED_PROP: @@ -2311,9 +2183,40 @@ HB_FUNC( ADSDDSETDATABASEPROPERTY ) case ADS_DD_ADMIN_PASSWORD: case ADS_DD_ENCRYPT_TABLE_PASSWORD: { - ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, hb_itemGetCPtr( pParam ), ( UNSIGNED16 ) hb_itemGetCLen( pParam )+1 ); + ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, HB_IS_STRING( pParam ) ? hb_itemGetCPtr( pParam ) : NULL, ( UNSIGNED16 ) hb_itemGetCLen( pParam ) + 1 ); break; } + /* String properties (NULL not accepted) */ +#if ADS_LIB_VERSION >= 710 + case ADS_DD_FTS_DELIMITERS: + case ADS_DD_FTS_NOISE: + case ADS_DD_FTS_DROP_CHARS: + case ADS_DD_FTS_CONDITIONAL_CHARS: + case ADS_DD_LOGINS_DISABLED_ERRSTR: + { + ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, hb_itemGetCPtr( pParam ), ( UNSIGNED16 ) hb_itemGetCLen( pParam ) + 1 ); + break; + } +#endif + /* Boolean properties */ + case ADS_DD_LOG_IN_REQUIRED: + case ADS_DD_VERIFY_ACCESS_RIGHTS: + case ADS_DD_ENCRYPT_NEW_TABLE: + case ADS_DD_ENABLE_INTERNET: +#if ADS_LIB_VERSION >= 710 + case ADS_DD_LOGINS_DISABLED: +#endif +#if ADS_LIB_VERSION >= 800 + case ADS_DD_DISABLE_DLL_CACHING: + case ADS_DD_ENCRYPT_INDEXES: + case ADS_DD_ENCRYPT_COMMUNICATION: +#endif + { + ulBuffer = hb_itemGetL( pParam ); + ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, &ulBuffer, sizeof( ulBuffer ) ); + break; + } + /* Integer properties */ case ADS_DD_MAX_FAILED_ATTEMPTS: case ADS_DD_INTERNET_SECURITY_LEVEL: #if ADS_LIB_VERSION >= 620 @@ -2322,16 +2225,7 @@ HB_FUNC( ADSDDSETDATABASEPROPERTY ) #endif { ulBuffer = hb_itemGetNI( pParam ); - ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, &ulBuffer, 2 ); - break; - } - case ADS_DD_LOG_IN_REQUIRED: - case ADS_DD_VERIFY_ACCESS_RIGHTS: - case ADS_DD_ENCRYPT_NEW_TABLE: - case ADS_DD_ENABLE_INTERNET: - { - ulBuffer = hb_itemGetL( pParam ); - ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, &ulBuffer, 2 ); + ulRetVal = AdsDDSetDatabaseProperty( hConnect, ulProperty, &ulBuffer, sizeof( ulBuffer ) ); break; } default: @@ -2340,53 +2234,42 @@ HB_FUNC( ADSDDSETDATABASEPROPERTY ) break; } } + hb_retl( ulRetVal == AE_SUCCESS ); } -/* -UNSIGNED32 ENTRYPOINT AdsDDGetUserProperty( ADSHANDLE hObject, - UNSIGNED8 *pucUserName, - UNSIGNED16 usPropertyID, - VOID *pvProperty, - UNSIGNED16 *pusPropertyLen ); -*/ HB_FUNC( ADSDDGETUSERPROPERTY ) { - UNSIGNED32 ulRetVal; UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parcx( 1 ); UNSIGNED16 usPropertyID = hb_parni( 2 ); - BOOL fPropertyByRef = ISBYREF( 3 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 4 ); - UNSIGNED16 usPropertyLen = ADS_MAX_PARAMDEF_LEN ; - UNSIGNED8 pvProperty[ ADS_MAX_PARAMDEF_LEN ] = { 0 }; + UNSIGNED8 pvProperty[ ADS_MAX_PARAMDEF_LEN ] = { 0 }; + UNSIGNED16 usPropertyLen = ADS_MAX_PARAMDEF_LEN; - if( ! fPropertyByRef ) + if( ISBYREF( 3 ) /* fPropertyByRef */ ) { - hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSDDGETUSERPROPERTY" ); - return; - } + ulRetVal = AdsDDGetUserProperty( hConnect, + pucUserName, + usPropertyID, + pvProperty, + &usPropertyLen ); - ulRetVal = AdsDDGetUserProperty( hConnect, pucUserName, usPropertyID, - pvProperty, &usPropertyLen ); + hb_storc( ulRetVal == AE_SUCCESS ? ( char * ) pvProperty : NULL, 3 ); - if(ulRetVal == AE_SUCCESS ) - { - hb_storc( (char *) pvProperty, 3 ); + hb_retl( ulRetVal == AE_SUCCESS ); } else { - hb_storc( "", 3 ); + hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSDDGETUSERPROPERTY" ); } - - hb_retl( ulRetVal == AE_SUCCESS ); } /* Verify if a username/password combination is valid for this database - Call : ADSTESTLOGIN(serverpath,servertypes,username,password,options, - [userproperty,buffer,bufferlength]) + Call : ADSTESTLOGIN( serverpath, servertypes, username, password, options, + [ userproperty, buffer, bufferlength ] ) Returns : True if login succeeds Notes: This creates a temporary connection only during the execution of this @@ -2402,12 +2285,12 @@ HB_FUNC( ADSTESTLOGIN ) UNSIGNED32 ulRetVal ; UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 1 ); UNSIGNED16 usServerTypes = (UNSIGNED16) hb_parni( 2 ); - UNSIGNED8 *pucUserName = ISCHAR( 3 ) ? (UNSIGNED8 *) hb_parcx( 3 ) : NULL; - UNSIGNED8 *pucPassword = ISCHAR( 4 ) ? (UNSIGNED8 *) hb_parcx( 4 ) : NULL; + UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 3 ); + UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 4 ); UNSIGNED32 ulOptions = ISNUM( 5 ) ? hb_parnl( 5 ) : ADS_DEFAULT; - UNSIGNED16 usPropertyID = ISNUM( 6 ) ? hb_parni( 6 ) : 0; - UNSIGNED8 *pvProperty = ISCHAR( 7 ) ? (UNSIGNED8 *) hb_parcx( 7 ) : NULL; - UNSIGNED16 usPropertyLen = ISNUM( 8 ) ? hb_parni( 8 ) : 0; + UNSIGNED16 usPropertyID = hb_parni( 6 ); + UNSIGNED8 *pvProperty = (UNSIGNED8 *) hb_parc( 7 ); + UNSIGNED16 usPropertyLen = hb_parni( 8 ); ADSHANDLE adsTestHandle; ulRetVal = AdsConnect60( pucServerPath, @@ -2419,7 +2302,7 @@ HB_FUNC( ADSTESTLOGIN ) if( ulRetVal == AE_SUCCESS ) { - if( usPropertyLen > 0 ) + if( usPropertyLen ) { AdsDDGetUserProperty( adsTestHandle, pucUserName, usPropertyID, pvProperty, &usPropertyLen ); @@ -2435,15 +2318,6 @@ HB_FUNC( ADSTESTLOGIN ) HB_FUNC( ADSRESTRUCTURETABLE ) { - // call: - // AdsRestructureTable( cTable, cAddFields, cDeleteFields, cChangeFields ) - - //UNSIGNED32 AdsRestructureTable( ADSHANDLE hConnect,UNSIGNED8 *pucName, - // UNSIGNED8 *pucAlias,UNSIGNED16 usTableType,UNSIGNED16 usCharType, - // UNSIGNED16 usLockType,UNSIGNED16 usCheckRights,UNSIGNED8 - // *pucAddFields,UNSIGNED8 *pucDeleteFields,UNSIGNED8 *pucChangeFields ); - //adsFileType ADS_DEFAULT, ADS_ADT, ADS_NTX and ADS_CDX - UNSIGNED32 ulRetVal; UNSIGNED8 *pTableName = (UNSIGNED8 *) hb_parcx( 1 ); UNSIGNED8 *pucAddFields = (UNSIGNED8 *) hb_parcx( 2 ); @@ -2451,15 +2325,18 @@ HB_FUNC( ADSRESTRUCTURETABLE ) UNSIGNED8 *pucChangeFields = (UNSIGNED8 *) hb_parcx( 4 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 5 ); - ulRetVal = AdsRestructureTable( hConnect, pTableName, NULL, - adsFileType, adsCharType, adsLockType, - adsRights, - pucAddFields, - pucDeleteFields, - pucChangeFields ); - - hb_retl( (long) ulRetVal ); + ulRetVal = AdsRestructureTable( hConnect, + pTableName, + NULL /* pucAlias */, + adsFileType, + adsCharType, + adsLockType, + adsRights, + pucAddFields, + pucDeleteFields, + pucChangeFields ); + hb_retl( ulRetVal == AE_SUCCESS ); } HB_FUNC( ADSCOPYTABLECONTENTS ) @@ -2480,14 +2357,7 @@ HB_FUNC( ADSCOPYTABLECONTENTS ) ulRetVal = AdsCopyTableContents( pArea->hTable, pDest->hTable, ADS_IGNOREFILTERS ); - if( ulRetVal == AE_SUCCESS ) - { - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } + hb_retl( ulRetVal == AE_SUCCESS ); } } else @@ -2501,30 +2371,30 @@ HB_FUNC( ADSCOPYTABLECONTENTS ) } } - HB_FUNC( ADSDIRECTORY ) { UNSIGNED32 ulRetVal; UNSIGNED8 ucFileName[ ADS_MAX_TABLE_NAME ]; - UNSIGNED16 usFileNameLen; + UNSIGNED16 usFileNameLen = ADS_MAX_TABLE_NAME; #if ADS_LIB_VERSION >= 900 ADSHANDLE sHandle = 0; #else SIGNED32 sHandle = 0; #endif - PHB_ITEM pitmDir, pitmFileName; + PHB_ITEM pitmDir; + PHB_ITEM pitmFileName; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); pitmDir = hb_itemNew( NULL ); hb_arrayNew( pitmDir, 0 ); - usFileNameLen = ADS_MAX_TABLE_NAME; - ulRetVal = AdsFindFirstTable( hConnect, ( UNSIGNED8* ) ( ISCHAR( 1 ) ? hb_parcx( 1 ) : "" ), ( UNSIGNED8* ) ucFileName, &usFileNameLen, &sHandle ); - if( ulRetVal == AE_SUCCESS || ulRetVal == AE_NO_FILE_FOUND ) + 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 ); + pitmFileName = hb_itemPutCL( NULL, ( char * ) ucFileName, usFileNameLen ); hb_arrayAddForward( pitmDir, pitmFileName ); usFileNameLen = ADS_MAX_TABLE_NAME; @@ -2536,29 +2406,20 @@ HB_FUNC( ADSDIRECTORY ) hb_itemReturnRelease( pitmDir ); } - HB_FUNC( ADSCHECKEXISTENCE ) { - UNSIGNED16 usExist; + UNSIGNED16 usExist = 0; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); hb_retl( AdsCheckExistence( hConnect, ( UNSIGNED8* ) hb_parcx( 1 ), &usExist ) == AE_SUCCESS && usExist ); } - -/* Function is not documented, but exists in ace32.dll version 6.x, 7.x */ -#ifdef __cplusplus - extern "C" -#endif -UNSIGNED32 ENTRYPOINT AdsDeleteFile( ADSHANDLE hConnection, UNSIGNED8* pucFileName ); - HB_FUNC( ADSDELETEFILE ) { ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); hb_retl( AdsDeleteFile( hConnect, ( UNSIGNED8* ) hb_parcx( 1 ) ) == AE_SUCCESS ); } - HB_FUNC( ADSSTMTSETTABLEPASSWORD ) { ADSAREAP pArea; @@ -2567,45 +2428,49 @@ HB_FUNC( ADSSTMTSETTABLEPASSWORD ) char * pucPassword = hb_parcx( 2 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); - if( !pucTableName || ( strlen( pucTableName ) == 0 ) || !pucPassword || ( strlen( pucPassword ) == 0 ) ) + if( pucTableName && strlen( pucTableName ) && + pucPassword && strlen( pucPassword ) ) { - hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSSTMTSETTABLEPASSWORD" ); - hb_retni( 0 ); - } - - if( !hConnect ) - { - hb_errRT_DBCMD( EG_NOTABLE, AE_NO_CONNECTION, NULL, "AE_NO_CONNECTION" ); - hb_retni( 0 ); - } - - pArea = hb_rddGetADSWorkAreaPointer(); - - if( pArea ) - { - ulRetVal = AdsStmtSetTablePassword( pArea->hStatement, ( UNSIGNED8 * ) pucTableName, ( UNSIGNED8 * ) pucPassword ); - hb_retni( ulRetVal ); + if( hConnect ) + { + pArea = hb_rddGetADSWorkAreaPointer(); + + if( pArea ) + { + ulRetVal = AdsStmtSetTablePassword( pArea->hStatement, ( UNSIGNED8 * ) pucTableName, ( UNSIGNED8 * ) pucPassword ); + hb_retni( ulRetVal ); + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSSTMTSETTABLEPASSWORD" ); + } + } + else + { + hb_errRT_DBCMD( EG_NOTABLE, AE_NO_CONNECTION, NULL, "AE_NO_CONNECTION" ); + } } else { - hb_errRT_DBCMD( EG_NOTABLE, 2001, NULL, "ADSSTMTSETTABLEPASSWORD" ); + hb_errRT_DBCMD( EG_ARG, 1014, NULL, "ADSSTMTSETTABLEPASSWORD" ); } - } HB_FUNC( ADSGETSERVERNAME ) { ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - UNSIGNED16 usLen = 256; UNSIGNED8 buf[ 256 ]; + UNSIGNED16 usLen = 256; if( AdsGetServerName( hConnect, buf, &usLen ) == AE_SUCCESS ) { hb_retclen( ( char * ) buf, usLen ); } + + /* QUESTION: Design decision or mistake to return NIL on error? [vszakats] */ } -#endif /* ADS_LIB_VERSION >= 600 */ +#endif /* ADS_LIB_VERSION >= 600 */ #if ADS_LIB_VERSION >= 700 @@ -2624,7 +2489,7 @@ HB_FUNC( ADSCLOSECACHEDTABLES ) } } -#endif /* ADS_LIB_VERSION >= 700 */ +#endif /* ADS_LIB_VERSION >= 700 */ #if ADS_LIB_VERSION >= 800 @@ -2639,9 +2504,10 @@ HB_FUNC( ADSCREATESAVEPOINT ) HB_FUNC( ADSROLLBACKSAVEPOINT ) { - ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); - char* pucSavepoint = hb_parc( 2 ); - UNSIGNED32 ulOptions = ADS_DEFAULT; + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); + char * pucSavepoint = hb_parc( 2 ); + UNSIGNED32 ulOptions = ADS_DEFAULT; + hb_retnl( AdsRollbackTransaction80( hConnect, (UNSIGNED8 *) pucSavepoint, ulOptions ) ); } @@ -2655,16 +2521,16 @@ HB_FUNC( ADSDDCREATELINK ) ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); UNSIGNED8 *pucLinkAlias = (UNSIGNED8 *) hb_parcx( 2 ); UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 3 ); - UNSIGNED8 *pucUserName = ISCHAR( 4 ) ? (UNSIGNED8 *) hb_parcx( 4 ) : NULL; - UNSIGNED8 *pucPassword = ISCHAR( 5 ) ? (UNSIGNED8 *) hb_parcx( 5 ) : NULL; + UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 4 ); + UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 5 ); UNSIGNED32 ulOptions = ISNUM( 6 ) ? hb_parnl( 6 ) : ADS_DEFAULT; - ulRetVal = AdsDDCreateLink( hConnect , - pucLinkAlias , - pucServerPath , - pucUserName , - pucPassword , - ulOptions ); + ulRetVal = AdsDDCreateLink( hConnect , + pucLinkAlias , + pucServerPath , + pucUserName , + pucPassword , + ulOptions ); hb_retl( ulRetVal == AE_SUCCESS ); } @@ -2675,8 +2541,8 @@ HB_FUNC( ADSDDMODIFYLINK ) ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 1 ); UNSIGNED8 *pucLinkAlias = (UNSIGNED8 *) hb_parcx( 2 ); UNSIGNED8 *pucServerPath = (UNSIGNED8 *) hb_parcx( 3 ); - UNSIGNED8 *pucUserName = ISCHAR( 4 ) ? (UNSIGNED8 *) hb_parcx( 4 ) : NULL; - UNSIGNED8 *pucPassword = ISCHAR( 5 ) ? (UNSIGNED8 *) hb_parcx( 5 ) : NULL; + UNSIGNED8 *pucUserName = (UNSIGNED8 *) hb_parc( 4 ); + UNSIGNED8 *pucPassword = (UNSIGNED8 *) hb_parc( 5 ); UNSIGNED32 ulOptions = ISNUM( 6 ) ? hb_parnl( 6 ) : ADS_DEFAULT; ulRetVal = AdsDDModifyLink( hConnect , @@ -2704,5 +2570,3 @@ HB_FUNC( ADSDDDROPLINK ) } #endif - -/* Please add all-version functions above this block */ diff --git a/harbour/contrib/rddads/adsmgmnt.c b/harbour/contrib/rddads/adsmgmnt.c index c725fddeac..e47f9f13b2 100644 --- a/harbour/contrib/rddads/adsmgmnt.c +++ b/harbour/contrib/rddads/adsmgmnt.c @@ -4,9 +4,9 @@ /* * Harbour Project source code: - * Advantage Database Server RDD ( Management functions ) + * Advantage Database Server RDD (Management functions) * - * Copyright 2001 Brian Hays + * Copyright 2001 Brian Hays * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -67,14 +67,10 @@ ADSHANDLE ads_g_hMgmtHandle = 0; HB_FUNC( ADSMGCONNECT ) { - /* ulRetVal = AdsMgConnect( "\\\\server\\volume:", NULL, NULL, &ads_g_hMgmtHandle ); - // UNSIGNED32 ENTRYPOINT AdsMgConnect( UNSIGNED8 *pucServerName, - // UNSIGNED8 *pucUserName, - // UNSIGNED8 *pucPassword, - // ADSHANDLE *pads_g_hMgmtHandle ); - */ - - hb_retnl( AdsMgConnect( (UNSIGNED8 *) hb_parcx(1), (UNSIGNED8 *) hb_parcx(2), (UNSIGNED8 *) hb_parcx(3), &ads_g_hMgmtHandle ) ); + hb_retnl( AdsMgConnect( (UNSIGNED8 *) hb_parcx( 1 ) /* pucServerName */, + (UNSIGNED8 *) hb_parcx( 2 ) /* pucUserName */, + (UNSIGNED8 *) hb_parcx( 3 ) /* pucPassword */, + &ads_g_hMgmtHandle ) ); } HB_FUNC( ADSMGDISCONNECT ) @@ -86,60 +82,63 @@ HB_FUNC( ADSMGDISCONNECT ) HB_FUNC( ADSMGGETINSTALLINFO ) { UNSIGNED32 ulRetVal; - UNSIGNED16 usStructSize; ADS_MGMT_INSTALL_INFO stInstallInfo; + UNSIGNED16 usStructSize = sizeof( ADS_MGMT_INSTALL_INFO ); - usStructSize = sizeof( ADS_MGMT_INSTALL_INFO ); ulRetVal = AdsMgGetInstallInfo( ads_g_hMgmtHandle, &stInstallInfo, &usStructSize ); /* - //if( sizeof( ADS_MGMT_INSTALL_INFO ) < usStructSize ) - // printf( "\nInstallation Information structure on server is larger." ); - // printf( "\nMore possible info available." ); + if( sizeof( ADS_MGMT_INSTALL_INFO ) < usStructSize ) + { + HB_TRACE(HB_TR_INFO, ("AdsMgGetInstallInfo() structure on the server is larger.\n" + "More info is available with newer client lib." )); + } */ if( ulRetVal == AE_SUCCESS ) { hb_reta( 8 ); - hb_stornl( stInstallInfo.ulUserOption , -1, 1 ); /* User option purchased*/ - hb_storc ( (char *) stInstallInfo.aucRegisteredOwner, -1, 2 ); /* Registered owner */ - hb_storc ( (char *) stInstallInfo.aucVersionStr , -1, 3 ); /* Advantage version */ - hb_storc ( (char *) stInstallInfo.aucInstallDate , -1, 4 ); /* Install date string */ - hb_storc ( (char *) stInstallInfo.aucOemCharName , -1, 5 ); /* OEM char language */ - hb_storc ( (char *) stInstallInfo.aucAnsiCharName , -1, 6 ); /* ANSI char language */ - hb_storc ( (char *) stInstallInfo.aucEvalExpireDate , -1, 7 ); /* Eval expiration date */ - hb_storc ( (char *) stInstallInfo.aucSerialNumber , -1, 8 ); /* Serial number string */ + hb_stornl( stInstallInfo.ulUserOption , -1, 1 ); /* User option purchased */ + hb_storc ( (char *) stInstallInfo.aucRegisteredOwner, -1, 2 ); /* Registered owner */ + hb_storc ( (char *) stInstallInfo.aucVersionStr , -1, 3 ); /* Advantage version */ + hb_storc ( (char *) stInstallInfo.aucInstallDate , -1, 4 ); /* Install date string */ + hb_storc ( (char *) stInstallInfo.aucOemCharName , -1, 5 ); /* OEM char language */ + hb_storc ( (char *) stInstallInfo.aucAnsiCharName , -1, 6 ); /* ANSI char language */ + hb_storc ( (char *) stInstallInfo.aucEvalExpireDate , -1, 7 ); /* Eval expiration date */ + hb_storc ( (char *) stInstallInfo.aucSerialNumber , -1, 8 ); /* Serial number string */ } } HB_FUNC( ADSMGGETACTIVITYINFO ) { UNSIGNED32 ulRetVal; - UNSIGNED16 usStructSize; ADS_MGMT_ACTIVITY_INFO stActivityInfo; + UNSIGNED16 usStructSize = sizeof( ADS_MGMT_ACTIVITY_INFO ); unsigned int iOption = hb_parni( 1 ); - usStructSize = sizeof( ADS_MGMT_ACTIVITY_INFO ); ulRetVal = AdsMgGetActivityInfo( ads_g_hMgmtHandle, &stActivityInfo, &usStructSize ); - /* - // if( sizeof( ADS_MGMT_ACTIVITY_INFO ) < usStructSize ) - // printf( "\nActivity Information structure on server is larger." ); - // printf( "\nMore possible info available." ); - */ + + /* + if( sizeof( ADS_MGMT_ACTIVITY_INFO ) < usStructSize ) + { + HB_TRACE(HB_TR_INFO, ("AdsMgGetActivityInfo() structure on the server is larger.\n" + "More info is available with newer client lib." )); + } + */ + if( iOption && ulRetVal == AE_SUCCESS ) { switch( iOption ) { - case 1 : + case 1: hb_retnl( stActivityInfo.ulOperations ); /* Number operations since started */ break; - case 2 : + case 2: hb_retnl( stActivityInfo.ulLoggedErrors ); /* Number logged errors */ break; - - case 3 : + case 3: hb_reta( 4 ); /* Length of time ADS has been up */ hb_stornl( stActivityInfo.stUpTime.usDays, -1, 1 ); hb_stornl( stActivityInfo.stUpTime.usHours, -1, 2 ); @@ -147,86 +146,75 @@ HB_FUNC( ADSMGGETACTIVITYINFO ) hb_stornl( stActivityInfo.stUpTime.usSeconds, -1, 4 ); break; - - case 4 : + case 4: hb_reta( 3 ); /* Users in use, max, rejected */ hb_stornl( stActivityInfo.stUsers.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stUsers.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stUsers.ulRejected, -1, 3 ); break; - - case 5 : + case 5: hb_reta( 3 ); /* Conns in use, max, rejected */ hb_stornl( stActivityInfo.stConnections.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stConnections.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stConnections.ulRejected, -1, 3 ); break; - - case 6 : + case 6: hb_reta( 3 ); /* WAs in use, max, rejected */ hb_stornl( stActivityInfo.stWorkAreas.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stWorkAreas.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stWorkAreas.ulRejected, -1, 3 ); break; - - case 7 : + case 7: hb_reta( 3 ); /* Tables in use, max, rejected */ hb_stornl( stActivityInfo.stTables.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stTables.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stTables.ulRejected, -1, 3 ); break; - - case 8 : + case 8: hb_reta( 3 ); /* Indexes in use, max, rejected */ hb_stornl( stActivityInfo.stIndexes.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stIndexes.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stIndexes.ulRejected, -1, 3 ); break; - - case 9 : + case 9: hb_reta( 3 ); /* Locks in use, max, rejected */ hb_stornl( stActivityInfo.stLocks.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stLocks.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stLocks.ulRejected, -1, 3 ); break; - - case 10 : + case 10: hb_reta( 3 ); /* TPS header elems in use, max */ hb_stornl( stActivityInfo.stTpsHeaderElems.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stTpsHeaderElems.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stTpsHeaderElems.ulRejected, -1, 3 ); break; - - case 11 : + case 11: hb_reta( 3 ); /* TPS vis elems in use, max */ hb_stornl( stActivityInfo.stTpsVisElems.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stTpsVisElems.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stTpsVisElems.ulRejected, -1, 3 ); break; - - case 12 : + case 12: hb_reta( 3 ); /* TPS memo elems in use, max */ hb_stornl( stActivityInfo.stTpsMemoElems.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stTpsMemoElems.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stTpsMemoElems.ulRejected, -1, 3 ); break; - - case 13 : + case 13: hb_reta( 3 ); /* Worker threads in use, max */ hb_stornl( stActivityInfo.stWorkerThreads.ulInUse, -1, 1 ); hb_stornl( stActivityInfo.stWorkerThreads.ulMaxUsed, -1, 2 ); hb_stornl( stActivityInfo.stWorkerThreads.ulRejected, -1, 3 ); break; - } } } @@ -234,32 +222,33 @@ HB_FUNC( ADSMGGETACTIVITYINFO ) HB_FUNC( ADSMGGETCOMMSTATS ) { UNSIGNED32 ulRetVal; - UNSIGNED16 usStructSize; ADS_MGMT_COMM_STATS stCommStats; + UNSIGNED16 usStructSize = sizeof( ADS_MGMT_COMM_STATS ); - usStructSize = sizeof( ADS_MGMT_COMM_STATS ); ulRetVal = AdsMgGetCommStats( ads_g_hMgmtHandle, &stCommStats, &usStructSize ); - /* - // if( sizeof( ADS_MGMT_COMM_STATS ) < usStructSize ) - // { - // HB_TRACE(HB_TR_INFO, ("The Communication Statistics structure on the server is larger. - // \nMore info is available with the current ACE.H." )); - // } - */ + + /* + if( sizeof( ADS_MGMT_COMM_STATS ) < usStructSize ) + { + HB_TRACE(HB_TR_INFO, ("AdsMgGetCommStats() structure on the server is larger.\n" + "More info is available with newer client lib." )); + } + */ + if( ulRetVal == AE_SUCCESS ) { hb_reta( 11 ); - hb_stornd( stCommStats.dPercentCheckSums, -1, 1 ); /* % of pkts with checksum failures */ - hb_stornl( stCommStats.ulTotalPackets, -1, 2 ); /* Total packets received */ - hb_stornl( stCommStats.ulRcvPktOutOfSeq , -1, 3 ); /* Receive packets out of sequence */ - hb_stornl( stCommStats.ulNotLoggedIn , -1, 4 ); /* Packet owner not logged in */ - hb_stornl( stCommStats.ulRcvReqOutOfSeq , -1, 5 ); /* Receive requests out of sequence */ - hb_stornl( stCommStats.ulCheckSumFailures, -1, 6 ); /* Checksum failures */ - hb_stornl( stCommStats.ulDisconnectedUsers,-1, 7 ); /* Server initiated disconnects */ - hb_stornl( stCommStats.ulPartialConnects , -1, 8 ); /* Removed partial connections */ - hb_stornl( stCommStats.ulInvalidPackets , -1, 9 ); /* Rcvd invalid packets (NT only) */ - hb_stornl( stCommStats.ulRecvFromErrors , -1, 10); /* RecvFrom failed (NT only) */ - hb_stornl( stCommStats.ulSendToErrors , -1, 11); /* SendTo failed (NT only) */ + hb_stornd( stCommStats.dPercentCheckSums , -1, 1 ); /* % of pkts with checksum failures */ + hb_stornl( stCommStats.ulTotalPackets , -1, 2 ); /* Total packets received */ + hb_stornl( stCommStats.ulRcvPktOutOfSeq , -1, 3 ); /* Receive packets out of sequence */ + hb_stornl( stCommStats.ulNotLoggedIn , -1, 4 ); /* Packet owner not logged in */ + hb_stornl( stCommStats.ulRcvReqOutOfSeq , -1, 5 ); /* Receive requests out of sequence */ + hb_stornl( stCommStats.ulCheckSumFailures , -1, 6 ); /* Checksum failures */ + hb_stornl( stCommStats.ulDisconnectedUsers, -1, 7 ); /* Server initiated disconnects */ + hb_stornl( stCommStats.ulPartialConnects , -1, 8 ); /* Removed partial connections */ + hb_stornl( stCommStats.ulInvalidPackets , -1, 9 ); /* Rcvd invalid packets (NT only) */ + hb_stornl( stCommStats.ulRecvFromErrors , -1, 10); /* RecvFrom failed (NT only) */ + hb_stornl( stCommStats.ulSendToErrors , -1, 11); /* SendTo failed (NT only) */ } } @@ -277,29 +266,33 @@ HB_FUNC( ADSMGRESETCOMMSTATS ) HB_FUNC( ADSMGGETCONFIGINFO ) { - UNSIGNED32 ulRetVal ; - ADS_MGMT_CONFIG_PARAMS stConfigValues; - ADS_MGMT_CONFIG_MEMORY stConfigMemory; - UNSIGNED16 usConfigValuesStructSize; - UNSIGNED16 usConfigMemoryStructSize; - int iOption = ISNUM(1) ? hb_parni(1) : 1 ; /* Pass 0 for Values, 1 for memory */ + UNSIGNED32 ulRetVal; + ADS_MGMT_CONFIG_PARAMS stConfigValues; + ADS_MGMT_CONFIG_MEMORY stConfigMemory; + UNSIGNED16 usConfigValuesStructSize = sizeof( ADS_MGMT_CONFIG_PARAMS ); + UNSIGNED16 usConfigMemoryStructSize = sizeof( ADS_MGMT_CONFIG_MEMORY ); + int iOption = ISNUM( 1 ) ? hb_parni( 1 ) : 1; /* Pass 0 for Values, 1 for memory */ - usConfigValuesStructSize = sizeof( ADS_MGMT_CONFIG_PARAMS ); - usConfigMemoryStructSize = sizeof( ADS_MGMT_CONFIG_MEMORY ); + ulRetVal = AdsMgGetConfigInfo( ads_g_hMgmtHandle, + &stConfigValues, + &usConfigValuesStructSize, + &stConfigMemory, + &usConfigMemoryStructSize ); - usConfigValuesStructSize = sizeof( ADS_MGMT_CONFIG_PARAMS ); - usConfigMemoryStructSize = sizeof( ADS_MGMT_CONFIG_MEMORY ); + /* + if( sizeof( ADS_MGMT_CONFIG_PARAMS ) < usConfigValuesStructSize ) + { + HB_TRACE(HB_TR_INFO, ("AdsMgGetConfigInfo() values structure on the server is larger.\n" + "More info is available with newer client lib." )); + } - ulRetVal = AdsMgGetConfigInfo( ads_g_hMgmtHandle, &stConfigValues, - &usConfigValuesStructSize, - &stConfigMemory, &usConfigMemoryStructSize ); + if( sizeof( ADS_MGMT_CONFIG_MEMORY ) < usConfigMemoryStructSize ) + { + HB_TRACE(HB_TR_INFO, ("AdsMgGetConfigInfo() memory structure on the server is larger.\n" + "More info is available with newer client lib." )); + } + */ - /* - // if( sizeof( ADS_MGMT_CONFIG_PARAMS ) < usConfigValuesStructSize ) - // printf( "\nConfiguration Values structure on server is larger." ); - // if( sizeof( ADS_MGMT_CONFIG_MEMORY ) < usConfigMemoryStructSize ) - // printf( "\nConfiguration Memory structure on server is larger." ); - */ if( ulRetVal == AE_SUCCESS ) { if( iOption == 0 ) @@ -366,41 +359,33 @@ HB_FUNC( ADSMGGETCONFIGINFO ) HB_FUNC( ADSMGGETUSERNAMES ) /* Return array of connected users */ { - - UNSIGNED32 ulRetVal; - UNSIGNED16 ulMaxUsers = 2000; /* needed for array memory allocation; caller can set with 2nd arg */ - UNSIGNED16 ulCount; - UNSIGNED16 usStructSize = sizeof( ADS_MGMT_USER_INFO ); - ADS_MGMT_USER_INFO * pastUserInfo; - /* - ADS_MGMT_USER_INFO astUserInfo[MAX_NUM_USERS]; + ADS_MGMT_USER_INFO astUserInfo[ MAX_NUM_USERS ]; bh: Enhancement: Get # of tables from ADS_MGMT_ACTIVITY_INFO.stUsers instead of set size */ - if( ISNUM( 2 ) ) - { - ulMaxUsers = (UNSIGNED16) hb_parnl( 2 ); - } + + UNSIGNED32 ulRetVal; + UNSIGNED16 ulMaxUsers = ISNUM( 2 ) ? (UNSIGNED16) hb_parnl( 2 ) : 2000; /* needed for array memory allocation; caller can set with 2nd arg */ + UNSIGNED16 ulCount; + ADS_MGMT_USER_INFO * pastUserInfo; + UNSIGNED16 usStructSize = sizeof( ADS_MGMT_USER_INFO ); pastUserInfo = (ADS_MGMT_USER_INFO *) hb_xgrab( sizeof( ADS_MGMT_USER_INFO ) * ulMaxUsers ); - /* - AdsMgGetUserNames ( ADSHANDLE hMgmtConnect, - UNSIGNED8 *pucFileName, - ADS_MGMT_USER_INFO astUserInfo[], - UNSIGNED16 *pusArrayLen, - UNSIGNED16 *pusStructSize ); - */ - ulRetVal = AdsMgGetUserNames( ads_g_hMgmtHandle, ISCHAR( 1 ) ? (UNSIGNED8 *) hb_parcx( 1 ) : NULL, + + ulRetVal = AdsMgGetUserNames( ads_g_hMgmtHandle, + (UNSIGNED8 *) hb_parc( 1 ) /* pucFileName */, pastUserInfo, &ulMaxUsers, &usStructSize ); - /* - if( sizeof( ADS_MGMT_USER_INFO ) < usStructSize ) - { - HB_TRACE(HB_TR_INFO, ("The \nUser Information structure on the server is larger. - \nMore info is available with the current ACE.H." )); - } - */ + + /* + if( sizeof( ADS_MGMT_USER_INFO ) < usStructSize ) + { + HB_TRACE(HB_TR_INFO, ("AdsMgGetUserNames() structure on the server is larger.\n" + "More info is available with newer client lib." )); + } + */ + if( ulRetVal == AE_SUCCESS ) { PHB_ITEM pArray = hb_itemArrayNew( ulMaxUsers ), pArrayItm; @@ -408,28 +393,32 @@ HB_FUNC( ADSMGGETUSERNAMES ) /* Return array of connected users */ for( ulCount = 1; ulCount <= ulMaxUsers; ulCount++ ) { pArrayItm = hb_arrayGetItemPtr( pArray, ulCount ); -#if ADS_LIB_VERSION >= 810 hb_arrayNew( pArrayItm, 6 ); -#elif ADS_LIB_VERSION >= 800 - hb_arrayNew( pArrayItm, 5 ); -#else - hb_arrayNew( pArrayItm, 3 ); -#endif + hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 1 ), ( char * ) pastUserInfo[ulCount].aucUserName ); hb_itemPutNL( hb_arrayGetItemPtr( pArrayItm, 2 ), pastUserInfo[ulCount].usConnNumber ); +#if ADS_LIB_VERSION >= 600 hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 3 ), ( char * ) pastUserInfo[ulCount].aucAddress ); +#else + hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 3 ), NULL ); +#endif #if ADS_LIB_VERSION >= 800 hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 4 ), ( char * ) pastUserInfo[ulCount].aucAuthUserName ); hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 5 ), ( char * ) pastUserInfo[ulCount].aucOSUserLoginName ); +#else + hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 4 ), NULL ); + hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 5 ), NULL ); #endif #if ADS_LIB_VERSION >= 810 hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 6 ), ( char * ) pastUserInfo[ulCount].aucTSAddress ); +#else + hb_itemPutC( hb_arrayGetItemPtr( pArrayItm, 6 ), NULL ); #endif } hb_itemReturnRelease( pArray ); @@ -440,19 +429,11 @@ HB_FUNC( ADSMGGETUSERNAMES ) /* Return array of connected users */ } hb_xfree( pastUserInfo ); - } HB_FUNC( ADSMGGETLOCKOWNER ) { /* - // UNSIGNED32 AdsMgGetLockOwner (ADSHANDLE hMgmtConnect, - // UNSIGNED8 *pucTableName, - // UNSIGNED32 ulRecordNumber, - // ADS_MGMT_USER_INFO *pstUserInfo, - // UNSIGNED16 *pusStructSize, - // UNSIGNED16 *pusLockType); - // // returns an array of 5 elements if successful // [1] Client machine name when server runs on NT/2000 // Client Username when server runs on Netware @@ -465,25 +446,30 @@ HB_FUNC( ADSMGGETLOCKOWNER ) // */ UNSIGNED32 ulRetVal; - UNSIGNED16 usStructSize = sizeof( ADS_MGMT_USER_INFO ); UNSIGNED16 pusLockType; ADS_MGMT_USER_INFO * pstUserInfo; + UNSIGNED16 usStructSize = sizeof( ADS_MGMT_USER_INFO ); pstUserInfo = (ADS_MGMT_USER_INFO *) hb_xgrab( sizeof( ADS_MGMT_USER_INFO ) ); ulRetVal = AdsMgGetLockOwner( ads_g_hMgmtHandle, - (UNSIGNED8 *) hb_parcx( 1 ), - (UNSIGNED32) hb_parnl(2), + (UNSIGNED8 *) hb_parcx( 1 ) /* pucTableName */, + (UNSIGNED32) hb_parnl( 2 ) /* ulRecordNumber */, pstUserInfo, &usStructSize, - &pusLockType); - if( ulRetVal== AE_SUCCESS ) + &pusLockType ); + if( ulRetVal == AE_SUCCESS ) { - hb_reta(5); - hb_storc ( (char *) pstUserInfo->aucUserName , -1, 1); /* Machine name under NT */ - hb_stornl( (UNSIGNED16) pstUserInfo->usConnNumber, -1, 2); /* NetWare conn # (NLM only) */ - hb_storc ( (char *) pstUserInfo->aucAuthUserName, -1, 3); /* logon name with Data Dictionary */ - hb_storc ( (char *) pstUserInfo->aucAddress, -1, 4); /* IP adddress */ - hb_stornl( pusLockType, -1, 5); /* type of lock */ + hb_reta( 5 ); + hb_storc( ( char * ) pstUserInfo->aucUserName , -1, 1 ); /* Machine name under NT */ + hb_stornl( (UNSIGNED16) pstUserInfo->usConnNumber, -1, 2 ); /* NetWare conn # (NLM only) */ +#if ADS_LIB_VERSION >= 600 + hb_storc( ( char * ) pstUserInfo->aucAuthUserName, -1, 3 ); /* logon name with Data Dictionary */ + hb_storc( ( char * ) pstUserInfo->aucAddress, -1, 4 ); /* IP adddress */ +#else + hb_storc( NULL, -1, 3 ); /* logon name with Data Dictionary */ + hb_storc( NULL, -1, 4 ); /* IP adddress */ +#endif + hb_stornl( pusLockType, -1, 5 ); /* type of lock */ } else { @@ -494,8 +480,8 @@ HB_FUNC( ADSMGGETLOCKOWNER ) HB_FUNC( ADSMGGETSERVERTYPE ) /* Determine OS ADS is running on; see ADS_MGMT_* constants */ { - UNSIGNED32 ulRetVal; - UNSIGNED16 usServerType; + UNSIGNED32 ulRetVal; + UNSIGNED16 usServerType = 0; ulRetVal = AdsMgGetServerType( ads_g_hMgmtHandle, &usServerType ); if( ulRetVal == AE_SUCCESS ) @@ -530,7 +516,7 @@ HB_FUNC( ADSMGGETOPENTABLES ) /* nMaxNumberOfFilesToReturn, cUserName, if( !pucUserName || ( strlen( pucUserName ) == 0 ) ) { - pucUserName = NULL; + pucUserName = NULL; } if( ISNUM( 3 ) ) @@ -588,12 +574,12 @@ HB_FUNC( ADSMGGETOPENINDEXES ) /* nMaxNumberOfFilesToReturn, cTableName, cU if( !pucTableName || ( strlen( pucTableName ) == 0 ) ) { - pucTableName = NULL; + pucTableName = NULL; } if( !pucUserName || ( strlen( pucUserName ) == 0 ) ) { - pucUserName = NULL; + pucUserName = NULL; } if( ISNUM( 4 ) ) @@ -646,20 +632,16 @@ HB_FUNC( ADSMGGETWORKERTHREADACTIVITY ) AdsMgGetWorkerThreadActivity(); } -HB_FUNC( ADSMGKILLUSER ) -{ - UNSIGNED32 ulRetVal = AE_SUCCESS; - AdsMgKillUser(); -} - */ HB_FUNC( ADSMGKILLUSER ) { - hb_retnl( (UNSIGNED16) AdsMgKillUser( ads_g_hMgmtHandle, (UNSIGNED8 *) hb_parc(1), (UNSIGNED16) hb_parnl(2) )); + hb_retnl( (UNSIGNED16) AdsMgKillUser( ads_g_hMgmtHandle, + (UNSIGNED8 *) hb_parc( 1 ), + (UNSIGNED16) hb_parnl( 2 ) ) ); } HB_FUNC( ADSMGGETHANDLE ) { - hb_retnl( (LONG) ads_g_hMgmtHandle ); + hb_retnl( ( LONG ) ads_g_hMgmtHandle ); } diff --git a/harbour/contrib/rddads/make_b32.bat b/harbour/contrib/rddads/make_b32.bat index 40e0841e61..76f3f9f5ae 100644 --- a/harbour/contrib/rddads/make_b32.bat +++ b/harbour/contrib/rddads/make_b32.bat @@ -6,12 +6,9 @@ rem if not "%ADS_DIR%" == "" goto DIR_OK echo --------------------------------------------------------------- -echo IMPORTANT: You'll need Advantage Client Engine installed and -echo these envvars set to successfully build this library: -echo set ADS_VER=8 +echo IMPORTANT: You'll need Advantage Client Engine (5.0 or upper) +echo and this envvar to be set to successfully build this library: echo set ADS_DIR=C:\ads\acesdk -echo NOTE: The lowest tested version is ACE 6.x, it -echo may also work with 5.x. echo --------------------------------------------------------------- goto POST_EXIT @@ -19,7 +16,6 @@ goto POST_EXIT set CFLAGS=-I%ADS_DIR% set HB_DLL_NAME=ace32 -if exist "%SystemRoot%\system32\%HB_DLL_NAME%.dll" set HB_DLL_DIR=%SystemRoot%\system32 if exist "%ADS_DIR%\Redistribute\%HB_DLL_NAME%.dll" set HB_DLL_DIR=%ADS_DIR%\Redistribute if exist "%ADS_DIR%\%HB_DLL_NAME%.dll" set HB_DLL_DIR=%ADS_DIR% if exist "%ADS_DIR%\32bit\%HB_DLL_NAME%.dll" set HB_DLL_DIR=%ADS_DIR%\32bit diff --git a/harbour/contrib/rddads/make_gcc.sh b/harbour/contrib/rddads/make_gcc.sh index 623420af5e..075e53ea03 100755 --- a/harbour/contrib/rddads/make_gcc.sh +++ b/harbour/contrib/rddads/make_gcc.sh @@ -7,9 +7,10 @@ if [ "${ADS_INC}" == "" ] then echo "---------------------------------------------------------------" - echo "IMPORTANT: You will need Advantage package installed and this" - echo " envvar to be set to successfully build this library:" - echo " export ADS_INC=C:/Ads/acesdk" + echo "IMPORTANT: You will need Advantage Client Engine (5.0 or upper)" + echo " installed and this envvar to be set to successfully" + echo " build this library:" + echo " export ADS_INC=C:/ads/acesdk" echo " or" echo " export ADS_INC=/usr/include/ads" echo "---------------------------------------------------------------" diff --git a/harbour/contrib/rddads/make_vc.bat b/harbour/contrib/rddads/make_vc.bat index 2c713c1136..525a977590 100644 --- a/harbour/contrib/rddads/make_vc.bat +++ b/harbour/contrib/rddads/make_vc.bat @@ -6,12 +6,9 @@ rem if not "%ADS_DIR%" == "" goto DIR_OK echo --------------------------------------------------------------- -echo IMPORTANT: You'll need Advantage Client Engine installed and -echo these envvars set to successfully build this library: -echo set ADS_VER=8 +echo IMPORTANT: You'll need Advantage Client Engine (5.0 or upper) +echo and this envvar to be set to successfully build this library: echo set ADS_DIR=C:\ads\acesdk -echo NOTE: The lowest tested version is ACE 6.x, it -echo may also work with 5.x. echo --------------------------------------------------------------- goto POST_EXIT @@ -19,7 +16,6 @@ goto POST_EXIT set CFLAGS=-I%ADS_DIR% set HB_DLL_NAME=ace32 -if exist "%SystemRoot%\system32\%HB_DLL_NAME%.dll" set HB_DLL_DIR=%SystemRoot%\system32 if exist "%ADS_DIR%\Redistribute\%HB_DLL_NAME%.dll" set HB_DLL_DIR=%ADS_DIR%\Redistribute if exist "%ADS_DIR%\%HB_DLL_NAME%.dll" set HB_DLL_DIR=%ADS_DIR% if exist "%ADS_DIR%\32bit\%HB_DLL_NAME%.dll" set HB_DLL_DIR=%ADS_DIR%\32bit diff --git a/harbour/contrib/rddads/rddads.h b/harbour/contrib/rddads/rddads.h index 887d695e76..cb71c0b098 100644 --- a/harbour/contrib/rddads/rddads.h +++ b/harbour/contrib/rddads/rddads.h @@ -51,6 +51,7 @@ */ #include "hbapirdd.h" + #if defined( HB_OS_WIN_32 ) && !defined( WIN32 ) #define WIN32 #endif @@ -111,7 +112,8 @@ HB_EXTERN_BEGIN - +/* Function is not documented, but exists in ace32.dll version 6.x, 7.x */ +UNSIGNED32 ENTRYPOINT AdsDeleteFile( ADSHANDLE hConnection, UNSIGNED8* pucFileName ); /* * ADS WORKAREA @@ -233,5 +235,4 @@ extern ADSAREAP hb_rddGetADSWorkAreaPointer( void ); # define hb_adsOemAnsiFree( s ) #endif - HB_EXTERN_END diff --git a/harbour/contrib/xhb/hbcompat.ch b/harbour/contrib/xhb/hbcompat.ch index c57ef25ffa..22ca715f80 100644 --- a/harbour/contrib/xhb/hbcompat.ch +++ b/harbour/contrib/xhb/hbcompat.ch @@ -61,8 +61,10 @@ #xtranslate hb_gtInfo([]) => gtInfo() #xtranslate hb_gtVersion([]) => hb_gt_Version() - #xtranslate hb_ScrMaxRow() => MaxRow(.T.) - #xtranslate hb_ScrMaxCol() => MaxCol(.T.) + #xtranslate hb_ScrMaxRow() => hb_gtInfo( HB_GTI_SCREENHEIGHT ) + #xtranslate hb_ScrMaxCol() => hb_gtInfo( HB_GTI_SCREENWIDTH ) + #xtranslate MaxRow(.T.) => hb_gtInfo( HB_GTI_SCREENHEIGHT ) + #xtranslate MaxCol(.T.) => hb_gtInfo( HB_GTI_SCREENWIDTH ) #xtranslate hb_isregex([]) => hb_isregexstring() #xtranslate hb_pvalue([]) => pvalue() @@ -124,8 +126,8 @@ #xtranslate gtProcessMessages() => NextKey() #xtranslate gfxPrimitive([]) => hb_gfxPrimitive() #xtranslate gfxText([]) => hb_gfxText() - #xtranslate MaxRow(.T.) => hb_ScrMaxRow() - #xtranslate MaxCol(.T.) => hb_ScrMaxCol() + #xtranslate MaxRow(.T.) => hb_gtInfo( HB_GTI_VIEWPORTHEIGHT ) + #xtranslate MaxCol(.T.) => hb_gtInfo( HB_GTI_VIEWPORTWIDTH ) #xtranslate hb_isregexstring([]) => hb_isregex() #xtranslate pvalue([]) => hb_pvalue() diff --git a/harbour/include/hbgtinfo.ch b/harbour/include/hbgtinfo.ch index aaf8ebb7cb..8faa535b60 100644 --- a/harbour/include/hbgtinfo.ch +++ b/harbour/include/hbgtinfo.ch @@ -56,7 +56,7 @@ #define HB_GTI_ISGRAPHIC 0 /* 1 if GT has graphic support / pixel oriented */ #define HB_GTI_SCREENWIDTH 1 /* Get/set width of application window in pixels */ -#define HB_GTI_SCREENHEIGHT 2 /* Get/set height of appl. window in pixels */ +#define HB_GTI_SCREENHEIGHT 2 /* Get/set height of application window in pixels */ #define HB_GTI_SCREENDEPTH 3 /* Amount of bits used for colors in the application */ #define HB_GTI_FONTSIZE 4 /* Get/set height of application font in pixels */ #define HB_GTI_FONTWIDTH 5 /* Get/set width of application font characters */ diff --git a/harbour/source/compiler/hbmain.c b/harbour/source/compiler/hbmain.c index 3bbe473ec3..0dcc476c76 100644 --- a/harbour/source/compiler/hbmain.c +++ b/harbour/source/compiler/hbmain.c @@ -4631,7 +4631,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType ) szFileName, szPpoName ); else snprintf( buffer, sizeof( buffer ), "Compiling '%s'...\n", szFileName ); - hb_compOutErr( HB_COMP_PARAM, buffer ); + hb_compOutStd( HB_COMP_PARAM, buffer ); } if( HB_COMP_PARAM->fI18n ) @@ -4749,7 +4749,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType ) "\r%i error%s\n\nNo code generated\n", HB_COMP_PARAM->iErrorCount, HB_COMP_PARAM->iErrorCount > 1 ? "s" : "" ); - hb_compOutErr( HB_COMP_PARAM, buffer ); + hb_compOutStd( HB_COMP_PARAM, buffer ); } else if( HB_COMP_PARAM->iExitLevel == HB_EXITLEVEL_SETEXIT ) { @@ -4759,7 +4759,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType ) { iStatus = EXIT_FAILURE; bSkipGen = TRUE; - hb_compOutErr( HB_COMP_PARAM, "\nNo code generated.\n" ); + hb_compOutStd( HB_COMP_PARAM, "\nNo code generated.\n" ); } } @@ -4817,7 +4817,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, int iFileType ) "\rLines %i, Functions/Procedures %i\n", hb_pp_lineTot( HB_COMP_PARAM->pLex->pPP ), HB_COMP_PARAM->iFunctionCnt ); - hb_compOutErr( HB_COMP_PARAM, buffer ); + hb_compOutStd( HB_COMP_PARAM, buffer ); } hb_compGenOutput( HB_COMP_PARAM, HB_COMP_PARAM->iLanguage ); diff --git a/harbour/source/rtl/maxrow.c b/harbour/source/rtl/maxrow.c index d008e861c1..5d4679a165 100644 --- a/harbour/source/rtl/maxrow.c +++ b/harbour/source/rtl/maxrow.c @@ -53,12 +53,54 @@ #include "hbapi.h" #include "hbapigt.h" -HB_FUNC( MAXROW ) /* Return the maximum screen/"viewport" row number (zero origin) */ +/* NOTE: This is a hack to emulate the overloaded MaxRow()/MaxCol() + functions provided by CT3 library for CA-Cl*pper. + Application code is encouraged to rather use the + hbct_MaxRow(.T.)/hbct_MaxCol(.T.) functions provided by + Harbour CT library, or hb_ScrMaxRow()/hb_ScrMaxCol() + provided by Harbour RTL, since this extension may + collide in the future with extensions of other overloaded + versions (like the one of FlagShip), and it's currently + (2008 May) the only known non-standard extension slipped + into Harbour core. [vszakats] */ +#define HB_COMPAT_CT3 + +HB_FUNC( MAXROW ) /* Return the maximum screen/window row number (zero origin) */ { - hb_retni( hb_gtMaxRow() ); +#ifdef HB_COMPAT_CT3 + /* + * if called with logical .T. parameter then return real screen high - 1 + * It gives exactly the same result in all standard GT drivers so we + * are still Clipper compatible. The difference can appear in some extended + * GT drivers which have additional functionality, f.e. CTW GT which + * is upper level GT and add CTIII Window support. When it's activated + * then MaxRow() will return current window max row and MaxRow(.T.) real + * screen (window 0) max row what is the exact behavior of MaxRow() + * in CT3, [druzus] + */ + + if( ISLOG( 1 ) && hb_parl( 1 ) ) + { + USHORT uiRows, uiCols; + hb_gtScrDim( &uiRows, &uiCols ); + hb_retni( uiRows - 1 ); + } + else +#endif + hb_retni( hb_gtMaxRow() ); } -HB_FUNC( MAXCOL ) /* Return the maximum screen/"viewport" column number (zero origin) */ +HB_FUNC( MAXCOL ) /* Return the maximum screen/window column number (zero origin) */ { - hb_retni( hb_gtMaxCol() ); +#ifdef HB_COMPAT_CT3 + /* See notes about MaxRow(.T.) above */ + if( ISLOG( 1 ) && hb_parl( 1 ) ) + { + USHORT uiRows, uiCols; + hb_gtScrDim( &uiRows, &uiCols ); + hb_retni( uiCols - 1 ); + } + else +#endif + hb_retni( hb_gtMaxCol() ); }