From 87a69afab1ee81380813c249ccb98d2dc118063f Mon Sep 17 00:00:00 2001 From: Bruno Cantero Date: Sun, 22 Aug 1999 16:38:00 +0000 Subject: [PATCH] ChangeLogTag:19990822-18:20 GMT+1 Bruno Cantero --- harbour/ChangeLog | 6 ++++ harbour/include/rddapi.h | 14 ++++++--- harbour/source/rdd/dbcmd.c | 18 +++++++++-- harbour/source/rdd/dbf1.c | 64 ++++++++++++++++++++++++++++++++------ 4 files changed, 87 insertions(+), 15 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b48f201800..7fa38bdc18 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +19990822-18:20 GMT+1 Bruno Cantero + * include/rddapi.h + source/rdd/dbcmd.c + source/rdd/dbf1.c + * Bug in PutValue removed + 19990822-14:12 GMT+1 Victor Szel * config/win32/gcc.cf + -( -) parameters temporarly readded, to make it work, new circular diff --git a/harbour/include/rddapi.h b/harbour/include/rddapi.h index d5d986b817..7a36e1bd6d 100644 --- a/harbour/include/rddapi.h +++ b/harbour/include/rddapi.h @@ -177,9 +177,10 @@ typedef struct USHORT uiHeaderLen; /* Size of header */ USHORT uiRecordLen; /* Size of record */ BYTE * bRecord; /* Buffer of the data */ - BYTE * bOldRecord; /* Buffer of the data for undelete */ BOOL fHasMemo; /* Work Area with Memo fields */ PHB_ITEM pRecNo; /* Current record */ + BOOL fExclusive; /* Share the Work Area */ + BOOL fFileLocked; /* File Locked */ } DBEXTENDINFO; typedef DBEXTENDINFO * LPDBEXTENDINFO; @@ -554,11 +555,13 @@ typedef USHORT ( * DBENTRYP_I )( AREAP area, PHB_ITEM param ); typedef USHORT ( * DBENTRYP_SI )( AREAP area, USHORT index, PHB_ITEM param ); typedef USHORT ( * DBENTRYP_VP )( AREAP area, LPDBOPENINFO param ); typedef USHORT ( * DBENTRYP_VF )( AREAP area, LPDBFIELDINFO param ); +typedef USHORT ( * DBENTRYP_VL )( AREAP area, LPDBLOCKINFO param ); typedef USHORT ( * DBENTRYP_SP )( AREAP area, USHORT * param ); typedef USHORT ( * DBENTRYP_P )( AREAP area, BYTE * param ); typedef USHORT ( * DBENTRYP_S )( AREAP area, USHORT param ); typedef USHORT ( * DBENTRYP_LP )( AREAP area, LONG * param ); typedef USHORT ( * DBENTRYP_SVP )( AREAP area, USHORT index, void * param ); +typedef USHORT ( * DBENTRYP_VSP )( AREAP area, USHORT action, LONG lRecord ); #if 0 typedef USHORT ( * DBENTRYP_PP )( AREAP area, void ** param); @@ -568,7 +571,6 @@ typedef USHORT ( * DBENTRYP_VPLP )( AREAP area, void * p1, LONGP p2); typedef USHORT ( * DBENTRYP_LSP )( AREAP area, LONG p1, USHORTP p2); typedef USHORT ( * DBENTRYP_SSI )( AREAP area, USHORT p1, USHORT p2, PHB_ITEM p3); typedef USHORT ( * DBENTRYP_ISI )( AREAP area, PHB_ITEM p1, USHORT p2, PHB_ITEM p3); -typedef USHORT ( * DBENTRYP_VSP )( AREAP area, USHORT action, LONG lRecord); #endif @@ -698,19 +700,23 @@ typedef struct _RDDFUNCS /* Miscellaneous */ DBENTRYP_VP compile; - DBENTRYP_VP error; +#endif + DBENTRYP_I error; +#if 0 DBENTRYP_I evalBlock; +#endif /* Network operations */ DBENTRYP_VSP rawlock; - DBENTRYP_VP lock; + DBENTRYP_VL lock; DBENTRYP_L unlock; /* Memofile functions */ +#if 0 DBENTRYP_V closeMemFile; DBENTRYP_VP createMemFile; DBENTRYP_SVPB getValueFile; diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index 0eb20cb921..3affe4b3c3 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -230,6 +230,17 @@ static ERRCODE Eof( AREAP pArea, BOOL * pEof ) return SUCCESS; } +static ERRCODE Error( AREAP pArea, PHB_ITEM pError ) +{ + char * szRddName; + + szRddName = ( char * ) hb_xgrab( HARBOUR_MAX_RDD_DRIVERNAME_LENGTH + 1 ); + SELF_SYSNAME( pArea, ( BYTE * ) szRddName ); + hb_errPutSubSystem( pError, szRddName ); + hb_xfree( szRddName ); + return hb_errLaunch( pError ); +} + static ERRCODE FieldCount( AREAP pArea, USHORT * uiFields ) { * uiFields = pArea->uiFieldCount; @@ -321,6 +332,7 @@ static ERRCODE Open( AREAP pArea, LPDBOPENINFO pOpenInfo ) ( ( PHB_DYNS ) pArea->atomAlias )->hArea = 0; return FAILURE; } + pArea->lpExtendInfo->fExclusive = !pOpenInfo->fShared; return SELF_GOTOP( pArea ); } @@ -353,8 +365,6 @@ static ERRCODE Release( AREAP pArea ) { if( pArea->lpExtendInfo->bRecord ) hb_xfree( pArea->lpExtendInfo->bRecord ); - if( pArea->lpExtendInfo->bOldRecord ) - hb_xfree( pArea->lpExtendInfo->bOldRecord ); hb_itemRelease( pArea->lpExtendInfo->pRecNo ); hb_xfree( pArea->lpExtendInfo ); } @@ -446,6 +456,10 @@ static RDDFUNCS defTable = { Bof, Release, StructSize, SysName, + Error, + ( DBENTRYP_VSP ) UnSupported, + ( DBENTRYP_VL ) UnSupported, + ( DBENTRYP_L ) UnSupported, UnSupported, UnSupported }; diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index d3fbaf38c2..cdec0ff3f0 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -31,6 +31,7 @@ #include "rddsys.ch" #include "errorapi.h" #include "dates.h" +#include "langapi.h" typedef struct { @@ -223,6 +224,20 @@ static ERRCODE Info( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) return SUCCESS; } +static ERRCODE Lock( AREAP pArea, LPDBLOCKINFO pLockInfo ) +{ + if( SELF_RAWLOCK( pArea, pLockInfo->uiMethod, pLockInfo->itmRecID ) == SUCCESS ) + { + pLockInfo->fResult = TRUE; + return SUCCESS; + } + else + { + pLockInfo->fResult = FALSE; + return FAILURE; + } +} + static ERRCODE PutValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { LPFIELD pField; @@ -233,7 +248,7 @@ static ERRCODE PutValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( uiIndex > pArea->uiFieldCount ) return FAILURE; - + pField = pArea->lpFields; uiOffset = 1; for( uiCount = 1; uiCount < uiIndex; uiCount++ ) @@ -255,18 +270,34 @@ static ERRCODE PutValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { szOldChar = szText + pField->uiLen + ( ( USHORT ) pField->uiDec << 8 ); szEndChar = * szOldChar; - sprintf( (char *)szText, "%-*s", pField->uiLen, pItem->item.asString.value ); + sprintf( ( char * ) szText, "%-*s", pField->uiLen, pItem->item.asString.value ); bError = FALSE; } break; case 'N': - if( pItem->type & IT_NUMERIC ) + if( pItem->type & IT_INTEGER ) { if( pField->uiDec ) - sprintf( (char *)szText, "%*.*f", pField->uiLen, pField->uiDec, pItem->item.asDouble.value ); + sprintf( ( char * ) szText, "%*.*f", pField->uiLen, pField->uiDec, pItem->item.asInteger.value ); else - sprintf( (char *)szText, "%*ld", pField->uiLen, pItem->item.asInteger.value ); + sprintf( ( char * ) szText, "%*i", pField->uiLen, pItem->item.asInteger.value ); + bError = FALSE; + } + else if( pItem->type & IT_LONG ) + { + if( pField->uiDec ) + sprintf( ( char * ) szText, "%*.*f", pField->uiLen, pField->uiDec, pItem->item.asLong.value ); + else + sprintf( ( char * ) szText, "%*l", pField->uiLen, pItem->item.asLong.value ); + bError = FALSE; + } + else if( pItem->type & IT_DOUBLE ) + { + if( pField->uiDec ) + sprintf( ( char * ) szText, "%*.*f", pField->uiLen, pField->uiDec, pItem->item.asDouble.value ); + else + sprintf( ( char * ) szText, "%*l", pField->uiLen, pItem->item.asDouble.value ); bError = FALSE; } break; @@ -275,7 +306,7 @@ static ERRCODE PutValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( pItem->type & IT_DATE ) { hb_dateDecode( pItem->item.asDate.value, &lDay, &lMonth, &lYear ); - hb_dateStrPut( (char *)szText, lDay, lMonth, lYear ); + hb_dateStrPut( ( char * ) szText, lDay, lMonth, lYear ); bError = FALSE; } break; @@ -301,6 +332,14 @@ static ERRCODE PutValue( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) return SUCCESS; } +static ERRCODE RawLock( AREAP pArea, USHORT uiAction, LONG lRecNo ) +{ + switch( uiAction ) + { + } + return SUCCESS; +} + static ERRCODE ReadBuffer( AREAP pArea, LONG lRecNo ) { hb_fsSeek( pArea->lpFileInfo->hFile, pArea->lpExtendInfo->uiHeaderLen + @@ -388,9 +427,6 @@ static ERRCODE ReadDBHeader( AREAP pArea ) pArea->lpExtendInfo->bRecord = ( BYTE * ) hb_xgrab( pArea->lpExtendInfo->uiRecordLen + 1 ); memset( pArea->lpExtendInfo->bRecord, ' ', pArea->lpExtendInfo->uiRecordLen ); pArea->lpExtendInfo->bRecord[ pArea->lpExtendInfo->uiRecordLen ] = 0; - pArea->lpExtendInfo->bOldRecord = ( BYTE * ) hb_xgrab( pArea->lpExtendInfo->uiRecordLen + 1 ); - memset( pArea->lpExtendInfo->bOldRecord, ' ', pArea->lpExtendInfo->uiRecordLen ); - pArea->lpExtendInfo->bOldRecord[ pArea->lpExtendInfo->uiRecordLen ] = 0; return SUCCESS; } @@ -417,6 +453,11 @@ static ERRCODE SkipRaw( AREAP pArea, LONG lToSkip ) return SELF_GOTO( pArea, hb_itemGetNL( pArea->lpExtendInfo->pRecNo ) + lToSkip ); } +static ERRCODE UnLock( AREAP pArea, LONG lRecNo ) +{ + return SELF_RAWLOCK( pArea, REC_UNLOCK, lRecNo ); +} + static ERRCODE WriteDBHeader( AREAP pArea ) { DBFHEADER pHeader; @@ -544,6 +585,10 @@ static RDDFUNCS dbfTable = { 0, /* Super Bof */ 0, /* Super Release */ 0, /* Super StructSize */ 0, /* Super SysName */ + 0, /* Super Error */ + RawLock, + Lock, + UnLock, ReadDBHeader, WriteDBHeader }; @@ -565,3 +610,4 @@ HARBOUR HB_DBF_GETFUNCTABLE( void ) else hb_retni( FAILURE ); } +