From d51f2c9df520cdebcb645ebbf8ad56c96dc2c36a Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 11 Dec 2006 13:42:49 +0000 Subject: [PATCH] 2006-12-11 14:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/rdd_ads/ads1.c * harbour/contrib/rdd_ads/adsfunc.c * harbour/source/rdd/dbfcdx/dbfcdx1.c * harbour/source/rdd/hsx/hsx.c * synced with xHarbour * harbour/source/rtl/gtsln/gtsln.h * changed #if to #ifdef to avoid problems with some unofficially patched slang versions --- harbour/ChangeLog | 11 +++++ harbour/contrib/rdd_ads/ads1.c | 41 ++++++++-------- harbour/contrib/rdd_ads/adsfunc.c | 64 +++++++++++++++++++++---- harbour/source/rdd/dbfcdx/dbfcdx1.c | 72 +++++++++++++++++++---------- harbour/source/rdd/hsx/hsx.c | 7 +-- harbour/source/rtl/gtsln/gtsln.h | 6 +-- 6 files changed, 141 insertions(+), 60 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a83b785f9b..a1cc3cb7dd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,17 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2006-12-11 14:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/rdd_ads/ads1.c + * harbour/contrib/rdd_ads/adsfunc.c + * harbour/source/rdd/dbfcdx/dbfcdx1.c + * harbour/source/rdd/hsx/hsx.c + * synced with xHarbour + + * harbour/source/rtl/gtsln/gtsln.h + * changed #if to #ifdef to avoid problems with some unofficially + patched slang versions + 2006-12-09 17:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/config/bsd/gcc.cf * harbour/config/darwin/gcc.cf diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index d4fb3d3721..4c74af9c8c 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -1787,7 +1787,7 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) pField = pArea->lpFields + uiIndex - 1; /* This code was optimized for use ADSFIELD() macro instead */ - /* AdsGetFieldName() function for speed. Toninho@fwi, 22/07/2003 */ + /* AdsGetFieldName() function for speed. ToninhoFwi, 22/07/2003 */ switch( pField->uiType ) { @@ -1899,7 +1899,7 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) AdsGetMemoDataType( pArea->hTable, ADSFIELD( uiIndex ), &pusType ); - if( pusType != ADS_BINARY ) + if( pusType != ADS_BINARY && pusType != ADS_IMAGE ) { if( AdsGetMemoLength( pArea->hTable, ADSFIELD( uiIndex ), &pulLen ) == AE_NO_CURRENT_RECORD ) { @@ -1930,18 +1930,15 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) else { if( AdsGetBinaryLength( pArea->hTable, ADSFIELD( uiIndex ), &pulLen ) == AE_NO_CURRENT_RECORD ) - hb_itemPutC( pItem, "" ); + { + hb_itemPutC( pItem, "" ); + } else { - char * szRet; - - pulLen++; /* make room for NULL */ - pucBuf = (UNSIGNED8*) hb_xgrab( pulLen ); + pulLen++; /* make room for NULL */ + pucBuf = ( UNSIGNED8 * ) hb_xgrab( pulLen ); AdsGetBinary( pArea->hTable, ADSFIELD( uiIndex ), 0, pucBuf, &pulLen ); - szRet = hb_adsAnsiToOem( ( char * ) pucBuf, pulLen ); - hb_itemPutCL( pItem, szRet, pulLen ); - hb_adsOemAnsiFree( szRet ); - hb_xfree( pucBuf ); + hb_itemPutCPtr( pItem, ( char * ) pucBuf, pulLen ); } } hb_itemSetCMemo( pItem ); @@ -2080,7 +2077,7 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) szText = pArea->pRecord; /* This code was optimized for use ADSFIELD() macro instead */ - /* AdsGetFieldName() function for speed. Toninho@fwi, 22/07/2003 */ + /* AdsGetFieldName() function for speed. ToninhoFwi, 22/07/2003 */ switch( pField->uiType ) { @@ -2139,25 +2136,31 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) case HB_IT_MEMO: if( HB_IS_STRING( pItem ) ) { - char * szRet; ULONG ulLen; bTypeError = FALSE; ulLen = hb_itemGetCLen( pItem ); - szRet = hb_adsOemToAnsi( hb_itemGetCPtr( pItem ), ulLen ); - if( ulLen < 0xFFFF ) + /* ToninhoFwi - 09/12/2006 - In the previous code ulLen was limited to 0xFFFF + so, I comment it, because ADS support up to 4Gb in memo/binary/image fields. + Advantage documentations says that we need use AdsSetBinary in binary/image + fields. I tested these special fields with AdsSetString() and it works, but + is a little bit slower to save big image file in the fields, so I keep + AdsSetString() only for commom memo fields and AdsSetBinary() for the others. + */ + if( pField->uiTypeExtended != ADS_BINARY && pField->uiTypeExtended != ADS_IMAGE ) { + char * szRet = hb_adsOemToAnsi( hb_itemGetCPtr( pItem ), ulLen ); ulRetVal = AdsSetString( pArea->hTable, ADSFIELD( uiIndex ), (UNSIGNED8*) szRet, ulLen ); + hb_adsOemAnsiFree( szRet ); } else { ulRetVal = AdsSetBinary( pArea->hTable, ADSFIELD( uiIndex ), - ADS_BINARY, ulLen, 0, - (UNSIGNED8*) szRet, ulLen ); + pField->uiTypeExtended, ulLen, 0, + (UNSIGNED8*) hb_itemGetCPtr( pItem ), ulLen ); } - hb_adsOemAnsiFree( szRet ); } break; } @@ -3361,7 +3364,7 @@ static ERRCODE adsOrderCreate( ADSAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ) if( u16 == ADS_STRING ) /* add quotation marks around the key */ { hb_strncat( ( char * ) pucWhile, "<=\"", sizeof( pucWhile ) - 1 ); - hb_strncat( ( char * ) pucWhile, (char * ) pucScope, sizeof( pucWhile ) - 1 ); + hb_strncat( ( char * ) pucWhile, ( char * ) pucScope, sizeof( pucWhile ) - 1 ); hb_strncat( ( char * ) pucWhile, "\"", sizeof( pucWhile ) - 1 ); } else diff --git a/harbour/contrib/rdd_ads/adsfunc.c b/harbour/contrib/rdd_ads/adsfunc.c index 879f0aaa6a..c5de95e49b 100644 --- a/harbour/contrib/rdd_ads/adsfunc.c +++ b/harbour/contrib/rdd_ads/adsfunc.c @@ -68,7 +68,7 @@ int adsFileType = ADS_CDX; int adsLockType = ADS_PROPRIETARY_LOCKING; -int adsRights = 1; +int adsRights = ADS_CHECKRIGHTS; int adsCharType = ADS_ANSI; BOOL bTestRecLocks = FALSE; /* Debug Implicit locks */ ADSHANDLE adsConnectHandle = 0; @@ -375,11 +375,11 @@ HB_FUNC( ADSLOCKING ) HB_FUNC( ADSRIGHTSCHECK ) { - int oldType = ( adsRights == 1 ) ? 1 : 0; + int oldType = ( adsRights == ADS_CHECKRIGHTS ) ? 1 : 0; if( hb_pcount() > 0 ) { - adsRights = ( hb_parl( 1 ) ) ? 1 : 2; + adsRights = ( hb_parl( 1 ) ) ? ADS_CHECKRIGHTS : ADS_IGNORERIGHTS; } hb_retl( oldType ); @@ -2031,6 +2031,25 @@ HB_FUNC( ADSDDADDTABLE ) } } +HB_FUNC( ADSDDREMOVETABLE ) +{ + UNSIGNED32 ulRetVal; + UNSIGNED8 *pTableName = (UNSIGNED8 *) hb_parcx( 1 ); + UNSIGNED16 usDeleteFiles = (UNSIGNED16) ( ISNUM( 2 ) ? hb_parnl( 2 ) : ( ISLOG( 2 ) ? hb_parl( 2 ) : 0 ) ); + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 4 ); + + ulRetVal = AdsDDRemoveTable( hConnect, pTableName, usDeleteFiles ); + + if( ulRetVal == AE_SUCCESS ) + { + hb_retl( 1 ); + } + else + { + hb_retl( 0 ); + } +} + HB_FUNC( ADSDDADDUSERTOGROUP ) { UNSIGNED32 ulRetVal; @@ -2038,9 +2057,27 @@ HB_FUNC( ADSDDADDUSERTOGROUP ) UNSIGNED8 *pName = (UNSIGNED8 *) hb_parcx( 2 ); ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); - ulRetVal = AdsDDAddUserToGroup( hConnect, - pGroup, - pName ); + ulRetVal = AdsDDAddUserToGroup( hConnect, pGroup, pName ); + + if( ulRetVal == AE_SUCCESS ) + { + hb_retl( 1 ); + } + else + { + hb_retl( 0 ); + } + +} + +HB_FUNC( ADSDDREMOVEUSERFROMGROUP ) +{ + UNSIGNED32 ulRetVal; + UNSIGNED8 *pGroup = (UNSIGNED8 *) hb_parcx( 1 ); + UNSIGNED8 *pName = (UNSIGNED8 *) hb_parcx( 2 ); + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 ); + + ulRetVal = AdsDDRemoveUserFromGroup( hConnect, pGroup, pName ); if( ulRetVal == AE_SUCCESS ) { @@ -2114,7 +2151,6 @@ HB_FUNC( ADSDDCREATE ) } } - HB_FUNC( ADSDDCREATEUSER ) { UNSIGNED32 ulRetVal; @@ -2129,6 +2165,15 @@ HB_FUNC( ADSDDCREATEUSER ) hb_retl( ulRetVal == AE_SUCCESS ); } +HB_FUNC( ADSDDDELETEUSER ) +{ + UNSIGNED32 ulRetVal; + UNSIGNED8 *pucUserName = ISCHAR( 1 ) ? (UNSIGNED8 *) hb_parcx( 1 ) : NULL; + ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 5 ); + + ulRetVal = AdsDDDeleteUser( hConnect, pucUserName ); + hb_retl( ulRetVal == AE_SUCCESS ); +} HB_FUNC( ADSDDGETDATABASEPROPERTY ) { @@ -2413,13 +2458,14 @@ HB_FUNC( ADSDIRECTORY ) ulRetVal = AdsFindFirstTable( hConnect, ( UNSIGNED8* ) ( ISCHAR( 1 ) ? hb_parcx( 1 ) : "" ), ucFileName, &usFileNameLen, &sHandle ); if ( ulRetVal == AE_SUCCESS || ulRetVal == AE_NO_FILE_FOUND ) { - do { + while( ulRetVal == AE_SUCCESS ) + { pitmFileName = hb_itemPutCL( NULL, (char *) ucFileName, usFileNameLen ); hb_arrayAddForward( pitmDir, pitmFileName ); usFileNameLen = ADS_MAX_TABLE_NAME; ulRetVal = AdsFindNextTable( hConnect, sHandle, ucFileName, &usFileNameLen ); - } while( ulRetVal == AE_SUCCESS ); + } AdsFindClose( hConnect, sHandle ); } diff --git a/harbour/source/rdd/dbfcdx/dbfcdx1.c b/harbour/source/rdd/dbfcdx/dbfcdx1.c index d58ef36f22..b3e6e70634 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/source/rdd/dbfcdx/dbfcdx1.c @@ -3908,23 +3908,35 @@ static BOOL hb_cdxPageReadPrevKey( LPCDXPAGE pPage ) pPage = pPage->Child; } - pPage->iCurKey--; - while ( pPage->iCurKey < 0 ) + do { - if ( pPage->Left == CDX_DUMMYNODE || !pOwnerPage ) + pPage->iCurKey--; + while ( pPage->iCurKey < 0 ) { - pPage->iCurKey = 0; - if ( pPage->iKeys > 0 ) - hb_cdxSetCurKey( pPage ); - return FALSE; + if ( pPage->Left == CDX_DUMMYNODE || !pOwnerPage ) + { + pPage->iCurKey = 0; + if ( pPage->iKeys > 0 ) + hb_cdxSetCurKey( pPage ); + return FALSE; + } + pOwnerPage->Child = hb_cdxPageNew( pPage->TagParent, pPage->Owner, pPage->Left ); + hb_cdxPageFree( pPage, !pPage->fChanged ); + pPage = pOwnerPage->Child; + pPage->iCurKey = pPage->iKeys - 1; + } + if( pPage->iCurKey == 0 ) + { + hb_cdxSetCurKey( pPage ); + if( !hb_cdxTopScope( pPage->TagParent ) || + !hb_cdxBottomScope( pPage->TagParent ) ) + break; } - pOwnerPage->Child = hb_cdxPageNew( pPage->TagParent, pPage->Owner, pPage->Left ); - hb_cdxPageFree( pPage, !pPage->fChanged ); - pPage = pOwnerPage->Child; - pPage->iCurKey = pPage->iKeys - 1; } - - hb_cdxSetCurKey( pPage ); + while( !hb_cdxCheckRecordScope( pPage->TagParent->pIndex->pArea, + hb_cdxPageGetKeyRec( pPage, pPage->iCurKey ) ) ); + if( pPage->iCurKey != 0 ) + hb_cdxSetCurKey( pPage ); return TRUE; } @@ -3941,21 +3953,33 @@ static BOOL hb_cdxPageReadNextKey( LPCDXPAGE pPage ) pPage = pPage->Child; } - pPage->iCurKey++; - while ( pPage->iCurKey >= pPage->iKeys ) + do { - if ( pPage->Right == CDX_DUMMYNODE || !pOwnerPage ) + pPage->iCurKey++; + while ( pPage->iCurKey >= pPage->iKeys ) { - pPage->iCurKey = pPage->iKeys; - return FALSE; + if ( pPage->Right == CDX_DUMMYNODE || !pOwnerPage ) + { + pPage->iCurKey = pPage->iKeys; + return FALSE; + } + pOwnerPage->Child = hb_cdxPageNew( pPage->TagParent, pPage->Owner, pPage->Right ); + hb_cdxPageFree( pPage, !pPage->fChanged ); + pPage = pOwnerPage->Child; + pPage->iCurKey = 0; + } + if( pPage->iCurKey == 0 ) + { + hb_cdxSetCurKey( pPage ); + if( !hb_cdxTopScope( pPage->TagParent ) || + !hb_cdxBottomScope( pPage->TagParent ) ) + break; } - pOwnerPage->Child = hb_cdxPageNew( pPage->TagParent, pPage->Owner, pPage->Right ); - hb_cdxPageFree( pPage, !pPage->fChanged ); - pPage = pOwnerPage->Child; - pPage->iCurKey = 0; } - - hb_cdxSetCurKey( pPage ); + while( !hb_cdxCheckRecordScope( pPage->TagParent->pIndex->pArea, + hb_cdxPageGetKeyRec( pPage, pPage->iCurKey ) ) ); + if( pPage->iCurKey != 0 ) + hb_cdxSetCurKey( pPage ); return TRUE; } diff --git a/harbour/source/rdd/hsx/hsx.c b/harbour/source/rdd/hsx/hsx.c index 49955e68a7..a7b5026db0 100644 --- a/harbour/source/rdd/hsx/hsx.c +++ b/harbour/source/rdd/hsx/hsx.c @@ -1956,12 +1956,9 @@ HB_FUNC( HS_VERSION ) { static const char szVer[] = "HiPer-SEEK / FTS library emulation"; char * pszHBVersion, * pszVersion; - int iLen; pszHBVersion = hb_verHarbour(); - iLen = strlen( szVer ) + strlen( pszHBVersion ) + 2; - pszVersion = ( char * ) hb_xgrab( iLen + 1 ); - snprintf( pszVersion, iLen + 1, "%s: %s", szVer, pszHBVersion ); - hb_retclen_buffer( pszVersion, iLen ); + pszVersion = hb_xstrcat( NULL, szVer, ": ", pszHBVersion ); + hb_retclen_buffer( pszVersion, strlen( pszVersion ) ); hb_xfree( pszHBVersion ); } diff --git a/harbour/source/rtl/gtsln/gtsln.h b/harbour/source/rtl/gtsln/gtsln.h index 55ed40aa9f..931c234f3d 100644 --- a/harbour/source/rtl/gtsln/gtsln.h +++ b/harbour/source/rtl/gtsln/gtsln.h @@ -87,10 +87,10 @@ * need to modified it for your slang version because UTF-8 patches * are still unoficial */ -#if ( UTF8 && SLSMG_HLINE_CHAR_TERM ) - #define HB_SLN_UNICODE -#elif SLANG_VERSION >= 20000 +#if SLANG_VERSION >= 20000 #define HB_SLN_UTF8 +#elif defined( UTF8 ) && defined( SLSMG_HLINE_CHAR_TERM ) + #define HB_SLN_UNICODE #endif /* missing defines in previous versions of Slang - this may not work ok ! */