From 764d241a1cdec330f32d986a57de1a09ea6445f7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 18 Feb 2011 21:20:38 +0000 Subject: [PATCH] 2011-02-18 22:20 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/rddads/rddads.h * contrib/rddads/ads1.c ! Fixed to check ADS_LIB_VERSION instead of ADS_LONGLONG to enable longlong related features. * Changed to use ADS_LIB_VERSION to detect availability of ADS_MONEY. * Deleted hack (which was a pending QUESTION for at least 4 years now) which redefined ADS_MAX_KEY_LENGTH for ADS 7.10 to 256, while the official value is 4082 there. Now rddads uses whatever value is defined by ADS header. ! Deleted hack to force usage of ADS_CISTRING, ADS_ROWVERSION, ADS_MODTIME. Now these features will be enabled based on ADS_LIB_VERSION. This was old pending TOFIX. It may theoretically change behavior for these field types in certain client/server version combinations, ..or not. Pls comment, I'm not ADS user. ! Added missing cast/warning when built against ADS 5.00. --- harbour/ChangeLog | 19 +++++++++++++++++ harbour/contrib/rddads/ads1.c | 38 +++++++++++++++++++-------------- harbour/contrib/rddads/rddads.h | 19 ----------------- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 289e0c5c89..684420d89b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,25 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-18 22:20 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/rddads/rddads.h + * contrib/rddads/ads1.c + ! Fixed to check ADS_LIB_VERSION instead of ADS_LONGLONG to + enable longlong related features. + * Changed to use ADS_LIB_VERSION to detect availability of + ADS_MONEY. + * Deleted hack (which was a pending QUESTION for at least 4 years + now) which redefined ADS_MAX_KEY_LENGTH for ADS 7.10 to 256, + while the official value is 4082 there. Now rddads uses whatever + value is defined by ADS header. + ! Deleted hack to force usage of ADS_CISTRING, ADS_ROWVERSION, + ADS_MODTIME. Now these features will be enabled based on + ADS_LIB_VERSION. This was old pending TOFIX. It may + theoretically change behavior for these field types in certain + client/server version combinations, ..or not. Pls comment, + I'm not ADS user. + ! Added missing cast/warning when built against ADS 5.00. + 2011-02-18 21:44 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/rddads/ads.ch ! Deleted COMMIT command which collided with Clipper diff --git a/harbour/contrib/rddads/ads1.c b/harbour/contrib/rddads/ads1.c index b8cf302417..b6d6ba9f07 100644 --- a/harbour/contrib/rddads/ads1.c +++ b/harbour/contrib/rddads/ads1.c @@ -1558,7 +1558,7 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) dbFieldInfo.uiLen = 8; dbFieldInfo.uiDec = uiDec; } -#ifdef ADS_CISTRING +#if ADS_LIB_VERSION >= 710 else if( pArea->iFileType == ADS_ADT && ! hb_strnicmp( szFieldType, "cicharacter", 2 ) ) { dbFieldInfo.uiType = HB_FT_STRING; @@ -1633,7 +1633,7 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) dbFieldInfo.uiTypeExtended = ADS_LOGICAL; dbFieldInfo.uiLen = 1; } -#ifdef ADS_LONGLONG +#if ADS_LIB_VERSION >= 700 else if( ! hb_strnicmp( szFieldType, "longlong", 3 ) ) { dbFieldInfo.uiType = HB_FT_INTEGER; @@ -1654,7 +1654,7 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) dbFieldInfo.uiTypeExtended = ADS_MEMO; dbFieldInfo.uiLen = ( pArea->iFileType == ADS_ADT ) ? 9 : ( uiLen == 4 ? 4 : 10 ); } -#ifdef ADS_MONEY +#if ADS_LIB_VERSION >= 700 else if( ! hb_strnicmp( szFieldType, "money", 3 ) || ( iNameLen == 1 && iData == 'Y' ) ) { dbFieldInfo.uiType = HB_FT_CURRENCY; @@ -1663,7 +1663,7 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) dbFieldInfo.uiDec = 4; } #endif -#ifdef ADS_MODTIME +#if ADS_LIB_VERSION >= 800 else if( pArea->iFileType == ADS_ADT && ( ! hb_strnicmp( szFieldType, "modtime", 3 ) || ( iNameLen == 1 && iData == '=' ) ) ) { @@ -1681,7 +1681,7 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) if( ( iNameLen == 1 && iData == 'I' ) || ! hb_strnicmp( szFieldType, "integer", 2 ) ) { dbFieldInfo.uiType = HB_FT_INTEGER; -#ifdef ADS_LONGLONG +#if ADS_LIB_VERSION >= 700 dbFieldInfo.uiLen = ( pArea->iFileType == ADS_ADT && uiLen == 2 ) ? 2 : ( uiLen == 8 ? 8 : 4 ); dbFieldInfo.uiTypeExtended = dbFieldInfo.uiLen == 4 ? ADS_INTEGER : ( dbFieldInfo.uiLen == 2 ? ADS_SHORTINT : ADS_LONGLONG); @@ -1815,7 +1815,7 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) dbFieldInfo.uiTypeExtended = ADS_RAW; dbFieldInfo.uiFlags = HB_FF_BINARY; } -#if ADS_ROWVERSION +#if ADS_LIB_VERSION >= 800 else if( pArea->iFileType == ADS_ADT && ( ! hb_strnicmp( szFieldType, "rowversion", 2 ) || ( iNameLen == 1 && iData == '^' ) ) ) { @@ -1991,7 +1991,7 @@ static HB_ERRCODE adsFieldInfo( ADSAREAP pArea, HB_USHORT uiIndex, HB_USHORT uiT hb_itemPutC( pItem, "RAW" ); else if( pField->uiFlags & HB_FF_UNICODE ) hb_itemPutC( pItem, "NCHAR" ); -#ifdef ADS_CISTRING +#if ADS_LIB_VERSION >= 710 else if( pField->uiTypeExtended == ADS_CISTRING ) hb_itemPutC( pItem, "CICHARACTER" ); #endif @@ -2255,7 +2255,7 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, HB_USHORT uiIndex, PHB_ITEM pItem } case HB_FT_INTEGER: { -#ifdef ADS_LONGLONG +#if ADS_LIB_VERSION >= 700 if( pField->uiTypeExtended == ADS_LONGLONG ) { #ifndef HB_LONG_LONG_OFF @@ -2349,7 +2349,7 @@ static HB_ERRCODE adsGetValue( ADSAREAP pArea, HB_USHORT uiIndex, PHB_ITEM pItem dVal = 0.0; pArea->area.fEof = HB_TRUE; } -#ifdef ADS_MONEY /* Not defined below 7.00 */ +#if ADS_LIB_VERSION >= 700 if( pField->uiTypeExtended == ADS_CURDOUBLE || pField->uiTypeExtended == ADS_DOUBLE || pField->uiTypeExtended == ADS_MONEY ) @@ -2997,7 +2997,7 @@ static HB_ERRCODE adsCreate( ADSAREAP pArea, LPDBOPENINFO pCreateInfo ) cType = "NChar"; fUnicode = HB_TRUE; } -#ifdef ADS_CISTRING +#if ADS_LIB_VERSION >= 710 else if( pField->uiTypeExtended == ADS_CISTRING ) cType = "CICharacter"; #endif @@ -3023,7 +3023,7 @@ static HB_ERRCODE adsCreate( ADSAREAP pArea, LPDBOPENINFO pCreateInfo ) case HB_FT_INTEGER: if( pField->uiTypeExtended == ADS_SHORTINT ) cType = "ShortInt"; -#ifdef ADS_LONGLONG +#if ADS_LIB_VERSION >= 700 else if( pField->uiTypeExtended == ADS_LONGLONG ) cType = "Longlong"; #endif @@ -3546,7 +3546,7 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) dbFieldInfo.uiFlags = HB_FF_BINARY; break; -#ifdef ADS_CISTRING /* Not defined below 7.10 */ +#if ADS_LIB_VERSION >= 710 case ADS_CISTRING: dbFieldInfo.uiType = HB_FT_STRING; break; @@ -3570,7 +3570,7 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) dbFieldInfo.uiDec = ( HB_USHORT ) usDecimals; break; -#ifdef ADS_MONEY /* Not defined below 7.00 */ +#if ADS_LIB_VERSION >= 700 case ADS_MONEY: dbFieldInfo.uiType = HB_FT_CURRENCY; AdsGetFieldDecimals( pArea->hTable, szName, &usDecimals ); @@ -3580,7 +3580,7 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) case ADS_INTEGER: case ADS_SHORTINT: -#ifdef ADS_LONGLONG +#if ADS_LIB_VERSION >= 700 case ADS_LONGLONG: #endif dbFieldInfo.uiType = HB_FT_INTEGER; @@ -3594,17 +3594,21 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) dbFieldInfo.uiType = HB_FT_TIMESTAMP; break; +#if ADS_LIB_VERSION >= 800 case ADS_MODTIME: dbFieldInfo.uiType = HB_FT_MODTIME; break; +#endif case ADS_AUTOINC: dbFieldInfo.uiType = HB_FT_AUTOINC; break; +#if ADS_LIB_VERSION >= 800 case ADS_ROWVERSION: dbFieldInfo.uiType = HB_FT_ROWVER; break; +#endif case ADS_LOGICAL: dbFieldInfo.uiType = HB_FT_LOGICAL; @@ -4149,8 +4153,10 @@ static HB_ERRCODE adsOrderCreate( ADSAREAP pArea, LPDBORDERCREATEINFO pOrderInfo ( UNSIGNED8 * ) pArea->area.lpdbOrdCondInfo->abFor : ( UNSIGNED8 * ) "", pucWhile, u32Options, ADS_DEFAULT, &hIndex); #else - u32RetVal = AdsCreateIndex( hTableOrIndex, pOrderInfo->abBagName, - pOrderInfo->atomBagName, ( UNSIGNED8 * ) hb_itemGetCPtr( pExprItem ), + u32RetVal = AdsCreateIndex( hTableOrIndex, + ( UNSIGNED8 * ) pOrderInfo->abBagName, + ( UNSIGNED8 * ) pOrderInfo->atomBagName, + ( UNSIGNED8 * ) hb_itemGetCPtr( pExprItem ), ( pArea->area.lpdbOrdCondInfo && pArea->area.lpdbOrdCondInfo->abFor ) ? ( UNSIGNED8 * ) pArea->area.lpdbOrdCondInfo->abFor : ( UNSIGNED8 * ) "", pucWhile, u32Options, &hIndex); diff --git a/harbour/contrib/rddads/rddads.h b/harbour/contrib/rddads/rddads.h index d9c0e05529..76ecf07f21 100644 --- a/harbour/contrib/rddads/rddads.h +++ b/harbour/contrib/rddads/rddads.h @@ -105,25 +105,6 @@ #define ADS_LIB_VERSION _ADS_LIB_VERSION #endif -/* QUESTION: Why do we redefine this? Normally it is 4082 in 7.10 or upper and 256 in lower versions. [vszakats] */ -#undef ADS_MAX_KEY_LENGTH -#if ADS_LIB_VERSION >= 800 - #define ADS_MAX_KEY_LENGTH 4082 /* maximum key value length. This is the max key length */ -#else /* of ADI indexes. Max CDX key length is 240. Max */ - #define ADS_MAX_KEY_LENGTH 256 /* NTX key length is 256 */ -#endif - -/* TOFIX: These should rather be guarded with ADS_LIB_VERSION than being defined here. [vszakats] */ -#ifndef ADS_CISTRING - #define ADS_CISTRING 20 /* CaSe INSensiTIVE character data (>= 7.10) */ -#endif -#ifndef ADS_ROWVERSION - #define ADS_ROWVERSION 21 /* 8 byte integer, incremented for every update, unique to entire table (>= 8.00) */ -#endif -#ifndef ADS_MODTIME - #define ADS_MODTIME 22 /* 8 byte timestamp, updated when record is updated (>= 8.00) */ -#endif - HB_EXTERN_BEGIN #if ADS_LIB_VERSION >= 600