From 322a643b3752f57c4002fc6301979e5503fd6136 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 27 Apr 2008 23:40:34 +0000 Subject: [PATCH] 2008-04-28 01:00 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/rdd_ads/adsfunc.c ! Fixed warning in ADSDIRECTORY() for ADS >= 9.00. * contrib/rdd_ads/adsfunc.c * contrib/rdd_ads/adsmgmnt.c + Added AdsIsEmpty( ) -> With .adt tables will return .T. if value of the field is NULL. With .dbf it's just equivalent to Empty(). (by Luis Krause Mantilla) + Added ADSMGGetOpenTables( nMaxNumberOfFilesToReturn, cUserName, nConnection ) + Added ADSMGGetOpenIndexes( nMaxNumberOfFilesToReturn, cTableName, cUserName, nConnection ) (by Antonio Carlos Pantaglione & Brian Hays) ; Changes borrowed from xhb, added minor optimization, formatting and warning fix. * include/hbclass.ch ! Comment typos. --- harbour/ChangeLog | 18 ++++ harbour/contrib/rddads/adsfunc.c | 35 +++++++- harbour/contrib/rddads/adsmgmnt.c | 144 ++++++++++++++++++++++++++---- harbour/include/hbclass.ch | 12 +-- 4 files changed, 185 insertions(+), 24 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 45c17e6998..8c774f903e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,24 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-04-28 01:00 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * contrib/rdd_ads/adsfunc.c + ! Fixed warning in ADSDIRECTORY() for ADS >= 9.00. + + * contrib/rdd_ads/adsfunc.c + * contrib/rdd_ads/adsmgmnt.c + + Added AdsIsEmpty( ) -> + With .adt tables will return .T. if value of the field is NULL. + With .dbf it's just equivalent to Empty(). + (by Luis Krause Mantilla) + + Added ADSMGGetOpenTables( nMaxNumberOfFilesToReturn, cUserName, nConnection ) + + Added ADSMGGetOpenIndexes( nMaxNumberOfFilesToReturn, cTableName, cUserName, nConnection ) + (by Antonio Carlos Pantaglione & Brian Hays) + ; Changes borrowed from xhb, added minor optimization, formatting and warning fix. + + * include/hbclass.ch + ! Comment typos. + 2008-04-27 22:42 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * source/common/hbver.c + OS(), hb_verPlatform(): Added detection of Windows Server 2008. diff --git a/harbour/contrib/rddads/adsfunc.c b/harbour/contrib/rddads/adsfunc.c index 001ee2f05e..a349db57b3 100644 --- a/harbour/contrib/rddads/adsfunc.c +++ b/harbour/contrib/rddads/adsfunc.c @@ -2002,6 +2002,35 @@ HB_FUNC( ADSCACHEOPENCURSORS ) hb_retnl( ulRetVal ); } +// 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 = FALSE; + ADSAREAP pArea; + UNSIGNED8* pucFldName; + + pArea = hb_rddGetADSWorkAreaPointer(); + if( ! ISCHAR( 1 ) && ! ISNUM( 1 ) ) + { + 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 ); +} + #if ADS_REQUIRE_VERSION >= 6 HB_FUNC( ADSGETNUMACTIVELINKS ) // requires 6.2 ! Only valid for a DataDict @@ -2469,7 +2498,11 @@ HB_FUNC( ADSDIRECTORY ) UNSIGNED32 ulRetVal; UNSIGNED8 ucFileName[ ADS_MAX_TABLE_NAME ]; UNSIGNED16 usFileNameLen; +#if ADS_REQUIRE_VERSION >= 900 + ADSHANDLE sHandle = 0; +#else SIGNED32 sHandle = 0; +#endif PHB_ITEM pitmDir, pitmFileName; ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 2 ); @@ -2477,7 +2510,7 @@ HB_FUNC( ADSDIRECTORY ) hb_arrayNew( pitmDir, 0 ); usFileNameLen = ADS_MAX_TABLE_NAME; - ulRetVal = AdsFindFirstTable( hConnect, ( UNSIGNED8* ) ( ISCHAR( 1 ) ? hb_parcx( 1 ) : "" ), ucFileName, &usFileNameLen, &sHandle ); + ulRetVal = AdsFindFirstTable( hConnect, ( UNSIGNED8* ) ( ISCHAR( 1 ) ? hb_parcx( 1 ) : "" ), ( UNSIGNED8* ) ucFileName, &usFileNameLen, &sHandle ); if ( ulRetVal == AE_SUCCESS || ulRetVal == AE_NO_FILE_FOUND ) { while( ulRetVal == AE_SUCCESS ) diff --git a/harbour/contrib/rddads/adsmgmnt.c b/harbour/contrib/rddads/adsmgmnt.c index 020795edde..fc0081798e 100644 --- a/harbour/contrib/rddads/adsmgmnt.c +++ b/harbour/contrib/rddads/adsmgmnt.c @@ -98,7 +98,7 @@ HB_FUNC( ADSMGGETINSTALLINFO ) // printf( "\nMore possible info available." ); */ - if ( ulRetVal == AE_SUCCESS ) + if( ulRetVal == AE_SUCCESS ) { hb_reta( 8 ); hb_stornl( stInstallInfo.ulUserOption , -1, 1 ); /* User option purchased*/ @@ -504,24 +504,132 @@ HB_FUNC( ADSMGGETSERVERTYPE ) /* Determine OS ADS is running on; see ADS_MGMT_ } } + +HB_FUNC( ADSMGGETOPENTABLES ) /* nMaxNumberOfFilesToReturn, cUserName, nConnection */ +{ /* TODO: We're throwing away the locktype info. First edition + * should have returned a 2-dim array. Perhaps see if a 4th arg + * is passed as an (empty) array, if so populate parallel array + * of locktypes. OR pass a logical to tell it to return 2-dim array */ + UNSIGNED32 ulRetVal; + char * pucUserName = hb_parc( 2 ); + UNSIGNED16 pusArrayLen = 300; + UNSIGNED16 ulCount; + UNSIGNED16 pusStructSize = sizeof( ADS_MGMT_TABLE_INFO ); + ADS_MGMT_TABLE_INFO * astOpenTableInfo; + UNSIGNED16 usConnNumber = 0 ; // = HB_ADS_PARCONNECTION( 3 ) >>> only valid for netware, + // so don't default to current, only take a passed value + + if( ISNUM( 1 ) ) + { + pusArrayLen = ( UNSIGNED16 ) hb_parnl( 1 ); + } + + if( !pucUserName || ( strlen( pucUserName ) == 0 ) ) + { + pucUserName = NULL; + } + + if( ISNUM( 3 ) ) + { + usConnNumber = (UNSIGNED16) hb_parnl( 3 ); + } + + astOpenTableInfo = ( ADS_MGMT_TABLE_INFO * ) hb_xgrab( sizeof( ADS_MGMT_TABLE_INFO ) * pusArrayLen ); + + ulRetVal = AdsMgGetOpenTables( hMgmtHandle, + (UNSIGNED8 *) pucUserName, + usConnNumber, + astOpenTableInfo, + &pusArrayLen, + &pusStructSize ); + + if( ulRetVal == AE_SUCCESS ) + { + PHB_ITEM pArray = hb_itemArrayNew( pusArrayLen ); + + for( ulCount = 1; ulCount <= pusArrayLen; ulCount++ ) + { + hb_itemPutC( hb_arrayGetItemPtr( pArray, ( ULONG ) ulCount ), ( char * ) astOpenTableInfo[ ulCount - 1 ].aucTableName ); + } + hb_itemReturnRelease( pArray ); + } + else + { + hb_reta( 0 ); + } + + if( astOpenTableInfo ) + { + hb_xfree( astOpenTableInfo ); + } +} + + +HB_FUNC( ADSMGGETOPENINDEXES ) /* nMaxNumberOfFilesToReturn, cTableName, cUserName, nConnection */ +{ + UNSIGNED32 ulRetVal; + UNSIGNED16 pusArrayLen = 300; + char * pucTableName = hb_parc( 2 ); // fully qualified path to that table + char * pucUserName = hb_parc( 3 ); + UNSIGNED16 usConnNumber = 0 ; // = HB_ADS_PARCONNECTION( 4 ) >>> only valid for netware, + // so don't default to current, only take a passed value + UNSIGNED16 ulCount; + UNSIGNED16 pusStructSize = sizeof( ADS_MGMT_INDEX_INFO ); + ADS_MGMT_INDEX_INFO * astOpenIndexInfo; + + if( ISNUM( 1 ) ) + { + pusArrayLen = ( UNSIGNED16 ) hb_parnl( 1 ); + } + + if( !pucTableName || ( strlen( pucTableName ) == 0 ) ) + { + pucTableName = NULL; + } + + if( !pucUserName || ( strlen( pucUserName ) == 0 ) ) + { + pucUserName = NULL; + } + + if( ISNUM( 4 ) ) + { + usConnNumber = (UNSIGNED16) hb_parnl( 4 ); + } + + astOpenIndexInfo = ( ADS_MGMT_INDEX_INFO * ) hb_xgrab( sizeof( ADS_MGMT_INDEX_INFO ) * pusArrayLen ); + + ulRetVal = AdsMgGetOpenIndexes( hMgmtHandle, + (UNSIGNED8 *) pucTableName, + (UNSIGNED8 *) pucUserName, + usConnNumber, + astOpenIndexInfo, + &pusArrayLen, + &pusStructSize ); + + if( ulRetVal == AE_SUCCESS ) + { + PHB_ITEM pArray = hb_itemArrayNew( pusArrayLen ); + + for( ulCount = 1; ulCount <= pusArrayLen; ulCount++ ) + { + hb_itemPutC( hb_arrayGetItemPtr( pArray, ( ULONG ) ulCount ), ( char * ) astOpenIndexInfo[ ulCount - 1 ].aucIndexName ); + } + hb_itemReturnRelease( pArray ); + } + else + { + hb_reta( 0 ); + } + + if( astOpenIndexInfo ) + { + hb_xfree( astOpenIndexInfo ); + } +} + /* -HB_FUNC( ADSMGGETOPENTABLES ) -{ - UNSIGNED32 ulRetVal ; - UNSIGNED32 ulMaxUsers = 100 ; // needed for array memory allocation; caller can set with 2nd arg - UNSIGNED32 ulCount; - UNSIGNED16 usStructSize = sizeof( ADS_MGMT_USER_INFO ); - ADS_MGMT_USER_INFO* pastUserInfo; -Get # of tables from ADS_MGMT_ACTIVITY_INFO -} - -HB_FUNC( ADSMGGETOPENINDEXES ) -{ - UNSIGNED32 ulRetVal = AE_SUCCESS; - AdsMgGetOpenIndexes(); -} - HB_FUNC( ADSMGGETLOCKS ) { UNSIGNED32 ulRetVal = AE_SUCCESS; @@ -539,7 +647,9 @@ HB_FUNC( ADSMGKILLUSER ) UNSIGNED32 ulRetVal = AE_SUCCESS; AdsMgKillUser(); } + */ + HB_FUNC( ADSMGKILLUSER ) { hb_retnl( (UNSIGNED16) AdsMgKillUser( hMgmtHandle, (UNSIGNED8 *) hb_parc(1), (UNSIGNED16) hb_parnl(2) )); diff --git a/harbour/include/hbclass.ch b/harbour/include/hbclass.ch index c71b437db3..5420473a4c 100644 --- a/harbour/include/hbclass.ch +++ b/harbour/include/hbclass.ch @@ -82,17 +82,17 @@ /* This is work in progress ... */ /* FWOBJECT AND CLASSY compatibility are the base of this work */ /* VO is just here as I like it's way of */ -/* instanciating object but there is only a very few VO keywords here :-( */ +/* instantiating object but there is only a very few VO keywords here :-( */ /* TOPCLASS is better implemented because I like the way some Classy command */ /* are simplified */ /* There is also a big common block extending in fact each of the four base syntax */ /* it seem actually impossible to completely separate it without creating */ -/* four differents include file (what I would not see in fact ) */ +/* four different include files (what I would not see in fact ) */ /* There is also two compatibility define you can use */ -/* HB_CLS_NOTOBJECT wich IF DEFINED, disable the auto inherit of HBObject */ -/* (wich in fact also disable the classy compatibility :new(...) => :Init(...) */ -/* HB_CLS_NOAUTOINIT wich disable the (VO like) AutoInit for Logical and Numeric */ +/* HB_CLS_NOTOBJECT which IF DEFINED, disable the auto inherit of HBObject */ +/* (which in fact also disable the classy compatibility :new(...) => :Init(...) */ +/* HB_CLS_NOAUTOINIT which disable the (VO like) AutoInit for Logical and Numeric */ /* when not specifically initiated */ /* These two are disabled by default */ /* So Each class _inherit_ of HBObject by default and */ @@ -156,7 +156,7 @@ #endif #endif -/* should we use <_ prefix for real method names? */ +/* should we use _ prefix for real method names? */ #ifdef HB_CLS_NO_DECORATION #xtranslate __HB_CLS_MTHNAME => #else