Updating RDD files, dbftools.c added

This commit is contained in:
Alexander S.Kresin
2000-02-04 19:20:45 +00:00
parent 841312164a
commit 41ed640cfd
4 changed files with 387 additions and 240 deletions

View File

@@ -1,6 +1,15 @@
20000204-22:12 GMT+3 Alexander Kresin
* source/rdd/dbcmd.c
+ added hb_rddGetCurrentWorkAreaPointer() function
+ source/rtl/tools/dbftools.c
Some Clipper Tools compatible functions
* contrib/rdd_ads/ads1.c
* Bugs fixed related to lock/unlock
* Memo support added
20000204-14:47 GMT+1 Victor Szakats <info@szelvesz.hu>
* source/rtl/itemapi.c
! hb_itemNew() fixed to set the item type *after* filling the item
! hb_itemNew() fixed to set the item type *after* filling the item
structure with zeros. It won't set the type at all when a param other
than NULL was passed.
* makewww.bat

View File

@@ -193,7 +193,7 @@ static ERRCODE adsBof( ADSAREAP pArea, BOOL * pBof )
{
HB_TRACE(HB_TR_DEBUG, ("adsBof(%p, %p)", pArea, pBof));
AdsAtBOF ( pArea->hTable, &(pArea->fBof) );
AdsAtBOF ( pArea->hTable, (UNSIGNED16 *)&(pArea->fBof) );
* pBof = pArea->fBof;
return SUCCESS;
}
@@ -202,7 +202,7 @@ static ERRCODE adsEof( ADSAREAP pArea, BOOL * pEof )
{
HB_TRACE(HB_TR_DEBUG, ("adsEof(%p, %p)", pArea, pEof));
AdsAtEOF( pArea->hTable, &(pArea->fEof) );
AdsAtEOF( pArea->hTable, (UNSIGNED16 *)&(pArea->fEof) );
* pEof = pArea->fEof;
return SUCCESS;
}
@@ -211,7 +211,7 @@ static ERRCODE adsFound( ADSAREAP pArea, BOOL * pFound )
{
HB_TRACE(HB_TR_DEBUG, ("adsFound(%p, %p)", pArea, pFound));
AdsIsFound( pArea->hTable, &(pArea->fFound) );
AdsIsFound( pArea->hTable, (UNSIGNED16 *)&(pArea->fFound) );
* pFound = pArea->fFound;
return SUCCESS;
}
@@ -427,6 +427,26 @@ static ERRCODE adsGetValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
else
hb_itemPutL( pItem, FALSE );
break;
case 'M':
{
UNSIGNED8 szName[HARBOUR_MAX_RDD_FIELDNAME_LENGTH+1];
UNSIGNED16 pusBufLen = HARBOUR_MAX_RDD_FIELDNAME_LENGTH;
UNSIGNED8 *pucBuf;
UNSIGNED32 pulLen;
AdsGetFieldName( pArea->hTable, uiIndex, szName, &pusBufLen );
AdsGetMemoLength( pArea->hTable, szName, &pulLen );
if( pulLen > 0 )
{
pucBuf = (UNSIGNED8*) hb_xgrab( pulLen );
AdsGetString( pArea->hTable, szName, pucBuf, &pulLen, ADS_NONE );
hb_itemPutCL( pItem, ( char * ) pucBuf, pulLen );
hb_xfree( pucBuf );
}
else
hb_itemPutC( pItem, "" );
break;
}
}
return SUCCESS;
@@ -485,8 +505,7 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
uiCount = pField->uiLen;
memcpy( szText, pItem->item.asString.value, uiCount );
memset( szText + uiCount, ' ', pField->uiLen - uiCount );
res = AdsSetString ( pArea->hTable, szName,
pItem->item.asString.value, uiCount );
AdsSetString ( pArea->hTable, szName, pItem->item.asString.value, uiCount );
bError = FALSE;
}
break;
@@ -539,6 +558,16 @@ static ERRCODE adsPutValue( ADSAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
}
break;
case 'M':
if( pItem->type & IT_STRING )
{
uiCount = pItem->item.asString.length;
AdsSetString ( pArea->hTable, szName,
pItem->item.asString.value, uiCount );
bError = FALSE;
}
break;
}
if( bError )
@@ -865,7 +894,9 @@ static ERRCODE adsOrderInfo( ADSAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrde
#define adsFilterText NULL
#define adsSetFilter NULL
#define adsSetLocate NULL
#define adsCompile NULL
#define adsError NULL
#define adsEvalBlock NULL
static ERRCODE adsRawLock( ADSAREAP pArea, USHORT uiAction, ULONG lRecNo )
{
@@ -887,15 +918,25 @@ static ERRCODE adsRawLock( ADSAREAP pArea, USHORT uiAction, ULONG lRecNo )
break;
case FILE_LOCK:
if( pArea->lpExtendInfo->fExclusive || pArea->lpDataInfo->fFileLocked )
return SUCCESS;
ulRetVal = AdsLockTable ( pArea->hTable );
if ( ulRetVal != AE_SUCCESS )
return FAILURE;
pArea->lpDataInfo->fFileLocked = TRUE;
break;
case FILE_UNLOCK:
ulRetVal = AdsUnlockTable ( pArea->hTable );
if ( ulRetVal != AE_SUCCESS )
return FAILURE;
if( pArea->lpExtendInfo->fExclusive )
return TRUE;
hb_adsUnLockAllRecords( pArea );
if( pArea->lpDataInfo->fFileLocked )
{
ulRetVal = AdsUnlockTable ( pArea->hTable );
if ( ulRetVal != AE_SUCCESS )
return FAILURE;
pArea->lpDataInfo->fFileLocked = FALSE;
}
break;
}
return SUCCESS;
@@ -910,6 +951,8 @@ static ERRCODE adsLock( ADSAREAP pArea, LPDBLOCKINFO pLockInfo )
hb_adsUnLockAllRecords( pArea );
/* Get current record */
AdsGetRecordNum( pArea->hTable, ADS_IGNOREFILTERS,
(UNSIGNED32 *)&(pArea->lpExtendInfo->ulRecNo) );
pLockInfo->itmRecID = pArea->lpExtendInfo->ulRecNo;
}
if( adsRawLock( pArea, pLockInfo->uiMethod, pLockInfo->itmRecID ) == SUCCESS )
@@ -972,7 +1015,7 @@ static ERRCODE adsReadDBHeader( ADSAREAP pArea )
break;
case ADS_NUMERIC:
pFieldInfo.uiType = 'N';
AdsGetFieldDecimals( pArea->hTable, szName, &pulLength );
AdsGetFieldDecimals( pArea->hTable, szName, (UNSIGNED16 *)&pulLength );
pFieldInfo.uiDec = ( USHORT ) pulLength;
break;
case ADS_LOGICAL:
@@ -1054,7 +1097,9 @@ static RDDFUNCS adsTable = { adsBof,
adsFilterText,
adsSetFilter,
adsSetLocate,
adsCompile,
adsError,
adsEvalBlock,
adsRawLock,
adsLock,
adsUnLock,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,82 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Some dbf structure related functions
*
* Copyright 2000 Alexander Kresin <alex@belacy.belgorod.su>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) with other files to produce
* an executable, this does not by itself cause the resulting executable
* to be covered by the GNU General Public License. Your use of that
* executable is in no way restricted on account of linking the HRL
* and/or HVM code into it.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#include "windows.h"
#include "extend.h"
#include "init.h"
#include "itemapi.h"
#include "rddsys.ch"
#include "langapi.h"
#include "dates.h"
#include "errorapi.h"
#include "rddapi.h"
extern void* hb_rddGetCurrentWorkAreaPointer( void );
HARBOUR HB_FIELDTYPE( void )
{
USHORT uiField;
LPFIELD pField;
AREAP pArea;
uiField = hb_parni( 1 );
pArea = (AREAP) hb_rddGetCurrentWorkAreaPointer();
pField = pArea->lpFields + uiField - 1;
hb_retc( (char*) &(pField->uiType) );
}
HARBOUR HB_FIELDSIZE( void )
{
USHORT uiField;
LPFIELD pField;
AREAP pArea;
uiField = hb_parni( 1 );
pArea = (AREAP) hb_rddGetCurrentWorkAreaPointer();
pField = pArea->lpFields + uiField - 1;
hb_retni( pField->uiLen );
}
HARBOUR HB_FIELDDECI( void )
{
USHORT uiField;
LPFIELD pField;
AREAP pArea;
uiField = hb_parni( 1 );
pArea = (AREAP) hb_rddGetCurrentWorkAreaPointer();
pField = pArea->lpFields + uiField - 1;
hb_retni( pField->uiDec );
}