BTREE.H 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*-------------------------------------------------------------------------*
  2. * *
  3. * btree.h - definitions for access to B-tree Toolkit *
  4. * *
  5. * COPYRIGHT (C) 1990 Jensen and Partners. All Rights Reserved *
  6. * *
  7. *--------------------------------------------------------------------------*/
  8. #ifndef _BTREE_DEF
  9. #define _BTREE_DEF
  10. #include <stddef.h>
  11. #pragma save
  12. #pragma name(prefix=>"")
  13. #ifndef TRUE
  14. #define TRUE 1
  15. #endif
  16. #ifndef FALSE
  17. #define FALSE 0
  18. #endif
  19. #define MAXKEYSIZE 128
  20. #define LOCKQSIZE 20
  21. typedef enum {FixSize,Size16,Size32,NoDealoc,Compress} AccessMode;
  22. typedef enum {Less,Eq,Greater} CmpRes;
  23. typedef CmpRes (* CompareFunction)(const void * a1, const void * a2);
  24. typedef void (* KeyFunction)(void * k, const void * r);
  25. typedef const void * FHandle;
  26. typedef struct {
  27. FHandle ID;
  28. unsigned In;
  29. } IHandle;
  30. typedef enum {OK, BadOpen, NoSlot, NotFHandle, NotIHandle, NotData, NotIndex,
  31. BadIndex, BadSize, KeyTooBig, ErrDupKey, BadFree, BadRead,
  32. BadWrite, Locked, NotLocked, FileError, LockOverflow,
  33. UnknownError} Errors;
  34. typedef void (* ErrorProc)(Errors, unsigned, const char[]);
  35. extern ErrorProc Btree@ErrorHandler;
  36. extern const IHandle Btree@Null;
  37. FHandle Btree$Open(const char Name[], unsigned MaxIHandle, AccessMode AMode, unsigned char readOnly, unsigned char shared, unsigned char Create);
  38. IHandle Btree$OpenData(FHandle F, unsigned I, unsigned RecordSize, unsigned char New);
  39. IHandle Btree$OpenIndex(FHandle F, IHandle D, unsigned I, CompareFunction CompFct, KeyFunction KeyFct, unsigned KeySize, unsigned char DupKey, unsigned char New);
  40. void Btree$Close(FHandle * F);
  41. void Btree$FreeIHandle(IHandle * F);
  42. void Btree$Flush(FHandle F);
  43. Errors Btree$LastError(IHandle H);
  44. Errors Btree$LastFError(FHandle F);
  45. void Btree$Add(IHandle D, const void * Data, unsigned Length);
  46. void Btree$AddIndex(IHandle I, const void * Key, unsigned long DataLoc);
  47. void Btree$Delete(IHandle D);
  48. void Btree$DeleteIndex(IHandle I, const void * Key, unsigned long DataLoc);
  49. void Btree$Change(IHandle D, const void * Data, unsigned Length);
  50. unsigned char Btree$Find(IHandle I, const void * Key, void * Data);
  51. unsigned char Btree$FindIndex(IHandle I, const void * Key, unsigned long * DataLoc);
  52. unsigned char Btree$Search(IHandle I, const void * Key, void * Data);
  53. unsigned char Btree$SearchIndex(IHandle I, const void * Key, unsigned long * DataLoc);
  54. unsigned char Btree$Next(IHandle I, void * Data);
  55. unsigned char Btree$NextIndex(IHandle I, unsigned long * DataLoc);
  56. unsigned char Btree$Prev(IHandle I, void * Data);
  57. unsigned char Btree$PrevIndex(IHandle I, unsigned long * DataLoc);
  58. void Btree$Reset(IHandle H);
  59. void Btree$SetSyncMode(IHandle D, unsigned char On);
  60. void Btree$ClearIndex(IHandle * I);
  61. void Btree$Release(IHandle H);
  62. unsigned char Btree$Lock(FHandle F, unsigned long DataLoc);
  63. void Btree$UnLock(FHandle F, unsigned long DataLoc);
  64. unsigned char Btree$LockIHandle(IHandle H);
  65. void Btree$UnLockIHandle(IHandle H);
  66. unsigned long Btree$Allocate(FHandle F, unsigned long Length);
  67. void Btree$DeAllocate(FHandle F, unsigned long DataLoc);
  68. void Btree$Read(FHandle F, unsigned long Position, unsigned Length, void * Data);
  69. void Btree$Write(FHandle F, unsigned long Position, unsigned Length, const void * Data);
  70. unsigned long Btree$LastRef(IHandle H);
  71. unsigned long Btree$RecordCount(IHandle D);
  72. extern char Btree$[];
  73. #define NO_ERROR 0
  74. #define DISK_FULL (-1)
  75. #define PAST_EOF (DISK_FULL-1)
  76. #define INVALID_PARAMETER 87
  77. typedef unsigned File;
  78. typedef struct {
  79. unsigned long pos, len;
  80. } LockRec;
  81. typedef unsigned (* CountProc)(void);
  82. typedef void (* DelayProc)(void);
  83. typedef enum {_multi_yes,_multi_no,_multi_file} MultiMode;
  84. typedef LockRec * LockRecPtr;
  85. extern const LockRecPtr FIOx@NULL;
  86. extern CountProc FIOx@RetryCount;
  87. extern DelayProc FIOx@Delay;
  88. unsigned char FIOx$Multi(void);
  89. unsigned char FIOx$Lock(File f, LockRec x);
  90. void FIOx$UnLock(File f, LockRec x);
  91. unsigned char FIOx$LockRange(File f, unsigned HIGH, const LockRec x[]);
  92. void FIOx$UnLockRange(File f, unsigned HIGH, const LockRec x[]);
  93. File FIOx$Open(const char Name[], unsigned char Share, unsigned char ReadOnly, unsigned char Create);
  94. void FIOx$Close(File * f);
  95. void FIOx$Read(File f, void * b, unsigned c);
  96. void FIOx$Write(File f, const void * b, unsigned c);
  97. void FIOx$Truncate(File f, unsigned long l);
  98. void FIOx$Seek(File f, unsigned long p);
  99. unsigned long FIOx$Size(File f);
  100. void FIOx$Flush(File f);
  101. unsigned FIOx$Error(void);
  102. extern char FIOx$[];
  103. #define PACK_BUF_SIZE 0x3800
  104. typedef unsigned char pack_buf[(PACK_BUF_SIZE/4)*5];
  105. unsigned apack2$reset_count;
  106. unsigned apack2$collision_count;
  107. pack_buf apack2$packed$buf;
  108. unsigned apack2$Pack(unsigned n, const void far * in);
  109. void apack2$Unpack(unsigned n, void far * out);
  110. unsigned apack2$CheckSum(unsigned n, const void far * a);
  111. #if defined(M_I86CM) | defined(M_I86LM) | defined(M_I86XM) | defined(M_I86MTM)
  112. extern char Pack$[];
  113. #endif
  114. #pragma restore
  115. #endif
  116.