diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3a61e66867..bd132cceb1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,19 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-14 19:20 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/bin/hb-func.sh + * respect HB_USER_LIBS creating hbmk.cfg + + * harbour/contrib/rddads/ads1.c + ! fixed minimal record buffer size calculation + ! fixed adsGetValue() method hacked to not report errors due to too + small field buffer. + Warning! Now ADS RDD will report any error as RTE if sth wrong + will happen in one of AdsGet*() function when field is read so + it's possible that also some other hidden bugs will be exploited + and you will see RTE. Please test it. + 2009-05-14 19:01 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.prg * -shareable -> -fullshared/-fixshared diff --git a/harbour/bin/hb-func.sh b/harbour/bin/hb-func.sh index 0f7c6c7925..bd85a0fa44 100755 --- a/harbour/bin/hb-func.sh +++ b/harbour/bin/hb-func.sh @@ -252,6 +252,9 @@ mk_hbtools() if [ -n "${CC_HB_USER_LDFLAGS}" ]; then echo "ldflags=${CC_HB_USER_LDFLAGS}">> ${hb_hbmkcfg} fi + if [ -n "${HB_USER_LIBS}" ]; then + echo "libs=${HB_USER_LIBS}">> ${hb_hbmkcfg} + fi if [ "${HB_GPM_MOUSE}" = "yes" ]; then echo "libs=gpm">> ${hb_hbmkcfg} fi diff --git a/harbour/contrib/rddads/ads1.c b/harbour/contrib/rddads/ads1.c index a3f17f78ff..c5320fb536 100644 --- a/harbour/contrib/rddads/ads1.c +++ b/harbour/contrib/rddads/ads1.c @@ -2010,11 +2010,12 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { case HB_FT_STRING: case HB_FT_VARLENGTH: - u32Length = pArea->maxFieldLen; + u32Length = pArea->maxFieldLen + 1; if( !pArea->fPositioned ) { u32Length = pField->uiType == HB_FT_STRING ? pField->uiLen : 0; memset( pBuffer, ' ', u32Length ); + ulRetVal = AE_SUCCESS; } #ifdef ADS_USE_OEM_TRANSLATION #if ADS_LIB_VERSION >= 900 @@ -2024,18 +2025,18 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) #endif { #if ADS_LIB_VERSION >= 600 - if( AdsGetFieldRaw( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length ) == AE_NO_CURRENT_RECORD ) + ulRetVal = AdsGetFieldRaw( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length ); + if( ulRetVal != AE_SUCCESS ) { u32Length = pField->uiType == HB_FT_STRING ? pField->uiLen : 0; memset( pBuffer, ' ', u32Length ); - hb_adsUpdateAreaFlags( pArea ); } #else - if( AdsGetField( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length, ADS_NONE ) == AE_NO_CURRENT_RECORD ) + ulRetVal = AdsGetField( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length, ADS_NONE ); + if( ulRetVal != AE_SUCCESS ) { u32Length = pField->uiType == HB_FT_STRING ? pField->uiLen : 0; memset( pBuffer, ' ', u32Length ); - hb_adsUpdateAreaFlags( pArea ); } else { @@ -2046,23 +2047,16 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) #endif } #endif - else if( AdsGetField( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length, ADS_NONE ) == AE_NO_CURRENT_RECORD ) + else { - u32Length = pField->uiType == HB_FT_STRING ? pField->uiLen : 0; - memset( pBuffer, ' ', u32Length ); - /* It should not happen - sth desynchronize WA with ADS, - update area flags, Druzus */ - hb_adsUpdateAreaFlags( pArea ); + ulRetVal = AdsGetField( pArea->hTable, ADSFIELD( uiIndex ), pBuffer, &u32Length, ADS_NONE ); + if( ulRetVal != AE_SUCCESS ) + { + u32Length = pField->uiType == HB_FT_STRING ? pField->uiLen : 0; + memset( pBuffer, ' ', u32Length ); + } + hb_itemPutCL( pItem, ( char * ) pBuffer, u32Length ); } - /* workaround for ACE bug: character fields longer then 23 bytes are - * increased by one byte when read by AdsGetField(). This hack can - * cut the results read from some type of compressed fields so it - * should be removed for ACE clients which does not have such - * problems [druzus]. - */ - if( u32Length > ( ULONG ) pField->uiLen ) - u32Length = pField->uiLen; - hb_itemPutCL( pItem, ( char * ) pBuffer, u32Length ); break; case HB_FT_TIME: @@ -2070,9 +2064,8 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) case HB_FT_MODTIME: { SIGNED32 lTime = 0, lDate = 0; - u32Length = pArea->maxFieldLen + 1; ulRetVal = AdsGetMilliseconds( pArea->hTable, ADSFIELD( uiIndex ), &lTime ); - if( ulRetVal == AE_NO_CURRENT_RECORD ) + if( ulRetVal != AE_SUCCESS ) { lTime = 0; pArea->fEof = TRUE; @@ -2080,7 +2073,7 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) else if( pField->uiType != HB_FT_TIME ) { ulRetVal = AdsGetJulian( pArea->hTable, ADSFIELD( uiIndex ), &lDate ); - if( ulRetVal == AE_NO_CURRENT_RECORD ) + if( ulRetVal != AE_SUCCESS ) { pArea->fEof = TRUE; lDate = 0; @@ -2093,7 +2086,7 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { SIGNED32 lVal = 0; ulRetVal = AdsGetLong( pArea->hTable, ADSFIELD( uiIndex ), &lVal ); - if( ulRetVal == AE_NO_CURRENT_RECORD ) + if( ulRetVal != AE_SUCCESS ) { lVal = 0; pArea->fEof = TRUE; @@ -2105,12 +2098,11 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) break; } #if ADS_LIB_VERSION >= 700 && !defined(HB_LONG_LONG_OFF) - case HB_FT_AUTOINC: { SIGNED64 qVal = 0; ulRetVal = AdsGetLongLong( pArea->hTable, ADSFIELD( uiIndex ), &qVal ); - if( ulRetVal == AE_NO_CURRENT_RECORD ) + if( ulRetVal != AE_SUCCESS ) { qVal = 0; pArea->fEof = TRUE; @@ -2122,7 +2114,7 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { SIGNED64 qVal = 0; ulRetVal = AdsGetLongLong( pArea->hTable, ADSFIELD( uiIndex ), &qVal ); - if( ulRetVal == AE_NO_CURRENT_RECORD ) + if( ulRetVal != AE_SUCCESS ) { qVal = 0; pArea->fEof = TRUE; @@ -2137,7 +2129,7 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) DOUBLE dVal = 0; ulRetVal = AdsGetDouble( pArea->hTable, ADSFIELD( uiIndex ), &dVal ); - if( ulRetVal == AE_NO_CURRENT_RECORD ) + if( ulRetVal != AE_SUCCESS ) { dVal = 0.0; pArea->fEof = TRUE; @@ -2154,7 +2146,7 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) DOUBLE dVal = 0; ulRetVal = AdsGetDouble( pArea->hTable, ADSFIELD( uiIndex ), &dVal ); - if( ulRetVal == AE_NO_CURRENT_RECORD ) + if( ulRetVal != AE_SUCCESS ) { dVal = 0.0; pArea->fEof = TRUE; @@ -2188,7 +2180,8 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { SIGNED32 lDate; - if( AdsGetJulian( pArea->hTable, ADSFIELD( uiIndex ), &lDate ) == AE_NO_CURRENT_RECORD ) + ulRetVal = AdsGetJulian( pArea->hTable, ADSFIELD( uiIndex ), &lDate ); + if( ulRetVal != AE_SUCCESS ) { pArea->fEof = TRUE; lDate = 0; @@ -2198,47 +2191,49 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) } case HB_FT_LOGICAL: + { + UNSIGNED16 pbValue = FALSE; + ulRetVal = AdsGetLogical( pArea->hTable, ADSFIELD( uiIndex ), &pbValue ); + if( ulRetVal != AE_SUCCESS ) { - UNSIGNED16 pbValue = FALSE; - if( AdsGetLogical( pArea->hTable, ADSFIELD( uiIndex ), &pbValue ) == AE_NO_CURRENT_RECORD ) - { - pbValue = FALSE; - pArea->fEof = TRUE; - } - hb_itemPutL( pItem, pbValue != 0 ); - break; + pbValue = FALSE; + pArea->fEof = TRUE; } + hb_itemPutL( pItem, pbValue != 0 ); + break; + } case HB_FT_MEMO: case HB_FT_BLOB: case HB_FT_IMAGE: { UNSIGNED8 *pucBuf; - UNSIGNED32 pulLen; - UNSIGNED16 pusType; + UNSIGNED32 u32Len; + UNSIGNED16 u16Type; - AdsGetMemoDataType( pArea->hTable, ADSFIELD( uiIndex ), &pusType ); - - if( pusType != ADS_BINARY && pusType != ADS_IMAGE ) + ulRetVal = AdsGetMemoDataType( pArea->hTable, ADSFIELD( uiIndex ), &u16Type ); + if( ulRetVal != AE_SUCCESS ) + hb_itemPutC( pItem, NULL ); + else if( u16Type != ADS_BINARY && u16Type != ADS_IMAGE ) { - if( AdsGetMemoLength( pArea->hTable, ADSFIELD( uiIndex ), &pulLen ) == AE_NO_CURRENT_RECORD ) - { + ulRetVal = AdsGetMemoLength( pArea->hTable, ADSFIELD( uiIndex ), &u32Len ); + if( ulRetVal != AE_SUCCESS ) hb_itemPutC( pItem, NULL ); - } else { - if( pulLen > 0 ) + if( u32Len > 0 ) { - char * szRet; - - pulLen++; /* make room for NULL */ - pucBuf = ( UNSIGNED8 * ) hb_xgrab( pulLen ); - AdsGetString( pArea->hTable, ADSFIELD( uiIndex ), pucBuf, &pulLen, ADS_NONE ); - - szRet = hb_adsAnsiToOem( ( char * ) pucBuf, pulLen ); - hb_itemPutCL( pItem, szRet, pulLen ); - hb_adsOemAnsiFree( szRet ); - + u32Len++; /* make room for NULL */ + pucBuf = ( UNSIGNED8 * ) hb_xgrab( u32Len ); + ulRetVal = AdsGetString( pArea->hTable, ADSFIELD( uiIndex ), pucBuf, &u32Len, ADS_NONE ); + if( ulRetVal != AE_SUCCESS ) + hb_itemPutC( pItem, NULL ); + else + { + char * szRet = hb_adsAnsiToOem( ( char * ) pucBuf, u32Len ); + hb_itemPutCL( pItem, szRet, u32Len ); + hb_adsOemAnsiFree( szRet ); + } hb_xfree( pucBuf ); } else @@ -2247,22 +2242,43 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) } else { - if( AdsGetBinaryLength( pArea->hTable, ADSFIELD( uiIndex ), &pulLen ) == AE_NO_CURRENT_RECORD ) - { + ulRetVal = AdsGetBinaryLength( pArea->hTable, ADSFIELD( uiIndex ), &u32Len ); + if( ulRetVal != AE_SUCCESS ) hb_itemPutC( pItem, NULL ); - } else { - pulLen++; /* make room for NULL */ - pucBuf = ( UNSIGNED8 * ) hb_xgrab( pulLen ); - AdsGetBinary( pArea->hTable, ADSFIELD( uiIndex ), 0, pucBuf, &pulLen ); - hb_itemPutCLPtr( pItem, ( char * ) pucBuf, pulLen ); + u32Len++; /* make room for NULL */ + pucBuf = ( UNSIGNED8 * ) hb_xgrab( u32Len ); + AdsGetBinary( pArea->hTable, ADSFIELD( uiIndex ), 0, pucBuf, &u32Len ); + hb_itemPutCLPtr( pItem, ( char * ) pucBuf, u32Len ); } } hb_itemSetCMemo( pItem ); break; } + default: + commonError( pArea, EG_DATATYPE, 1020, 0, NULL, 0, NULL ); + return HB_FAILURE; } + + if( ulRetVal == AE_NO_CURRENT_RECORD ) + { + if( pArea->fPositioned ) + { + /* It should not happen - sth desynchronize WA with ADS, + update area flags, Druzus */ + hb_adsUpdateAreaFlags( pArea ); + } + } + else if( ulRetVal != AE_SUCCESS ) + { + if( ulRetVal == AE_DATA_TOO_LONG ) + commonError( pArea, EG_DATAWIDTH, EDBF_DATAWIDTH, 0, NULL, 0, NULL ); + else + commonError( pArea, EG_READ, ( USHORT ) ulRetVal, 0, NULL, 0, NULL ); + return HB_FAILURE; + } + return HB_SUCCESS; } @@ -2286,7 +2302,7 @@ static HB_ERRCODE adsGetVarLen( ADSAREAP pArea, USHORT uiIndex, ULONG * ulLen ) if( !pArea->fPositioned ) *ulLen = 0; - else if( AdsGetMemoLength( pArea->hTable, ADSFIELD( uiIndex ), &u32Len ) == AE_NO_CURRENT_RECORD ) + else if( AdsGetMemoLength( pArea->hTable, ADSFIELD( uiIndex ), &u32Len ) != AE_SUCCESS ) { /* It should not happen - sth desynchronize WA with ADS, update area flags, Druzus */ @@ -2821,6 +2837,9 @@ static HB_ERRCODE adsCreate( ADSAREAP pArea, LPDBOPENINFO pCreateInfo ) } *ucfieldPtr = '\0'; + if( pArea->maxFieldLen < 24 ) + pArea->maxFieldLen = 24; + uRetVal = AdsCreateTable( hConnection, pCreateInfo->abName, pCreateInfo->atomAlias, @@ -2856,7 +2875,7 @@ static HB_ERRCODE adsCreate( ADSAREAP pArea, LPDBOPENINFO pCreateInfo ) pArea->uiRecordLen = (USHORT) u32Length; /* Alloc record buffer - because it's also used for some extended types conversion it has to be at least 25 bytes size */ - pArea->pRecord = ( BYTE * ) hb_xgrab( HB_MAX( pArea->uiRecordLen, 25 ) ); + pArea->pRecord = ( BYTE * ) hb_xgrab( HB_MAX( pArea->uiRecordLen, pArea->maxFieldLen ) + 1 ); return SELF_GOTOP( ( AREAP ) pArea ); } @@ -3197,9 +3216,8 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) dbFieldInfo.uiDec = 0; dbFieldInfo.uiFlags = 0; if( u32Length > pArea->maxFieldLen ) - { pArea->maxFieldLen = u32Length; - } + dbFieldInfo.uiTypeExtended = usType; switch( usType ) { @@ -3317,7 +3335,7 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) pArea->uiRecordLen = (USHORT) u32Length; /* Alloc record buffer - because it's also used for some extended types conversion it has to be at least 25 bytes size */ - pArea->pRecord = ( BYTE * ) hb_xgrab( HB_MAX( pArea->uiRecordLen, 25 ) ); + pArea->pRecord = ( BYTE * ) hb_xgrab( HB_MAX( pArea->uiRecordLen, pArea->maxFieldLen ) + 1 ); /* If successful call SUPER_OPEN to finish system jobs */ if( SUPER_OPEN( ( AREAP ) pArea, pOpenInfo ) == HB_FAILURE )