* src/pp/ppcore.c
* src/pp/hbpp.c
* src/vm/macro.c
* src/vm/runner.c
* src/vm/estack.c
* src/vm/itemapi.c
* src/vm/hvm.c
* src/vm/cmdarg.c
* src/vm/maindllp.c
* src/vm/fm.c
* src/vm/thread.c
* src/vm/memvars.c
* src/vm/eval.c
* src/vm/extend.c
* src/vm/classes.c
* src/debug/dbgentry.c
* src/common/expropt1.c
* src/common/expropt2.c
* src/common/hbhash.c
* src/nortl/nortl.c
* src/macro/macrolex.c
* src/rtl/gtxwc/gtxwc.c
* src/rtl/gtstd/gtstd.c
* src/rtl/gtcgi/gtcgi.c
* src/rtl/errapi.c
* src/rtl/hbprocfn.c
* src/rtl/hbsocket.c
* src/rtl/gtpca/gtpca.c
* src/rtl/filebuf.c
* src/rtl/hbproces.c
* src/rdd/dbfntx/dbfntx1.c
* src/rdd/dbsql.c
* src/rdd/hbdbsort.c
* src/rdd/workarea.c
* src/rdd/wacore.c
* src/rdd/sdf1.c
* src/rdd/dbcmdx.c
* src/rdd/dbfnsx/dbfnsx1.c
* src/rdd/dbcmd.c
* src/rdd/dbfcdx/dbfcdx1.c
* src/rdd/delim1.c
* src/rdd/dbf1.c
* src/rdd/hsx/hsx.c
* src/rdd/usrrdd/usrrdd.c
* src/rdd/wafunc.c
* src/rdd/dbffpt/dbffpt1.c
* src/rdd/hbsix/sxord.c
* src/rdd/hbsix/sxfname.c
* src/rdd/hbsix/sxtable.c
* src/rdd/hbsix/sxutil.c
* src/rdd/hbsix/sxcrypt.c
* src/compiler/ppcomp.c
* src/compiler/hbmain.c
* src/compiler/compi18n.c
* src/compiler/cmdcheck.c
* src/compiler/hbdbginf.c
* src/compiler/hbpcode.c
* src/compiler/genhrb.c
* src/compiler/hbdead.c
* src/compiler/complex.c
* src/compiler/genobj32.c
* src/compiler/genc.c
* src/compiler/hbopt.c
* src/compiler/hbident.c
* src/compiler/gencc.c
* src/compiler/hbcmplib.c
* src/compiler/hblbl.c
* src/compiler/harbour.yyc
* src/compiler/harbour.y
* include/hbpp.h
* include/hbrdddbf.h
* include/hbvmpub.h
* include/hbrddnsx.h
* include/hbstack.h
* include/hbgtcore.h
* include/hbapifs.h
* include/hbthread.h
* include/hbdefs.h
* include/hbmacro.h
* include/hbinit.h
* include/hbtypes.h
* include/hbrddsdf.h
* include/hbapi.h
* include/hbapiitm.h
* include/hbrddntx.h
* include/hbvm.h
* include/hbapidbg.h
* include/hbcomp.h
* include/hbapirdd.h
* include/hbcompdf.h
* include/hbrdddel.h
* include/hbexpra.c
* include/hbexprop.h
* include/hbrddcdx.h
* include/hbapicls.h
* include/hbapierr.h
* include/hbrddfpt.h
* include/hbhash.h
* include/hbregex.h
* include/hbexprb.c
* contrib/hbct/screen2.c
* contrib/hbct/token2.c
* contrib/hbct/dbftools.c
* contrib/hbct/atadjust.c
* contrib/hbct/ctwin.c
* contrib/hbct/files.c
* contrib/hbct/dattime3.c
* contrib/hbct/ctstr.c
* contrib/hbct/screen1.c
* contrib/hbct/token1.c
* contrib/hbct/ctc.c
* contrib/hbct/ct.h
* contrib/hbct/atnum.c
* contrib/hbct/asciisum.c
* contrib/hbct/numat.c
* contrib/hbct/atrepl.c
* contrib/xhb/bkgtsks.c
* contrib/xhb/hbcrypt.c
* contrib/xhb/fparse.c
* contrib/xhb/datesxhb.c
* contrib/xhb/hbnxs.h
* contrib/hbqt/gtqtc/gtqtc.cpp
* contrib/xpp/dbcmdx.c
* contrib/hbnf/dispc.c
* contrib/hbnf/ftattr.c
* contrib/hbmemio/memio.c
* contrib/hbnetio/netiocli.c
* contrib/rddsql/sddmy/mysqldd.c
* contrib/rddsql/sddpg/pgsqldd.c
* contrib/rddsql/sddfb/fbirddd.c
* contrib/rddsql/sddodbc/odbcdd.c
* contrib/rddsql/hbrddsql.h
* contrib/rddsql/sqlbase.c
* contrib/rddsql/sqlmix.c
* contrib/rddads/adsx.c
* contrib/rddads/adsfunc.c
* contrib/rddads/rddads.h
* contrib/rddads/ads1.c
* contrib/rddads/adsmgmnt.c
* contrib/hbmisc/spd.c
* contrib/hbtip/utils.c
* contrib/hbtip/encmthd.c
* contrib/hbbmcdx/bmdbfcdx.c
* contrib/hbbmcdx/hbbmcdx.h
* contrib/hbbtree/hb_btree.h
* contrib/hbbtree/hb_btree.c
* ULONG -> HB_ULONG, HB_SIZE
(except for external (OS) API specific usage)
* Formatting.
; NOTE: I converted ULONG to HB_SIZE where I felt it appropriate,
but didn't touch compiler, codeblock handling, low-level
RDD (Set/GetVarLen method) and high-level contrib RDDs, so
this needs to be cleaned.
Also there may be cases where I didn't change the whole
call chain to HB_SIZE.
; NOTE: It would be probably worthy to add new types for these purposes:
- line number (HB_USHORT)
- record number (HB_ULONG)
- RDD connection (HB_ULONG)
- parameter count / stack position / class member positions / etc (HB_USHORT, sometimes HB_ULONG)
- pcode (HB_BYTE and char)
- flags / modes (HB_USHORT / HB_ULONG)
- timers (HB_ULONG, HB_MAXINT)
- GT API character (HB_USHORT)
; REQUESTS:
- Pls don't over-align variable declarations. It makes
modification much much slower. Sometimes declarations are
aligned even if there was only one or two of them in a block.
- Pls always add variable names in declarations, otherwise the purpose
of the function is very slow to decipher when looking at it.
- Keep up the nice formatting according to Harbour standards,
it makes modifications much much easier.
; TODO:
- Verify with grep script
- Verify with HB_USER_CFLAGS=-DHB_LEGACY_TYPES_OFF
- Make HB_LEGACY_TYPES_OFF default for Harbour builds.
- Tie HB_LEGACY_TYPES_OFF to HB_LEGACY_LEVEL3
- Replace current windows.h inclusion hack with regular method
- Delete hacks dealing with former type chaos:
HB_CLIPPER_INT_ITEMS, HB_DONT_DEFINE_BASIC_TYPES, HB_DONT_DEFINE_BOOL, HB_DONT_DEFINE_BYTE, HB_DONT_DEFINE_LONG
- Retest hbfimage on *nix, delete hacks
- Normalize HB_BYTE vs. HB_UCHAR usage
- Type cleanups, f.e. HB_SIZE vs. HB_ULONG
- Add new special types (see above)
- Switch HB_SIZE to signed (big project), and delete HB_ISIZ afterwards.
372 lines
12 KiB
C
372 lines
12 KiB
C
/*
|
|
* $Id$
|
|
*/
|
|
|
|
/*
|
|
* Harbour Project source code:
|
|
* DBFNTX RDD
|
|
*
|
|
* Copyright 2000 Alexander Kresin <alex@belacy.belgorod.su>
|
|
* www - http://www.harbour-project.org
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, 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_RDDNTX_H_
|
|
#define HB_RDDNTX_H_
|
|
|
|
#include "hbrdddbf.h"
|
|
|
|
HB_EXTERN_BEGIN
|
|
|
|
/* DBFNTX default extensions */
|
|
#define NTX_INDEXEXT ".ntx"
|
|
|
|
/* DBFNTX constants declarations */
|
|
|
|
#define NTX_IGNORE_REC_NUM 0x0UL
|
|
#define NTX_MAX_REC_NUM 0xFFFFFFFFUL
|
|
|
|
#define NTX_DUMMYNODE 0xFFFFFFFFUL
|
|
|
|
#define NTX_FLAG_DEFALUT 0x0006
|
|
#define NTX_FLAG_OLDDEFALUT 0x0003
|
|
#define NTX_FLAG_FORITEM 0x0001
|
|
#define NTX_FLAG_PARTIAL 0x0008
|
|
#define NTX_FLAG_EXTLOCK 0x0010
|
|
#define NTX_FLAG_CUSTOM 0x0020
|
|
#define NTX_FLAG_CHGONLY 0x0040
|
|
#define NTX_FLAG_TEMPLATE 0x0080
|
|
#define NTX_FLAG_SORTRECNO 0x0100
|
|
#define NTX_FLAG_LARGEFILE 0x0200
|
|
#define NTX_FLAG_MULTIKEY 0x0400
|
|
#define NTX_FLAG_COMPOUND 0x8000
|
|
#define NTX_FLAG_MASK 0x87FF
|
|
|
|
#define CTX_MAX_TAGS 63
|
|
|
|
#define NTX_MAX_KEY 256 /* Max len of key */
|
|
#define NTX_MAX_EXP 256 /* Max len of KEY/FOR expression */
|
|
#define NTXBLOCKBITS 10 /* Size of NTX block in bits */
|
|
#define NTXBLOCKSIZE (1<<NTXBLOCKBITS) /* Size of block in NTX file */
|
|
#define NTX_MAX_TAGNAME 10 /* Max len of tag name */
|
|
#define NTX_TAGITEMSIZE 16 /* Size of tag item in CTX header */
|
|
#define NTX_HDR_UNUSED 473 /* the unused part of header */
|
|
#define NTX_PAGES_PER_TAG 8
|
|
#define NTX_STACKSIZE 32 /* Maximum page stack size */
|
|
|
|
#define NTX_ROOTHEAD_HEADSIZE 12
|
|
#define NTX_TAGHEAD_HEADSIZE 8
|
|
|
|
/* index file structures - defined as HB_BYTEs to avoid alignment problems */
|
|
|
|
typedef struct _NTXHEADER /* Header of NTX file */
|
|
{
|
|
HB_BYTE type[2];
|
|
HB_BYTE version[2];
|
|
HB_BYTE root[4];
|
|
HB_BYTE next_page[4];
|
|
HB_BYTE item_size[2];
|
|
HB_BYTE key_size[2];
|
|
HB_BYTE key_dec[2];
|
|
HB_BYTE max_item[2];
|
|
HB_BYTE half_page[2];
|
|
HB_BYTE key_expr[ NTX_MAX_EXP ];
|
|
HB_BYTE unique[1];
|
|
HB_BYTE unknown1[1];
|
|
HB_BYTE descend[1];
|
|
HB_BYTE unknown2[1];
|
|
HB_BYTE for_expr[ NTX_MAX_EXP ];
|
|
HB_BYTE tag_name[ NTX_MAX_TAGNAME + 2 ];
|
|
HB_BYTE custom[1];
|
|
HB_BYTE unused[ NTX_HDR_UNUSED ];
|
|
} NTXHEADER;
|
|
typedef NTXHEADER * LPNTXHEADER;
|
|
|
|
typedef struct _CTXTAGITEM /* TAG item in compound NTX (CTX) header */
|
|
{
|
|
HB_BYTE tag_name[ NTX_MAX_TAGNAME + 2 ];
|
|
HB_BYTE tag_header[ 4 ];
|
|
} CTXTAGITEM;
|
|
typedef CTXTAGITEM * LPCTXTAGITEM;
|
|
|
|
typedef struct _CTXHEADER /* Header of xHarbour CTX file */
|
|
{
|
|
HB_BYTE type[ 2 ]; /* 0x9591 LE */
|
|
HB_BYTE ntags[ 2 ]; /* number of tag entries MAX63 */
|
|
HB_BYTE version[ 4 ]; /* update counter LE */
|
|
HB_BYTE freepage[ 4 ]; /* first free page in index file */
|
|
HB_BYTE filesize[ 4 ]; /* size of index file in pages */
|
|
HB_BYTE tags[ CTX_MAX_TAGS * NTX_TAGITEMSIZE ];
|
|
} CTXHEADER;
|
|
typedef CTXHEADER * LPCTXHEADER;
|
|
|
|
#if 0
|
|
/* original CLIP CTX file header - for information only it's binary
|
|
compatible so both RDD can read the same file but it's not safe
|
|
to use CLIP for writing when the file is open by xHarbour.
|
|
In spare time I'll update CLIP to respect my extensions and send
|
|
patches to Rust - hope they will be included in CLIP.
|
|
*/
|
|
typedef struct _CTXHEADER /* Header of CLIP CTX file */
|
|
{
|
|
HB_BYTE type[ 2 ]; /* 0x9591 in LE */
|
|
HB_BYTE ntags[ 1 ]; /* number of tag entries */
|
|
HB_BYTE unused[ 13 ];
|
|
CTX_TAG tags[ 63 ];
|
|
} CTXHEADER
|
|
#endif
|
|
|
|
|
|
/* forward declarations
|
|
*/
|
|
struct _RDDFUNCS;
|
|
struct _NTXAREA;
|
|
struct _TAGINFO;
|
|
struct _NTXINDEX;
|
|
|
|
typedef struct _KEYINFO
|
|
{
|
|
HB_ULONG Tag; /* page number */
|
|
HB_ULONG Xtra; /* record number */
|
|
char key[ 1 ]; /* key value */
|
|
} KEYINFO;
|
|
typedef KEYINFO * LPKEYINFO;
|
|
|
|
typedef struct _TREE_STACK
|
|
{
|
|
HB_ULONG page;
|
|
HB_SHORT ikey;
|
|
} TREE_STACK;
|
|
typedef TREE_STACK * LPTREESTACK;
|
|
|
|
typedef struct _HB_PAGEINFO
|
|
{
|
|
HB_ULONG Page;
|
|
HB_BOOL Changed;
|
|
int iUsed;
|
|
HB_USHORT uiKeys;
|
|
struct _HB_PAGEINFO * pNext;
|
|
struct _HB_PAGEINFO * pPrev;
|
|
#ifdef HB_NTX_EXTERNAL_PAGEBUFFER
|
|
char * buffer;
|
|
#else
|
|
char buffer[ NTXBLOCKSIZE ];
|
|
#endif
|
|
} HB_PAGEINFO;
|
|
typedef HB_PAGEINFO * LPPAGEINFO;
|
|
|
|
typedef struct _HB_NTXSCOPE
|
|
{
|
|
PHB_ITEM scopeItem;
|
|
LPKEYINFO scopeKey;
|
|
HB_USHORT scopeKeyLen;
|
|
} HB_NTXSCOPE;
|
|
typedef HB_NTXSCOPE * PHB_NTXSCOPE;
|
|
|
|
typedef struct _TAGINFO
|
|
{
|
|
char * TagName;
|
|
char * KeyExpr;
|
|
char * ForExpr;
|
|
PHB_ITEM pKeyItem;
|
|
PHB_ITEM pForItem;
|
|
HB_NTXSCOPE top;
|
|
HB_NTXSCOPE bottom;
|
|
|
|
HB_USHORT Signature;
|
|
|
|
HB_BOOL fTagName;
|
|
HB_BOOL fUsrDescend;
|
|
HB_BOOL AscendKey;
|
|
HB_BOOL UniqueKey;
|
|
|
|
HB_BOOL Custom;
|
|
HB_BOOL ChgOnly;
|
|
HB_BOOL Partial;
|
|
HB_BOOL Template;
|
|
HB_BOOL MultiKey;
|
|
HB_BOOL fSortRec;
|
|
|
|
HB_BOOL HdrChanged;
|
|
HB_BOOL TagBOF;
|
|
HB_BOOL TagEOF;
|
|
HB_ULONG HeadBlock;
|
|
HB_ULONG RootBlock;
|
|
HB_USHORT uiNumber;
|
|
HB_BYTE KeyType;
|
|
HB_USHORT nField;
|
|
HB_USHORT KeyLength;
|
|
HB_USHORT KeyDec;
|
|
HB_USHORT MaxKeys;
|
|
LPTREESTACK stack;
|
|
HB_USHORT stackSize;
|
|
HB_USHORT stackLevel;
|
|
HB_ULONG keyCount;
|
|
LPKEYINFO CurKeyInfo;
|
|
LPKEYINFO HotKeyInfo;
|
|
HB_BOOL HotFor;
|
|
|
|
struct _NTXINDEX * Owner;
|
|
} TAGINFO;
|
|
typedef TAGINFO * LPTAGINFO;
|
|
|
|
typedef struct _NTXINDEX
|
|
{
|
|
char * IndexName;
|
|
char * RealName;
|
|
HB_ULONG Version; /* The index VERSION filed to signal index updates for other stations */
|
|
HB_ULONG NextAvail;
|
|
HB_ULONG TagBlock; /* Index attr, next free page */
|
|
struct _NTXAREA * Owner;
|
|
PHB_FILE DiskFile;
|
|
HB_BOOL fDelete; /* delete on close flag */
|
|
HB_BOOL fReadonly;
|
|
HB_BOOL fShared;
|
|
HB_BOOL fFlush;
|
|
HB_BOOL LargeFile;
|
|
HB_BOOL Changed;
|
|
HB_BOOL Update;
|
|
HB_BOOL Compound;
|
|
HB_BOOL Production; /* Production index */
|
|
HB_FOFFSET ulLockPos; /* readlock position for CL53 lock scheme */
|
|
int lockWrite; /* number of write lock set */
|
|
int lockRead; /* number of read lock set */
|
|
|
|
HB_BYTE * HeaderBuff; /* TODO: make it member */
|
|
HB_BOOL fValidHeader;
|
|
int iTags;
|
|
LPTAGINFO * lpTags;
|
|
|
|
HB_ULONG ulPages;
|
|
HB_ULONG ulPageLast;
|
|
HB_ULONG ulPagesDepth;
|
|
LPPAGEINFO *pages;
|
|
LPPAGEINFO pChanged;
|
|
LPPAGEINFO pFirst;
|
|
LPPAGEINFO pLast;
|
|
|
|
struct _NTXINDEX * pNext; /* The next index in the list */
|
|
} NTXINDEX;
|
|
typedef NTXINDEX * LPNTXINDEX;
|
|
|
|
/* for index creation */
|
|
typedef struct
|
|
{
|
|
HB_FOFFSET nOffset; /* offset in temporary file */
|
|
HB_ULONG ulKeys; /* number of keys in page */
|
|
HB_ULONG ulKeyBuf; /* number of keys in memory buffer */
|
|
HB_ULONG ulCurKey; /* current key in memory buffer */
|
|
HB_BYTE * pKeyPool; /* memory buffer */
|
|
} NTXSWAPPAGE;
|
|
typedef NTXSWAPPAGE * LPNTXSWAPPAGE;
|
|
|
|
typedef struct
|
|
{
|
|
LPTAGINFO pTag; /* current Tag */
|
|
HB_FHANDLE hTempFile; /* handle to temporary file */
|
|
char * szTempFileName; /* temporary file name */
|
|
int keyLen; /* key length */
|
|
HB_BOOL fUnique; /* HB_TRUE if index is unique */
|
|
HB_BOOL fReindex; /* HB_TRUE if reindexing is in process */
|
|
HB_ULONG ulMaxRec; /* the highest record number */
|
|
HB_ULONG ulTotKeys; /* total number of keys indexed */
|
|
HB_ULONG ulKeys; /* keys in curently created page */
|
|
HB_ULONG ulPages; /* number of pages */
|
|
HB_ULONG ulCurPage; /* current page */
|
|
HB_ULONG ulPgKeys; /* maximum number of key in page memory buffer */
|
|
HB_ULONG ulMaxKey; /* maximum number of keys in single page */
|
|
HB_BYTE * pKeyPool; /* memory buffer for current page then for pages */
|
|
HB_BYTE * pStartKey; /* begining of key pool after sorting */
|
|
LPNTXSWAPPAGE pSwapPage; /* list of pages */
|
|
LPPAGEINFO NodeList[ NTX_STACKSIZE ]; /* Stack of pages */
|
|
HB_ULONG ulFirst;
|
|
HB_ULONG * pSortedPages;
|
|
HB_BYTE pLastKey[ NTX_MAX_KEY ]; /* last key val */
|
|
HB_ULONG ulLastRec;
|
|
|
|
HB_BYTE * pBuffIO; /* index IO buffer */
|
|
HB_ULONG ulSizeIO; /* size of IO buffer in index pages */
|
|
HB_ULONG ulPagesIO; /* number of index pages in buffer */
|
|
HB_ULONG ulFirstIO; /* first page in buffer */
|
|
HB_ULONG ulLastIO; /* last page in buffer */
|
|
} NTXSORTINFO;
|
|
typedef NTXSORTINFO * LPNTXSORTINFO;
|
|
|
|
/*
|
|
* DBF WORKAREA
|
|
* ------------
|
|
* The Workarea Structure of DBFNTX RDD
|
|
*
|
|
*/
|
|
|
|
typedef struct _NTXAREA
|
|
{
|
|
DBFAREA dbfarea;
|
|
|
|
/*
|
|
* NTX's additions to the workarea structure
|
|
*
|
|
* Warning: The above section MUST match DBFAREA exactly! Any
|
|
* additions to the structure MUST be added below, as in this
|
|
* example.
|
|
*/
|
|
|
|
HB_BOOL fNtxAppend; /* HB_TRUE if new record is added */
|
|
HB_BOOL fSetTagNumbers; /* Tag number should be recreated */
|
|
LPNTXINDEX lpIndexes; /* Pointer to list of indexes */
|
|
LPTAGINFO lpCurTag; /* Pointer to current order */
|
|
LPNTXSORTINFO pSort; /* Index build structure */
|
|
|
|
} NTXAREA;
|
|
typedef NTXAREA * LPNTXAREA;
|
|
|
|
#ifndef NTXAREAP
|
|
#define NTXAREAP LPNTXAREA
|
|
#endif
|
|
|
|
#undef SUPERTABLE
|
|
#define SUPERTABLE ( &ntxSuper )
|
|
|
|
HB_EXTERN_END
|
|
|
|
#endif /* HB_RDDNTX_H_ */
|