update of dbfcdx RDD, (semi) working ordlistadd, gotop, bottom, skip, seek
This commit is contained in:
File diff suppressed because it is too large
Load Diff
173
harbour/source/rdd/dbfcdx/dbfcdx1.h
Normal file
173
harbour/source/rdd/dbfcdx/dbfcdx1.h
Normal file
@@ -0,0 +1,173 @@
|
||||
|
||||
//#define LOCK_START 0x40000000L
|
||||
//#define LOCK_APPEND 0x7FFFFFFEL
|
||||
//#define LOCK_FILE 0x3FFFFFFFL
|
||||
//#define MEMO_BLOCK 64
|
||||
//#define CDX_MAX_KEY 240
|
||||
//#define CDX_MAX_TAG_NAME_LEN 10
|
||||
//#define CDX_BLOCK_SIZE 512
|
||||
#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
|
||||
#define PAGE_NODE 2
|
||||
#define PAGE_LEAF 3
|
||||
#define TOP_RECORD 1
|
||||
#define BTTM_RECORD 2
|
||||
#define PREV_RECORD 3
|
||||
#define NEXT_RECORD 4
|
||||
#define SORT_CHUNK_LIMIT 16384
|
||||
#define SORT_ACTIVE_LIST 0
|
||||
#define SORT_END_OF_KEY 1
|
||||
#define SORT_END_OF_WORD 2
|
||||
#define SORT_STACK_OF_CHAR 3
|
||||
|
||||
|
||||
#if (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
|
||||
#pragma option -a1 /* byte alignment */
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
USHORT FreeSpace;
|
||||
LONG RecNumMask;
|
||||
BYTE DupCntMask;
|
||||
BYTE TrlCntMask;
|
||||
BYTE RecNumBits;
|
||||
BYTE DupCntBits;
|
||||
BYTE TrlCntBits;
|
||||
BYTE ShortBytes;
|
||||
BYTE ExtData[ CDX_EXTERNAL_SPACE ];
|
||||
} CDXEXTERNAL;
|
||||
typedef struct
|
||||
{
|
||||
BYTE IntData[ CDX_INTERNAL_SPACE ];
|
||||
} CDXINTERNAL;
|
||||
typedef struct _CDXDATA
|
||||
{
|
||||
USHORT Node_Atr;
|
||||
USHORT Entry_Ct;
|
||||
LONG Left_Ptr;
|
||||
LONG Rght_Ptr;
|
||||
union
|
||||
{
|
||||
CDXEXTERNAL External;
|
||||
CDXINTERNAL Internal;
|
||||
} cdxu;
|
||||
} CDXDATA;
|
||||
#if (__BORLANDC__ > 1040) /* Use this only above Borland C++ 3.1 */
|
||||
#pragma option -a /* default alignment */
|
||||
#endif
|
||||
typedef CDXDATA * LPCDXDATA;
|
||||
|
||||
typedef struct _KEYINFO
|
||||
{
|
||||
PHB_ITEM pItem;
|
||||
LONG Tag;
|
||||
LONG Xtra;
|
||||
struct _KEYINFO * pNext;
|
||||
} KEYINFO;
|
||||
typedef KEYINFO * LPKEYINFO;
|
||||
|
||||
typedef struct HB_PAGEINFO_STRU
|
||||
{
|
||||
LONG Page;
|
||||
LONG Left;
|
||||
LONG Right;
|
||||
BOOL Changed;
|
||||
BOOL NewRoot;
|
||||
BOOL LastEntry;
|
||||
BOOL Reload;
|
||||
BOOL ChkBOF;
|
||||
BOOL ChkEOF;
|
||||
BYTE PageType;
|
||||
LONG RNMask;
|
||||
BYTE ReqByte;
|
||||
BYTE RNBits;
|
||||
BYTE DCBits;
|
||||
BYTE TCBits;
|
||||
BYTE DCMask;
|
||||
BYTE TCMask;
|
||||
USHORT Space;
|
||||
LPKEYINFO pKeys;
|
||||
USHORT uiKeys;
|
||||
SHORT CurKey;
|
||||
struct HB_PAGEINFO_STRU * Owner;
|
||||
struct HB_PAGEINFO_STRU * Child;
|
||||
struct _CDXTAG * TagParent;
|
||||
} HB_PAGEINFO;
|
||||
typedef HB_PAGEINFO * LPPAGEINFO;
|
||||
|
||||
|
||||
/*SORT stuff*/
|
||||
typedef struct
|
||||
{
|
||||
char Character;
|
||||
BYTE NUse;
|
||||
USHORT WordArray;
|
||||
USHORT Fill02;
|
||||
USHORT LevelLink;
|
||||
} SORT_A;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE Fill03[ 4 ];
|
||||
char ChrStack[ 4 ];
|
||||
} SORT_B;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LONG Fill04;
|
||||
LONG ChrFill;
|
||||
} SORT_C;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
SORT_A A;
|
||||
SORT_B B;
|
||||
SORT_C C;
|
||||
} sortu;
|
||||
} SORTDATA;
|
||||
|
||||
typedef SORTDATA * LPSORTDATA;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LONG WordCount;
|
||||
LONG RootLink;
|
||||
LONG LevelPtr;
|
||||
LONG PriorPtr;
|
||||
LONG KeyTot;
|
||||
LONG KeyCnt;
|
||||
LONG LastTag;
|
||||
LONG * ChunkList;
|
||||
BYTE * SortBuffer;
|
||||
USHORT SortChunk;
|
||||
USHORT NodeLimit;
|
||||
USHORT NodeMask;
|
||||
USHORT NodeShift;
|
||||
USHORT ChunkSize;
|
||||
USHORT ChunkLimit;
|
||||
USHORT ChunkCur;
|
||||
USHORT NodeCur;
|
||||
USHORT KeySize;
|
||||
USHORT WCur;
|
||||
BOOL Unique;
|
||||
BOOL Ascend;
|
||||
BOOL Closing;
|
||||
char WPch[ 256 ];
|
||||
SORTDATA * WAdr;
|
||||
struct _CDXTAG * CurTag;
|
||||
LPCDXDATA NodeList[ 32 ];
|
||||
LPKEYINFO KeyWork;
|
||||
LPKEYINFO LastKey;
|
||||
} SORTINFO;
|
||||
|
||||
typedef SORTINFO * LPSORTINFO;
|
||||
77
harbour/source/rdd/dbfcdx/dbfcdx2.h
Normal file
77
harbour/source/rdd/dbfcdx/dbfcdx2.h
Normal file
@@ -0,0 +1,77 @@
|
||||
|
||||
static LPKEYINFO hb_cdxKeyNew( void );
|
||||
static void hb_cdxKeyFree( LPKEYINFO pKey );
|
||||
static int hb_cdxKeyCompare( LPKEYINFO pKey1, LPKEYINFO pKey2, USHORT * EndPos, 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 );
|
||||
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, LPPAGEINFO pPage );
|
||||
static void hb_cdxTagKeyRead( LPCDXTAG pTag, BYTE bTypRead );
|
||||
static void hb_cdxTagKeyAdd( LPCDXTAG pTag, LPKEYINFO pKey );
|
||||
static void hb_cdxTagPageStore( LPCDXTAG pTag, LPPAGEINFO PIK );
|
||||
static void hb_cdxTagExtNodeWrite( LPCDXTAG pTag, LONG PN, LPCDXDATA pData, LPPAGEINFO PIK );
|
||||
static USHORT hb_cdxTagFillExternalNode( LPCDXTAG pTag, LPCDXDATA pData, LPPAGEINFO PIK,
|
||||
USHORT kcnt, USHORT ck, LPKEYINFO * p );
|
||||
static void hb_cdxTagExtNodeBuild( LPCDXTAG pTag, LPCDXDATA pData, LPPAGEINFO pPage );
|
||||
static void hb_cdxTagTagLoad( LPCDXTAG pTag );
|
||||
static void hb_cdxTagSetRoot( LPCDXTAG pTag, LPPAGEINFO PIK );
|
||||
static void hb_cdxTagIntNodeWrite( LPCDXTAG pTag, LONG PN, LPCDXDATA pData, LPPAGEINFO PIK );
|
||||
static USHORT hb_cdxTagFillInternalNode( LPCDXTAG pTag, LPCDXDATA pData, LPPAGEINFO PIK,
|
||||
USHORT kcnt, USHORT ck, LPKEYINFO * p );
|
||||
static void hb_cdxTagIntNodeBuild( LPCDXTAG pTag, LPCDXDATA pData, LPPAGEINFO pPage );
|
||||
static LONG hb_cdxTagKeyFind( LPCDXTAG pTag, LPKEYINFO pKey );
|
||||
|
||||
static LPPAGEINFO hb_cdxPageNew( LPCDXTAG PIT, LPPAGEINFO PIK, LONG FilePosn );
|
||||
static void hb_cdxPageFree( LPPAGEINFO pPage );
|
||||
static BOOL hb_cdxPageReadTopKey( LPPAGEINFO pPage );
|
||||
static BOOL hb_cdxPageReadBottomKey( LPPAGEINFO pPage );
|
||||
static int hb_cdxPageSeekKey( LPPAGEINFO pPage, LONG lBlock, LPKEYINFO pKey, BOOL bExact );
|
||||
static void hb_cdxPageInsertKey( LPPAGEINFO pPage, LPKEYINFO pKey, BOOL bAddAfter );
|
||||
static void hb_cdxPagePageStore( LPPAGEINFO pPage );
|
||||
static BOOL hb_cdxPageReadNextKey( LPPAGEINFO pPage );
|
||||
static BOOL hb_cdxPageReadPrevKey( LPPAGEINFO pPage );
|
||||
static LPKEYINFO hb_cdxPageGetKey( LPPAGEINFO pPage, USHORT uiKey );
|
||||
static void hb_cdxPagePageLoad( LPPAGEINFO pPage );
|
||||
static int hb_cdxPageRetrieveKey( LPPAGEINFO pPage, LPKEYINFO pKey );
|
||||
static void hb_cdxPageAddNodeKey( LPPAGEINFO pPage, LPKEYINFO pKey );
|
||||
static int hb_cdxPageSeekNodeTag( LPPAGEINFO pPage, LONG Tag );
|
||||
static BOOL hb_cdxPageGetChild( LPPAGEINFO pPage, LONG Tag );
|
||||
static void hb_cdxPageDeleteKey( LPPAGEINFO pPage );
|
||||
|
||||
static LPCDXINDEX hb_cdxIndexNew( AREAP pArea );
|
||||
static void hb_cdxIndexFree( LPCDXINDEX pIndex );
|
||||
static LONG hb_cdxIndexGetAvailPage( LPCDXINDEX pIndex );
|
||||
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 void hb_cdxIndexAddTag( LPCDXINDEX pIndex, char * szTagName, char * szKeyExp,
|
||||
PHB_ITEM pKeyItem, BYTE bType, USHORT uiLen, char * szForExp,
|
||||
PHB_ITEM pForItem, BOOL bAscending, BOOL bUnique );
|
||||
|
||||
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 );
|
||||
static void hb_cdxSortStuffKey( LPSORTINFO pSort, LPSORTDATA * wx );
|
||||
static void hb_cdxSortGetNode( LPSORTINFO pSort, char Character, LONG * NewLink );
|
||||
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, char * Value );
|
||||
static void hb_cdxSortOutputWord( LPSORTINFO pSort, LONG Tag, char * Value );
|
||||
static void hb_cdxSortAddToNode( LPSORTINFO pSort, USHORT Lvl, LONG Tag, LONG Link,
|
||||
LPKEYINFO Value );
|
||||
static void hb_cdxSortAddExternal( LPSORTINFO pSort, USHORT Lvl, LONG Tag, LONG Link,
|
||||
LPKEYINFO Value );
|
||||
static void hb_cdxSortAddInternal( LPSORTINFO pSort, USHORT Lvl, LONG Tag, LONG Link,
|
||||
LPKEYINFO Value );
|
||||
Reference in New Issue
Block a user