/*-------------------------------------------------------------------------* * * * btree.h - definitions for access to B-tree Toolkit * * * * COPYRIGHT (C) 1990 Jensen and Partners. All Rights Reserved * * * *--------------------------------------------------------------------------*/ #ifndef _BTREE_DEF #define _BTREE_DEF #include #pragma save #pragma name(prefix=>"") #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #define MAXKEYSIZE 128 #define LOCKQSIZE 20 typedef enum {FixSize,Size16,Size32,NoDealoc,Compress} AccessMode; typedef enum {Less,Eq,Greater} CmpRes; typedef CmpRes (* CompareFunction)(const void * a1, const void * a2); typedef void (* KeyFunction)(void * k, const void * r); typedef const void * FHandle; typedef struct { FHandle ID; unsigned In; } IHandle; typedef enum {OK, BadOpen, NoSlot, NotFHandle, NotIHandle, NotData, NotIndex, BadIndex, BadSize, KeyTooBig, ErrDupKey, BadFree, BadRead, BadWrite, Locked, NotLocked, FileError, LockOverflow, UnknownError} Errors; typedef void (* ErrorProc)(Errors, unsigned, const char[]); extern ErrorProc Btree@ErrorHandler; extern const IHandle Btree@Null; FHandle Btree$Open(const char Name[], unsigned MaxIHandle, AccessMode AMode, unsigned char readOnly, unsigned char shared, unsigned char Create); IHandle Btree$OpenData(FHandle F, unsigned I, unsigned RecordSize, unsigned char New); IHandle Btree$OpenIndex(FHandle F, IHandle D, unsigned I, CompareFunction CompFct, KeyFunction KeyFct, unsigned KeySize, unsigned char DupKey, unsigned char New); void Btree$Close(FHandle * F); void Btree$FreeIHandle(IHandle * F); void Btree$Flush(FHandle F); Errors Btree$LastError(IHandle H); Errors Btree$LastFError(FHandle F); void Btree$Add(IHandle D, const void * Data, unsigned Length); void Btree$AddIndex(IHandle I, const void * Key, unsigned long DataLoc); void Btree$Delete(IHandle D); void Btree$DeleteIndex(IHandle I, const void * Key, unsigned long DataLoc); void Btree$Change(IHandle D, const void * Data, unsigned Length); unsigned char Btree$Find(IHandle I, const void * Key, void * Data); unsigned char Btree$FindIndex(IHandle I, const void * Key, unsigned long * DataLoc); unsigned char Btree$Search(IHandle I, const void * Key, void * Data); unsigned char Btree$SearchIndex(IHandle I, const void * Key, unsigned long * DataLoc); unsigned char Btree$Next(IHandle I, void * Data); unsigned char Btree$NextIndex(IHandle I, unsigned long * DataLoc); unsigned char Btree$Prev(IHandle I, void * Data); unsigned char Btree$PrevIndex(IHandle I, unsigned long * DataLoc); void Btree$Reset(IHandle H); void Btree$SetSyncMode(IHandle D, unsigned char On); void Btree$ClearIndex(IHandle * I); void Btree$Release(IHandle H); unsigned char Btree$Lock(FHandle F, unsigned long DataLoc); void Btree$UnLock(FHandle F, unsigned long DataLoc); unsigned char Btree$LockIHandle(IHandle H); void Btree$UnLockIHandle(IHandle H); unsigned long Btree$Allocate(FHandle F, unsigned long Length); void Btree$DeAllocate(FHandle F, unsigned long DataLoc); void Btree$Read(FHandle F, unsigned long Position, unsigned Length, void * Data); void Btree$Write(FHandle F, unsigned long Position, unsigned Length, const void * Data); unsigned long Btree$LastRef(IHandle H); unsigned long Btree$RecordCount(IHandle D); extern char Btree$[]; #define NO_ERROR 0 #define DISK_FULL (-1) #define PAST_EOF (DISK_FULL-1) #define INVALID_PARAMETER 87 typedef unsigned File; typedef struct { unsigned long pos, len; } LockRec; typedef unsigned (* CountProc)(void); typedef void (* DelayProc)(void); typedef enum {_multi_yes,_multi_no,_multi_file} MultiMode; typedef LockRec * LockRecPtr; extern const LockRecPtr FIOx@NULL; extern CountProc FIOx@RetryCount; extern DelayProc FIOx@Delay; unsigned char FIOx$Multi(void); unsigned char FIOx$Lock(File f, LockRec x); void FIOx$UnLock(File f, LockRec x); unsigned char FIOx$LockRange(File f, unsigned HIGH, const LockRec x[]); void FIOx$UnLockRange(File f, unsigned HIGH, const LockRec x[]); File FIOx$Open(const char Name[], unsigned char Share, unsigned char ReadOnly, unsigned char Create); void FIOx$Close(File * f); void FIOx$Read(File f, void * b, unsigned c); void FIOx$Write(File f, const void * b, unsigned c); void FIOx$Truncate(File f, unsigned long l); void FIOx$Seek(File f, unsigned long p); unsigned long FIOx$Size(File f); void FIOx$Flush(File f); unsigned FIOx$Error(void); extern char FIOx$[]; #define PACK_BUF_SIZE 0x3800 typedef unsigned char pack_buf[(PACK_BUF_SIZE/4)*5]; unsigned apack2$reset_count; unsigned apack2$collision_count; pack_buf apack2$packed$buf; unsigned apack2$Pack(unsigned n, const void far * in); void apack2$Unpack(unsigned n, void far * out); unsigned apack2$CheckSum(unsigned n, const void far * a); #if defined(M_I86CM) | defined(M_I86LM) | defined(M_I86XM) | defined(M_I86MTM) extern char Pack$[]; #endif #pragma restore #endif