2003-11-05 22:50 UTC+0300 Alexander Kresin <alex@belacy.belgorod.su>
This commit is contained in:
@@ -8,6 +8,48 @@
|
||||
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2003-11-05 22:50 UTC+0300 Alexander Kresin <alex@belacy.belgorod.su>
|
||||
* config/global.cf
|
||||
* include/hbapirdd.h
|
||||
* include/hbapi.h
|
||||
* include/hbapifs.h
|
||||
* include/hbdefs.h
|
||||
* include/hbrddcdx.h
|
||||
* include/hbrddntx.h
|
||||
* include/hbrdddbf.h
|
||||
* include/hbrdddel.h
|
||||
* include/hbrddsdf.h
|
||||
+ include/hbdbferr.h
|
||||
+ include/hbrdddbt.h
|
||||
+ include/hbrddfpt.h
|
||||
|
||||
* source/rtl/filesys.c
|
||||
* source/rtl/spfiles.c
|
||||
* source/rtl/filehb.c
|
||||
|
||||
* source/rdd/dbcmd.c
|
||||
* source/rdd/dbf1.c
|
||||
* source/rdd/delim1.c
|
||||
* source/rdd/rddsys.prg
|
||||
* source/rdd/sdf1.c
|
||||
* source/rdd/workarea.c
|
||||
|
||||
* source/rdd/dbfcdx/dbfcdx0.prg
|
||||
* source/rdd/dbfcdx/dbfcdx1.c
|
||||
* source/rdd/dbfcdx/dbfcdx1.h
|
||||
- source/rdd/dbfcdx/dbfcdx2.h
|
||||
|
||||
* source/rdd/dbfntx/dbfntx1.c
|
||||
|
||||
+ source/rdd/dbfdbt/
|
||||
+ source/rdd/dbfdbt/dbfdbt0.prg
|
||||
+ source/rdd/dbfdbt/dbfdbt1.c
|
||||
|
||||
+ source/rdd/dbffpt/
|
||||
+ source/rdd/dbffpt/dbffpt0.prg
|
||||
+ source/rdd/dbffpt/dbffpt1.c
|
||||
* Latest RDD changes, has been made by Przemyslaw Czerpak - synced with xHarbour.
|
||||
|
||||
2003-10-30 19:50 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
|
||||
* source/compiler/harbour.l
|
||||
* source/compiler/harbour.y
|
||||
|
||||
@@ -9,6 +9,8 @@ HB_DB_DRIVERS=\
|
||||
nulsys \
|
||||
dbfntx \
|
||||
dbfcdx \
|
||||
dbffpt \
|
||||
dbfdbt \
|
||||
|
||||
ifeq ($(HB_BIN_COMPILE),)
|
||||
HB_BIN_COMPILE := $(TOP)$(ROOT)source/compiler/$(ARCH)
|
||||
|
||||
@@ -73,6 +73,7 @@ extern "C" {
|
||||
#define HB_IT_LONG ( ( USHORT ) 0x0008 )
|
||||
#define HB_IT_DOUBLE ( ( USHORT ) 0x0010 )
|
||||
#define HB_IT_DATE ( ( USHORT ) 0x0020 )
|
||||
#define HB_IT_LONGLONG ( ( USHORT ) 0x0040 )
|
||||
#define HB_IT_LOGICAL ( ( USHORT ) 0x0080 )
|
||||
#define HB_IT_SYMBOL ( ( USHORT ) 0x0100 )
|
||||
#define HB_IT_ALIAS ( ( USHORT ) 0x0200 )
|
||||
@@ -85,6 +86,7 @@ extern "C" {
|
||||
#define HB_IT_ARRAY ( ( USHORT ) 0x8000 )
|
||||
#define HB_IT_OBJECT HB_IT_ARRAY
|
||||
#define HB_IT_NUMERIC ( ( USHORT ) ( HB_IT_INTEGER | HB_IT_LONG | HB_IT_DOUBLE ) )
|
||||
#define HB_IS_NUMBER( p ) ( ( p )->type & HB_IT_NUMERIC )
|
||||
#define HB_IT_ANY ( ( USHORT ) 0xFFFF )
|
||||
|
||||
#define HB_IS_OF_TYPE( p, t ) ( ( ( p )->type & ~HB_IT_BYREF ) == t )
|
||||
|
||||
@@ -69,6 +69,12 @@ typedef int FHANDLE;
|
||||
/* File locking flags */
|
||||
#define FL_LOCK 0x0000 /* Lock a region */
|
||||
#define FL_UNLOCK 0x0001 /* Unlock a region */
|
||||
#define FL_MASK 0x00FF /* Mask for lock type */
|
||||
|
||||
/* Extended file locking flags */
|
||||
#define FLX_EXCLUSIVE 0x0000 /* Exclusive lock */
|
||||
#define FLX_SHARED 0x0100 /* Shared lock */
|
||||
#define FLX_WAIT 0x0200 /* Wait for lock until success */
|
||||
|
||||
/* File inheritance flags */
|
||||
#define FO_INHERITED 0x0000 /* Spawned processes can inherit this file handle */
|
||||
@@ -160,7 +166,7 @@ typedef struct _HB_PATHNAMES
|
||||
|
||||
extern void hb_fsAddSearchPath( char * szPath, HB_PATHNAMES * * pSearchList );
|
||||
|
||||
extern BOOL hb_spFile( BYTE * pFilename );
|
||||
extern BOOL hb_spFile( BYTE * pFilename, BYTE RetPath[ _POSIX_PATH_MAX + 3 + 10 ] );
|
||||
extern FHANDLE hb_spOpen( BYTE * pFilename, USHORT uiFlags );
|
||||
extern FHANDLE hb_spCreate( BYTE * pFilename, USHORT uiAttr );
|
||||
extern FHANDLE hb_spCreateEx( BYTE * pFilename, USHORT uiAttr, USHORT uiFlags );
|
||||
|
||||
@@ -68,6 +68,7 @@ extern "C" {
|
||||
/* RDD virtual machine integration functions */
|
||||
|
||||
extern USHORT hb_rddInsertAreaNode( char *szDriver );
|
||||
extern USHORT hb_rddGetCurrentFieldPos( char * szName );
|
||||
extern int hb_rddGetCurrentWorkAreaNumber( void );
|
||||
void * hb_rddGetCurrentWorkAreaPointer( void );
|
||||
extern ERRCODE hb_rddSelectWorkAreaAlias( char * szAlias );
|
||||
@@ -570,146 +571,145 @@ typedef USHORT ( * DBENTRYP_I2 )( PHB_ITEM p1, PHB_ITEM p2);
|
||||
|
||||
typedef struct _RDDFUNCS
|
||||
{
|
||||
|
||||
/* Movement and positioning methods */
|
||||
|
||||
DBENTRYP_BP bof;
|
||||
DBENTRYP_BP eof;
|
||||
DBENTRYP_BP found;
|
||||
DBENTRYP_V goBottom;
|
||||
DBENTRYP_UL go;
|
||||
DBENTRYP_I goToId;
|
||||
DBENTRYP_V goTop;
|
||||
DBENTRYP_BIB seek;
|
||||
DBENTRYP_L skip;
|
||||
DBENTRYP_L skipFilter;
|
||||
DBENTRYP_L skipRaw;
|
||||
DBENTRYP_BP bof; /* Determine logical beginning of file. */
|
||||
DBENTRYP_BP eof; /* Determine logical end of file. */
|
||||
DBENTRYP_BP found; /* Determine outcome of the last search operation. */
|
||||
DBENTRYP_V goBottom; /* Position cursor at the last record. */
|
||||
DBENTRYP_UL go; /* Position cursor at a specific physical record. */
|
||||
DBENTRYP_I goToId; /* Position the cursor to a specific, physical identity. */
|
||||
DBENTRYP_V goTop; /* Position cursor at the first record. */
|
||||
DBENTRYP_BIB seek; /* */
|
||||
DBENTRYP_L skip; /* Reposition cursor relative to current position. */
|
||||
DBENTRYP_L skipFilter; /*-Reposition cursor respecting any filter setting. */
|
||||
DBENTRYP_L skipRaw; /* Reposition cursor, regardless of filter. */
|
||||
|
||||
|
||||
/* Data management */
|
||||
|
||||
DBENTRYP_VF addField;
|
||||
DBENTRYP_B append;
|
||||
DBENTRYP_I createFields;
|
||||
DBENTRYP_V deleterec;
|
||||
DBENTRYP_BP deleted;
|
||||
DBENTRYP_SP fieldCount;
|
||||
DBENTRYP_VF fieldDisplay;
|
||||
DBENTRYP_SSI fieldInfo;
|
||||
DBENTRYP_SVP fieldName;
|
||||
DBENTRYP_V flush;
|
||||
DBENTRYP_PP getRec;
|
||||
DBENTRYP_SI getValue;
|
||||
DBENTRYP_SVL getVarLen;
|
||||
DBENTRYP_V goCold;
|
||||
DBENTRYP_V goHot;
|
||||
DBENTRYP_P putRec;
|
||||
DBENTRYP_SI putValue;
|
||||
DBENTRYP_V recall;
|
||||
DBENTRYP_ULP reccount;
|
||||
DBENTRYP_ISI recInfo;
|
||||
DBENTRYP_I recno;
|
||||
DBENTRYP_S setFieldExtent;
|
||||
DBENTRYP_VF addField; /* Add a field to the WorkArea. */
|
||||
DBENTRYP_B append; /* Append a record to the WorkArea. */
|
||||
DBENTRYP_I createFields; /*-Add all fields defined in an array to the WorkArea. */
|
||||
DBENTRYP_V deleterec; /* Delete a record. */
|
||||
DBENTRYP_BP deleted; /* Determine deleted status for a record. */
|
||||
DBENTRYP_SP fieldCount; /*-Determine the number of fields in the WorkArea. */
|
||||
DBENTRYP_VF fieldDisplay; /* */
|
||||
DBENTRYP_SSI fieldInfo; /*-Retrieve information about a field. */
|
||||
DBENTRYP_SVP fieldName; /*-Determine the name associated with a field number. */
|
||||
DBENTRYP_V flush; /* Write data buffer to the data store. */
|
||||
DBENTRYP_PP getRec; /* */
|
||||
DBENTRYP_SI getValue; /* Obtain the current value of a field. */
|
||||
DBENTRYP_SVL getVarLen; /* Obtain the length of a field value. */
|
||||
DBENTRYP_V goCold; /* Perform a write of WorkArea memory to the data store. */
|
||||
DBENTRYP_V goHot; /* Mark the WorkArea data buffer as hot. */
|
||||
DBENTRYP_P putRec; /* Replace the current record. */
|
||||
DBENTRYP_SI putValue; /* Assign a value to a field. */
|
||||
DBENTRYP_V recall; /* Undelete the current record. */
|
||||
DBENTRYP_ULP reccount; /* Obtain number of records in WorkArea. */
|
||||
DBENTRYP_ISI recInfo; /* */
|
||||
DBENTRYP_I recno; /* Obtain physical row number at current WorkArea cursor position. */
|
||||
DBENTRYP_S setFieldExtent; /* Establish the extent of the array of fields for a WorkArea. */
|
||||
|
||||
|
||||
/* WorkArea/Database management */
|
||||
|
||||
DBENTRYP_P alias;
|
||||
DBENTRYP_V close;
|
||||
DBENTRYP_VP create;
|
||||
DBENTRYP_SI info;
|
||||
DBENTRYP_V newarea;
|
||||
DBENTRYP_VP open;
|
||||
DBENTRYP_V release;
|
||||
DBENTRYP_SP structSize;
|
||||
DBENTRYP_P sysName;
|
||||
DBENTRYP_VEI dbEval;
|
||||
DBENTRYP_V pack;
|
||||
DBENTRYP_LSP packRec;
|
||||
DBENTRYP_VS sort;
|
||||
DBENTRYP_VT trans;
|
||||
DBENTRYP_VT transRec;
|
||||
DBENTRYP_V zap;
|
||||
DBENTRYP_P alias; /*-Obtain the alias of the WorkArea. */
|
||||
DBENTRYP_V close; /* Close the table in the WorkArea. */
|
||||
DBENTRYP_VP create; /* Create a data store in the specified WorkArea. */
|
||||
DBENTRYP_SI info; /* Retrieve information about the current driver (DBI). */
|
||||
DBENTRYP_V newarea; /* Clear the WorkArea for use. */
|
||||
DBENTRYP_VP open; /* Open a data store in the WorkArea. */
|
||||
DBENTRYP_V release; /*-Release all references to a WorkArea. */
|
||||
DBENTRYP_SP structSize; /* Retrieve the size of the WorkArea structure. */
|
||||
DBENTRYP_P sysName; /* Obtain the name of replaceable database driver (RDD) subsystem. */
|
||||
DBENTRYP_VEI dbEval; /*-Evaluate code block for each record in WorkArea. */
|
||||
DBENTRYP_V pack; /* Remove records marked for deletion from a database. */
|
||||
DBENTRYP_LSP packRec; /* */
|
||||
DBENTRYP_VS sort; /* Physically reorder a database. */
|
||||
DBENTRYP_VT trans; /* Copy one or more records from one WorkArea to another. */
|
||||
DBENTRYP_VT transRec; /* Copy a record to another WorkArea. */
|
||||
DBENTRYP_V zap; /* Physically remove all records from data store. */
|
||||
|
||||
|
||||
/* Relational Methods */
|
||||
|
||||
DBENTRYP_VR childEnd;
|
||||
DBENTRYP_VR childStart;
|
||||
DBENTRYP_VR childSync;
|
||||
DBENTRYP_V syncChildren;
|
||||
DBENTRYP_V clearRel;
|
||||
DBENTRYP_V forceRel;
|
||||
DBENTRYP_SVP relArea;
|
||||
DBENTRYP_VR relEval;
|
||||
DBENTRYP_SVP relText;
|
||||
DBENTRYP_VR setRel;
|
||||
DBENTRYP_VR childEnd; /* Report end of relation. */
|
||||
DBENTRYP_VR childStart; /* Report initialization of a relation. */
|
||||
DBENTRYP_VR childSync; /* Post a pending relational movement. */
|
||||
DBENTRYP_V syncChildren; /*-Force relational movement in child WorkAreas. */
|
||||
DBENTRYP_V clearRel; /* Clear all relations in the specified WorkArea. */
|
||||
DBENTRYP_V forceRel; /* Force relational seeks in the specified WorkArea. */
|
||||
DBENTRYP_SVP relArea; /*-Obtain the workarea number of the specified relation. */
|
||||
DBENTRYP_VR relEval; /*-Evaluate a block against the relation in specified WorkArea. */
|
||||
DBENTRYP_SVP relText; /*-Obtain the character expression of the specified relation. */
|
||||
DBENTRYP_VR setRel; /*-Set a relation in the parent file. */
|
||||
|
||||
|
||||
/* Order Management */
|
||||
|
||||
DBENTRYP_OI orderListAdd;
|
||||
DBENTRYP_V orderListClear;
|
||||
DBENTRYP_VP orderListDelete;
|
||||
DBENTRYP_OI orderListFocus;
|
||||
DBENTRYP_V orderListRebuild;
|
||||
DBENTRYP_VOI orderCondition;
|
||||
DBENTRYP_VOC orderCreate;
|
||||
DBENTRYP_OI orderDestroy;
|
||||
DBENTRYP_OII orderInfo;
|
||||
DBENTRYP_OI orderListAdd; /* */
|
||||
DBENTRYP_V orderListClear; /* */
|
||||
DBENTRYP_VP orderListDelete; /* */
|
||||
DBENTRYP_OI orderListFocus; /* */
|
||||
DBENTRYP_V orderListRebuild; /* */
|
||||
DBENTRYP_VOI orderCondition; /* */
|
||||
DBENTRYP_VOC orderCreate; /* */
|
||||
DBENTRYP_OI orderDestroy; /* */
|
||||
DBENTRYP_OII orderInfo; /*-Retrieve information about the current order that SELF could not. */
|
||||
|
||||
|
||||
/* Filters and Scope Settings */
|
||||
|
||||
DBENTRYP_V clearFilter;
|
||||
DBENTRYP_V clearLocate;
|
||||
DBENTRYP_V clearScope;
|
||||
DBENTRYP_VPLP countScope;
|
||||
DBENTRYP_I filterText;
|
||||
DBENTRYP_SI scopeInfo;
|
||||
DBENTRYP_VFI setFilter;
|
||||
DBENTRYP_VLO setLocate;
|
||||
DBENTRYP_VOS setScope;
|
||||
DBENTRYP_VPL skipScope;
|
||||
DBENTRYP_V clearFilter; /*-Clear the active filter expression. */
|
||||
DBENTRYP_V clearLocate; /*-Clear the active locate expression. */
|
||||
DBENTRYP_V clearScope; /* */
|
||||
DBENTRYP_VPLP countScope; /* */
|
||||
DBENTRYP_I filterText; /*-Return filter condition of the specified WorkArea. */
|
||||
DBENTRYP_SI scopeInfo; /* */
|
||||
DBENTRYP_VFI setFilter; /* Set the filter condition for the specified WorkArea. */
|
||||
DBENTRYP_VLO setLocate; /*-Set the locate scope for the specified WorkArea. */
|
||||
DBENTRYP_VOS setScope; /* */
|
||||
DBENTRYP_VPL skipScope; /* */
|
||||
|
||||
|
||||
/* Miscellaneous */
|
||||
|
||||
DBENTRYP_P compile;
|
||||
DBENTRYP_I error;
|
||||
DBENTRYP_I evalBlock;
|
||||
DBENTRYP_P compile; /*-Compile a character expression. */
|
||||
DBENTRYP_I error; /*-Raise a runtime error. */
|
||||
DBENTRYP_I evalBlock; /*-Evaluate a code block. */
|
||||
|
||||
|
||||
/* Network operations */
|
||||
|
||||
DBENTRYP_VSP rawlock;
|
||||
DBENTRYP_VL lock;
|
||||
DBENTRYP_UL unlock;
|
||||
DBENTRYP_VSP rawlock; /* Perform a lowlevel network lock in the specified WorkArea. */
|
||||
DBENTRYP_VL lock; /* Perform a network lock in the specified WorkArea. */
|
||||
DBENTRYP_UL unlock; /* Release network locks in the specified WorkArea. */
|
||||
|
||||
|
||||
/* Memofile functions */
|
||||
|
||||
DBENTRYP_V closeMemFile;
|
||||
DBENTRYP_VP createMemFile;
|
||||
DBENTRYP_SVPB getValueFile;
|
||||
DBENTRYP_VP openMemFile;
|
||||
DBENTRYP_SVP putValueFile;
|
||||
DBENTRYP_V closeMemFile; /* Close a memo file in the WorkArea. */
|
||||
DBENTRYP_VP createMemFile; /* Create a memo file in the WorkArea. */
|
||||
DBENTRYP_SVPB getValueFile; /* */
|
||||
DBENTRYP_VP openMemFile; /* Open a memo file in the specified WorkArea. */
|
||||
DBENTRYP_SVP putValueFile; /* */
|
||||
|
||||
|
||||
/* Database file header handling */
|
||||
|
||||
DBENTRYP_V readDBHeader;
|
||||
DBENTRYP_V writeDBHeader;
|
||||
DBENTRYP_V readDBHeader; /* Read the database file header record in the WorkArea. */
|
||||
DBENTRYP_V writeDBHeader; /* Write the database file header record in the WorkArea. */
|
||||
|
||||
|
||||
/* non WorkArea functions */
|
||||
DBENTRYP_I0 exit;
|
||||
DBENTRYP_I1 drop;
|
||||
DBENTRYP_I2 exists;
|
||||
DBENTRYP_I0 exit; /* */
|
||||
DBENTRYP_I1 drop; /* remove table */
|
||||
DBENTRYP_I2 exists; /* check if table exist */
|
||||
|
||||
/* Special and reserved methods */
|
||||
|
||||
DBENTRYP_SVP whoCares;
|
||||
DBENTRYP_SVP whoCares; /* */
|
||||
|
||||
} RDDFUNCS;
|
||||
|
||||
|
||||
81
harbour/include/hbdbferr.h
Normal file
81
harbour/include/hbdbferr.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* xHarbour Project source code:
|
||||
* DBF error codes
|
||||
*
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* www - http://www.xharbour.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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HB_DBFERR_H_
|
||||
#define HB_DBFERR_H_
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* DBF errors */
|
||||
#define EDBF_OPEN_DBF 1001
|
||||
#define EDBF_CREATE_DBF 1004
|
||||
#define EDBF_READ 1010
|
||||
#define EDBF_WRITE 1011
|
||||
#define EDBF_CORRUPT 1012
|
||||
#define EDBF_DATATYPE 1020
|
||||
#define EDBF_DATAWIDTH 1021
|
||||
#define EDBF_UNLOCKED 1022
|
||||
#define EDBF_SHARED 1023
|
||||
#define EDBF_APPENDLOCK 1024
|
||||
#define EDBF_READONLY 1025
|
||||
#define EDBF_LOCK 1038
|
||||
/* ORDER errors */
|
||||
#define EDBF_INVALIDKEY 1026
|
||||
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HB_DBFERR_H_ */
|
||||
@@ -163,6 +163,210 @@
|
||||
( ( ( ULONG ) ( b3 ) ) << 16 ) | \
|
||||
( ( ( ULONG ) ( b2 ) ) << 8 ) | \
|
||||
( ( ( ULONG ) ( b1 ) ) ) )
|
||||
#define HB_SWAP_USHORT( w ) ( ( USHORT ) ( ( ( ( USHORT ) ( w ) & 0xFF00 ) >> 8 ) | \
|
||||
( ( ( USHORT ) ( w ) & 0x00FF ) << 8 ) ) )
|
||||
#define HB_SWAP_ULONG( w ) ( ( ULONG ) ( ( ( ( ULONG ) ( w ) & 0x000000FFL ) << 24 ) | \
|
||||
( ( ( ULONG ) ( w ) & 0x0000FF00L ) << 8 ) | \
|
||||
( ( ( ULONG ) ( w ) & 0x00FF0000L ) >> 8 ) | \
|
||||
( ( ( ULONG ) ( w ) & 0xFF000000L ) >> 24 ) ) )
|
||||
/* Be careful with double conversion. Some machines can use mixed form
|
||||
(Little/Big) for BYTE ORDER and WORD ORDER or even completely differ
|
||||
internal representation */
|
||||
#define HB_SWAP_PDOUBLE( p ) ( { \
|
||||
union { \
|
||||
double d; \
|
||||
BYTE buffer[ 8 ]; \
|
||||
} u; \
|
||||
u.buffer[ 0 ] = ( ( BYTE * ) ( p ) )[ 7 ]; \
|
||||
u.buffer[ 1 ] = ( ( BYTE * ) ( p ) )[ 6 ]; \
|
||||
u.buffer[ 2 ] = ( ( BYTE * ) ( p ) )[ 5 ]; \
|
||||
u.buffer[ 3 ] = ( ( BYTE * ) ( p ) )[ 4 ]; \
|
||||
u.buffer[ 4 ] = ( ( BYTE * ) ( p ) )[ 3 ]; \
|
||||
u.buffer[ 5 ] = ( ( BYTE * ) ( p ) )[ 2 ]; \
|
||||
u.buffer[ 6 ] = ( ( BYTE * ) ( p ) )[ 1 ]; \
|
||||
u.buffer[ 7 ] = ( ( BYTE * ) ( p ) )[ 0 ]; \
|
||||
u.d; \
|
||||
} )
|
||||
#define HB_SWAP_DOUBLE( d ) ( { \
|
||||
BYTE double_var[ 8 ]; \
|
||||
*( double * )double_var = ( double ) ( d ); \
|
||||
HB_SWAP_PDOUBLE( double_var ); \
|
||||
} )
|
||||
|
||||
#if defined(HB_PDP_ENDIAN)
|
||||
#error PDP-Endian support unimplemented. If you have such machine do it yourself.
|
||||
#elif !defined(HB_BIG_ENDIAN)
|
||||
/* We use Little-Endian here */
|
||||
|
||||
#define HB_GET_LE_USHORT( p ) ( *( USHORT * )( p ) )
|
||||
#define HB_PUT_LE_USHORT( p, w ) ( *( USHORT * )( p ) = ( USHORT ) ( w ) )
|
||||
#define HB_GET_LE_ULONG( p ) ( *( ULONG * )( p ) )
|
||||
#define HB_PUT_LE_ULONG( p, l ) ( *( ULONG * )( p ) = ( ULONG ) ( l ) )
|
||||
#define HB_GET_LE_DOUBLE( p ) ( *( double * )( p ) )
|
||||
#define HB_PUT_LE_DOUBLE( p, d ) ( *( double * )( p ) = ( double ) ( d ) )
|
||||
|
||||
#define HB_GET_BE_USHORT( p ) HB_SWAP_USHORT( *( USHORT * )( p ) )
|
||||
#define HB_PUT_BE_USHORT( p, w ) ( *( USHORT * )( p ) = HB_SWAP_USHORT( w ) )
|
||||
#define HB_GET_BE_ULONG( p ) HB_SWAP_ULONG( *( ULONG * )( p ) )
|
||||
#define HB_PUT_BE_ULONG( p, l ) ( *( ULONG * )( p ) = HB_SWAP_ULONG( l ) )
|
||||
#define HB_GET_BE_DOUBLE( p ) HB_SWAP_PDOUBLE( p )
|
||||
#define HB_PUT_BE_DOUBLE( p, d ) ( *( double * )( p ) = HB_SWAP_DOUBLE( d ) )
|
||||
|
||||
#define HB_USHORT_FROM_LE( w ) ( ( USHORT )( w ) )
|
||||
#define HB_ULONG_FROM_LE( l ) ( ( ULONG )( l ) )
|
||||
#define HB_USHORT_TO_LE( w ) ( ( USHORT )( w ) )
|
||||
#define HB_ULONG_TO_LE( l ) ( ( ULONG )( l ) )
|
||||
#define HB_DOUBLE_TO_LE( d ) ( ( double )( d ) )
|
||||
|
||||
#define HB_PCODE_MKSHORT( p ) ( *( SHORT * )( p ) )
|
||||
#define HB_PCODE_MKUSHORT( p ) ( *( USHORT * )( p ) )
|
||||
#define HB_PCODE_MKLONG( p ) ( *( LONG * )( p ) )
|
||||
#define HB_PCODE_MKULONG( p ) ( *( ULONG * )( p ) )
|
||||
#define HB_PCODE_MKDOUBLE( p ) ( *( double * )( p ) )
|
||||
|
||||
/* the conversion for BIG endian can be used here but for speed reasons
|
||||
* I decided to write full version to avoid one bytes conversion */
|
||||
#define HB_GET_SORTDBL( v, p ) { \
|
||||
union { \
|
||||
double d; \
|
||||
BYTE buffer[ 8 ]; \
|
||||
} u; \
|
||||
if ( ( ( BYTE * ) ( p ) )[ 0 ] & 0x80 ) { \
|
||||
u.buffer[ 0 ] = ( ( BYTE * ) ( p ) )[ 7 ]; \
|
||||
u.buffer[ 1 ] = ( ( BYTE * ) ( p ) )[ 6 ]; \
|
||||
u.buffer[ 2 ] = ( ( BYTE * ) ( p ) )[ 5 ]; \
|
||||
u.buffer[ 3 ] = ( ( BYTE * ) ( p ) )[ 4 ]; \
|
||||
u.buffer[ 4 ] = ( ( BYTE * ) ( p ) )[ 3 ]; \
|
||||
u.buffer[ 5 ] = ( ( BYTE * ) ( p ) )[ 2 ]; \
|
||||
u.buffer[ 6 ] = ( ( BYTE * ) ( p ) )[ 1 ]; \
|
||||
u.buffer[ 7 ] = ( ( BYTE * ) ( p ) )[ 0 ] ^ 0x80; \
|
||||
} else { \
|
||||
u.buffer[ 0 ] = ( ( BYTE * ) ( p ) )[ 7 ] ^ 0xFF; \
|
||||
u.buffer[ 1 ] = ( ( BYTE * ) ( p ) )[ 6 ] ^ 0xFF; \
|
||||
u.buffer[ 2 ] = ( ( BYTE * ) ( p ) )[ 5 ] ^ 0xFF; \
|
||||
u.buffer[ 3 ] = ( ( BYTE * ) ( p ) )[ 4 ] ^ 0xFF; \
|
||||
u.buffer[ 4 ] = ( ( BYTE * ) ( p ) )[ 3 ] ^ 0xFF; \
|
||||
u.buffer[ 5 ] = ( ( BYTE * ) ( p ) )[ 2 ] ^ 0xFF; \
|
||||
u.buffer[ 6 ] = ( ( BYTE * ) ( p ) )[ 1 ] ^ 0xFF; \
|
||||
u.buffer[ 7 ] = ( ( BYTE * ) ( p ) )[ 0 ] ^ 0xFF; \
|
||||
} \
|
||||
v = u.d; \
|
||||
}
|
||||
|
||||
#define HB_PUT_SORTDBL( p, v ) { \
|
||||
union { \
|
||||
double d; \
|
||||
BYTE buffer[ 8 ]; \
|
||||
} u; \
|
||||
u.d = ( double ) ( v ); \
|
||||
if ( u.d >= 0.0 ) { \
|
||||
( ( BYTE * ) ( p ) )[ 0 ] = u.buffer[ 7 ] ^ 0x80; \
|
||||
( ( BYTE * ) ( p ) )[ 1 ] = u.buffer[ 6 ]; \
|
||||
( ( BYTE * ) ( p ) )[ 2 ] = u.buffer[ 5 ]; \
|
||||
( ( BYTE * ) ( p ) )[ 3 ] = u.buffer[ 4 ]; \
|
||||
( ( BYTE * ) ( p ) )[ 4 ] = u.buffer[ 3 ]; \
|
||||
( ( BYTE * ) ( p ) )[ 5 ] = u.buffer[ 2 ]; \
|
||||
( ( BYTE * ) ( p ) )[ 6 ] = u.buffer[ 1 ]; \
|
||||
( ( BYTE * ) ( p ) )[ 7 ] = u.buffer[ 0 ]; \
|
||||
} else { \
|
||||
( ( BYTE * ) ( p ) )[ 7 ] = u.buffer[ 0 ] ^ 0xFF; \
|
||||
( ( BYTE * ) ( p ) )[ 6 ] = u.buffer[ 1 ] ^ 0xFF; \
|
||||
( ( BYTE * ) ( p ) )[ 5 ] = u.buffer[ 2 ] ^ 0xFF; \
|
||||
( ( BYTE * ) ( p ) )[ 4 ] = u.buffer[ 3 ] ^ 0xFF; \
|
||||
( ( BYTE * ) ( p ) )[ 3 ] = u.buffer[ 4 ] ^ 0xFF; \
|
||||
( ( BYTE * ) ( p ) )[ 2 ] = u.buffer[ 5 ] ^ 0xFF; \
|
||||
( ( BYTE * ) ( p ) )[ 1 ] = u.buffer[ 6 ] ^ 0xFF; \
|
||||
( ( BYTE * ) ( p ) )[ 0 ] = u.buffer[ 7 ] ^ 0xFF; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
/* We use Big-Endian here */
|
||||
|
||||
#define HB_GET_LE_USHORT( p ) HB_SWAP_USHORT( *( USHORT * )( p ) )
|
||||
#define HB_PUT_LE_USHORT( p, w ) ( *( USHORT * )( p ) = HB_SWAP_USHORT( w ) )
|
||||
#define HB_GET_LE_ULONG( p ) HB_SWAP_ULONG( *( ULONG * )( p ) )
|
||||
#define HB_PUT_LE_ULONG( p, l ) ( *( ULONG * )( p ) = HB_SWAP_ULONG( l ) )
|
||||
#define HB_GET_BE_USHORT( p ) ( *( USHORT * )( p ) )
|
||||
#define HB_PUT_BE_USHORT( p, w ) ( *( USHORT * )( p ) = ( USHORT ) ( w ) )
|
||||
#define HB_GET_BE_ULONG( p ) ( *( ULONG * )( p ) )
|
||||
#define HB_PUT_BE_ULONG( p, l ) ( *( ULONG * )( p ) = ( ULONG ) ( l ) )
|
||||
#define HB_GET_BE_DOUBLE( p ) ( *( double * )( p ) )
|
||||
#define HB_PUT_BE_DOUBLE( p, d ) ( *( double * )( p ) = ( double ) ( d ) )
|
||||
|
||||
#define HB_USHORT_FROM_LE( w ) HB_MKUSHORT( HB_HIBYTE( w ), HB_LOBYTE( w ) )
|
||||
#define HB_ULONG_FROM_LE( l ) HB_MKULONG( HB_HIBYTE( HB_HIWORD( l ) ), HB_LOBYTE( HB_HIWORD( l ) ), HB_HIBYTE( l ), HB_LOBYTE( l ) )
|
||||
#define HB_USHORT_TO_LE( w ) HB_USHORT_FROM_LE( w )
|
||||
#define HB_ULONG_TO_LE( l ) HB_ULONG_FROM_LE( l )
|
||||
|
||||
#define HB_PCODE_MKSHORT( p ) HB_MKSHORT( *( BYTE * )( p ), ( ( BYTE * )( p ) )[ 1 ] )
|
||||
#define HB_PCODE_MKUSHORT( p ) HB_MKUSHORT( *( BYTE * )( p ), ( ( BYTE * )( p ) )[ 1 ] )
|
||||
#define HB_PCODE_MKLONG( p ) HB_MKLONG( *( BYTE * )( p ), ( ( BYTE * )( p ) )[ 1 ], ( ( BYTE * )( p ) )[ 2 ], ( ( BYTE * )( p ) )[ 3 ] )
|
||||
#define HB_PCODE_MKULONG( p ) HB_MKULONG( *( BYTE * )( p ), ( ( BYTE * )( p ) )[ 1 ], ( ( BYTE * )( p ) )[ 2 ], ( ( BYTE * )( p ) )[ 3 ] )
|
||||
|
||||
#if defined( __GNUC__ )
|
||||
#define HB_GET_LE_DOUBLE( p ) HB_SWAP_PDOUBLE( p )
|
||||
#define HB_PUT_LE_DOUBLE( p, d ) ( *( double * )( p ) = HB_SWAP_DOUBLE( d ) )
|
||||
|
||||
#define HB_DOUBLE_FROM_LE( d ) HB_SWAP_DOUBLE( d );
|
||||
#define HB_DOUBLE_TO_LE( d ) HB_DOUBLE_FROM_LE( d )
|
||||
#define HB_PCODE_MKDOUBLE( p ) HB_SWAP_PDOUBLE( p )
|
||||
|
||||
#define HB_GET_SORTDBL( v, p ) ( { \
|
||||
union { \
|
||||
double d; \
|
||||
BYTE buffer[ 8 ]; \
|
||||
} u; \
|
||||
u.d = HB_GET_BE_DOUBLE( p ); \
|
||||
if ( u.buffer[ 0 ] & 0x80 ) { \
|
||||
u.buffer[ 0 ] ^= 0x80; \
|
||||
} else { \
|
||||
( ( LONG * ) ( u.buffer ) )[ 0 ] ^= 0xFFFFFFFFL; \
|
||||
( ( LONG * ) ( u.buffer ) )[ 1 ] ^= 0xFFFFFFFFL; \
|
||||
} \
|
||||
v = u.d; \
|
||||
} )
|
||||
|
||||
#define HB_PUT_SORTDBL( p, v ) ( { \
|
||||
HB_PUT_BE_DOUBLE( p, v ); \
|
||||
if ( ( double ) ( v ) >= 0.0 ) { \
|
||||
( ( BYTE * ) ( p ) )[ 0 ] ^= 0x80; \
|
||||
} else { \
|
||||
( ( LONG * ) ( p ) )[ 0 ] ^= 0xFFFFFFFFL; \
|
||||
( ( LONG * ) ( p ) )[ 1 ] ^= 0xFFFFFFFFL; \
|
||||
} \
|
||||
} )
|
||||
|
||||
/*
|
||||
#define HB_DOUBLE_FROM_LE( d ) \
|
||||
( { \
|
||||
BYTE double_var[ 8 ]; \
|
||||
*( double * )double_var = d; \
|
||||
HB_PCODE_MKDOUBLE( double_var ); \
|
||||
} )
|
||||
#define HB_PCODE_MKDOUBLE( p ) \
|
||||
( { \
|
||||
union { \
|
||||
double d; \
|
||||
BYTE buffer[ 8 ]; \
|
||||
} u; \
|
||||
u.buffer[ 0 ] = ( p )[ 7 ]; \
|
||||
u.buffer[ 1 ] = ( p )[ 6 ]; \
|
||||
u.buffer[ 2 ] = ( p )[ 5 ]; \
|
||||
u.buffer[ 3 ] = ( p )[ 4 ]; \
|
||||
u.buffer[ 4 ] = ( p )[ 3 ]; \
|
||||
u.buffer[ 5 ] = ( p )[ 2 ]; \
|
||||
u.buffer[ 6 ] = ( p )[ 1 ]; \
|
||||
u.buffer[ 7 ] = ( p )[ 0 ]; \
|
||||
u.d; \
|
||||
} )
|
||||
*/
|
||||
#else
|
||||
#error Little-Endian IEEE 754 double type conversion unimplemented with a non-GCC compiler
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define HB_PCODE_MK24BIT( p ) HB_MKLONG( *( BYTE * )( p ), ( ( BYTE * )( p ) )[ 1 ], ( ( BYTE * )( p ) )[ 2 ], 0 )
|
||||
|
||||
#define HB_SYMBOL_UNUSED( symbol ) ( void ) symbol
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DBFCDX RDD
|
||||
* DBFCDX RDD (ver.2)
|
||||
*
|
||||
* Copyright 1999 Bruno Cantero <bruno@issnet.net>
|
||||
* www - http://www.harbour-project.org
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* www - http://www.xharbour.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
|
||||
@@ -54,244 +54,276 @@
|
||||
#define HB_RDDCDX_H_
|
||||
|
||||
#include "hbapirdd.h"
|
||||
#include "hbdbferr.h"
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
#include "hbapicdp.h"
|
||||
#endif
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* DBFCDX errors */
|
||||
|
||||
#define EDBF_OPEN_DBF 1001
|
||||
#define EDBF_CREATE_DBF 1004
|
||||
#define EDBF_READ 1010
|
||||
#define EDBF_WRITE 1011
|
||||
#define EDBF_CORRUPT 1012
|
||||
#define EDBF_DATATYPE 1020
|
||||
#define EDBF_DATAWIDTH 1021
|
||||
#define EDBF_UNLOCKED 1022
|
||||
#define EDBF_SHARED 1023
|
||||
#define EDBF_APPENDLOCK 1024
|
||||
#define EDBF_READONLY 1025
|
||||
#define EDBF_INVALIDKEY 1026
|
||||
|
||||
|
||||
|
||||
/* DBFCDX default extensions */
|
||||
#define CDX_MEMOEXT ".fpt"
|
||||
/* CDX constants and defaults */
|
||||
#define CDX_INDEXEXT ".cdx"
|
||||
|
||||
|
||||
|
||||
/* FPT's and CDX's */
|
||||
|
||||
#define FPT_DEFBLOCKSIZE 64
|
||||
#define SIZEOFMEMOFREEBLOCK 6
|
||||
#define MAXFREEBLOCKS 82
|
||||
#define CDX_MAXKEY 240
|
||||
#define CDX_MAXTAGNAMELEN 10
|
||||
#define CDX_PAGELEN 512
|
||||
#define CDX_RIGHTTYPE 0
|
||||
#define CDX_ROOTTYPE 1
|
||||
#define CDX_LEAFTYPE 2
|
||||
#define CDX_LEAFFREESPACE 488
|
||||
#define CDX_INT_FREESPACE 500
|
||||
#define CDX_EXT_FREESPACE 488
|
||||
#define CDX_DUMMYNODE 0xFFFFFFFFL
|
||||
#define CDX_LOCKOFFSET 0x7FFFFFFEL
|
||||
#define CDX_LOCKSIZE 1L
|
||||
#define CDX_STACKSIZE 64
|
||||
#define CDX_PAGECACHESIZE 16
|
||||
#define CDX_NODE_BRANCH 0
|
||||
#define CDX_NODE_ROOT 1
|
||||
#define CDX_NODE_LEAF 2
|
||||
#define CDX_NODE_UNUSED 0xFF
|
||||
#define CDX_IGNORE_REC_NUM 0x0L
|
||||
#define CDX_MAX_REC_NUM 0xFFFFFFFFL
|
||||
#define CDX_BALANCE_LEAFPAGES 3
|
||||
#define CDX_BALANCE_INTPAGES 3
|
||||
|
||||
/*
|
||||
#define CDX_CURKEY_UNDEF 1
|
||||
#define CDX_CURKEY_REC 2
|
||||
#define CDX_CURKEY_VAL 4
|
||||
#define CDX_CURKEY_INPAGE 8
|
||||
#define CDX_CURKEY_INSTACK 16
|
||||
#define CDX_CURKEY_NOTEXIST 32
|
||||
*/
|
||||
|
||||
#define TOP_RECORD 1
|
||||
#define BTTM_RECORD 2
|
||||
#define PREV_RECORD 3
|
||||
#define NEXT_RECORD 4
|
||||
#define PRVU_RECORD 6
|
||||
#define NXTU_RECORD 5
|
||||
|
||||
#define NODE_NEWLASTKEY 1
|
||||
#define NODE_SPLIT 2
|
||||
#define NODE_JOIN 4
|
||||
#define NODE_BALANCE 8
|
||||
#define NODE_EAT 16
|
||||
|
||||
/*
|
||||
#define CURKEY_UNDEF(pTag) (((pTag)->curKeyState & CDX_CURKEY_UNDEF) != 0)
|
||||
#define CURKEY_NOTEXIST(pTag) (((pTag)->curKeyState & CDX_CURKEY_NOTEXIST) != 0)
|
||||
#define CURKEY_ISSET(pTag) (((pTag)->curKeyState & (CDX_CURKEY_NOTEXIST | CDX_CURKEY_UNDEF)) == 0)
|
||||
#define CURKEY_REC(pTag) ((((pTag)->curKeyState & CDX_CURKEY_REC) != 0) ? (pTag)->curKey->rec : 0)
|
||||
#define CURKEY_VAL(pTag) ((((pTag)->curKeyState & CDX_CURKEY_VAL) != 0) ? (pTag)->curKey->val : NULL)
|
||||
#define CURKEY_REFRESH(pTag)
|
||||
*/
|
||||
|
||||
#define HB_CDXMAXKEY( x ) ((USHORT) ((x) > CDX_MAXKEY ? CDX_MAXKEY : (x)))
|
||||
#define HB_CDXBITMASK( x ) ((LONG) ((1L<<(x))-1))
|
||||
|
||||
//#define FAST_GOCOLD( A ) (((CDXAREAP) (A))->fRecordChanged || ((CDXAREAP) (A))->fCdxAppend ? (SELF_GOCOLD((A))) : SUCCESS)
|
||||
#define FAST_GOCOLD( A ) SELF_GOCOLD(A)
|
||||
|
||||
|
||||
|
||||
struct _CDXAREA;
|
||||
|
||||
typedef struct _MEMOHEADER
|
||||
{
|
||||
ULONG ulNextBlock; /* Next memo entry */
|
||||
ULONG ulBlockSize; /* Size of block */
|
||||
} MEMOHEADER;
|
||||
|
||||
typedef MEMOHEADER * LPMEMOHEADER;
|
||||
|
||||
|
||||
|
||||
typedef struct _MEMOBLOCK
|
||||
{
|
||||
ULONG ulType; /* 0 = binary, 1 = text */
|
||||
ULONG ulSize; /* length of data */
|
||||
} MEMOBLOCK;
|
||||
|
||||
typedef MEMOBLOCK * LPMEMOBLOCK;
|
||||
|
||||
|
||||
|
||||
typedef struct _MEMOFREEBLOCK
|
||||
{
|
||||
USHORT uiBlocks; /* Number of blocks */
|
||||
ULONG ulBlock; /* Block number */
|
||||
} MEMOFREEBLOCK;
|
||||
|
||||
typedef MEMOFREEBLOCK * LPMEMOFREEBLOCK;
|
||||
|
||||
|
||||
|
||||
typedef struct _MEMOROOT
|
||||
{
|
||||
ULONG ulNextBlock; /* Next block in the list */
|
||||
ULONG ulBlockSize; /* Size of block */
|
||||
BYTE szSignature[ 8 ]; /* Signature */
|
||||
BYTE fChanged; /* TRUE if root block is changed */
|
||||
USHORT uiListLen; /* Length of list */
|
||||
BYTE pFreeList[ 492 ]; /* Array of free memo blocks (82 MEMOFREEBLOCK's) */
|
||||
} MEMOROOT;
|
||||
|
||||
typedef MEMOROOT * LPMEMOROOT;
|
||||
|
||||
|
||||
|
||||
/* CDX's */
|
||||
|
||||
struct _CDXINDEX; /* forward declaration */
|
||||
typedef struct _CDXTAG
|
||||
{
|
||||
char * szName; /* Name of tag */
|
||||
PHB_ITEM pKeyItem; /* item with a macro pcode for a tag key expression */
|
||||
PHB_ITEM pForItem; /* item with a macro pcode for a tag for expression */
|
||||
char * KeyExpr; /* a tag key expression as text */
|
||||
char * ForExpr; /* a tag for expression as text */
|
||||
USHORT uiType; /* a type of key expression value */
|
||||
USHORT uiLen; /* length of the key expression value */
|
||||
USHORT nField;
|
||||
struct _CDXINDEX * pIndex; /* a parent index info */
|
||||
// review this ...
|
||||
struct _CDXTAG * pNext;
|
||||
BOOL AscendKey; /* ascending/descending order flag */
|
||||
BOOL UniqueKey; /* unique order flag */
|
||||
BOOL Temporary;
|
||||
BOOL Custom;
|
||||
BOOL TagChanged;
|
||||
BOOL TagBOF;
|
||||
BOOL TagEOF;
|
||||
//BYTE KeyType;
|
||||
BYTE OptFlags;
|
||||
LONG TagBlock; /* a page offset where a tag header is stored */
|
||||
LONG RootBlock; /* a page offset with the root of keys tree */
|
||||
//USHORT KeyLength;
|
||||
USHORT MaxKeys;
|
||||
LPCDXKEYINFO CurKeyInfo; /* current value of key expression */
|
||||
LPCDXPAGEINFO RootPage;
|
||||
LPCDXKEYINFO HotKey; /* value of hot key expression */
|
||||
PHB_ITEM topScope;
|
||||
LPCDXKEYINFO topScopeKey;
|
||||
PHB_ITEM bottomScope;
|
||||
LPCDXKEYINFO bottomScopeKey;
|
||||
LPCDXPAGEINFO pagePool;
|
||||
ULONG ulVersion;
|
||||
} CDXTAG;
|
||||
typedef CDXTAG * LPCDXTAG;
|
||||
|
||||
typedef struct _CDXINDEX
|
||||
{
|
||||
char * szFileName; /* Name of index file */
|
||||
FHANDLE hFile; /* Index file handle */
|
||||
struct _CDXAREA * pArea; /* Parent WorkArea */
|
||||
LPCDXTAG pCompound;
|
||||
LONG NextAvail;
|
||||
// review this...
|
||||
LPCDXTAG TagList;
|
||||
struct _CDXINDEX * pNext; /* The next index in the list */
|
||||
/* USHORT uiTag; */ /* current tag focus */
|
||||
BOOL fShared; /* Shared file */
|
||||
BOOL fReadonly; /* Read only file */
|
||||
int lockWrite;
|
||||
int lockRead;
|
||||
int changesWritten;
|
||||
ULONG ulVersion;
|
||||
} CDXINDEX;
|
||||
typedef CDXINDEX * LPCDXINDEX;
|
||||
|
||||
#if (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
|
||||
#pragma option -a1 /* byte alignment */
|
||||
#elif defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
#elif defined(__WATCOMC__)
|
||||
#pragma push(pack, 1);
|
||||
#elif defined(__cplusplus)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
/* ----
|
||||
typedef struct _CDXHEADER
|
||||
{ ...
|
||||
LONG Root;
|
||||
LONG FreePtr;
|
||||
LONG ChgFlag;
|
||||
USHORT Key_Lgth;
|
||||
BYTE IndexOpts;
|
||||
BYTE IndexSig;
|
||||
BYTE Reserve3[ 486 ];
|
||||
USHORT AscDesc;
|
||||
USHORT Reserve4;
|
||||
USHORT ForExpLen;
|
||||
USHORT Reserve5;
|
||||
USHORT KeyExpLen;
|
||||
BYTE KeyPool[ CDX_BLOCK_SIZE ];
|
||||
} CDXHEADER;
|
||||
|
||||
typedef CDXHEADER * LPCDXHEADER;
|
||||
----- */
|
||||
|
||||
#define CDX_TYPE_UNIQUE 1 /* unique index */
|
||||
#define CDX_TYPE_UNIQUE 0x01 /* unique index */
|
||||
#define CDX_TYPE_TEMPORARY 0x02 /* temporary index */
|
||||
#define CDX_TYPE_CUSTOM 0x04 /* custom index */
|
||||
#define CDX_TYPE_FORFILTER 0x08 /* for expression present */
|
||||
#define CDX_TYPE_BITVECTOR 0x10 /* SoftC? */
|
||||
#define CDX_TYPE_COMPACT 0x20 /* FoxPro */
|
||||
#define CDX_TYPE_COMPOUND 0x40 /* FoxPro */
|
||||
#define CDX_TYPE_STRUCTURE 0x80 /* FoxPro */
|
||||
|
||||
/* CDX index node strucutres */
|
||||
/* Compact Index Header Record */
|
||||
typedef struct _CDXTAGHEADER
|
||||
{
|
||||
LONG lRoot; /* offset of the root node */
|
||||
LONG lFreeList; /* offset of list of free pages or -1 */
|
||||
LONG lChgFlag; //lLength; /* Version number ? MSDN: pointer to end of file */
|
||||
USHORT uiKeySize; /* key length */
|
||||
BYTE bType; /* index options see CDX_TYPE_* */
|
||||
BYTE bSignature; /* index signature */
|
||||
BYTE bReserved1[ 486 ];
|
||||
USHORT iDescending; /* 0 = ascending 1 = descending */
|
||||
USHORT iFilterPos; /* offset of filter expression */
|
||||
USHORT iFilterLen; /* length of filter expression */
|
||||
USHORT iExprPos; /* offset of key expression */
|
||||
USHORT iExprLen; /* length of key expression */
|
||||
BYTE KeyPool[ CDX_PAGELEN ];
|
||||
BYTE rootPtr [ 4 ]; /* offset of the root node */
|
||||
BYTE freePtr [ 4 ]; /* offset of list of free pages or -1 */
|
||||
BYTE reserved1[ 4 ]; /* Version number ??? */
|
||||
BYTE keySize [ 2 ]; /* key length */
|
||||
BYTE indexOpt; /* index options see CDX_TYPE_* */
|
||||
BYTE indexSig; /* index signature */
|
||||
BYTE reserved2[ 486 ];
|
||||
BYTE ascendFlg[ 2 ]; /* 0 = ascending 1 = descending */
|
||||
BYTE forExpPos[ 2 ]; /* offset of filter expression */
|
||||
BYTE forExpLen[ 2 ]; /* length of filter expression */
|
||||
BYTE keyExpPos[ 2 ]; /* offset of key expression */
|
||||
BYTE keyExpLen[ 2 ]; /* length of key expression */
|
||||
BYTE keyExpPool[ CDX_PAGELEN ];
|
||||
} CDXTAGHEADER;
|
||||
typedef CDXTAGHEADER * LPCDXTAGHEADER;
|
||||
|
||||
#define CDX_NODE_BRANCH 0
|
||||
#define CDX_NODE_ROOT 1
|
||||
#define CDX_NODE_LEAF 2
|
||||
|
||||
typedef struct _CDXLEAFHEADER
|
||||
/* Compact Index Interior Node Record */
|
||||
typedef struct _CDXINTNODE
|
||||
{
|
||||
USHORT uiNodeType; /* node type see CDX_NODE_* */
|
||||
USHORT uiKeyCount; /* number of keys */
|
||||
LONG lLeftNode; /* offset of left node or -1 */
|
||||
LONG lRightNode; /* offset of right node or -1 */
|
||||
USHORT uiFreeSpace; /* free space available in a page */
|
||||
ULONG ulRecNumMask; /* record number mask */
|
||||
BYTE bDupByteMask; /* duplicate bytes count mask */
|
||||
BYTE bTrailByteMask; /* trailing bytes count mask */
|
||||
BYTE bRecNumLen; /* number of bits for record number */
|
||||
BYTE bDupCntLen; /* number of bits for duplicate count */
|
||||
BYTE bTrailCntLen; /* number of bits for trailing count */
|
||||
BYTE bInfo; /* total number of bytes for recnn/dup/trail info */
|
||||
BYTE bData[ CDX_LEAFFREESPACE ];
|
||||
} CDXLEAFHEADER;
|
||||
typedef CDXLEAFHEADER * LPCDXLEAFHEADER;
|
||||
#if (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
|
||||
#pragma option -a /* default alignment */
|
||||
#elif defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#elif defined(__WATCOMC__)
|
||||
#pragma pop(pack);
|
||||
#elif defined(__cplusplus)
|
||||
#pragma pack()
|
||||
#endif
|
||||
BYTE attr [ 2 ]; /* node type see CDX_NODE_* */
|
||||
BYTE nKeys [ 2 ]; /* number of keys */
|
||||
BYTE leftPtr [ 4 ]; /* offset of left node or -1 */
|
||||
BYTE rightPtr[ 4 ]; /* offset of right node or -1 */
|
||||
BYTE keyPool [ CDX_INT_FREESPACE ];
|
||||
} CDXINTNODE;
|
||||
typedef CDXINTNODE * LPCDXINTNODE;
|
||||
typedef CDXINTNODE CDXNODE;
|
||||
typedef CDXNODE * LPCDXNODE;
|
||||
|
||||
/* Compact Index Exterior Node Record */
|
||||
typedef struct _CDXEXTNODE
|
||||
{
|
||||
BYTE attr [ 2 ]; /* node type see CDX_NODE_* */
|
||||
BYTE nKeys [ 2 ]; /* number of keys */
|
||||
BYTE leftPtr [ 4 ]; /* offset of left node or -1 */
|
||||
BYTE rightPtr[ 4 ]; /* offset of right node or -1 */
|
||||
BYTE freeSpc [ 2 ]; /* free space available in a page */
|
||||
BYTE recMask [ 4 ]; /* record number mask */
|
||||
BYTE dupMask; /* duplicate bytes count mask */
|
||||
BYTE trlMask; /* trailing bytes count mask */
|
||||
BYTE recBits; /* number of bits for record number */
|
||||
BYTE dupBits; /* number of bits for duplicate count */
|
||||
BYTE trlBits; /* number of bits for trailing count */
|
||||
BYTE keyBytes; /* total number of bytes for recnn/dup/trail info */
|
||||
BYTE keyPool [ CDX_EXT_FREESPACE ]; /* rec/dup/trl */
|
||||
} CDXEXTNODE;
|
||||
typedef CDXEXTNODE * LPCDXEXTNODE;
|
||||
|
||||
|
||||
|
||||
/* CDX internal memory structures */
|
||||
|
||||
struct _CDXAREA; /* forward declaration */
|
||||
struct _CDXINDEX; /* forward declaration */
|
||||
struct _CDXTAG; /* forward declaration */
|
||||
|
||||
typedef struct _CDXKEY
|
||||
{
|
||||
BYTE * val;
|
||||
BYTE len;
|
||||
ULONG rec;
|
||||
} CDXKEY;
|
||||
typedef CDXKEY * LPCDXKEY;
|
||||
|
||||
typedef struct _CDXPAGE
|
||||
{
|
||||
ULONG Page;
|
||||
ULONG Left;
|
||||
ULONG Right;
|
||||
|
||||
BYTE PageType;
|
||||
SHORT iKeys;
|
||||
SHORT iCurKey;
|
||||
|
||||
BOOL fChanged;
|
||||
BYTE bUsed;
|
||||
|
||||
ULONG RNMask;
|
||||
BYTE ReqByte;
|
||||
BYTE RNBits;
|
||||
BYTE DCBits;
|
||||
BYTE TCBits;
|
||||
BYTE DCMask;
|
||||
BYTE TCMask;
|
||||
BOOL fBufChanged;
|
||||
union
|
||||
{
|
||||
CDXEXTNODE extNode;
|
||||
CDXINTNODE intNode;
|
||||
} node;
|
||||
BYTE bufKeyVal[ CDX_MAXKEY ]; /* buffer for leaf key val or added branch key */
|
||||
SHORT bufKeyNum; /* do not change these vars' order */
|
||||
SHORT bufKeyPos; /* they have to be just after the node */
|
||||
SHORT bufKeyLen; /* and maybe temporary overwriten when adding */
|
||||
SHORT iFree; /* new key to interior node record. */
|
||||
BYTE * pKeyBuf; /* pointer to uncompressed leaf page key pool */
|
||||
//SHORT iKeyInBuf;
|
||||
|
||||
struct _CDXPAGE * Owner;
|
||||
struct _CDXPAGE * Child;
|
||||
struct _CDXTAG * TagParent;
|
||||
struct _CDXPAGE * pPoolPrev;
|
||||
struct _CDXPAGE * pPoolNext;
|
||||
} CDXPAGE;
|
||||
typedef CDXPAGE * LPCDXPAGE;
|
||||
|
||||
typedef struct _CDXSTACK
|
||||
{
|
||||
LPCDXPAGE Page;
|
||||
SHORT iKey;
|
||||
} CDXSTACK;
|
||||
typedef CDXSTACK * LPCDXSTACK;
|
||||
|
||||
typedef struct _CDXLIST
|
||||
{
|
||||
ULONG ulAddr;
|
||||
BOOL fStat;
|
||||
struct _CDXLIST * pNext;
|
||||
} CDXLIST;
|
||||
typedef CDXLIST * LPCDXLIST;
|
||||
|
||||
typedef struct _CDXTAG
|
||||
{
|
||||
char * szName; /* Name of tag */
|
||||
char * KeyExpr; /* a tag key expression as text */
|
||||
char * ForExpr; /* a tag for expression as text */
|
||||
PHB_ITEM pKeyItem; /* item with a macro pcode for a tag key expression */
|
||||
PHB_ITEM pForItem; /* item with a macro pcode for a tag for expression */
|
||||
USHORT uiType; /* a type of key expression value */
|
||||
USHORT uiLen; /* length of the key expression value */
|
||||
USHORT nField; /* Field number for simple (one field) key expersion */
|
||||
BYTE OptFlags; /* index options flag */
|
||||
BOOL AscendKey; /* ascending/descending order flag */
|
||||
BOOL UniqueKey; /* unique order flag */
|
||||
BOOL Temporary; /* temporary order flag */
|
||||
BOOL Custom; /* custom order flag */
|
||||
|
||||
BOOL UsrAscend; /* user settable ascending/descending order flag */
|
||||
BOOL UsrUnique; /* user settable unique order flag */
|
||||
|
||||
BOOL TagChanged;
|
||||
BOOL TagBOF;
|
||||
BOOL TagEOF;
|
||||
|
||||
BOOL fRePos;
|
||||
BYTE curKeyState; /* see: CDX_CURKEY_* */
|
||||
|
||||
ULONG TagBlock; /* a page offset where a tag header is stored */
|
||||
ULONG RootBlock; /* a page offset with the root of keys tree */
|
||||
USHORT MaxKeys; /* maximum number of keys in Interior node */
|
||||
|
||||
struct _CDXINDEX * pIndex; /* a parent index info */
|
||||
struct _CDXTAG * pNext; /* pointer to next tag in index */
|
||||
|
||||
//CDXSTACK PageStack[ CDX_STACKSIZE ]; /* stack with page path to current key */
|
||||
LPCDXPAGE RootPage; /* pointer to root of keys tree in memory */
|
||||
LPCDXKEY CurKey; /* current value of key expression */
|
||||
LPCDXKEY HotKey; /* value of hot key expression */
|
||||
BOOL HotFor; /* index FOR condition for HotKey */
|
||||
|
||||
PHB_ITEM topScope; /* Top scope HB_ITEM */
|
||||
LPCDXKEY topScopeKey; /* Top scope index key */
|
||||
PHB_ITEM bottomScope; /* Bottom scope HB_ITEM */
|
||||
LPCDXKEY bottomScopeKey; /* Bottom index key */
|
||||
|
||||
LPCDXPAGE pagePool; /* page buffer in memory */
|
||||
} CDXTAG;
|
||||
typedef CDXTAG * LPCDXTAG;
|
||||
|
||||
typedef struct _CDXINDEX
|
||||
{
|
||||
char * szFileName; /* Name of index file */
|
||||
FHANDLE hFile; /* Index file handle */
|
||||
struct _CDXAREA * pArea; /* Parent WorkArea */
|
||||
struct _CDXINDEX * pNext; /* The next index in the list */
|
||||
LPCDXTAG pCompound; /* Compound Tag (index of tags) */
|
||||
LPCDXTAG TagList; /* List of tags in index file */
|
||||
BOOL fShared; /* Shared file */
|
||||
BOOL fReadonly; /* Read only file */
|
||||
ULONG nextAvail; /* offset to next free page in the end of index file */
|
||||
ULONG freePage; /* offset to next free page inside index file */
|
||||
LPCDXLIST freeLst; /* list of free pages in index file */
|
||||
int lockWrite; /* number of write lock set */
|
||||
int lockRead; /* number of read lock set */
|
||||
BOOL fChanged; /* changes written to index, need upadte ulVersion */
|
||||
ULONG ulVersion; /* network version/update flag */
|
||||
} CDXINDEX;
|
||||
typedef CDXINDEX * LPCDXINDEX;
|
||||
|
||||
|
||||
/*
|
||||
@@ -341,9 +373,12 @@ typedef struct _CDXAREA
|
||||
ULONG ulRecCount; /* Total records */
|
||||
char * szDataFileName; /* Name of data file */
|
||||
char * szMemoFileName; /* Name of memo file */
|
||||
USHORT uiMemoBlockSize; /* Size of memo block */
|
||||
BYTE bMemoType; /* MEMO type used in DBF memo fields */
|
||||
BOOL fHasMemo; /* WorkArea with Memo fields */
|
||||
BOOL fHasTags; /* WorkArea with MDX or CDX index */
|
||||
BYTE bCodePage;
|
||||
BYTE bVersion; /* DBF version ID byte */
|
||||
BYTE bCodePage; /* DBF codepage ID */
|
||||
BOOL fShared; /* Shared file */
|
||||
BOOL fReadonly; /* Read only file */
|
||||
USHORT * pFieldOffset; /* Pointer to field offset array */
|
||||
@@ -362,21 +397,21 @@ typedef struct _CDXAREA
|
||||
BYTE bDay;
|
||||
ULONG * pLocksPos; /* List of records locked */
|
||||
ULONG ulNumLocksPos; /* Number of records locked */
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
PHB_CODEPAGE cdPage; /* Area's codepage pointer */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CDX's additions to the workarea structure
|
||||
*
|
||||
* Warning: The above section MUST match WORKAREA exactly! Any
|
||||
* Warning: The above section MUST match DBFAREA exactly! Any
|
||||
* additions to the structure MUST be added below, as in this
|
||||
* example.
|
||||
*/
|
||||
|
||||
USHORT uiMemoBlockSize; /* Size of memo block */
|
||||
LPMEMOROOT pMemoRoot; /* Array of free memo blocks */
|
||||
//LPCDXTAG * lpIndexes; /* Pointer to indexes array */
|
||||
LPCDXINDEX lpIndexes; /* Pointer to indexes array */
|
||||
USHORT uiTag; /* current tag focus */
|
||||
BOOL fCdxAppend; /* Appended record changed */
|
||||
LPCDXINDEX lpIndexes; /* Pointer to indexes array */
|
||||
USHORT uiTag; /* current tag focus */
|
||||
|
||||
} CDXAREA;
|
||||
|
||||
@@ -396,15 +431,14 @@ typedef CDXAREA * LPCDXAREA;
|
||||
#define hb_cdxBof NULL
|
||||
#define hb_cdxEof NULL
|
||||
#define hb_cdxFound NULL
|
||||
extern ERRCODE hb_cdxGoBottom( CDXAREAP pArea );
|
||||
//#define hb_cdxGoTo NULL
|
||||
extern ERRCODE hb_cdxGoTo( CDXAREAP pArea, ULONG ulRecNo );
|
||||
static ERRCODE hb_cdxGoBottom( CDXAREAP pArea );
|
||||
#define hb_cdxGoTo NULL
|
||||
#define hb_cdxGoToId NULL
|
||||
extern ERRCODE hb_cdxGoTop( CDXAREAP pArea );
|
||||
extern ERRCODE hb_cdxSeek( CDXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFindLast );
|
||||
static ERRCODE hb_cdxGoTop( CDXAREAP pArea );
|
||||
static ERRCODE hb_cdxSeek( CDXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFindLast );
|
||||
#define hb_cdxSkip NULL
|
||||
#define hb_cdxSkipFilter NULL
|
||||
extern ERRCODE hb_cdxSkipRaw( CDXAREAP pArea, LONG lToSkip );
|
||||
static ERRCODE hb_cdxSkipRaw( CDXAREAP pArea, LONG lToSkip );
|
||||
#define hb_cdxAddField NULL
|
||||
#define hb_cdxAppend NULL
|
||||
#define hb_cdxCreateFields NULL
|
||||
@@ -416,36 +450,33 @@ extern ERRCODE hb_cdxSkipRaw( CDXAREAP pArea, LONG lToSkip );
|
||||
#define hb_cdxFieldName NULL
|
||||
#define hb_cdxFlush NULL
|
||||
#define hb_cdxGetRec NULL
|
||||
extern ERRCODE hb_cdxGetValue( CDXAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
extern ERRCODE hb_cdxGetVarLen( CDXAREAP pArea, USHORT uiIndex, ULONG * pLength );
|
||||
//#define hb_cdxGoCold NULL
|
||||
extern ERRCODE hb_cdxGoCold( CDXAREAP pArea );
|
||||
//#define hb_cdxGoHot NULL
|
||||
extern ERRCODE hb_cdxGoHot( CDXAREAP pArea );
|
||||
#define hb_cdxGetValue NULL
|
||||
#define hb_cdxGetVarLen NULL
|
||||
static ERRCODE hb_cdxGoCold( CDXAREAP pArea );
|
||||
static ERRCODE hb_cdxGoHot( CDXAREAP pArea );
|
||||
#define hb_cdxPutRec NULL
|
||||
extern ERRCODE hb_cdxPutValue( CDXAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
#define hb_cdxPutValue NULL
|
||||
#define hb_cdxRecall NULL
|
||||
#define hb_cdxRecCount NULL
|
||||
#define hb_cdxRecInfo NULL
|
||||
#define hb_cdxRecNo NULL
|
||||
#define hb_cdxSetFieldExtent NULL
|
||||
#define hb_cdxAlias NULL
|
||||
extern ERRCODE hb_cdxClose( CDXAREAP pArea );
|
||||
static ERRCODE hb_cdxClose( CDXAREAP pArea );
|
||||
#define hb_cdxCreate NULL
|
||||
extern ERRCODE hb_cdxInfo( CDXAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
#define hb_cdxInfo NULL
|
||||
#define hb_cdxNewArea NULL
|
||||
extern ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
static ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
#define hb_cdxRelease NULL
|
||||
extern ERRCODE hb_cdxStructSize( CDXAREAP pArea, USHORT * uiSize );
|
||||
extern ERRCODE hb_cdxSysName( CDXAREAP pArea, BYTE * pBuffer );
|
||||
static ERRCODE hb_cdxStructSize( CDXAREAP pArea, USHORT * uiSize );
|
||||
static ERRCODE hb_cdxSysName( CDXAREAP pArea, BYTE * pBuffer );
|
||||
#define hb_cdxEval NULL
|
||||
extern ERRCODE hb_cdxPack ( CDXAREAP pArea );
|
||||
static ERRCODE hb_cdxPack ( CDXAREAP pArea );
|
||||
#define hb_cdxPackRec NULL
|
||||
#define hb_cdxSort NULL
|
||||
#define hb_cdxTrans NULL
|
||||
#define hb_cdxTransRec NULL
|
||||
/* #define hb_cdxZap NULL */
|
||||
extern ERRCODE hb_cdxZap ( CDXAREAP pArea );
|
||||
static ERRCODE hb_cdxZap ( CDXAREAP pArea );
|
||||
#define hb_cdxChildEnd NULL
|
||||
#define hb_cdxChildStart NULL
|
||||
#define hb_cdxChildSync NULL
|
||||
@@ -456,26 +487,23 @@ extern ERRCODE hb_cdxZap ( CDXAREAP pArea );
|
||||
#define hb_cdxRelEval NULL
|
||||
#define hb_cdxRelText NULL
|
||||
#define hb_cdxSetRel NULL
|
||||
extern ERRCODE hb_cdxOrderListAdd( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
|
||||
extern ERRCODE hb_cdxOrderListClear( CDXAREAP pArea );
|
||||
static ERRCODE hb_cdxOrderListAdd( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
|
||||
static ERRCODE hb_cdxOrderListClear( CDXAREAP pArea );
|
||||
#define hb_cdxOrderListDelete NULL
|
||||
extern ERRCODE hb_cdxOrderListFocus( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
|
||||
static ERRCODE hb_cdxOrderListFocus( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
|
||||
static ERRCODE hb_cdxOrderListRebuild( CDXAREAP pArea );
|
||||
#define hb_cdxOrderCondition NULL
|
||||
extern ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo );
|
||||
extern ERRCODE hb_cdxOrderDestroy( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
|
||||
extern ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrderInfo );
|
||||
static ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo );
|
||||
static ERRCODE hb_cdxOrderDestroy( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
|
||||
static ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrderInfo );
|
||||
#define hb_cdxClearFilter NULL
|
||||
#define hb_cdxClearLocate NULL
|
||||
/* #define hb_cdxClearScope NULL */
|
||||
static ERRCODE hb_cdxClearScope( CDXAREAP pArea );
|
||||
#define hb_cdxCountScope NULL
|
||||
#define hb_cdxFilterText NULL
|
||||
/* #define hb_cdxScopeInfo NULL */
|
||||
static ERRCODE hb_cdxScopeInfo( CDXAREAP pArea, USHORT nScope, PHB_ITEM pItem );
|
||||
#define hb_cdxSetFilter NULL
|
||||
#define hb_cdxSetLocate NULL
|
||||
/* #define hb_cdxSetScope NULL */
|
||||
static ERRCODE hb_cdxSetScope( CDXAREAP pArea, LPDBORDSCOPEINFO sInfo );
|
||||
#define hb_cdxSkipScope NULL
|
||||
#define hb_cdxCompile NULL
|
||||
@@ -485,14 +513,19 @@ static ERRCODE hb_cdxSetScope( CDXAREAP pArea, LPDBORDSCOPEINFO sInfo );
|
||||
#define hb_cdxLock NULL
|
||||
#define hb_cdxUnLock NULL
|
||||
#define hb_cdxCloseMemFile NULL
|
||||
extern ERRCODE hb_cdxCreateMemFile( CDXAREAP pArea, LPDBOPENINFO pCreateInfo );
|
||||
#define hb_cdxCreateMemFile NULL
|
||||
#define hb_cdxGetValueFile NULL
|
||||
extern ERRCODE hb_cdxOpenMemFile( CDXAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
#define hb_cdxOpenMemFile NULL
|
||||
#define hb_cdxPutValueFile NULL
|
||||
extern ERRCODE hb_cdxReadDBHeader( CDXAREAP pArea );
|
||||
extern ERRCODE hb_cdxWriteDBHeader( CDXAREAP pArea );
|
||||
#define hb_cdxReadDBHeader NULL
|
||||
#define hb_cdxWriteDBHeader NULL
|
||||
#define hb_cdxExit NULL
|
||||
#define hb_cdxDrop NULL
|
||||
#define hb_cdxExists NULL
|
||||
#define hb_cdxWhoCares NULL
|
||||
|
||||
//#define hb_cdxSwapBytes( n ) HB_SWAP_ULONG( n );
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -54,47 +54,21 @@
|
||||
#define HB_RDDDBF_H_
|
||||
|
||||
#include "hbapirdd.h"
|
||||
#include "hbdbferr.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* DBF errors */
|
||||
|
||||
#define EDBF_OPEN_DBF 1001
|
||||
#define EDBF_CREATE_DBF 1004
|
||||
#define EDBF_READ 1010
|
||||
#define EDBF_WRITE 1011
|
||||
#define EDBF_CORRUPT 1012
|
||||
#define EDBF_DATATYPE 1020
|
||||
#define EDBF_DATAWIDTH 1021
|
||||
#define EDBF_UNLOCKED 1022
|
||||
#define EDBF_SHARED 1023
|
||||
#define EDBF_APPENDLOCK 1024
|
||||
#define EDBF_READONLY 1025
|
||||
|
||||
|
||||
|
||||
/* DBF default file extensions */
|
||||
|
||||
#define DBF_TABLEEXT ".dbf"
|
||||
#define DBF_MEMOEXT ".dbt"
|
||||
|
||||
|
||||
|
||||
/* DBF lock */
|
||||
|
||||
#define DBF_LOCKPOS 1000000000L
|
||||
|
||||
|
||||
|
||||
/* DBT's */
|
||||
|
||||
#define DBT_BLOCKSIZE 512
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* DBF WORKAREA
|
||||
* ------------
|
||||
@@ -105,26 +79,26 @@ extern "C" {
|
||||
typedef struct _DBFAREA
|
||||
{
|
||||
struct _RDDFUNCS * lprfsHost; /* Virtual method table for this workarea */
|
||||
USHORT uiArea; /* The number assigned to this workarea */
|
||||
USHORT uiArea; /* The number assigned to this workarea */
|
||||
void * atomAlias; /* Pointer to the alias symbol for this workarea */
|
||||
USHORT uiFieldExtent; /* Total number of fields allocated */
|
||||
USHORT uiFieldCount; /* Total number of fields used */
|
||||
LPFIELD lpFields; /* Pointer to an array of fields */
|
||||
void * lpFieldExtents; /* Void ptr for additional field properties */
|
||||
USHORT uiFieldExtent; /* Total number of fields allocated */
|
||||
USHORT uiFieldCount; /* Total number of fields used */
|
||||
LPFIELD lpFields; /* Pointer to an array of fields */
|
||||
void * lpFieldExtents; /* Void ptr for additional field properties */
|
||||
PHB_ITEM valResult; /* All purpose result holder */
|
||||
BOOL fTop; /* TRUE if "top" */
|
||||
BOOL fBottom; /* TRUE if "bottom" */
|
||||
BOOL fBof; /* TRUE if "bof" */
|
||||
BOOL fEof; /* TRUE if "eof" */
|
||||
BOOL fFound; /* TRUE if "found" */
|
||||
DBSCOPEINFO dbsi; /* Info regarding last LOCATE */
|
||||
DBSCOPEINFO dbsi; /* Info regarding last LOCATE */
|
||||
DBFILTERINFO dbfi; /* Filter in effect */
|
||||
LPDBORDERCONDINFO lpdbOrdCondInfo;
|
||||
LPDBRELINFO lpdbRelations; /* Parent/Child relationships used */
|
||||
USHORT uiParents; /* Number of parents for this area */
|
||||
USHORT heap;
|
||||
USHORT heapSize;
|
||||
USHORT rddID;
|
||||
USHORT heap;
|
||||
USHORT heapSize;
|
||||
USHORT rddID;
|
||||
USHORT uiMaxFieldNameLength;
|
||||
|
||||
/*
|
||||
@@ -142,9 +116,12 @@ typedef struct _DBFAREA
|
||||
ULONG ulRecCount; /* Total records */
|
||||
char * szDataFileName; /* Name of data file */
|
||||
char * szMemoFileName; /* Name of memo file */
|
||||
USHORT uiMemoBlockSize; /* Size of memo block */
|
||||
BYTE bMemoType; /* MEMO type used in DBF memo fields */
|
||||
BOOL fHasMemo; /* WorkArea with Memo fields */
|
||||
BOOL fHasTags; /* WorkArea with MDX or CDX index */
|
||||
BYTE bCodePage;
|
||||
BYTE bVersion; /* DBF version ID byte */
|
||||
BYTE bCodePage; /* DBF codepage ID */
|
||||
BOOL fShared; /* Shared file */
|
||||
BOOL fReadonly; /* Read only file */
|
||||
USHORT * pFieldOffset; /* Pointer to field offset array */
|
||||
@@ -173,6 +150,7 @@ typedef DBFAREA * LPDBFAREA;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HB_EXTRANAL_RDDDBF_USE
|
||||
|
||||
/*
|
||||
* -- DBF METHODS --
|
||||
@@ -180,61 +158,61 @@ typedef DBFAREA * LPDBFAREA;
|
||||
|
||||
#define SUPERTABLE ( &dbfSuper )
|
||||
|
||||
extern ERRCODE hb_dbfBof( DBFAREAP pArea, BOOL * pBof );
|
||||
extern ERRCODE hb_dbfEof( DBFAREAP pArea, BOOL * pEof );
|
||||
extern ERRCODE hb_dbfFound( DBFAREAP pArea, BOOL * pFound );
|
||||
extern ERRCODE hb_dbfGoBottom( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfGoTo( DBFAREAP pArea, ULONG ulRecNo );
|
||||
extern ERRCODE hb_dbfGoToId( DBFAREAP pArea, PHB_ITEM pItem );
|
||||
extern ERRCODE hb_dbfGoTop( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfBof( DBFAREAP pArea, BOOL * pBof );
|
||||
static ERRCODE hb_dbfEof( DBFAREAP pArea, BOOL * pEof );
|
||||
static ERRCODE hb_dbfFound( DBFAREAP pArea, BOOL * pFound );
|
||||
static ERRCODE hb_dbfGoBottom( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfGoTo( DBFAREAP pArea, ULONG ulRecNo );
|
||||
static ERRCODE hb_dbfGoToId( DBFAREAP pArea, PHB_ITEM pItem );
|
||||
static ERRCODE hb_dbfGoTop( DBFAREAP pArea );
|
||||
#define hb_dbfSeek NULL
|
||||
extern ERRCODE hb_dbfSkip( DBFAREAP pArea, LONG lToSkip );
|
||||
static ERRCODE hb_dbfSkip( DBFAREAP pArea, LONG lToSkip );
|
||||
#define hb_dbfSkipFilter NULL
|
||||
extern ERRCODE hb_dbfSkipRaw( DBFAREAP pArea, LONG lToSkip );
|
||||
extern ERRCODE hb_dbfAddField( DBFAREAP pArea, LPDBFIELDINFO pFieldInfo );
|
||||
extern ERRCODE hb_dbfAppend( DBFAREAP pArea, BOOL bUnLockAll );
|
||||
static ERRCODE hb_dbfSkipRaw( DBFAREAP pArea, LONG lToSkip );
|
||||
static ERRCODE hb_dbfAddField( DBFAREAP pArea, LPDBFIELDINFO pFieldInfo );
|
||||
static ERRCODE hb_dbfAppend( DBFAREAP pArea, BOOL bUnLockAll );
|
||||
#define hb_dbfCreateFields NULL
|
||||
extern ERRCODE hb_dbfDeleteRec( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfDeleted( DBFAREAP pArea, BOOL * pDeleted );
|
||||
static ERRCODE hb_dbfDeleteRec( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfDeleted( DBFAREAP pArea, BOOL * pDeleted );
|
||||
#define hb_dbfFieldCount NULL
|
||||
#define hb_dbfFieldDisplay NULL
|
||||
#define hb_dbfFieldInfo NULL
|
||||
#define hb_dbfFieldName NULL
|
||||
extern ERRCODE hb_dbfFlush( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfFlush( DBFAREAP pArea );
|
||||
#define hb_dbfGetRec NULL
|
||||
extern ERRCODE hb_dbfGetValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
extern ERRCODE hb_dbfGetVarLen( DBFAREAP pArea, USHORT uiIndex, ULONG * pLength );
|
||||
extern ERRCODE hb_dbfGoCold( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfGoHot( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfPutRec( DBFAREAP pArea, BYTE * pBuffer );
|
||||
extern ERRCODE hb_dbfPutValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
extern ERRCODE hb_dbfRecall( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfRecCount( DBFAREAP pArea, ULONG * pRecCount );
|
||||
static ERRCODE hb_dbfGetValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
static ERRCODE hb_dbfGetVarLen( DBFAREAP pArea, USHORT uiIndex, ULONG * pLength );
|
||||
static ERRCODE hb_dbfGoCold( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfGoHot( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfPutRec( DBFAREAP pArea, BYTE * pBuffer );
|
||||
static ERRCODE hb_dbfPutValue( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
static ERRCODE hb_dbfRecall( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfRecCount( DBFAREAP pArea, ULONG * pRecCount );
|
||||
#define hb_dbfRecInfo NULL
|
||||
extern ERRCODE hb_dbfRecNo( DBFAREAP pArea, PHB_ITEM pRecNo );
|
||||
extern ERRCODE hb_dbfSetFieldExtent( DBFAREAP pArea, USHORT uiFieldExtent );
|
||||
static ERRCODE hb_dbfRecNo( DBFAREAP pArea, PHB_ITEM pRecNo );
|
||||
static ERRCODE hb_dbfSetFieldExtent( DBFAREAP pArea, USHORT uiFieldExtent );
|
||||
#define hb_dbfAlias NULL
|
||||
extern ERRCODE hb_dbfClose( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo );
|
||||
extern ERRCODE hb_dbfInfo( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
extern ERRCODE hb_dbfNewArea( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
static ERRCODE hb_dbfClose( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo );
|
||||
static ERRCODE hb_dbfInfo( DBFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
static ERRCODE hb_dbfNewArea( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
#define hb_dbfRelease NULL
|
||||
extern ERRCODE hb_dbfStructSize( DBFAREAP pArea, USHORT * uiSize );
|
||||
extern ERRCODE hb_dbfSysName( DBFAREAP pArea, BYTE * pBuffer );
|
||||
static ERRCODE hb_dbfStructSize( DBFAREAP pArea, USHORT * uiSize );
|
||||
static ERRCODE hb_dbfSysName( DBFAREAP pArea, BYTE * pBuffer );
|
||||
#define hb_dbfEval NULL
|
||||
extern ERRCODE hb_dbfPack( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfPack( DBFAREAP pArea );
|
||||
#define hb_dbfPackRec NULL
|
||||
extern ERRCODE hb_dbfSort( DBFAREAP pArea, LPDBSORTINFO pSortInfo );
|
||||
extern ERRCODE hb_dbfTrans( DBFAREAP pArea, LPDBTRANSINFO pTransInfo );
|
||||
extern ERRCODE hb_dbfTransRec( DBFAREAP pArea, LPDBTRANSINFO pTransInfo );
|
||||
extern ERRCODE hb_dbfZap( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfChildEnd( DBFAREAP pArea, LPDBRELINFO pRelInfo );
|
||||
extern ERRCODE hb_dbfChildStart( DBFAREAP pArea, LPDBRELINFO pRelInfo );
|
||||
extern ERRCODE hb_dbfChildSync( DBFAREAP pArea, LPDBRELINFO pRelInfo );
|
||||
static ERRCODE hb_dbfSort( DBFAREAP pArea, LPDBSORTINFO pSortInfo );
|
||||
static ERRCODE hb_dbfTrans( DBFAREAP pArea, LPDBTRANSINFO pTransInfo );
|
||||
static ERRCODE hb_dbfTransRec( DBFAREAP pArea, LPDBTRANSINFO pTransInfo );
|
||||
static ERRCODE hb_dbfZap( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfChildEnd( DBFAREAP pArea, LPDBRELINFO pRelInfo );
|
||||
static ERRCODE hb_dbfChildStart( DBFAREAP pArea, LPDBRELINFO pRelInfo );
|
||||
static ERRCODE hb_dbfChildSync( DBFAREAP pArea, LPDBRELINFO pRelInfo );
|
||||
#define hb_dbfSyncChildren NULL
|
||||
#define hb_dbfClearRel NULL
|
||||
extern ERRCODE hb_dbfForceRel( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfForceRel( DBFAREAP pArea );
|
||||
#define hb_dbfRelArea NULL
|
||||
#define hb_dbfRelEval NULL
|
||||
#define hb_dbfRelText NULL
|
||||
@@ -254,30 +232,32 @@ extern ERRCODE hb_dbfForceRel( DBFAREAP pArea );
|
||||
#define hb_dbfCountScope NULL
|
||||
#define hb_dbfFilterText NULL
|
||||
#define hb_dbfScopeInfo NULL
|
||||
extern ERRCODE hb_dbfSetFilter( DBFAREAP pArea, LPDBFILTERINFO pFilterInfo );
|
||||
static ERRCODE hb_dbfSetFilter( DBFAREAP pArea, LPDBFILTERINFO pFilterInfo );
|
||||
#define hb_dbfSetLocate NULL
|
||||
#define hb_dbfSetScope NULL
|
||||
#define hb_dbfSkipScope NULL
|
||||
#define hb_dbfCompile NULL
|
||||
#define hb_dbfError NULL
|
||||
#define hb_dbfEvalBlock NULL
|
||||
#define hb_dbfRawLock NULL
|
||||
extern ERRCODE hb_dbfLock( DBFAREAP pArea, LPDBLOCKINFO pLockInfo );
|
||||
extern ERRCODE hb_dbfUnLock( DBFAREAP pArea, ULONG ulRecNo );
|
||||
static ERRCODE hb_dbfRawLock( DBFAREAP pArea, USHORT uiAction, ULONG lRecNo );
|
||||
static ERRCODE hb_dbfLock( DBFAREAP pArea, LPDBLOCKINFO pLockInfo );
|
||||
static ERRCODE hb_dbfUnLock( DBFAREAP pArea, ULONG ulRecNo );
|
||||
#define hb_dbfCloseMemFile NULL
|
||||
extern ERRCODE hb_dbfCreateMemFile( DBFAREAP pArea, LPDBOPENINFO pCreateInfo );
|
||||
static ERRCODE hb_dbfCreateMemFile( DBFAREAP pArea, LPDBOPENINFO pCreateInfo );
|
||||
#define hb_dbfGetValueFile NULL
|
||||
extern ERRCODE hb_dbfOpenMemFile( DBFAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
static ERRCODE hb_dbfOpenMemFile( DBFAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
#define hb_dbfPutValueFile NULL
|
||||
extern ERRCODE hb_dbfReadDBHeader( DBFAREAP pArea );
|
||||
extern ERRCODE hb_dbfWriteDBHeader( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfReadDBHeader( DBFAREAP pArea );
|
||||
static ERRCODE hb_dbfWriteDBHeader( DBFAREAP pArea );
|
||||
|
||||
#define hb_dbfExit NULL
|
||||
extern ERRCODE hb_dbfDrop( PHB_ITEM pItemTable );
|
||||
extern BOOL hb_dbfExists( PHB_ITEM pItemTable, PHB_ITEM pItemIndex );
|
||||
static ERRCODE hb_dbfDrop( PHB_ITEM pItemTable );
|
||||
static BOOL hb_dbfExists( PHB_ITEM pItemTable, PHB_ITEM pItemIndex );
|
||||
|
||||
#define hb_dbfWhoCares NULL
|
||||
|
||||
#endif /* HB_EXTRANAL_RDDDBF_USE */
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
}
|
||||
#endif
|
||||
|
||||
200
harbour/include/hbrdddbt.h
Normal file
200
harbour/include/hbrdddbt.h
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* xHarbour Project source code:
|
||||
* DBFDBT RDD
|
||||
*
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* www - http://www.xharbour.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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HB_RDDDBT_H_
|
||||
#define HB_RDDDBT_H_
|
||||
|
||||
#include "hbdbf.h"
|
||||
#include "hbdbferr.h"
|
||||
#include "hbapirdd.h"
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
#include "hbapicdp.h"
|
||||
#endif
|
||||
#define HB_EXTRANAL_RDDDBF_USE
|
||||
#include "hbrdddbf.h"
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* MEMO constants and defaults */
|
||||
#define DBT_MEMOEXT ".dbt"
|
||||
#define DBT_BLOCKSIZE 512
|
||||
#define DBT_LOCKPOS 0x00000001L
|
||||
#define DBT_LOCKSIZE 0x7FFFFFFFL
|
||||
|
||||
/*
|
||||
* DBFDBT WORKAREA
|
||||
* ------------
|
||||
* The Workarea Structure of DBFDBT RDD
|
||||
*
|
||||
*/
|
||||
|
||||
/* we don't have to change DBFAREA to create DBTAREA */
|
||||
typedef DBFAREA DBTAREA;
|
||||
typedef DBTAREA * LPDBTAREA;
|
||||
#ifndef DBTAREAP
|
||||
#define DBTAREAP LPDBTAREA
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* -- DBFDBT METHODS --
|
||||
*/
|
||||
|
||||
#define SUPERTABLE ( &dbtSuper )
|
||||
|
||||
#define hb_dbtBof NULL
|
||||
#define hb_dbtEof NULL
|
||||
#define hb_dbtFound NULL
|
||||
#define hb_dbtGoBottom NULL
|
||||
#define hb_dbtGoTo NULL
|
||||
#define hb_dbtGoToId NULL
|
||||
#define hb_dbtGoTop NULL
|
||||
#define hb_dbtSeek NULL
|
||||
#define hb_dbtSkip NULL
|
||||
#define hb_dbtSkipFilter NULL
|
||||
#define hb_dbtSkipRaw NULL
|
||||
#define hb_dbtAddField NULL
|
||||
#define hb_dbtAppend NULL
|
||||
#define hb_dbtCreateFields NULL
|
||||
#define hb_dbtDeleteRec NULL
|
||||
#define hb_dbtDeleted NULL
|
||||
#define hb_dbtFieldCount NULL
|
||||
#define hb_dbtFieldDisplay NULL
|
||||
#define hb_dbtFieldInfo NULL
|
||||
#define hb_dbtFieldName NULL
|
||||
#define hb_dbtFlush NULL
|
||||
#define hb_dbtGetRec NULL
|
||||
static ERRCODE hb_dbtGetValue( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
static ERRCODE hb_dbtGetVarLen( DBTAREAP pArea, USHORT uiIndex, ULONG * pLength );
|
||||
#define hb_dbtGoCold NULL
|
||||
#define hb_dbtGoHot NULL
|
||||
#define hb_dbtPutRec NULL
|
||||
static ERRCODE hb_dbtPutValue( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
#define hb_dbtRecall NULL
|
||||
#define hb_dbtRecCount NULL
|
||||
#define hb_dbtRecInfo NULL
|
||||
#define hb_dbtRecNo NULL
|
||||
#define hb_dbtSetFieldExtent NULL
|
||||
#define hb_dbtAlias NULL
|
||||
#define hb_dbtClose NULL
|
||||
#define hb_dbtCreate NULL
|
||||
static ERRCODE hb_dbtInfo( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
#define hb_dbtNewArea NULL
|
||||
#define hb_dbtOpen NULL
|
||||
#define hb_dbtRelease NULL
|
||||
static ERRCODE hb_dbtStructSize( DBTAREAP pArea, USHORT * uiSize );
|
||||
static ERRCODE hb_dbtSysName( DBTAREAP pArea, BYTE * pBuffer );
|
||||
#define hb_dbtEval NULL
|
||||
#define hb_dbtPack NULL
|
||||
#define hb_dbtPackRec NULL
|
||||
#define hb_dbtSort NULL
|
||||
#define hb_dbtTrans NULL
|
||||
#define hb_dbtTransRec NULL
|
||||
#define hb_dbtZap NULL
|
||||
#define hb_dbtChildEnd NULL
|
||||
#define hb_dbtChildStart NULL
|
||||
#define hb_dbtChildSync NULL
|
||||
#define hb_dbtSyncChildren NULL
|
||||
#define hb_dbtClearRel NULL
|
||||
#define hb_dbtForceRel NULL
|
||||
#define hb_dbtRelArea NULL
|
||||
#define hb_dbtRelEval NULL
|
||||
#define hb_dbtRelText NULL
|
||||
#define hb_dbtSetRel NULL
|
||||
#define hb_dbtOrderListAdd NULL
|
||||
#define hb_dbtOrderListClear NULL
|
||||
#define hb_dbtOrderListDelete NULL
|
||||
#define hb_dbtOrderListFocus NULL
|
||||
#define hb_dbtOrderListRebuild NULL
|
||||
#define hb_dbtOrderCondition NULL
|
||||
#define hb_dbtOrderCreate NULL
|
||||
#define hb_dbtOrderDestroy NULL
|
||||
#define hb_dbtOrderInfo NULL
|
||||
#define hb_dbtClearFilter NULL
|
||||
#define hb_dbtClearLocate NULL
|
||||
#define hb_dbtClearScope NULL
|
||||
#define hb_dbtCountScope NULL
|
||||
#define hb_dbtFilterText NULL
|
||||
#define hb_dbtScopeInfo NULL
|
||||
#define hb_dbtSetFilter NULL
|
||||
#define hb_dbtSetLocate NULL
|
||||
#define hb_dbtSetScope NULL
|
||||
#define hb_dbtSkipScope NULL
|
||||
#define hb_dbtCompile NULL
|
||||
#define hb_dbtError NULL
|
||||
#define hb_dbtEvalBlock NULL
|
||||
#define hb_dbtRawLock NULL
|
||||
#define hb_dbtLock NULL
|
||||
#define hb_dbtUnLock NULL
|
||||
#define hb_dbtCloseMemFile NULL
|
||||
static ERRCODE hb_dbtCreateMemFile( DBTAREAP pArea, LPDBOPENINFO pCreateInfo );
|
||||
#define hb_dbtGetValueFile NULL
|
||||
static ERRCODE hb_dbtOpenMemFile( DBTAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
#define hb_dbtPutValueFile NULL
|
||||
static ERRCODE hb_dbtReadDBHeader( DBTAREAP pArea );
|
||||
static ERRCODE hb_dbtWriteDBHeader( DBTAREAP pArea );
|
||||
#define hb_dbtExit NULL
|
||||
#define hb_dbtDrop NULL
|
||||
#define hb_dbtExists NULL
|
||||
#define hb_dbtWhoCares NULL
|
||||
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
}
|
||||
#endif
|
||||
|
||||
extern ULONG hb_dbfGetMemoBlock( DBFAREAP pArea, USHORT uiIndex );
|
||||
extern void hb_dbfPutMemoBlock( DBFAREAP pArea, USHORT uiIndex, ULONG ulBlock );
|
||||
|
||||
#endif /* HB_RDDDBT */
|
||||
@@ -154,6 +154,9 @@ extern "C" {
|
||||
#define hb_delimPutValueFile NULL
|
||||
#define hb_delimReadDBHeader NULL
|
||||
#define hb_delimWriteDBHeader NULL
|
||||
#define hb_delimExit NULL
|
||||
#define hb_delimDrop NULL
|
||||
#define hb_delimExists NULL
|
||||
#define hb_delimWhoCares NULL
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
|
||||
318
harbour/include/hbrddfpt.h
Normal file
318
harbour/include/hbrddfpt.h
Normal file
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* xHarbour Project source code:
|
||||
* DBFFPT RDD
|
||||
*
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* www - http://www.xharbour.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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HB_RDDFPT_H_
|
||||
#define HB_RDDFPT_H_
|
||||
|
||||
#include "hbdbf.h"
|
||||
#include "hbdbferr.h"
|
||||
#include "hbapirdd.h"
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
#include "hbapicdp.h"
|
||||
#endif
|
||||
#define HB_EXTRANAL_RDDDBF_USE
|
||||
#include "hbrdddbf.h"
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* MEMO constants and defaults */
|
||||
#define FPT_MEMOEXT ".fpt"
|
||||
#define FPT_LOCKPOS 0x00000000L
|
||||
#define FPT_LOCKSIZE 0x7FFFFFFFL
|
||||
#define FPT_DEFBLOCKSIZE 64
|
||||
#define SIX_ITEM_BUFSIZE 14
|
||||
#define FLEX_ITEM_BUFSIZE 8
|
||||
#define MAX_SIXFREEBLOCKS 82
|
||||
#define MAX_FLEXFREEBLOCKS 126
|
||||
#define FLEXGCPAGE_SIZE 1010
|
||||
|
||||
/* usMemoType */
|
||||
#define MEMO_DBT 1
|
||||
#define MEMO_FPT_HB 2
|
||||
#define MEMO_FPT_SIX 3
|
||||
#define MEMO_FPT_SIXHB 4
|
||||
#define MEMO_FPT_FLEX 5
|
||||
#define MEMO_FPT_CLIP 6
|
||||
|
||||
#define FPTIT_BINARY 0x0000
|
||||
#define FPTIT_PICT 0x0000 /* Picture */
|
||||
#define FPTIT_TEXT 0x0001 /* Text */
|
||||
#define FPTIT_OBJ 0x0002 /* Object */
|
||||
|
||||
#define FPTIT_SIX_LNUM 0x0002 /* LONG LE */
|
||||
#define FPTIT_SIX_DNUM 0x0008 /* DOUBLE LE */
|
||||
#define FPTIT_SIX_LDATE 0x0020 /* DATE (LONG LE) */
|
||||
#define FPTIT_SIX_LOG 0x0080 /* LOGIC */
|
||||
#define FPTIT_SIX_CHAR 0x0400 /* CHAR */
|
||||
#define FPTIT_SIX_ARRAY 0x8000 /* ARRAY */
|
||||
|
||||
//#define FPTIT_SIX_BLOCK 0x1000
|
||||
//#define FPTIT_SIX_VREF 0x2000
|
||||
//#define FPTIT_SIX_MREF 0x4000
|
||||
|
||||
#define FPTIT_FLEX_GC 0x03E8
|
||||
#define FPTIT_FLEX_UNUSED 0x03E9
|
||||
|
||||
#define FPTIT_FLEX_ARRAY 0x03EA
|
||||
#define FPTIT_FLEX_NIL 0x03EE
|
||||
#define FPTIT_FLEX_TRUE 0x03EF
|
||||
#define FPTIT_FLEX_FALSE 0x03F0
|
||||
#define FPTIT_FLEX_LDATE 0x03F1
|
||||
#define FPTIT_FLEX_BYTE 0x03F2
|
||||
#define FPTIT_FLEX_SHORT 0x03F4
|
||||
#define FPTIT_FLEX_LONG 0x03F6
|
||||
#define FPTIT_FLEX_DOUBLE 0x03F8
|
||||
|
||||
#define FPTIT_FLEXAR_ARAY 0x0C
|
||||
#define FPTIT_FLEXAR_NIL 0x00
|
||||
#define FPTIT_FLEXAR_TRUE 0x19
|
||||
#define FPTIT_FLEXAR_FALSE 0x1A
|
||||
#define FPTIT_FLEXAR_DATE 0x0E
|
||||
#define FPTIT_FLEXAR_BYTE 0x12
|
||||
#define FPTIT_FLEXAR_SHORT 0x13
|
||||
#define FPTIT_FLEXAR_LONG 0x20
|
||||
#define FPTIT_FLEXAR_DBL 0x0F
|
||||
#define FPTIT_FLEXAR_STR 0x07
|
||||
|
||||
/*
|
||||
#define HB_IT_NIL ( ( USHORT ) 0x0000 )
|
||||
#define HB_IT_POINTER ( ( USHORT ) 0x0001 )
|
||||
#define HB_IT_LONGLONG ( ( USHORT ) 0x0040 )
|
||||
#define HB_IT_SYMBOL ( ( USHORT ) 0x0100 )
|
||||
#define HB_IT_ALIAS ( ( USHORT ) 0x0200 )
|
||||
#define HB_IT_BLOCK ( ( USHORT ) 0x1000 )
|
||||
#define HB_IT_BYREF ( ( USHORT ) 0x2000 )
|
||||
#define HB_IT_MEMVAR ( ( USHORT ) 0x4000 )
|
||||
#define HB_IT_ANY ( ( USHORT ) 0xFFFF )
|
||||
*/
|
||||
|
||||
/* MEMO file strucutres */
|
||||
typedef struct _FPTHEADER
|
||||
{
|
||||
BYTE nextBlock[ 4 ]; /* Next free block in the file */
|
||||
BYTE reserved1[ 2 ]; /* */
|
||||
BYTE blockSize[ 2 ]; /* Size of block */
|
||||
BYTE signature1[ 10 ]; /* Signature: "SixMemo", "Harbour", "Made by CLIP"-overwrites next bytes*/
|
||||
BYTE nGCitems[ 2 ]; /* number of GC items in reserved2 (max 82)*/
|
||||
BYTE reserved2[ 492 ]; /* */
|
||||
BYTE signature2[ 12 ]; /* Signature: "FlexFile3\003" */
|
||||
BYTE flexRev[ 4 ]; /* Offset of reversed GC page */
|
||||
BYTE flexDir[ 4 ]; /* Offset of GC page */
|
||||
BYTE counter[ 4 ]; /* cyclic counter to sign changes in network env. */
|
||||
BYTE reserved3[ 4 ]; /* */
|
||||
BYTE flexSize[ 2 ]; /* FlexFile3 alternative block size */
|
||||
BYTE reserved4[ 482 ]; /* */
|
||||
} FPTHEADER;
|
||||
typedef FPTHEADER * LPFPTHEADER;
|
||||
|
||||
typedef struct _FPTBLOCK
|
||||
{
|
||||
BYTE type[ 4 ]; /* see: FPTIT_ */
|
||||
BYTE size[ 4 ]; /* length of data in bytes */
|
||||
} FPTBLOCK;
|
||||
typedef FPTBLOCK * LPFPTBLOCK;
|
||||
|
||||
|
||||
/* MEMO internal memory structures */
|
||||
typedef struct _MEMOGCITEM
|
||||
{
|
||||
ULONG ulOffset; /* Number of blocks */
|
||||
ULONG ulSize; /* Block number */
|
||||
BOOL fChanged; /* Mark the free page as changed */
|
||||
} MEMOGCITEM;
|
||||
typedef MEMOGCITEM * LPMEMOGCITEM;
|
||||
|
||||
typedef struct _MEMOGCTABLE
|
||||
{
|
||||
BYTE bType; /* MEMO_FPT_SIX or MEMO_FPT_FLEX */
|
||||
BYTE bChanged; /* Should we write GC data to disk */
|
||||
ULONG ulNextBlock; /* Next free block in the file */
|
||||
ULONG ulRevPage; /* FLEX Rev GC page offset */
|
||||
ULONG ulDirPage; /* FLEX Dir GC page offset */
|
||||
ULONG ulCounter; /* FLEX cyclic counter */
|
||||
ULONG ulSize; /* FLEX GC page size in bytes */
|
||||
USHORT usMaxItem; /* max number of items in pGCitems */
|
||||
USHORT usItems; /* number of items in pGCitems */
|
||||
LPMEMOGCITEM pGCitems; /* free block list */
|
||||
FPTHEADER fptHeader; /* FPT file header */
|
||||
} MEMOGCTABLE;
|
||||
typedef MEMOGCTABLE * LPMEMOGCTABLE;
|
||||
|
||||
|
||||
/*
|
||||
* DBFFPT WORKAREA
|
||||
* ------------
|
||||
* The Workarea Structure of DBFFPT RDD
|
||||
*
|
||||
*/
|
||||
|
||||
/* we don't have to change DBFAREA to create FPTAREA */
|
||||
typedef DBFAREA FPTAREA;
|
||||
typedef FPTAREA * LPFPTAREA;
|
||||
#ifndef FPTAREAP
|
||||
#define FPTAREAP LPFPTAREA
|
||||
#endif
|
||||
|
||||
/*
|
||||
* -- DBFFPT METHODS --
|
||||
*/
|
||||
|
||||
#define SUPERTABLE ( &fptSuper )
|
||||
|
||||
#define hb_fptBof NULL
|
||||
#define hb_fptEof NULL
|
||||
#define hb_fptFound NULL
|
||||
#define hb_fptGoBottom NULL
|
||||
#define hb_fptGoTo NULL
|
||||
#define hb_fptGoToId NULL
|
||||
#define hb_fptGoTop NULL
|
||||
#define hb_fptSeek NULL
|
||||
#define hb_fptSkip NULL
|
||||
#define hb_fptSkipFilter NULL
|
||||
#define hb_fptSkipRaw NULL
|
||||
#define hb_fptAddField NULL
|
||||
#define hb_fptAppend NULL
|
||||
#define hb_fptCreateFields NULL
|
||||
#define hb_fptDeleteRec NULL
|
||||
#define hb_fptDeleted NULL
|
||||
#define hb_fptFieldCount NULL
|
||||
#define hb_fptFieldDisplay NULL
|
||||
#define hb_fptFieldInfo NULL
|
||||
#define hb_fptFieldName NULL
|
||||
#define hb_fptFlush NULL
|
||||
#define hb_fptGetRec NULL
|
||||
static ERRCODE hb_fptGetValue( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
static ERRCODE hb_fptGetVarLen( FPTAREAP pArea, USHORT uiIndex, ULONG * pLength );
|
||||
#define hb_fptGoCold NULL
|
||||
#define hb_fptGoHot NULL
|
||||
#define hb_fptPutRec NULL
|
||||
static ERRCODE hb_fptPutValue( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
#define hb_fptRecall NULL
|
||||
#define hb_fptRecCount NULL
|
||||
#define hb_fptRecInfo NULL
|
||||
#define hb_fptRecNo NULL
|
||||
#define hb_fptSetFieldExtent NULL
|
||||
#define hb_fptAlias NULL
|
||||
#define hb_fptClose NULL
|
||||
#define hb_fptCreate NULL
|
||||
static ERRCODE hb_fptInfo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem );
|
||||
#define hb_fptNewArea NULL
|
||||
#define hb_fptOpen NULL
|
||||
#define hb_fptRelease NULL
|
||||
static ERRCODE hb_fptStructSize( FPTAREAP pArea, USHORT * uiSize );
|
||||
static ERRCODE hb_fptSysName( FPTAREAP pArea, BYTE * pBuffer );
|
||||
#define hb_fptEval NULL
|
||||
#define hb_fptPack NULL
|
||||
#define hb_fptPackRec NULL
|
||||
#define hb_fptSort NULL
|
||||
#define hb_fptTrans NULL
|
||||
#define hb_fptTransRec NULL
|
||||
#define hb_fptZap NULL
|
||||
#define hb_fptChildEnd NULL
|
||||
#define hb_fptChildStart NULL
|
||||
#define hb_fptChildSync NULL
|
||||
#define hb_fptSyncChildren NULL
|
||||
#define hb_fptClearRel NULL
|
||||
#define hb_fptForceRel NULL
|
||||
#define hb_fptRelArea NULL
|
||||
#define hb_fptRelEval NULL
|
||||
#define hb_fptRelText NULL
|
||||
#define hb_fptSetRel NULL
|
||||
#define hb_fptOrderListAdd NULL
|
||||
#define hb_fptOrderListClear NULL
|
||||
#define hb_fptOrderListDelete NULL
|
||||
#define hb_fptOrderListFocus NULL
|
||||
#define hb_fptOrderListRebuild NULL
|
||||
#define hb_fptOrderCondition NULL
|
||||
#define hb_fptOrderCreate NULL
|
||||
#define hb_fptOrderDestroy NULL
|
||||
#define hb_fptOrderInfo NULL
|
||||
#define hb_fptClearFilter NULL
|
||||
#define hb_fptClearLocate NULL
|
||||
#define hb_fptClearScope NULL
|
||||
#define hb_fptCountScope NULL
|
||||
#define hb_fptFilterText NULL
|
||||
#define hb_fptScopeInfo NULL
|
||||
#define hb_fptSetFilter NULL
|
||||
#define hb_fptSetLocate NULL
|
||||
#define hb_fptSetScope NULL
|
||||
#define hb_fptSkipScope NULL
|
||||
#define hb_fptCompile NULL
|
||||
#define hb_fptError NULL
|
||||
#define hb_fptEvalBlock NULL
|
||||
#define hb_fptRawLock NULL
|
||||
#define hb_fptLock NULL
|
||||
#define hb_fptUnLock NULL
|
||||
#define hb_fptCloseMemFile NULL
|
||||
static ERRCODE hb_fptCreateMemFile( FPTAREAP pArea, LPDBOPENINFO pCreateInfo );
|
||||
#define hb_fptGetValueFile NULL
|
||||
static ERRCODE hb_fptOpenMemFile( FPTAREAP pArea, LPDBOPENINFO pOpenInfo );
|
||||
#define hb_fptPutValueFile NULL
|
||||
static ERRCODE hb_fptReadDBHeader( FPTAREAP pArea );
|
||||
static ERRCODE hb_fptWriteDBHeader( FPTAREAP pArea );
|
||||
#define hb_fptExit NULL
|
||||
#define hb_fptDrop NULL
|
||||
#define hb_fptExists NULL
|
||||
#define hb_fptWhoCares NULL
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
}
|
||||
#endif
|
||||
|
||||
extern ULONG hb_dbfGetMemoBlock( DBFAREAP pArea, USHORT uiIndex );
|
||||
extern void hb_dbfPutMemoBlock( DBFAREAP pArea, USHORT uiIndex, ULONG ulBlock );
|
||||
extern ERRCODE hb_dbfGetEGcode( ERRCODE errCode );
|
||||
|
||||
#endif /* HB_RDDFPT */
|
||||
@@ -54,6 +54,7 @@
|
||||
#define HB_RDDNTX_H_
|
||||
|
||||
#include "hbapirdd.h"
|
||||
#include "hbdbferr.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
@@ -61,23 +62,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* DBFNTX errors */
|
||||
|
||||
#define EDBF_OPEN_DBF 1001
|
||||
#define EDBF_CREATE_DBF 1004
|
||||
#define EDBF_READ 1010
|
||||
#define EDBF_WRITE 1011
|
||||
#define EDBF_CORRUPT 1012
|
||||
#define EDBF_DATATYPE 1020
|
||||
#define EDBF_DATAWIDTH 1021
|
||||
#define EDBF_UNLOCKED 1022
|
||||
#define EDBF_SHARED 1023
|
||||
#define EDBF_APPENDLOCK 1024
|
||||
#define EDBF_READONLY 1025
|
||||
#define EDBF_INVALIDKEY 1026
|
||||
|
||||
|
||||
|
||||
/* DBFNTX default extensions */
|
||||
#define NTX_MEMOEXT ".dbt"
|
||||
#define NTX_INDEXEXT ".ntx"
|
||||
@@ -103,7 +87,7 @@ struct _NTXINDEX;
|
||||
|
||||
typedef struct _KEYINFO
|
||||
{
|
||||
// PHB_ITEM pItem;
|
||||
/* PHB_ITEM pItem; */
|
||||
LONG Tag;
|
||||
LONG Xtra;
|
||||
char key[ 1 ]; /* value of key */
|
||||
@@ -265,6 +249,7 @@ typedef struct _NTXAREA
|
||||
USHORT heapSize;
|
||||
USHORT rddID;
|
||||
USHORT uiMaxFieldNameLength;
|
||||
|
||||
/*
|
||||
* DBFS's additions to the workarea structure
|
||||
*
|
||||
@@ -280,9 +265,12 @@ typedef struct _NTXAREA
|
||||
ULONG ulRecCount; /* Total records */
|
||||
char * szDataFileName; /* Name of data file */
|
||||
char * szMemoFileName; /* Name of memo file */
|
||||
USHORT uiMemoBlockSize; /* Size of memo block */
|
||||
BYTE bMemoType; /* MEMO type used in DBF memo fields */
|
||||
BOOL fHasMemo; /* WorkArea with Memo fields */
|
||||
BOOL fHasTags; /* WorkArea with MDX or CDX index */
|
||||
BYTE bCodePage;
|
||||
BYTE bVersion; /* DBF version ID byte */
|
||||
BYTE bCodePage; /* DBF codepage ID */
|
||||
BOOL fShared; /* Shared file */
|
||||
BOOL fReadonly; /* Read only file */
|
||||
USHORT * pFieldOffset; /* Pointer to field offset array */
|
||||
@@ -306,14 +294,14 @@ typedef struct _NTXAREA
|
||||
/*
|
||||
* NTX's additions to the workarea structure
|
||||
*
|
||||
* Warning: The above section MUST match WORKAREA exactly! Any
|
||||
* Warning: The above section MUST match DBFAREA exactly! Any
|
||||
* additions to the structure MUST be added below, as in this
|
||||
* example.
|
||||
*/
|
||||
|
||||
LPTAGINFO lpCurTag; /* Pointer to current order */
|
||||
LPTAGINFO lpNtxTag; /* Pointer to tags list */
|
||||
BOOL fNtxAppend; /* TRUE if new record is added */
|
||||
LPTAGINFO lpCurTag; /* Pointer to current order */
|
||||
LPTAGINFO lpNtxTag; /* Pointer to tags list */
|
||||
BOOL fNtxAppend; /* TRUE if new record is added */
|
||||
|
||||
} NTXAREA;
|
||||
|
||||
@@ -342,7 +330,7 @@ static ERRCODE ntxSeek( NTXAREAP pArea, BOOL bSoftSeek, PHB_ITEM pKey, BOOL bFin
|
||||
#define ntxSkipFilter NULL
|
||||
static ERRCODE ntxSkipRaw( NTXAREAP pArea, LONG lToSkip );
|
||||
#define ntxAddField NULL
|
||||
// static ERRCODE ntxAppend( NTXAREAP pArea, BOOL bUnLockAll );
|
||||
/* static ERRCODE ntxAppend( NTXAREAP pArea, BOOL bUnLockAll ); */
|
||||
#define ntxAppend NULL
|
||||
#define ntxCreateFields NULL
|
||||
#define ntxDeleteRec NULL
|
||||
@@ -428,6 +416,9 @@ static ERRCODE ntxSetScope( NTXAREAP pArea, LPDBORDSCOPEINFO sInfo );
|
||||
#define ntxPutValueFile NULL
|
||||
#define ntxReadDBHeader NULL
|
||||
#define ntxWriteDBHeader NULL
|
||||
#define ntxExit NULL
|
||||
#define ntxDrop NULL
|
||||
#define ntxExists NULL
|
||||
#define ntxWhoCares NULL
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
|
||||
@@ -154,6 +154,9 @@ extern "C" {
|
||||
#define hb_sdfPutValueFile NULL
|
||||
#define hb_sdfReadDBHeader NULL
|
||||
#define hb_sdfWriteDBHeader NULL
|
||||
#define hb_sdfExit NULL
|
||||
#define hb_sdfDrop NULL
|
||||
#define hb_sdfExists NULL
|
||||
#define hb_sdfWhoCares NULL
|
||||
|
||||
#if defined(HB_EXTERN_C)
|
||||
|
||||
@@ -2230,6 +2230,7 @@ HB_FUNC( FLOCK )
|
||||
dbLockInfo.fResult = FALSE;
|
||||
if( s_pCurrArea )
|
||||
{
|
||||
dbLockInfo.itmRecID = NULL;
|
||||
dbLockInfo.uiMethod = DBLM_FILE;
|
||||
SELF_LOCK( ( AREAP ) s_pCurrArea->pArea, &dbLockInfo );
|
||||
}
|
||||
@@ -2638,6 +2639,45 @@ HB_FUNC( ORDKEYNO )
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "ORDKEYNO" );
|
||||
}
|
||||
|
||||
HB_FUNC( ORDKEYGOTO )
|
||||
{
|
||||
DBORDERINFO pOrderInfo;
|
||||
|
||||
if( s_pCurrArea )
|
||||
{
|
||||
pOrderInfo.itmOrder = hb_param( 1, HB_IT_STRING );
|
||||
if( !pOrderInfo.itmOrder )
|
||||
pOrderInfo.itmOrder = hb_param( 1, HB_IT_NUMERIC );
|
||||
pOrderInfo.atomBagName = hb_param( 2, HB_IT_STRING );
|
||||
/* Either or both may be NIL */
|
||||
|
||||
pOrderInfo.itmNewVal = hb_param( 3 , HB_IT_NUMERIC );
|
||||
pOrderInfo.itmResult = hb_itemPutL( NULL, FALSE );
|
||||
SELF_ORDINFO( ( AREAP ) s_pCurrArea->pArea, DBOI_POSITION, &pOrderInfo );
|
||||
hb_retl( hb_itemGetL( pOrderInfo.itmResult ) );
|
||||
hb_itemRelease( pOrderInfo.itmResult );
|
||||
}
|
||||
else
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "ORDKEYGOTO" );
|
||||
}
|
||||
|
||||
HB_FUNC( ORDSKIPUNIQUE )
|
||||
{
|
||||
DBORDERINFO pOrderInfo;
|
||||
|
||||
if( s_pCurrArea )
|
||||
{
|
||||
pOrderInfo.itmOrder = NULL;
|
||||
pOrderInfo.itmNewVal = hb_param( 1, HB_IT_ANY );
|
||||
pOrderInfo.itmResult = hb_itemPutL( NULL, FALSE );
|
||||
SELF_ORDINFO( ( AREAP ) s_pCurrArea->pArea, DBOI_SKIPUNIQUE, &pOrderInfo );
|
||||
hb_retl( hb_itemGetL( pOrderInfo.itmResult ) );
|
||||
hb_itemRelease( pOrderInfo.itmResult );
|
||||
}
|
||||
else
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "ORDSKIPUNIQUE" );
|
||||
}
|
||||
|
||||
HB_FUNC( ORDKEYVAL )
|
||||
{
|
||||
DBORDERINFO pOrderInfo;
|
||||
@@ -2695,6 +2735,48 @@ HB_FUNC( ORDKEYDEL )
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "ORDKEYDEL" );
|
||||
}
|
||||
|
||||
HB_FUNC( ORDDESCEND )
|
||||
{
|
||||
DBORDERINFO pOrderInfo;
|
||||
|
||||
if( s_pCurrArea )
|
||||
{
|
||||
pOrderInfo.itmOrder = hb_param( 1, HB_IT_STRING );
|
||||
if( !pOrderInfo.itmOrder )
|
||||
pOrderInfo.itmOrder = hb_param( 1, HB_IT_NUMERIC );
|
||||
pOrderInfo.atomBagName = hb_param( 2, HB_IT_STRING );
|
||||
/* Either or both may be NIL */
|
||||
pOrderInfo.itmNewVal = hb_param( 3 , HB_IT_LOGICAL );
|
||||
pOrderInfo.itmResult = hb_itemPutL( NULL, FALSE );
|
||||
SELF_ORDINFO( ( AREAP ) s_pCurrArea->pArea, DBOI_ISDESC, &pOrderInfo );
|
||||
hb_retl( hb_itemGetL( pOrderInfo.itmResult ) );
|
||||
hb_itemRelease( pOrderInfo.itmResult );
|
||||
}
|
||||
else
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "ORDDESCEND" );
|
||||
}
|
||||
|
||||
HB_FUNC( ORDISUNIQUE )
|
||||
{
|
||||
DBORDERINFO pOrderInfo;
|
||||
|
||||
if( s_pCurrArea )
|
||||
{
|
||||
pOrderInfo.itmOrder = hb_param( 1, HB_IT_STRING );
|
||||
if( !pOrderInfo.itmOrder )
|
||||
pOrderInfo.itmOrder = hb_param( 1, HB_IT_NUMERIC );
|
||||
pOrderInfo.atomBagName = hb_param( 2, HB_IT_STRING );
|
||||
/* HARBOUR extension: NewVal to set/reset unique flag */
|
||||
pOrderInfo.itmNewVal = hb_param( 3 , HB_IT_LOGICAL );
|
||||
pOrderInfo.itmResult = hb_itemPutL( NULL, FALSE );
|
||||
SELF_ORDINFO( ( AREAP ) s_pCurrArea->pArea, DBOI_UNIQUE, &pOrderInfo );
|
||||
hb_retl( hb_itemGetL( pOrderInfo.itmResult ) );
|
||||
hb_itemRelease( pOrderInfo.itmResult );
|
||||
}
|
||||
else
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "ORDISUNIQUE" );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HB_FUNC( ORDLISTADD )
|
||||
@@ -2725,16 +2807,18 @@ HB_FUNC( ORDLISTADD )
|
||||
hb_itemRelease( pOrderInfo.itmResult );
|
||||
return;
|
||||
}
|
||||
SELF_ORDLSTADD( ( AREAP ) s_pCurrArea->pArea, &pOrderInfo );
|
||||
|
||||
if ( bFirst ) /* set as controlling order and go top */
|
||||
if( SELF_ORDLSTADD( ( AREAP ) s_pCurrArea->pArea, &pOrderInfo ) == SUCCESS )
|
||||
{
|
||||
pOrderInfo.itmOrder = hb_itemPutNI( NULL, 1 );
|
||||
SELF_ORDLSTFOCUS( ( AREAP ) s_pCurrArea->pArea, &pOrderInfo );
|
||||
hb_itemRelease( pOrderInfo.itmOrder );
|
||||
SELF_GOTOP( ( AREAP ) s_pCurrArea->pArea );
|
||||
if ( bFirst ) /* set as controlling order and go top */
|
||||
{
|
||||
pOrderInfo.itmOrder = hb_itemPutNI( NULL, 1 );
|
||||
SELF_ORDLSTFOCUS( ( AREAP ) s_pCurrArea->pArea, &pOrderInfo );
|
||||
hb_itemRelease( pOrderInfo.itmOrder );
|
||||
SELF_GOTOP( ( AREAP ) s_pCurrArea->pArea );
|
||||
}
|
||||
hb_itemRelease( pOrderInfo.itmResult );
|
||||
}
|
||||
hb_itemRelease( pOrderInfo.itmResult );
|
||||
}
|
||||
else
|
||||
hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, "ORDLISTADD" );
|
||||
@@ -2877,8 +2961,10 @@ HB_FUNC( RDDREGISTER )
|
||||
uiLen = ( USHORT ) hb_parclen( 1 );
|
||||
if( uiLen > 0 )
|
||||
{
|
||||
hb_strncpyUpper( szDriver, hb_parc( 1 ),
|
||||
min( uiLen, HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ) );
|
||||
if( uiLen > HARBOUR_MAX_RDD_DRIVERNAME_LENGTH )
|
||||
uiLen = HARBOUR_MAX_RDD_DRIVERNAME_LENGTH;
|
||||
|
||||
hb_strncpyUpper( szDriver, hb_parc( 1 ), uiLen );
|
||||
/*
|
||||
* hb_rddRegister returns:
|
||||
*
|
||||
@@ -2932,6 +3018,7 @@ HB_FUNC( RLOCK )
|
||||
dbLockInfo.fResult = FALSE;
|
||||
if( s_pCurrArea )
|
||||
{
|
||||
dbLockInfo.itmRecID = NULL;
|
||||
dbLockInfo.uiMethod = DBLM_EXCLUSIVE;
|
||||
SELF_LOCK( ( AREAP ) s_pCurrArea->pArea, &dbLockInfo );
|
||||
}
|
||||
@@ -2979,9 +3066,23 @@ HB_FUNC( __RDDSETDEFAULT )
|
||||
hb_retc( s_szDefDriver );
|
||||
|
||||
uiLen = ( USHORT ) hb_parclen( 1 );
|
||||
|
||||
if( uiLen > 0 )
|
||||
{
|
||||
s_szDefDriver = ( char * ) hb_xrealloc( s_szDefDriver, uiLen + 1 );
|
||||
if( uiLen > HARBOUR_MAX_RDD_DRIVERNAME_LENGTH )
|
||||
{
|
||||
uiLen = HARBOUR_MAX_RDD_DRIVERNAME_LENGTH;
|
||||
}
|
||||
|
||||
if( s_szDefDriver )
|
||||
{
|
||||
s_szDefDriver = ( char * ) hb_xrealloc( s_szDefDriver, uiLen + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
s_szDefDriver = ( char * ) hb_xgrab( uiLen + 1 );
|
||||
}
|
||||
|
||||
hb_strncpyUpper( s_szDefDriver, hb_parc( 1 ), uiLen );
|
||||
}
|
||||
}
|
||||
@@ -2989,41 +3090,61 @@ HB_FUNC( __RDDSETDEFAULT )
|
||||
HB_FUNC( RDDSETDEFAULT )
|
||||
{
|
||||
USHORT uiLen;
|
||||
char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH +1 ];
|
||||
char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH + 1 ];
|
||||
|
||||
hb_rddCheck();
|
||||
hb_retc( s_szDefDriver );
|
||||
|
||||
uiLen = ( USHORT ) hb_parclen( 1 );
|
||||
|
||||
if( uiLen > 0 )
|
||||
{
|
||||
hb_strncpyUpper( szNewDriver, hb_parc( 1 ),
|
||||
min( uiLen, HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ) );
|
||||
if( uiLen > HARBOUR_MAX_RDD_DRIVERNAME_LENGTH )
|
||||
{
|
||||
uiLen = HARBOUR_MAX_RDD_DRIVERNAME_LENGTH;
|
||||
}
|
||||
|
||||
if( !hb_rddFindNode( szNewDriver, NULL ) )
|
||||
hb_strncpyUpper( szNewDriver, hb_parc( 1 ), uiLen );
|
||||
|
||||
if( ! hb_rddFindNode( szNewDriver, NULL ) )
|
||||
{
|
||||
hb_errRT_DBCMD( EG_ARG, EDBCMD_BADPARAMETER, NULL, "RDDSETDEFAULT" );
|
||||
return;
|
||||
}
|
||||
|
||||
s_szDefDriver = ( char * ) hb_xrealloc( s_szDefDriver, uiLen + 1 );
|
||||
strcpy( s_szDefDriver, szNewDriver );
|
||||
if( s_szDefDriver )
|
||||
{
|
||||
s_szDefDriver = ( char * ) hb_xrealloc( s_szDefDriver, uiLen + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
s_szDefDriver = ( char * ) hb_xgrab( uiLen + 1 );
|
||||
}
|
||||
|
||||
strncpy( s_szDefDriver, szNewDriver, uiLen );
|
||||
s_szDefDriver[ uiLen ] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( DBSETDRIVER )
|
||||
{
|
||||
|
||||
USHORT uiLen;
|
||||
char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH +1 ];
|
||||
char szNewDriver[ HARBOUR_MAX_RDD_DRIVERNAME_LENGTH + 1 ];
|
||||
|
||||
hb_rddCheck();
|
||||
hb_retc( s_szDefDriver );
|
||||
|
||||
uiLen = ( USHORT ) hb_parclen( 1 );
|
||||
|
||||
if( uiLen > 0 )
|
||||
{
|
||||
hb_strncpyUpper( szNewDriver, hb_parc( 1 ),
|
||||
min( uiLen, HARBOUR_MAX_RDD_DRIVERNAME_LENGTH ) );
|
||||
if( uiLen > HARBOUR_MAX_RDD_DRIVERNAME_LENGTH )
|
||||
{
|
||||
uiLen = HARBOUR_MAX_RDD_DRIVERNAME_LENGTH;
|
||||
}
|
||||
|
||||
hb_strncpyUpper( szNewDriver, hb_parc( 1 ), uiLen );
|
||||
|
||||
if( !hb_rddFindNode( szNewDriver, NULL ) )
|
||||
{
|
||||
@@ -3031,8 +3152,17 @@ HB_FUNC( DBSETDRIVER )
|
||||
return;
|
||||
}
|
||||
|
||||
s_szDefDriver = ( char * ) hb_xrealloc( s_szDefDriver, uiLen + 1 );
|
||||
strcpy( s_szDefDriver, szNewDriver );
|
||||
if( s_szDefDriver )
|
||||
{
|
||||
s_szDefDriver = ( char * ) hb_xrealloc( s_szDefDriver, uiLen + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
s_szDefDriver = ( char * ) hb_xgrab( uiLen + 1 );
|
||||
}
|
||||
|
||||
strncpy( s_szDefDriver, szNewDriver, uiLen );
|
||||
s_szDefDriver[ uiLen ] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,10 +4,11 @@
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DBFCDX RDD
|
||||
* DBFCDX RDD (ver.2)
|
||||
*
|
||||
* Copyright 1999 Bruno Cantero <bruno@issnet.net>
|
||||
* www - http://www.harbour-project.org
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* www - http://www.xharbour.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
|
||||
@@ -50,12 +51,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "error.ch"
|
||||
#include "rddsys.ch"
|
||||
|
||||
ANNOUNCE DBFCDX
|
||||
|
||||
init procedure DBFCDXInit
|
||||
procedure DBFCDXInit
|
||||
|
||||
REQUEST _DBFCDX
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,19 +51,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
#define LOCK_START 0x40000000L
|
||||
#define LOCK_APPEND 0x7FFFFFFEL
|
||||
#define LOCK_FILE 0x3FFFFFFFL
|
||||
#define MEMO_BLOCK 64
|
||||
#define CDX_MAX_KEY 240
|
||||
#define CDX_BLOCK_SIZE 512
|
||||
*/
|
||||
#define CDX_MAX_TAG_NAME_LEN 10
|
||||
|
||||
#define CDX_INTERNAL_SPACE 500
|
||||
#define CDX_EXTERNAL_SPACE 488
|
||||
#define CDX_MAX_REC_NUM 0x7FFFFFFFL
|
||||
#define CDX_IGNORE_REC_NUM -1
|
||||
#define PAGE_ROOT 1
|
||||
@@ -73,6 +63,11 @@
|
||||
#define BTTM_RECORD 2
|
||||
#define PREV_RECORD 3
|
||||
#define NEXT_RECORD 4
|
||||
*/
|
||||
|
||||
#define CDX_INTERNAL_SPACE 500
|
||||
#define CDX_EXTERNAL_SPACE 488
|
||||
|
||||
#define SORT_CHUNK_LIMIT 16384
|
||||
#define SORT_ACTIVE_LIST 0
|
||||
#define SORT_END_OF_KEY 1
|
||||
@@ -80,14 +75,12 @@
|
||||
#define SORT_STACK_OF_CHAR 3
|
||||
#define SORT_NOT_KEY 0x10
|
||||
|
||||
#define HB_CDXMAXKEY( x ) ((USHORT) ((x) > CDX_MAXKEY ? CDX_MAXKEY : (x)))
|
||||
|
||||
#if (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
|
||||
#pragma option -a1 /* byte alignment */
|
||||
#elif defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
#elif defined(__WATCOMC__)
|
||||
#pragma push(pack, 1);
|
||||
#pragma pack(push, 1);
|
||||
#elif defined(__cplusplus)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
@@ -122,6 +115,7 @@ typedef struct _CDXDATA
|
||||
CDXINTERNAL Internal;
|
||||
} cdxu;
|
||||
} CDXDATA;
|
||||
typedef CDXDATA * LPCDXDATA;
|
||||
|
||||
typedef struct _SORTSWAPPAGE
|
||||
{
|
||||
@@ -154,64 +148,11 @@ typedef SORTSWAPITEM * LPSORTSWAPITEM;
|
||||
#elif defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#elif defined(__WATCOMC__)
|
||||
#pragma pop(pack);
|
||||
#pragma pack(pop);
|
||||
#elif defined(__cplusplus)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
typedef CDXDATA * LPCDXDATA;
|
||||
|
||||
typedef struct _CDXKEYINFO
|
||||
{
|
||||
char * Value;
|
||||
USHORT length;
|
||||
USHORT realLength;
|
||||
BOOL fString;
|
||||
LONG Tag;
|
||||
LONG Xtra;
|
||||
struct _CDXKEYINFO * pNext;
|
||||
} CDXKEYINFO;
|
||||
|
||||
typedef CDXKEYINFO * LPCDXKEYINFO;
|
||||
|
||||
struct _CDXTAG; /* forward declaration */
|
||||
|
||||
typedef struct HB_CDXPAGEINFO_STRU
|
||||
{
|
||||
LONG Page;
|
||||
LONG Left;
|
||||
LONG Right;
|
||||
BOOL Changed;
|
||||
BOOL keyAdded;
|
||||
BYTE bUsed;
|
||||
BOOL NewRoot;
|
||||
BOOL LastEntry;
|
||||
BOOL Reload;
|
||||
BOOL ChkBOF;
|
||||
BOOL ChkEOF;
|
||||
BYTE PageType;
|
||||
ULONG RNMask;
|
||||
BYTE ReqByte;
|
||||
BYTE RNBits;
|
||||
BYTE DCBits;
|
||||
BYTE TCBits;
|
||||
BYTE DCMask;
|
||||
BYTE TCMask;
|
||||
/* USHORT Space; */
|
||||
SHORT FreeSpace;
|
||||
LPCDXKEYINFO pKeys;
|
||||
USHORT uiKeys;
|
||||
SHORT CurKey;
|
||||
struct HB_CDXPAGEINFO_STRU * Owner;
|
||||
struct HB_CDXPAGEINFO_STRU * Child;
|
||||
struct _CDXTAG * TagParent;
|
||||
struct HB_CDXPAGEINFO_STRU * pPoolPrev;
|
||||
struct HB_CDXPAGEINFO_STRU * pPoolNext;
|
||||
} HB_CDXPAGEINFO;
|
||||
|
||||
typedef HB_CDXPAGEINFO * LPCDXPAGEINFO;
|
||||
|
||||
|
||||
/*SORT stuff*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -251,6 +192,18 @@ typedef struct
|
||||
|
||||
typedef SORTDATA * LPSORTDATA;
|
||||
|
||||
typedef struct _CDXKEYINFO
|
||||
{
|
||||
BYTE * Value;
|
||||
USHORT length;
|
||||
USHORT realLength;
|
||||
BOOL fString;
|
||||
ULONG Tag;
|
||||
ULONG Xtra;
|
||||
struct _CDXKEYINFO * pNext;
|
||||
} CDXKEYINFO;
|
||||
typedef CDXKEYINFO * LPCDXKEYINFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LONG WordCount;
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DBFCDX RDD
|
||||
*
|
||||
* Copyright 1999 Bruno Cantero <bruno@issnet.net>
|
||||
* Copyright 2000-2002 Horacio Roldan <harbour_ar@yahoo.com.ar> (portions)
|
||||
* 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
static LPCDXKEYINFO hb_cdxKeyNew( void );
|
||||
static void hb_cdxKeyFree( LPCDXKEYINFO pKey );
|
||||
static int hb_cdxKeyCompare( LPCDXKEYINFO pKey1, LPCDXKEYINFO pKey2, BOOL Exact );
|
||||
|
||||
static LPCDXTAG hb_cdxTagNew( LPCDXINDEX PIF, char * ITN, LONG TagHdr );
|
||||
static void hb_cdxTagFree( LPCDXTAG pTag );
|
||||
static void hb_cdxTagIndexTagNew( LPCDXTAG pTag, char * KeyExp, PHB_ITEM pKeyItem,
|
||||
BYTE bType, USHORT uiLen, char * ForExp,
|
||||
PHB_ITEM pForItem, BOOL Ascnd, BOOL Uniq, BOOL bCustom );
|
||||
static void hb_cdxTagDoIndex( LPCDXTAG pTag );
|
||||
static void hb_cdxTagEmptyIndex( LPCDXTAG pTag );
|
||||
static void hb_cdxTagTagStore( LPCDXTAG pTag );
|
||||
static void hb_cdxTagTagOpen( LPCDXTAG pTag, BYTE bCode );
|
||||
static void hb_cdxTagTagClose( LPCDXTAG pTag );
|
||||
static LONG hb_cdxTagNewRoot( LPCDXTAG pTag );
|
||||
static void hb_cdxTagPageLoad( LPCDXTAG pTag, LPCDXPAGEINFO pPage, short noKeys );
|
||||
static void hb_cdxTagKeyRead( LPCDXTAG pTag, BYTE bTypRead );
|
||||
static void hb_cdxTagKeyAdd( LPCDXTAG pTag, LPCDXKEYINFO pKey );
|
||||
static void hb_cdxTagPageStore( LPCDXTAG pTag, LPCDXPAGEINFO PIK );
|
||||
static void hb_cdxTagExtNodeWrite( LPCDXTAG pTag, LONG PN, LPCDXDATA pData, LPCDXPAGEINFO PIK );
|
||||
static USHORT hb_cdxTagFillExternalNode( LPCDXTAG pTag, LPCDXDATA pData, LPCDXPAGEINFO PIK,
|
||||
USHORT kcnt, USHORT ck, LPCDXKEYINFO * p );
|
||||
static void hb_cdxTagExtNodeBuild( LPCDXTAG pTag, LPCDXDATA pData, LPCDXPAGEINFO pPage, short noKeys );
|
||||
static void hb_cdxTagTagLoad( LPCDXTAG pTag );
|
||||
static void hb_cdxTagSetRoot( LPCDXTAG pTag, LPCDXPAGEINFO PIK );
|
||||
static void hb_cdxTagIntNodeWrite( LPCDXTAG pTag, LONG PN, LPCDXDATA pData, LPCDXPAGEINFO PIK );
|
||||
static USHORT hb_cdxTagFillInternalNode( LPCDXTAG pTag, LPCDXDATA pData, LPCDXPAGEINFO PIK,
|
||||
USHORT kcnt, USHORT ck, LPCDXKEYINFO * p );
|
||||
static void hb_cdxTagIntNodeBuild( LPCDXTAG pTag, LPCDXDATA pData, LPCDXPAGEINFO pPage );
|
||||
static LONG hb_cdxTagKeyFind( LPCDXTAG pTag, LPCDXKEYINFO pKey );
|
||||
|
||||
static LPCDXPAGEINFO hb_cdxPageNew( LPCDXTAG PIT, LPCDXPAGEINFO PIK, LONG FilePosn );
|
||||
static void hb_cdxPageFree( LPCDXPAGEINFO pPage );
|
||||
static BOOL hb_cdxPageReadTopKey( LPCDXPAGEINFO pPage );
|
||||
static BOOL hb_cdxPageReadBottomKey( LPCDXPAGEINFO pPage );
|
||||
static int hb_cdxPageSeekKey( LPCDXPAGEINFO pPage, LONG lBlock, LPCDXKEYINFO pKey, BOOL bExact );
|
||||
static void hb_cdxPageInsertKey( LPCDXPAGEINFO pPage, LPCDXKEYINFO pKey, BOOL bAddAfter );
|
||||
static void hb_cdxPagePageStore( LPCDXPAGEINFO pPage );
|
||||
static BOOL hb_cdxPageReadNextKey( LPCDXPAGEINFO pPage );
|
||||
static BOOL hb_cdxPageReadPrevKey( LPCDXPAGEINFO pPage );
|
||||
static LPCDXKEYINFO hb_cdxPageGetKey( LPCDXPAGEINFO pPage, USHORT uiKey );
|
||||
static void hb_cdxPagePageLoad( LPCDXPAGEINFO pPage );
|
||||
static int hb_cdxPageRetrieveKey( LPCDXPAGEINFO pPage, LPCDXKEYINFO *pKey );
|
||||
static void hb_cdxPageAddNodeKey( LPCDXPAGEINFO pPage, LPCDXKEYINFO pKey );
|
||||
static int hb_cdxPageSeekNodeTag( LPCDXPAGEINFO pPage, LONG Tag );
|
||||
static BOOL hb_cdxPageGetChild( LPCDXPAGEINFO pPage, LONG Tag );
|
||||
static void hb_cdxPageDeleteKey( LPCDXPAGEINFO pPage );
|
||||
static void hb_cdxPageReplaceNodeKey( LPCDXPAGEINFO pPage, LPCDXKEYINFO pKey );
|
||||
static void hb_cdxPageDeleteNodeKey( LPCDXPAGEINFO pPage );
|
||||
|
||||
static LPCDXINDEX hb_cdxIndexNew( AREAP pArea );
|
||||
static void hb_cdxIndexFree( LPCDXINDEX pIndex );
|
||||
static LONG hb_cdxIndexGetAvailPage( LPCDXINDEX pIndex );
|
||||
static void hb_cdxIndexPutAvailPage( LPCDXPAGEINFO pPage );
|
||||
static void hb_cdxIndexResetAvailPage( LPCDXINDEX pIndex );
|
||||
static void hb_cdxIndexPageRead( LPCDXINDEX pIndex, LONG lPos, void * pBuffer, USHORT uiSize );
|
||||
static void hb_cdxIndexPageWrite( LPCDXINDEX pIndex, LONG lPos, void * pBuffer, USHORT uiSize );
|
||||
static LPCDXTAG hb_cdxIndexAddTag( LPCDXINDEX pIndex, char * szTagName, char * szKeyExp,
|
||||
PHB_ITEM pKeyItem, BYTE bType, USHORT uiLen, char * szForExp,
|
||||
PHB_ITEM pForItem, BOOL bAscending, BOOL bUnique, BOOL bCustom );
|
||||
|
||||
static LPSORTINFO hb_cdxSortNew( LPCDXTAG pTag, BOOL bUnique );
|
||||
static void hb_cdxSortFree( LPSORTINFO pSort );
|
||||
static void hb_cdxSortLinkNew( LPSORTINFO pSort, LONG * NewLink );
|
||||
static void hb_cdxSortGetNewChunk( LPSORTINFO pSort );
|
||||
static void hb_cdxSortInsertWord( LPSORTINFO pSort, LONG Tag, char * Value,
|
||||
USHORT uiLen );
|
||||
static void hb_cdxSortStuffKey( LPSORTINFO pSort, LPSORTDATA * wx, BOOL fTag );
|
||||
static void hb_cdxSortGetNode( LPSORTINFO pSort, BYTE Character,
|
||||
LONG * NewLink, BOOL fTag );
|
||||
static LPSORTDATA hb_cdxSortLinkGet( LPSORTINFO pSort, LONG Value );
|
||||
static void hb_cdxSortDisplayWord( LPSORTINFO pSort );
|
||||
static void hb_cdxSortRecurseDict( LPSORTINFO pSort, LONG WPtr, LONG WBgn );
|
||||
static void hb_cdxSortSendWord( LPSORTINFO pSort, BYTE * Value );
|
||||
static void hb_cdxSortOutputWord( LPSORTINFO pSort, LONG Tag, BYTE * Value,
|
||||
USHORT uiLen );
|
||||
static void hb_cdxSortAddToNode( LPSORTINFO pSort, USHORT Lvl, LONG Tag, LONG Link,
|
||||
LPCDXKEYINFO Value );
|
||||
static void hb_cdxSortAddExternal( LPSORTINFO pSort, USHORT Lvl, LONG Tag, LONG Link,
|
||||
LPCDXKEYINFO Value );
|
||||
static void hb_cdxSortAddInternal( LPSORTINFO pSort, USHORT Lvl, LONG Tag, LONG Link,
|
||||
LPCDXKEYINFO Value );
|
||||
|
||||
/* static LPCDXTAG hb_cdxGetActiveTag( LPCDXINDEX PIF ); */
|
||||
static LPCDXTAG hb_cdxGetActiveTag( CDXAREAP pArea );
|
||||
static USHORT hb_cdxFindTag( CDXAREAP pArea, LPDBORDERINFO pOrderInfo );
|
||||
static LPCDXTAG hb_cdxGetTagByNumber(CDXAREAP pArea, USHORT uiTag );
|
||||
static USHORT hb_cdxGetTagNumber(CDXAREAP pArea, LPCDXTAG pFindTag);
|
||||
static PHB_ITEM hb_cdxKeyGetItem( LPCDXKEYINFO pKey, PHB_ITEM pItem, USHORT uiType );
|
||||
static LPCDXTAG hb_cdxReorderTagList ( LPCDXTAG TagList );
|
||||
static ERRCODE hb_cdxGoEof( CDXAREAP pArea );
|
||||
static BOOL hb_cdxTopScope( LPCDXTAG pTag, LPCDXKEYINFO pKey );
|
||||
static BOOL hb_cdxBottomScope( LPCDXTAG pTag, LPCDXKEYINFO pKey );
|
||||
static void hb_cdxTagClearScope( LPCDXTAG pTag, USHORT nScope );
|
||||
|
||||
|
||||
static USHORT hb_cdxIndexCheckVersion( LPCDXINDEX pIndex );
|
||||
static USHORT hb_cdxIndexUnLockRead( LPCDXINDEX pIndex, LPCDXTAG pTag );
|
||||
static USHORT hb_cdxIndexLockRead( LPCDXINDEX pIndex, LPCDXTAG pTag );
|
||||
static USHORT hb_cdxIndexLockWrite ( LPCDXINDEX pIndex, LPCDXTAG pTag );
|
||||
static USHORT hb_cdxIndexUnLockWrite ( LPCDXINDEX pIndex, LPCDXTAG pTag );
|
||||
static void hb_cdxIndexDelTag( LPCDXINDEX pIndex, char * szTagName );
|
||||
|
||||
static int hb_cdxKeyValCompare( LPCDXTAG pTag, char * pKeyVal1, BYTE keyLen1,
|
||||
char * pKeyVal2, BYTE keyLen2, BOOL Exact );
|
||||
static void hb_cdxMacroRun( AREAP pArea, HB_MACRO_PTR pMacro );
|
||||
static ERRCODE cdxError( CDXAREAP pArea, USHORT uiGenCode, USHORT uiSubCode, char * filename, USHORT uiFlags );
|
||||
static void hb_cdxIndexReindex( LPCDXINDEX pIndex );
|
||||
static ERRCODE hb_cdxOrdListClear( CDXAREAP pArea, int iComplete, LPCDXINDEX pKeepIndex );
|
||||
static LPCDXINDEX hb_cdxFindBag( CDXAREAP pArea, char * szBagName );
|
||||
static LPCDXKEYINFO hb_cdxEvalKey( CDXAREAP pArea, LPCDXTAG pTag );
|
||||
static BOOL hb_cdxEvalCond ( CDXAREAP pArea, PHB_ITEM pCondItem, BOOL checkenv );
|
||||
|
||||
|
||||
static BYTE hb_cdxPageKeyLeafInsert( LPCDXPAGEINFO pPage, LPCDXKEYINFO pKey, BOOL bAddAfter );
|
||||
static BYTE hb_cdxPageKeyInsert( LPCDXPAGEINFO pPage, LPCDXKEYINFO pKey, BOOL bAddAfter );
|
||||
static void hb_cdxPageCalcLeafSpace( LPCDXPAGEINFO pPage );
|
||||
static SHORT hb_cdxPageCalcLeafKeySpace( LPCDXPAGEINFO pPage,
|
||||
LPCDXKEYINFO pKeyPrev, LPCDXKEYINFO pKey, LPCDXKEYINFO pKeyNext);
|
||||
static BYTE hb_cdxPageKeyLeafBalance( LPCDXPAGEINFO pPage );
|
||||
static BYTE hb_cdxPageKeyIntBalance( LPCDXPAGEINFO pPage );
|
||||
static BYTE hb_cdxPageRootSplit( LPCDXPAGEINFO pPage );
|
||||
|
||||
static BYTE hb_cdxPageKeyDelete( LPCDXPAGEINFO pPage );
|
||||
static BYTE hb_cdxPageKeyLeafDelete( LPCDXPAGEINFO pPage );
|
||||
|
||||
static void hb_cdxPagePoolFree( LPCDXINDEX pIndex, int nPagesLeft );
|
||||
static void hb_cdxPagePoolFreeTag( LPCDXTAG pTag, int nPagesLeft );
|
||||
static void hb_cdxPagePoolFlush( LPCDXINDEX pIndex );
|
||||
static void hb_cdxPagePoolFlushTag( LPCDXTAG pTag );
|
||||
static void hb_cdxPageRealFree( LPCDXPAGEINFO pPage );
|
||||
|
||||
static void hb_cdxKeyListFree( LPCDXKEYINFO pKeyList );
|
||||
static LPCDXKEYINFO hb_cdxKeyListGetKey ( LPCDXKEYINFO pKeyList, USHORT uiKey );
|
||||
static LPCDXKEYINFO hb_cdxKeyListGetLast ( LPCDXKEYINFO pKeyList );
|
||||
|
||||
#define FAST_GOCOLD(A) ( ((CDXAREAP) (A))->fRecordChanged ? ( SELF_GOCOLD( (A) ) ) : SUCCESS )
|
||||
|
||||
static void hb_cdxErrInternal ( char * szMsg );
|
||||
#ifndef HB_CDX_DBGCODE_OFF
|
||||
static void hb_cdxPagePoolCheck( LPCDXTAG pTag );
|
||||
static void hb_cdxPageLeafCheckKeys( LPCDXPAGEINFO pPage );
|
||||
#endif
|
||||
15
harbour/source/rdd/dbfdbt/Makefile
Normal file
15
harbour/source/rdd/dbfdbt/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
ROOT = ../../../
|
||||
|
||||
C_SOURCES=\
|
||||
dbfdbt1.c \
|
||||
|
||||
PRG_SOURCES=\
|
||||
dbfdbt0.prg \
|
||||
|
||||
LIBNAME=dbfdbt
|
||||
|
||||
include $(TOP)$(ROOT)config/lib.cf
|
||||
64
harbour/source/rdd/dbfdbt/dbfdbt0.prg
Normal file
64
harbour/source/rdd/dbfdbt/dbfdbt0.prg
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DBFDBT RDD
|
||||
*
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* www - http://www.xharbour.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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "rddsys.ch"
|
||||
|
||||
ANNOUNCE DBFDBT
|
||||
|
||||
procedure DBFDBTInit
|
||||
|
||||
REQUEST _DBFDBT
|
||||
|
||||
rddRegister( "DBF", RDT_FULL )
|
||||
rddRegister( "DBFDBT", RDT_FULL )
|
||||
|
||||
return
|
||||
748
harbour/source/rdd/dbfdbt/dbfdbt1.c
Normal file
748
harbour/source/rdd/dbfdbt/dbfdbt1.c
Normal file
@@ -0,0 +1,748 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* xHarbour Project source code:
|
||||
* DBFDBT RDD
|
||||
*
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* www - http://www.xharbour.org
|
||||
* Most of code taken from dbf1.c
|
||||
* Copyright 1999 Bruno Cantero <bruno@issnet.net>
|
||||
* 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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbinit.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbapilng.h"
|
||||
#include "hbset.h"
|
||||
#include "hbdate.h"
|
||||
#include "hbrdddbt.h"
|
||||
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
# include "hbapicdp.h"
|
||||
extern PHB_CODEPAGE s_cdpage;
|
||||
#endif
|
||||
|
||||
#define __PRG_SOURCE__ __FILE__
|
||||
#ifndef __XHARBOUR__
|
||||
# define HB_VM_STACK hb_stack
|
||||
#endif
|
||||
#ifdef HB_PCODE_VER
|
||||
# undef HB_PRG_PCODE_VER
|
||||
# define HB_PRG_PCODE_VER HB_PCODE_VER
|
||||
#endif
|
||||
|
||||
static RDDFUNCS dbtSuper;
|
||||
static RDDFUNCS dbtTable =
|
||||
{
|
||||
|
||||
/* Movement and positioning methods */
|
||||
|
||||
( DBENTRYP_BP ) hb_dbtBof,
|
||||
( DBENTRYP_BP ) hb_dbtEof,
|
||||
( DBENTRYP_BP ) hb_dbtFound,
|
||||
( DBENTRYP_V ) hb_dbtGoBottom,
|
||||
( DBENTRYP_UL ) hb_dbtGoTo,
|
||||
( DBENTRYP_I ) hb_dbtGoToId,
|
||||
( DBENTRYP_V ) hb_dbtGoTop,
|
||||
( DBENTRYP_BIB ) hb_dbtSeek,
|
||||
( DBENTRYP_L ) hb_dbtSkip,
|
||||
( DBENTRYP_L ) hb_dbtSkipFilter,
|
||||
( DBENTRYP_L ) hb_dbtSkipRaw,
|
||||
|
||||
|
||||
/* Data management */
|
||||
|
||||
( DBENTRYP_VF ) hb_dbtAddField,
|
||||
( DBENTRYP_B ) hb_dbtAppend,
|
||||
( DBENTRYP_I ) hb_dbtCreateFields,
|
||||
( DBENTRYP_V ) hb_dbtDeleteRec,
|
||||
( DBENTRYP_BP ) hb_dbtDeleted,
|
||||
( DBENTRYP_SP ) hb_dbtFieldCount,
|
||||
( DBENTRYP_VF ) hb_dbtFieldDisplay,
|
||||
( DBENTRYP_SSI ) hb_dbtFieldInfo,
|
||||
( DBENTRYP_SVP ) hb_dbtFieldName,
|
||||
( DBENTRYP_V ) hb_dbtFlush,
|
||||
( DBENTRYP_PP ) hb_dbtGetRec,
|
||||
( DBENTRYP_SI ) hb_dbtGetValue,
|
||||
( DBENTRYP_SVL ) hb_dbtGetVarLen,
|
||||
( DBENTRYP_V ) hb_dbtGoCold,
|
||||
( DBENTRYP_V ) hb_dbtGoHot,
|
||||
( DBENTRYP_P ) hb_dbtPutRec,
|
||||
( DBENTRYP_SI ) hb_dbtPutValue,
|
||||
( DBENTRYP_V ) hb_dbtRecall,
|
||||
( DBENTRYP_ULP ) hb_dbtRecCount,
|
||||
( DBENTRYP_ISI ) hb_dbtRecInfo,
|
||||
( DBENTRYP_I ) hb_dbtRecNo,
|
||||
( DBENTRYP_S ) hb_dbtSetFieldExtent,
|
||||
|
||||
|
||||
/* WorkArea/Database management */
|
||||
|
||||
( DBENTRYP_P ) hb_dbtAlias,
|
||||
( DBENTRYP_V ) hb_dbtClose,
|
||||
( DBENTRYP_VP ) hb_dbtCreate,
|
||||
( DBENTRYP_SI ) hb_dbtInfo,
|
||||
( DBENTRYP_V ) hb_dbtNewArea,
|
||||
( DBENTRYP_VP ) hb_dbtOpen,
|
||||
( DBENTRYP_V ) hb_dbtRelease,
|
||||
( DBENTRYP_SP ) hb_dbtStructSize,
|
||||
( DBENTRYP_P ) hb_dbtSysName,
|
||||
( DBENTRYP_VEI ) hb_dbtEval,
|
||||
( DBENTRYP_V ) hb_dbtPack,
|
||||
( DBENTRYP_LSP ) hb_dbtPackRec,
|
||||
( DBENTRYP_VS ) hb_dbtSort,
|
||||
( DBENTRYP_VT ) hb_dbtTrans,
|
||||
( DBENTRYP_VT ) hb_dbtTransRec,
|
||||
( DBENTRYP_V ) hb_dbtZap,
|
||||
|
||||
|
||||
/* Relational Methods */
|
||||
|
||||
( DBENTRYP_VR ) hb_dbtChildEnd,
|
||||
( DBENTRYP_VR ) hb_dbtChildStart,
|
||||
( DBENTRYP_VR ) hb_dbtChildSync,
|
||||
( DBENTRYP_V ) hb_dbtSyncChildren,
|
||||
( DBENTRYP_V ) hb_dbtClearRel,
|
||||
( DBENTRYP_V ) hb_dbtForceRel,
|
||||
( DBENTRYP_SVP ) hb_dbtRelArea,
|
||||
( DBENTRYP_VR ) hb_dbtRelEval,
|
||||
( DBENTRYP_SVP ) hb_dbtRelText,
|
||||
( DBENTRYP_VR ) hb_dbtSetRel,
|
||||
|
||||
|
||||
/* Order Management */
|
||||
|
||||
( DBENTRYP_OI ) hb_dbtOrderListAdd,
|
||||
( DBENTRYP_V ) hb_dbtOrderListClear,
|
||||
( DBENTRYP_VP ) hb_dbtOrderListDelete,
|
||||
( DBENTRYP_OI ) hb_dbtOrderListFocus,
|
||||
( DBENTRYP_V ) hb_dbtOrderListRebuild,
|
||||
( DBENTRYP_VOI ) hb_dbtOrderCondition,
|
||||
( DBENTRYP_VOC ) hb_dbtOrderCreate,
|
||||
( DBENTRYP_OI ) hb_dbtOrderDestroy,
|
||||
( DBENTRYP_OII ) hb_dbtOrderInfo,
|
||||
|
||||
|
||||
/* Filters and Scope Settings */
|
||||
|
||||
( DBENTRYP_V ) hb_dbtClearFilter,
|
||||
( DBENTRYP_V ) hb_dbtClearLocate,
|
||||
( DBENTRYP_V ) hb_dbtClearScope,
|
||||
( DBENTRYP_VPLP ) hb_dbtCountScope,
|
||||
( DBENTRYP_I ) hb_dbtFilterText,
|
||||
( DBENTRYP_SI ) hb_dbtScopeInfo,
|
||||
( DBENTRYP_VFI ) hb_dbtSetFilter,
|
||||
( DBENTRYP_VLO ) hb_dbtSetLocate,
|
||||
( DBENTRYP_VOS ) hb_dbtSetScope,
|
||||
( DBENTRYP_VPL ) hb_dbtSkipScope,
|
||||
|
||||
|
||||
/* Miscellaneous */
|
||||
|
||||
( DBENTRYP_P ) hb_dbtCompile,
|
||||
( DBENTRYP_I ) hb_dbtError,
|
||||
( DBENTRYP_I ) hb_dbtEvalBlock,
|
||||
|
||||
|
||||
/* Network operations */
|
||||
|
||||
( DBENTRYP_VSP ) hb_dbtRawLock,
|
||||
( DBENTRYP_VL ) hb_dbtLock,
|
||||
( DBENTRYP_UL ) hb_dbtUnLock,
|
||||
|
||||
|
||||
/* Memofile functions */
|
||||
|
||||
( DBENTRYP_V ) hb_dbtCloseMemFile,
|
||||
( DBENTRYP_VP ) hb_dbtCreateMemFile,
|
||||
( DBENTRYP_SVPB ) hb_dbtGetValueFile,
|
||||
( DBENTRYP_VP ) hb_dbtOpenMemFile,
|
||||
( DBENTRYP_SVP ) hb_dbtPutValueFile,
|
||||
|
||||
|
||||
/* Database file header handling */
|
||||
|
||||
( DBENTRYP_V ) hb_dbtReadDBHeader,
|
||||
( DBENTRYP_V ) hb_dbtWriteDBHeader,
|
||||
|
||||
|
||||
/* non WorkArea functions */
|
||||
( DBENTRYP_I0 ) hb_dbtExit,
|
||||
( DBENTRYP_I1 ) hb_dbtDrop,
|
||||
( DBENTRYP_I2 ) hb_dbtExists,
|
||||
|
||||
/* Special and reserved methods */
|
||||
|
||||
( DBENTRYP_SVP ) hb_dbtWhoCares
|
||||
};
|
||||
|
||||
|
||||
HB_FUNC( _DBFDBT ) {;}
|
||||
|
||||
HB_FUNC( DBFDBT_GETFUNCTABLE )
|
||||
{
|
||||
RDDFUNCS * pTable;
|
||||
USHORT * uiCount;
|
||||
|
||||
uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) );
|
||||
pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) );
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("DBFDBT_GETFUNCTABLE(%i, %p)", uiCount, pTable));
|
||||
|
||||
if( pTable )
|
||||
{
|
||||
if ( uiCount )
|
||||
* uiCount = RDDFUNCSCOUNT;
|
||||
hb_retni( hb_rddInherit( pTable, &dbtTable, &dbtSuper, ( BYTE * ) "DBF" ) );
|
||||
}
|
||||
else
|
||||
hb_retni( FAILURE );
|
||||
}
|
||||
|
||||
|
||||
HB_INIT_SYMBOLS_BEGIN( dbfdbt1__InitSymbols )
|
||||
{ "_DBFDBT", HB_FS_PUBLIC, HB_FUNCNAME( _DBFDBT ), NULL },
|
||||
{ "DBFDBT_GETFUNCTABLE", HB_FS_PUBLIC, HB_FUNCNAME( DBFDBT_GETFUNCTABLE ), NULL }
|
||||
HB_INIT_SYMBOLS_END( dbfdbt1__InitSymbols )
|
||||
|
||||
#if defined(HB_STATIC_STARTUP)
|
||||
# pragma startup dbfdbt1__InitSymbols
|
||||
#elif defined(_MSC_VER)
|
||||
# if _MSC_VER >= 1010
|
||||
# pragma data_seg( ".CRT$XIY" )
|
||||
# pragma comment( linker, "/Merge:.CRT=.data" )
|
||||
# else
|
||||
# pragma data_seg( "XIY" )
|
||||
# endif
|
||||
static HB_$INITSYM hb_vm_auto_dbfdbt1__InitSymbols = dbfdbt1__InitSymbols;
|
||||
# pragma data_seg()
|
||||
#elif ! defined(__GNUC__)
|
||||
# pragma startup dbfdbt1__InitSymbols
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Exclusive lock memo file.
|
||||
*/
|
||||
static BOOL hb_dbtFileLockEx( DBTAREAP pArea )
|
||||
{
|
||||
BOOL bRet;
|
||||
|
||||
while ( ! ( bRet = hb_fsLock( pArea->hMemoFile, DBT_LOCKPOS, DBT_LOCKSIZE,
|
||||
FL_LOCK | FLX_EXCLUSIVE | FLX_WAIT ) ) );
|
||||
return bRet;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shared lock memo file.
|
||||
*/
|
||||
static BOOL hb_dbtFileLockSh( DBTAREAP pArea )
|
||||
{
|
||||
BOOL bRet;
|
||||
|
||||
while ( ! ( bRet = hb_fsLock( pArea->hMemoFile, DBT_LOCKPOS, DBT_LOCKSIZE,
|
||||
FL_LOCK | FLX_SHARED | FLX_WAIT ) ) );
|
||||
return bRet;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unlock memo file.
|
||||
*/
|
||||
static BOOL hb_dbtFileUnLock( DBTAREAP pArea )
|
||||
{
|
||||
return hb_fsLock( pArea->hMemoFile, DBT_LOCKPOS, DBT_LOCKSIZE, FL_UNLOCK );
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the size of memo.
|
||||
*/
|
||||
static ULONG hb_dbtGetMemoLen( DBTAREAP pArea, USHORT uiIndex )
|
||||
{
|
||||
ULONG ulBlock;
|
||||
BYTE pBlock[ DBT_BLOCKSIZE ];
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtGetMemoLen(%p, %hu)", pArea, uiIndex));
|
||||
|
||||
ulBlock = hb_dbfGetMemoBlock( ( DBFAREAP ) pArea, uiIndex );
|
||||
if( ulBlock == 0 )
|
||||
return 0;
|
||||
hb_fsSeek( pArea->hMemoFile, ulBlock * DBT_BLOCKSIZE, FS_SET );
|
||||
ulBlock = 0;
|
||||
do
|
||||
{
|
||||
hb_fsRead( pArea->hMemoFile, pBlock, DBT_BLOCKSIZE );
|
||||
uiIndex = 0;
|
||||
while( uiIndex < DBT_BLOCKSIZE && pBlock[ uiIndex ] != 0x1A )
|
||||
uiIndex++;
|
||||
ulBlock += uiIndex;
|
||||
} while( uiIndex == DBT_BLOCKSIZE );
|
||||
return ulBlock;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read memo data.
|
||||
*/
|
||||
static void hb_dbtGetMemo( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
|
||||
{
|
||||
ULONG ulSize, ulBlock;
|
||||
BYTE * pBuffer;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtGetMemo(%p, %hu, %p)", pArea, uiIndex, pItem));
|
||||
|
||||
ulSize = hb_dbtGetMemoLen( pArea, uiIndex );
|
||||
|
||||
pBuffer = ( BYTE * ) hb_xgrab( ulSize + 1 );
|
||||
if( ulSize > 0 )
|
||||
{
|
||||
ulBlock = hb_dbfGetMemoBlock( ( DBFAREAP ) pArea, uiIndex );
|
||||
hb_fsSeek( pArea->hMemoFile, ulBlock * DBT_BLOCKSIZE, FS_SET );
|
||||
hb_fsReadLarge( pArea->hMemoFile, pBuffer, ulSize );
|
||||
}
|
||||
else
|
||||
*pBuffer = '\0';
|
||||
|
||||
hb_itemPutCPtr( pItem, ( char * ) pBuffer, ulSize );
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
hb_cdpTranslate( pItem->item.asString.value, pArea->cdPage, s_cdpage );
|
||||
#endif
|
||||
hb_itemSetCMemo( pItem );
|
||||
}
|
||||
|
||||
/*
|
||||
* Write memo data.
|
||||
*/
|
||||
static void hb_dbtWriteMemo( DBTAREAP pArea, ULONG ulBlock, PHB_ITEM pItem, ULONG ulLen,
|
||||
ULONG * ulStoredBlock )
|
||||
{
|
||||
BYTE pBlock[ DBT_BLOCKSIZE ];
|
||||
BOOL bNewBlock;
|
||||
ULONG ulNewBlock, ulNextBlock;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtWriteMemo(%p, %lu, %p, %lu, %p)", pArea, ulBlock, pItem,
|
||||
ulLen, ulStoredBlock));
|
||||
|
||||
memset( pBlock, 0x1A, DBT_BLOCKSIZE );
|
||||
bNewBlock = !( ulBlock && ulLen < DBT_BLOCKSIZE - 1 );
|
||||
if( bNewBlock )
|
||||
{
|
||||
/* Get next block from header */
|
||||
hb_fsSeek( pArea->hMemoFile, 0, FS_SET );
|
||||
hb_fsRead( pArea->hMemoFile, ( BYTE * ) &ulNewBlock, sizeof( ulNewBlock ) );
|
||||
ulNextBlock = ulNewBlock * DBT_BLOCKSIZE;
|
||||
hb_fsSeek( pArea->hMemoFile, ulNextBlock, FS_SET );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_fsSeek( pArea->hMemoFile, ulBlock * DBT_BLOCKSIZE, FS_SET );
|
||||
ulNewBlock = ulBlock;
|
||||
}
|
||||
* ulStoredBlock = ulNewBlock;
|
||||
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
hb_cdpTranslate( pItem->item.asString.value, s_cdpage, pArea->cdPage );
|
||||
#endif
|
||||
/* Write memo data and eof mark */
|
||||
hb_fsWriteLarge( pArea->hMemoFile, ( BYTE * ) hb_itemGetCPtr( pItem ), ulLen );
|
||||
hb_fsWrite( pArea->hMemoFile, pBlock, ( DBT_BLOCKSIZE - ( USHORT ) ( ulLen % DBT_BLOCKSIZE ) ) );
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
hb_cdpTranslate( pItem->item.asString.value, pArea->cdPage, s_cdpage );
|
||||
#endif
|
||||
|
||||
if( bNewBlock )
|
||||
{
|
||||
ulNextBlock += ulLen + 1;
|
||||
ulNextBlock += ( DBT_BLOCKSIZE - ulNextBlock % DBT_BLOCKSIZE );
|
||||
ulNextBlock /= DBT_BLOCKSIZE;
|
||||
hb_fsSeek( pArea->hMemoFile, 0, FS_SET );
|
||||
hb_fsWrite( pArea->hMemoFile, ( BYTE * ) &ulNextBlock, sizeof( ulNextBlock ) );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Assign a value to the specified memo field.
|
||||
*/
|
||||
static BOOL hb_dbtPutMemo( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
|
||||
{
|
||||
ULONG ulLen, ulBlock;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtPutMemo(%p, %hu, %p)", pArea, uiIndex, pItem));
|
||||
|
||||
ulLen = hb_itemGetCLen( pItem );
|
||||
if( ulLen > 0 )
|
||||
{
|
||||
ulBlock = hb_dbfGetMemoBlock( ( DBFAREAP ) pArea, uiIndex );
|
||||
hb_dbtWriteMemo( pArea, ulBlock, pItem, ulLen, &ulBlock );
|
||||
}
|
||||
else
|
||||
ulBlock = 0;
|
||||
hb_dbfPutMemoBlock( ( DBFAREAP ) pArea, uiIndex, ulBlock );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* DBT METHODS */
|
||||
|
||||
/*
|
||||
* Obtain the length of a field value.
|
||||
* ( DBENTRYP_SVL ) hb_dbtGetVarLen
|
||||
*/
|
||||
static ERRCODE hb_dbtGetVarLen( DBTAREAP pArea, USHORT uiIndex, ULONG * pLength )
|
||||
{
|
||||
BOOL bDeleted;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtGetVarLen(%p, %hu, %p)", pArea, uiIndex, pLength));
|
||||
|
||||
if( pArea->fHasMemo && pArea->hMemoFile != FS_ERROR )
|
||||
{
|
||||
/* Force read record */
|
||||
if( SELF_DELETED( ( AREAP ) pArea, &bDeleted ) == FAILURE )
|
||||
return FAILURE;
|
||||
|
||||
if( pArea->lpFields[ uiIndex - 1 ].uiType == HB_IT_MEMO )
|
||||
{
|
||||
if( hb_dbtFileLockSh( pArea ) )
|
||||
{
|
||||
* pLength = hb_dbtGetMemoLen( pArea, uiIndex - 1 );
|
||||
hb_dbtFileUnLock( pArea );
|
||||
}
|
||||
else
|
||||
{
|
||||
* pLength = 0;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return SUPER_GETVARLEN( ( AREAP ) pArea, uiIndex, pLength );
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve information about the current driver.
|
||||
* ( DBENTRYP_SI ) hb_dbtInfo
|
||||
*/
|
||||
static ERRCODE hb_dbtInfo( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtInfo(%p, %hu, %p)", pArea, uiIndex, pItem));
|
||||
|
||||
switch( uiIndex )
|
||||
{
|
||||
case DBI_MEMOEXT:
|
||||
hb_itemPutC( pItem, DBT_MEMOEXT );
|
||||
break;
|
||||
|
||||
/* case DBI_RDD_VERSION */
|
||||
|
||||
default:
|
||||
return SUPER_INFO( ( AREAP ) pArea, uiIndex, pItem );
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the size of the WorkArea structure.
|
||||
* ( DBENTRYP_SP ) hb_dbtStructSize
|
||||
*/
|
||||
static ERRCODE hb_dbtStructSize( DBTAREAP pArea, USHORT * uiSize )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtStrucSize(%p, %p)", pArea, uiSize));
|
||||
HB_SYMBOL_UNUSED( pArea );
|
||||
|
||||
* uiSize = sizeof( DBTAREA );
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Obtain the name of replaceable database driver (RDD) subsystem.
|
||||
* ( DBENTRYP_P ) hb_dbtSysName
|
||||
*/
|
||||
static ERRCODE hb_dbtSysName( DBTAREAP pArea, BYTE * pBuffer )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtSysName(%p, %p)", pArea, pBuffer));
|
||||
HB_SYMBOL_UNUSED( pArea );
|
||||
|
||||
strncpy( ( char * ) pBuffer, "DBFDBT", 7 /* HARBOUR_MAX_RDD_DRIVERNAME_LENGTH */ );
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Obtain the current value of a field.
|
||||
* ( DBENTRYP_SI ) hb_dbtGetValue
|
||||
*/
|
||||
static ERRCODE hb_dbtGetValue( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
|
||||
{
|
||||
BOOL bDeleted;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtGetValue(%p, %hu, %p)", pArea, uiIndex, pItem));
|
||||
|
||||
if( pArea->fHasMemo && pArea->hMemoFile != FS_ERROR &&
|
||||
pArea->lpFields[ uiIndex - 1 ].uiType == HB_IT_MEMO )
|
||||
{
|
||||
/* Force read record */
|
||||
if( SELF_DELETED( ( AREAP ) pArea, &bDeleted ) == FAILURE )
|
||||
return FAILURE;
|
||||
|
||||
if( hb_dbtFileLockSh( pArea ) )
|
||||
{
|
||||
hb_dbtGetMemo( pArea, uiIndex - 1, pItem );
|
||||
hb_dbtFileUnLock( pArea );
|
||||
}
|
||||
else
|
||||
{
|
||||
PHB_ITEM pError = hb_errNew();
|
||||
|
||||
hb_errPutGenCode( pError, EG_LOCK );
|
||||
hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_LOCK ) );
|
||||
hb_errPutSubCode( pError, EDBF_LOCK );
|
||||
hb_errPutFlags( pError, EF_CANDEFAULT );
|
||||
SELF_ERROR( ( AREAP ) pArea, pError );
|
||||
hb_errRelease( pError );
|
||||
return FAILURE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
else
|
||||
return SUPER_GETVALUE( ( AREAP ) pArea, uiIndex, pItem );
|
||||
}
|
||||
|
||||
/*
|
||||
* Assign a value to a field.
|
||||
* ( DBENTRYP_SI ) hb_dbtPutValue
|
||||
*/
|
||||
static ERRCODE hb_dbtPutValue( DBTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem )
|
||||
{
|
||||
BOOL bDeleted;
|
||||
PHB_ITEM pError;
|
||||
ERRCODE uiError, uiErrorG;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtPutValue(%p, %hu, %p)", pArea, uiIndex, pItem));
|
||||
|
||||
if( pArea->fHasMemo && pArea->hMemoFile != FS_ERROR &&
|
||||
pArea->lpFields[ uiIndex - 1 ].uiType == HB_IT_MEMO )
|
||||
{
|
||||
if( HB_IS_MEMO( pItem ) || HB_IS_STRING( pItem ) )
|
||||
{
|
||||
/* Force read record */
|
||||
if( SELF_DELETED( ( AREAP ) pArea, &bDeleted ) == FAILURE )
|
||||
return FAILURE;
|
||||
|
||||
if( !pArea->fPositioned )
|
||||
return SUCCESS;
|
||||
|
||||
/* Buffer is hot? */
|
||||
if( !pArea->fRecordChanged && SELF_GOHOT( ( AREAP ) pArea ) == FAILURE )
|
||||
return FAILURE;
|
||||
|
||||
if( hb_dbtFileLockEx( pArea ) )
|
||||
{
|
||||
uiError = hb_dbtPutMemo( pArea, uiIndex -1, pItem ) ? SUCCESS : EDBF_DATAWIDTH;
|
||||
hb_dbtFileUnLock( pArea );
|
||||
}
|
||||
else
|
||||
{
|
||||
uiError = EDBF_LOCK;
|
||||
}
|
||||
/* Update deleted flag */
|
||||
pArea->pRecord[ 0 ] = (BYTE) (pArea->fDeleted ? '*' : ' ');
|
||||
}
|
||||
else
|
||||
uiError = EDBF_DATATYPE;
|
||||
|
||||
if( uiError != SUCCESS )
|
||||
{
|
||||
uiErrorG = uiError == EDBF_DATAWIDTH ? EG_DATAWIDTH :
|
||||
( uiError == EDBF_LOCK ? EG_LOCK : EG_DATATYPE );
|
||||
pError = hb_errNew();
|
||||
hb_errPutGenCode( pError, uiErrorG );
|
||||
hb_errPutDescription( pError, hb_langDGetErrorDesc( uiErrorG ) );
|
||||
hb_errPutSubCode( pError, uiError );
|
||||
hb_errPutFlags( pError, EF_CANDEFAULT );
|
||||
SELF_ERROR( ( AREAP ) pArea, pError );
|
||||
hb_errRelease( pError );
|
||||
return FAILURE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
return SUPER_PUTVALUE( ( AREAP ) pArea, uiIndex, pItem);
|
||||
}
|
||||
|
||||
|
||||
/* ( DBENTRYP_V ) hb_dbtCloseMemFile : NULL */
|
||||
|
||||
/*
|
||||
* Create a memo file in the WorkArea.
|
||||
* ( DBENTRYP_VP ) hb_dbtCreateMemFile
|
||||
*/
|
||||
static ERRCODE hb_dbtCreateMemFile( DBTAREAP pArea, LPDBOPENINFO pCreateInfo )
|
||||
{
|
||||
BYTE pBlock[ DBT_BLOCKSIZE ];
|
||||
BOOL bRetry;
|
||||
PHB_ITEM pError;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtCreateMemFile(%p, %p)", pArea, pCreateInfo));
|
||||
|
||||
pArea->uiMemoBlockSize = DBT_BLOCKSIZE;
|
||||
|
||||
if( pCreateInfo )
|
||||
{
|
||||
pError = NULL;
|
||||
/* Try create */
|
||||
do
|
||||
{
|
||||
pArea->hMemoFile = hb_spCreate( pCreateInfo->abName, FC_NORMAL );
|
||||
if( pArea->hMemoFile == FS_ERROR )
|
||||
{
|
||||
if( !pError )
|
||||
{
|
||||
pError = hb_errNew();
|
||||
hb_errPutGenCode( pError, EG_CREATE );
|
||||
hb_errPutSubCode( pError, EDBF_CREATE_DBF );
|
||||
hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) );
|
||||
hb_errPutFileName( pError, ( char * ) pCreateInfo->abName );
|
||||
hb_errPutFlags( pError, EF_CANRETRY );
|
||||
}
|
||||
bRetry = ( SELF_ERROR( ( AREAP ) pArea, pError ) == E_RETRY );
|
||||
}
|
||||
else
|
||||
bRetry = FALSE;
|
||||
} while( bRetry );
|
||||
if( pError )
|
||||
hb_errRelease( pError );
|
||||
|
||||
if( pArea->hMemoFile == FS_ERROR )
|
||||
return FAILURE;
|
||||
}
|
||||
else /* For zap file */
|
||||
hb_fsSeek( pArea->hMemoFile, 0, FS_SET );
|
||||
|
||||
memset( pBlock, 0, DBT_BLOCKSIZE );
|
||||
* ( ( LONG * ) pBlock ) = 1;
|
||||
if( hb_fsWrite( pArea->hMemoFile, pBlock, DBT_BLOCKSIZE ) != DBT_BLOCKSIZE )
|
||||
return FAILURE;
|
||||
hb_fsWrite( pArea->hMemoFile, NULL, 0 );
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* ( DBENTRYP_SVPB ) hb_dbtGetValueFile : NULL */
|
||||
|
||||
/*
|
||||
* Open a memo file in the specified WorkArea.
|
||||
* ( DBENTRYP_VP ) hb_dbtOpenMemFile
|
||||
*/
|
||||
static ERRCODE hb_dbtOpenMemFile( DBTAREAP pArea, LPDBOPENINFO pOpenInfo )
|
||||
{
|
||||
USHORT uiFlags;
|
||||
BOOL bRetry;
|
||||
PHB_ITEM pError = NULL;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtOpenMemFile(%p, %p)", pArea, pOpenInfo));
|
||||
|
||||
uiFlags = (pOpenInfo->fReadonly ? FO_READ : FO_READWRITE) |
|
||||
(pOpenInfo->fShared ? FO_DENYNONE : FO_EXCLUSIVE);
|
||||
|
||||
/* Try open */
|
||||
do
|
||||
{
|
||||
pArea->hMemoFile = hb_spOpen( pOpenInfo->abName, uiFlags );
|
||||
if( pArea->hMemoFile == FS_ERROR )
|
||||
{
|
||||
if( !pError )
|
||||
{
|
||||
pError = hb_errNew();
|
||||
hb_errPutGenCode( pError, EG_OPEN );
|
||||
hb_errPutSubCode( pError, EDBF_OPEN_DBF );
|
||||
hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_OPEN ) );
|
||||
hb_errPutFileName( pError, ( char * ) pOpenInfo->abName );
|
||||
hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT );
|
||||
}
|
||||
bRetry = ( SELF_ERROR( ( AREAP ) pArea, pError ) == E_RETRY );
|
||||
}
|
||||
else
|
||||
bRetry = FALSE;
|
||||
} while( bRetry );
|
||||
|
||||
if( pError )
|
||||
{
|
||||
hb_errRelease( pError );
|
||||
}
|
||||
pArea->uiMemoBlockSize = DBT_BLOCKSIZE;
|
||||
|
||||
return ( pArea->hMemoFile == FS_ERROR ? FAILURE : SUCCESS );
|
||||
}
|
||||
|
||||
/* ( DBENTRYP_SVP ) hb_dbtPutValueFile : NULL */
|
||||
|
||||
/*
|
||||
* Read the database file header record in the WorkArea.
|
||||
* ( DBENTRYP_V ) hb_dbtReadDBHeader
|
||||
*/
|
||||
static ERRCODE hb_dbtReadDBHeader( DBTAREAP pArea )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtReadHeader(%p)", pArea));
|
||||
|
||||
if( SUPER_READDBHEADER( ( AREAP ) pArea ) == FAILURE )
|
||||
return FAILURE;
|
||||
|
||||
pArea->fHasMemo = ( pArea->bVersion == 0x83 );
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the database file header record in the WorkArea.
|
||||
* ( DBENTRYP_V ) hb_dbtWriteDBHeader
|
||||
*/
|
||||
static ERRCODE hb_dbtWriteDBHeader( DBTAREAP pArea )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dbtWriteDBHeader(%p)", pArea));
|
||||
|
||||
if ( pArea->fHasMemo )
|
||||
pArea->bVersion = 0x83;
|
||||
|
||||
return SUPER_WRITEDBHEADER( ( AREAP ) pArea );
|
||||
}
|
||||
15
harbour/source/rdd/dbffpt/Makefile
Normal file
15
harbour/source/rdd/dbffpt/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
ROOT = ../../../
|
||||
|
||||
C_SOURCES=\
|
||||
dbffpt1.c \
|
||||
|
||||
PRG_SOURCES=\
|
||||
dbffpt0.prg \
|
||||
|
||||
LIBNAME=dbffpt
|
||||
|
||||
include $(TOP)$(ROOT)config/lib.cf
|
||||
64
harbour/source/rdd/dbffpt/dbffpt0.prg
Normal file
64
harbour/source/rdd/dbffpt/dbffpt0.prg
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* DBFFPT RDD
|
||||
*
|
||||
* Copyright 2003 Przemyslaw Czerpak <druzus@acn.waw.pl>
|
||||
* www - http://www.xharbour.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, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "rddsys.ch"
|
||||
|
||||
ANNOUNCE DBFFPT
|
||||
|
||||
procedure DBFFPTInit
|
||||
|
||||
REQUEST _DBFFPT
|
||||
|
||||
rddRegister( "DBF", RDT_FULL )
|
||||
rddRegister( "DBFFPT", RDT_FULL )
|
||||
|
||||
return
|
||||
2122
harbour/source/rdd/dbffpt/dbffpt1.c
Normal file
2122
harbour/source/rdd/dbffpt/dbffpt1.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -130,6 +130,7 @@
|
||||
#include "hbapicdp.h"
|
||||
|
||||
extern PHB_CODEPAGE s_cdpage;
|
||||
#define __PRG_SOURCE__ __FILE__
|
||||
extern USHORT hb_rddFieldIndex( AREAP pArea, char * szName );
|
||||
|
||||
|
||||
@@ -158,7 +159,7 @@ HB_INIT_SYMBOLS_END( dbfntx1__InitSymbols )
|
||||
#pragma startup dbfntx1__InitSymbols
|
||||
#endif
|
||||
|
||||
static RDDFUNCS ntxSuper = { 0 };
|
||||
static RDDFUNCS ntxSuper;
|
||||
|
||||
/* Internal functions */
|
||||
static LPKEYINFO hb_ntxKeyNew( LPKEYINFO pKeyFrom, int keylen );
|
||||
@@ -2526,12 +2527,23 @@ static ERRCODE hb_ntxIndexCreate( LPNTXINDEX pIndex )
|
||||
USHORT nAttemptLeft = 999;
|
||||
pszTempName = (char*) hb_xgrab( _POSIX_PATH_MAX );
|
||||
// sortInfo.tempHandle = hb_fsCreateTemp( NULL, NULL, FC_NORMAL, pszTempName );
|
||||
#if defined( HB_OS_LINUX ) || defined( HB_OS_BSD )
|
||||
strcpy(pszTempName, "sort-tmp.XXXXXX" );
|
||||
#endif
|
||||
while( --nAttemptLeft )
|
||||
{
|
||||
#if !defined( HB_OS_LINUX ) && !defined( HB_OS_BSD )
|
||||
tmpnam( pszTempName );
|
||||
sortInfo.tempHandle = hb_fsCreate( (BYTE*)pszTempName,FC_NORMAL );
|
||||
if( sortInfo.tempHandle != FS_ERROR )
|
||||
break;
|
||||
#else
|
||||
sortInfo.tempHandle = mkstemp( pszTempName );
|
||||
if( sortInfo.tempHandle > -1 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if( sortInfo.tempHandle == FS_ERROR )
|
||||
hb_errInternal( HB_EI_ERRUNRECOV, "Cannot create temp file", "hb_ntxIndexCreate", NULL );
|
||||
@@ -4281,12 +4293,13 @@ static RDDFUNCS ntxTable = { ntxBof,
|
||||
ntxPutValueFile,
|
||||
ntxReadDBHeader,
|
||||
ntxWriteDBHeader,
|
||||
ntxExit,
|
||||
ntxDrop,
|
||||
ntxExists,
|
||||
ntxWhoCares
|
||||
};
|
||||
|
||||
HB_FUNC(_DBFNTX )
|
||||
{
|
||||
}
|
||||
HB_FUNC(_DBFNTX ){;}
|
||||
|
||||
HB_FUNC( DBFNTX_GETFUNCTABLE )
|
||||
{
|
||||
@@ -4294,10 +4307,22 @@ HB_FUNC( DBFNTX_GETFUNCTABLE )
|
||||
USHORT * uiCount;
|
||||
|
||||
uiCount = ( USHORT * ) hb_itemGetPtr( hb_param( 1, HB_IT_POINTER ) );
|
||||
* uiCount = RDDFUNCSCOUNT;
|
||||
pTable = ( RDDFUNCS * ) hb_itemGetPtr( hb_param( 2, HB_IT_POINTER ) );
|
||||
if( pTable )
|
||||
hb_retni( hb_rddInherit( pTable, &ntxTable, &ntxSuper, ( BYTE * ) "DBF" ) );
|
||||
{
|
||||
SHORT iRet;
|
||||
|
||||
if ( uiCount )
|
||||
* uiCount = RDDFUNCSCOUNT;
|
||||
iRet = hb_rddInherit( pTable, &ntxTable, &ntxSuper, ( BYTE * ) "DBFDBT" );
|
||||
if ( iRet == FAILURE )
|
||||
iRet = hb_rddInherit( pTable, &ntxTable, &ntxSuper, ( BYTE * ) "DBFFPT" );
|
||||
if ( iRet == FAILURE )
|
||||
iRet = hb_rddInherit( pTable, &ntxTable, &ntxSuper, ( BYTE * ) "DBF" );
|
||||
hb_retni( iRet );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_retni( FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,14 +57,22 @@
|
||||
#include "hbapiitm.h"
|
||||
#include "hbrdddel.h"
|
||||
|
||||
#define __PRG_SOURCE__ __FILE__
|
||||
|
||||
HB_FUNC( _DELIMC );
|
||||
HB_FUNC( DELIM_GETFUNCTABLE );
|
||||
|
||||
#undef HB_PRG_PCODE_VER
|
||||
#define HB_PRG_PCODE_VER HB_PCODE_VER
|
||||
|
||||
HB_INIT_SYMBOLS_BEGIN( delim1__InitSymbols )
|
||||
{ "_DELIMC", HB_FS_PUBLIC, HB_FUNCNAME( _DELIMC ), NULL },
|
||||
{ "DELIM_GETFUNCTABLE", HB_FS_PUBLIC, HB_FUNCNAME( DELIM_GETFUNCTABLE ), NULL }
|
||||
HB_INIT_SYMBOLS_END( delim1__InitSymbols )
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#if defined(HB_STATIC_STARTUP)
|
||||
#pragma startup delim1__InitSymbols
|
||||
#elif defined(_MSC_VER)
|
||||
#if _MSC_VER >= 1010
|
||||
#pragma data_seg( ".CRT$XIY" )
|
||||
#pragma comment( linker, "/Merge:.CRT=.data" )
|
||||
@@ -77,8 +85,7 @@ HB_INIT_SYMBOLS_END( delim1__InitSymbols )
|
||||
#pragma startup delim1__InitSymbols
|
||||
#endif
|
||||
|
||||
static RDDFUNCS delimSuper = { NULL };
|
||||
|
||||
static RDDFUNCS delimSuper;
|
||||
static RDDFUNCS delimTable = { hb_delimBof,
|
||||
hb_delimEof,
|
||||
hb_delimFound,
|
||||
@@ -170,6 +177,9 @@ static RDDFUNCS delimTable = { hb_delimBof,
|
||||
hb_delimPutValueFile,
|
||||
hb_delimReadDBHeader,
|
||||
hb_delimWriteDBHeader,
|
||||
hb_delimExit,
|
||||
hb_delimDrop,
|
||||
hb_delimExists,
|
||||
hb_delimWhoCares
|
||||
};
|
||||
|
||||
|
||||
@@ -54,9 +54,10 @@
|
||||
|
||||
ANNOUNCE RDDSYS
|
||||
|
||||
init procedure RddInit
|
||||
PROCEDURE RddInit
|
||||
|
||||
REQUEST DBFNTX
|
||||
REQUEST DBFDBT
|
||||
|
||||
/* NOTE: Using this internal version of this functions, since at this
|
||||
point the DBFNTX RDD may not be registered, depending on the
|
||||
|
||||
@@ -57,14 +57,22 @@
|
||||
#include "hbapiitm.h"
|
||||
#include "hbrddsdf.h"
|
||||
|
||||
#define __PRG_SOURCE__ __FILE__
|
||||
|
||||
HB_FUNC( _SDFC );
|
||||
HB_FUNC( SDF_GETFUNCTABLE );
|
||||
|
||||
#undef HB_PRG_PCODE_VER
|
||||
#define HB_PRG_PCODE_VER HB_PCODE_VER
|
||||
|
||||
HB_INIT_SYMBOLS_BEGIN( sdf1__InitSymbols )
|
||||
{ "_SDFC", HB_FS_PUBLIC, HB_FUNCNAME( _SDFC ), NULL },
|
||||
{ "SDF_GETFUNCTABLE", HB_FS_PUBLIC, HB_FUNCNAME( SDF_GETFUNCTABLE ), NULL }
|
||||
HB_INIT_SYMBOLS_END( sdf1__InitSymbols )
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#if defined(HB_STATIC_STARTUP)
|
||||
#pragma startup sdf1__InitSymbols
|
||||
#elif defined(_MSC_VER)
|
||||
#if _MSC_VER >= 1010
|
||||
#pragma data_seg( ".CRT$XIY" )
|
||||
#pragma comment( linker, "/Merge:.CRT=.data" )
|
||||
@@ -77,8 +85,7 @@ HB_INIT_SYMBOLS_END( sdf1__InitSymbols )
|
||||
#pragma startup sdf1__InitSymbols
|
||||
#endif
|
||||
|
||||
static RDDFUNCS sdfSuper = { NULL };
|
||||
|
||||
static RDDFUNCS sdfSuper;
|
||||
static RDDFUNCS sdfTable = { hb_sdfBof,
|
||||
hb_sdfEof,
|
||||
hb_sdfFound,
|
||||
@@ -170,6 +177,9 @@ static RDDFUNCS sdfTable = { hb_sdfBof,
|
||||
hb_sdfPutValueFile,
|
||||
hb_sdfReadDBHeader,
|
||||
hb_sdfWriteDBHeader,
|
||||
hb_sdfExit,
|
||||
hb_sdfDrop,
|
||||
hb_sdfExists,
|
||||
hb_sdfWhoCares
|
||||
};
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include "hbapi.h"
|
||||
#include "hbapirdd.h"
|
||||
#include "hbinit.h"
|
||||
#include "hbvm.h"
|
||||
#include "hbapiitm.h"
|
||||
@@ -448,7 +449,6 @@ ERRCODE hb_waAlias( AREAP pArea, BYTE * szAlias )
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_waAlias(%p, %p)", pArea, szAlias));
|
||||
|
||||
szAlias[0] = '\0';
|
||||
|
||||
strncat( ( char * ) szAlias, ( ( PHB_DYNS ) pArea->atomAlias )->pSymbol->szName,
|
||||
HARBOUR_MAX_RDD_ALIAS_LENGTH );
|
||||
return SUCCESS;
|
||||
@@ -644,11 +644,11 @@ ERRCODE hb_waSysName( AREAP pArea, BYTE * pBuffer )
|
||||
ERRCODE hb_waEval( AREAP pArea, LPDBEVALINFO pEvalInfo )
|
||||
{
|
||||
BOOL bFor, bWhile;
|
||||
ULONG ulNext;
|
||||
LONG lNext;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_waEval(%p, %p)", pArea, pEvalInfo));
|
||||
|
||||
ulNext = 0;
|
||||
lNext = 0;
|
||||
if( pEvalInfo->dbsci.itmRecID )
|
||||
{
|
||||
SELF_GOTO( pArea, hb_itemGetNL( pEvalInfo->dbsci.itmRecID ) );
|
||||
@@ -676,30 +676,35 @@ ERRCODE hb_waEval( AREAP pArea, LPDBEVALINFO pEvalInfo )
|
||||
SELF_GOTOP( pArea );
|
||||
|
||||
if( pEvalInfo->dbsci.lNext )
|
||||
ulNext = hb_itemGetNL( pEvalInfo->dbsci.lNext );
|
||||
lNext = hb_itemGetNL( pEvalInfo->dbsci.lNext );
|
||||
|
||||
while( !pArea->fEof )
|
||||
if( !pEvalInfo->dbsci.lNext || lNext > 0 )
|
||||
{
|
||||
if( pEvalInfo->dbsci.lNext && ulNext-- < 1 )
|
||||
break;
|
||||
|
||||
if( pEvalInfo->dbsci.itmCobWhile )
|
||||
while( !pArea->fEof )
|
||||
{
|
||||
bWhile = hb_itemGetL( hb_vmEvalBlock( pEvalInfo->dbsci.itmCobWhile ) );
|
||||
if( !bWhile )
|
||||
|
||||
if( pEvalInfo->dbsci.itmCobWhile )
|
||||
{
|
||||
bWhile = hb_itemGetL( hb_vmEvalBlock( pEvalInfo->dbsci.itmCobWhile ) );
|
||||
if( !bWhile )
|
||||
break;
|
||||
}
|
||||
else
|
||||
bWhile = TRUE;
|
||||
|
||||
if( pEvalInfo->dbsci.itmCobFor )
|
||||
bFor = hb_itemGetL( hb_vmEvalBlock( pEvalInfo->dbsci.itmCobFor ) );
|
||||
else
|
||||
bFor = TRUE;
|
||||
|
||||
if( bFor && bWhile )
|
||||
hb_vmEvalBlock( pEvalInfo->itmBlock );
|
||||
|
||||
if( pEvalInfo->dbsci.lNext && --lNext < 1 )
|
||||
break;
|
||||
|
||||
SELF_SKIP( pArea, 1 );
|
||||
}
|
||||
else
|
||||
bWhile = TRUE;
|
||||
|
||||
if( pEvalInfo->dbsci.itmCobFor )
|
||||
bFor = hb_itemGetL( hb_vmEvalBlock( pEvalInfo->dbsci.itmCobFor ) );
|
||||
else
|
||||
bFor = TRUE;
|
||||
|
||||
if( bFor && bWhile )
|
||||
hb_vmEvalBlock( pEvalInfo->itmBlock );
|
||||
SELF_SKIP( pArea, 1 );
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
@@ -58,5 +58,5 @@
|
||||
|
||||
HB_FUNC( FILE )
|
||||
{
|
||||
hb_retl( ISCHAR( 1 ) ? hb_spFile( ( BYTE * ) hb_parc( 1 ) ) : FALSE );
|
||||
hb_retl( ISCHAR( 1 ) ? hb_spFile( ( BYTE * ) hb_parc( 1 ),NULL ) : FALSE );
|
||||
}
|
||||
|
||||
@@ -1291,7 +1291,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
#if defined(X__WIN32__)
|
||||
{
|
||||
errno = 0;
|
||||
switch( uiMode )
|
||||
switch( uiMode & FL_MASK )
|
||||
{
|
||||
case FL_LOCK:
|
||||
bResult = ( LockFile( DostoWinHandle(hFileHandle), ulStart,0, ulLength,0 ) == 0 );
|
||||
@@ -1314,7 +1314,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
|
||||
errno = 0;
|
||||
|
||||
switch( uiMode )
|
||||
switch( uiMode & FL_MASK )
|
||||
{
|
||||
case FL_LOCK:
|
||||
|
||||
@@ -1351,7 +1351,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
ULONG ulOldPos = hb_fsSeek( hFileHandle, ulStart, FS_SET );
|
||||
|
||||
errno = 0;
|
||||
switch( uiMode )
|
||||
switch( uiMode & FL_MASK )
|
||||
{
|
||||
case FL_LOCK:
|
||||
bResult = ( locking( hFileHandle, _LK_LOCK, ulLength ) == 0 );
|
||||
@@ -1375,7 +1375,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
ULONG ulOldPos = hb_fsSeek( hFileHandle, ulStart, FS_SET );
|
||||
|
||||
errno = 0;
|
||||
switch( uiMode )
|
||||
switch( uiMode & FL_MASK )
|
||||
{
|
||||
case FL_LOCK:
|
||||
bResult = ( _locking( hFileHandle, _LK_LOCK, ulLength ) == 0 );
|
||||
@@ -1402,7 +1402,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
|
||||
errno = 0;
|
||||
|
||||
switch( uiMode )
|
||||
switch( uiMode & FL_MASK )
|
||||
{
|
||||
case FL_LOCK:
|
||||
|
||||
@@ -1436,7 +1436,7 @@ BOOL hb_fsLock ( FHANDLE hFileHandle, ULONG ulStart,
|
||||
#elif defined(HAVE_POSIX_IO) && !defined(__IBMCPP__) && ( !defined(__GNUC__) || defined(__DJGPP__) )
|
||||
|
||||
errno = 0;
|
||||
switch( uiMode )
|
||||
switch( uiMode & FL_MASK )
|
||||
{
|
||||
case FL_LOCK:
|
||||
bResult = ( lock( hFileHandle, ulStart, ulLength ) == 0 );
|
||||
|
||||
@@ -53,64 +53,75 @@
|
||||
#include "hbapifs.h"
|
||||
#include "hbset.h"
|
||||
|
||||
static BOOL FindFile( BYTE * pFilename, BYTE * path )
|
||||
BOOL hb_spFile( BYTE * pFilename, BYTE RetPath[ _POSIX_PATH_MAX + 3 + 10 ] )
|
||||
{
|
||||
BYTE *Path;
|
||||
BOOL bIsFile = FALSE;
|
||||
PHB_FNAME pFilepath;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("FindFile(%s, %p)", (char*) pFilename, path));
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_spFile(%s, %p)", (char*) pFilename, RetPath));
|
||||
|
||||
if( RetPath )
|
||||
{
|
||||
Path = RetPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
Path = (BYTE *) hb_xgrab( _POSIX_PATH_MAX + 3 + 10 );
|
||||
}
|
||||
|
||||
pFilepath = hb_fsFNameSplit( (char*) pFilename );
|
||||
|
||||
if( pFilepath->szPath )
|
||||
{
|
||||
hb_fsFNameMerge( (char*) path, pFilepath );
|
||||
bIsFile = hb_fsFile( path );
|
||||
hb_fsFNameMerge( (char*) Path, pFilepath );
|
||||
bIsFile = hb_fsFile( Path );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( hb_set.HB_SET_DEFAULT )
|
||||
{
|
||||
pFilepath->szPath = hb_set.HB_SET_DEFAULT;
|
||||
hb_fsFNameMerge( (char*) path, pFilepath );
|
||||
bIsFile = hb_fsFile( path );
|
||||
hb_fsFNameMerge( (char*) Path, pFilepath );
|
||||
bIsFile = hb_fsFile( Path );
|
||||
}
|
||||
|
||||
if( !bIsFile && hb_set.HB_SET_PATH )
|
||||
{
|
||||
HB_PATHNAMES * nextPath = hb_setGetFirstSetPath();
|
||||
while( !bIsFile && nextPath )
|
||||
HB_PATHNAMES *NextPath = hb_setGetFirstSetPath();
|
||||
|
||||
while( bIsFile == FALSE && NextPath )
|
||||
{
|
||||
pFilepath->szPath = nextPath->szPath;
|
||||
hb_fsFNameMerge( (char*) path, pFilepath );
|
||||
bIsFile = hb_fsFile( path );
|
||||
nextPath = nextPath->pNext;
|
||||
pFilepath->szPath = NextPath->szPath;
|
||||
hb_fsFNameMerge( (char*) Path, pFilepath );
|
||||
bIsFile = hb_fsFile( Path );
|
||||
NextPath = NextPath->pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hb_xfree( pFilepath );
|
||||
|
||||
if( !bIsFile )
|
||||
*path = '\0';
|
||||
if( bIsFile == FALSE )
|
||||
{
|
||||
Path[0] = '\0';
|
||||
}
|
||||
|
||||
if( RetPath == NULL )
|
||||
{
|
||||
hb_xfree( Path );
|
||||
}
|
||||
|
||||
return bIsFile;
|
||||
}
|
||||
|
||||
BOOL hb_spFile( BYTE * pFilename )
|
||||
{
|
||||
BYTE path[ _POSIX_PATH_MAX + 1 ];
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_spFile(%s, %p)", (char*) pFilename, path));
|
||||
|
||||
return FindFile( pFilename, path );
|
||||
}
|
||||
|
||||
FHANDLE hb_spOpen( BYTE * pFilename, USHORT uiFlags )
|
||||
{
|
||||
BYTE path[ _POSIX_PATH_MAX + 1 ];
|
||||
BYTE path[ _POSIX_PATH_MAX + 3 + 10 ];
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_spOpen(%p, %hu)", pFilename, uiFlags));
|
||||
|
||||
if( FindFile( pFilename, path ) )
|
||||
if( hb_spFile( pFilename, path ) )
|
||||
return hb_fsOpen( path, uiFlags );
|
||||
else
|
||||
return hb_fsOpen( pFilename, uiFlags );
|
||||
|
||||
Reference in New Issue
Block a user