TSBTRV.DEF 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. (* Release 3.10 *)
  2. (*-------------------------------------------------------------------------*
  3. * *
  4. * TopSpeed Modula-2 Interface for BTRIEVE - Supports TopSpeed Extender *
  5. * Public Domain - May be used without restriction *
  6. * *
  7. *--------------------------------------------------------------------------*)
  8. DEFINITION MODULE TSBTRV;
  9. (* Data types *)
  10. TYPE
  11. StatusCodes = (
  12. (* 0 *) OK,BadOpcode,IOError,NoOpen,KeyNotFound,
  13. (* 5 *) DuplicateKey,InvalidKey,ChangedKey,InvalidPosition,EndOfFile,
  14. (* 10 *) NonModifiable,BadFileName,FileNotFound,ExtensionError,PreOpenError,
  15. (* 15 *) PreImageError,ExpansionError,CloseError,DiskFull,Unrecoverable,
  16. (* 20 *) BtrieveAbsent,KeyBufferSize,RecBufferSize,PosBlockSize,PageSize,
  17. (* 25 *) CreateError,KeySegments,KeyPosition,RecLength,KeyLength,
  18. (* 30 *) NotBtrieveFile,AlreadyExtended,CantExtend,Err33,BadExtendName,
  19. (* 35 *) DirectoryError,TransactError,NestedTransact,TransactControl,EndAbortError,
  20. (* 40 *) TransactMaximum,TransactFileErr,AccelFailure,BadRecAddress,NullKeyPath,
  21. (* 45 *) BadKeySpecs,AccessDenied,MaxOpenFiles,BadCollation,CollationKeyType,
  22. (* 50 *) OwnerSet,InvalidOwner,CacheWriteError,BadBtInterface,BadVariablePage,
  23. (* 55 *) AutoIncErr, IncompleteIndex, EMSErr, CompressBufTooShort,FileAlreadyExists,
  24. (* 60 *) Err60,Err61,Err62,Err63,Err64,
  25. (* 65 *) Err65,Err66,Err67,Err68,Err69,
  26. (* 70 *) Err70,Err71,Err72,Err73,Err74,
  27. (* 75 *) Err75,Err76,Err77,Err78,Err79,
  28. (* 80 *) AccessConflict,LockFailed,LostPosition,UnreadTransact,RecInUse,
  29. (* 85 *) FileInUse,FileTableFull,HandleTableFull,OpenModeError,DeviceNameError,
  30. (* 90 *) DeviceTableFull,ServerError,TransactTabFull,IncompatibleLockType,PermissionErr,
  31. (* 99 *) SessionNoLongerValid, ComEnvErr,DataBufTooSmall,InternalTransactionErr, DemoVersion
  32. );
  33. FileControlBlock = ARRAY[0..127] OF BYTE;
  34. KeyType = ARRAY[0..255] OF CHAR;
  35. OwnerType = ARRAY[0..7] OF CHAR;
  36. VAR
  37. StatusCode : StatusCodes; (* Status of last operation *)
  38. (* Btrieve functions - function number in brackets *)
  39. PROCEDURE AbortTransaction;
  40. (* Terminate transaction and abort all associated file operations (#21) *)
  41. PROCEDURE BeginTransaction;
  42. (* Mark beginning of a set of file operations (#19) *)
  43. PROCEDURE ClearOwner(VAR FileControl : FileControlBlock);
  44. (* Remove owner name associated with file (#30) *)
  45. PROCEDURE Close(VAR FileControl : FileControlBlock);
  46. (* Close a file (#1) *)
  47. PROCEDURE Create( VAR FileControl : FileControlBlock;
  48. FileDescriptor : ARRAY OF BYTE;
  49. DescriptorLength : CARDINAL;
  50. FileName : ARRAY OF CHAR);
  51. (* Create a file (#14) *)
  52. PROCEDURE DeleteRec(VAR FileControl : FileControlBlock; KeyID : SHORTCARD);
  53. (* Delete a record from a file (#4) *)
  54. PROCEDURE EndTransaction;
  55. (* Mark the end of a set of related file operations (#20) *)
  56. PROCEDURE Extend(VAR FileControl : FileControlBlock; FileName : ARRAY OF CHAR;
  57. UseNow : BOOLEAN);
  58. (* Extend a file to a second logical disk drive (#16) *)
  59. PROCEDURE FindEQ(VAR FileControl : FileControlBlock;
  60. VAR KeyBuffer : ARRAY OF BYTE;
  61. KeyID : SHORTCARD);
  62. (* Find record with key value equal to given key (#55) *)
  63. PROCEDURE FindGT(VAR FileControl : FileControlBlock;
  64. VAR KeyBuffer : ARRAY OF BYTE;
  65. KeyID : SHORTCARD);
  66. (* Find record with key value greater than given key (#58) *)
  67. PROCEDURE FindGE(VAR FileControl : FileControlBlock;
  68. VAR KeyBuffer : ARRAY OF BYTE;
  69. KeyID : SHORTCARD);
  70. (* Find record with key value greater than or equal to given key (#59) *)
  71. PROCEDURE FindLast(VAR FileControl : FileControlBlock;
  72. VAR KeyBuffer : ARRAY OF BYTE;
  73. KeyID : SHORTCARD);
  74. (* Find record with highest key value for given key (#63) *)
  75. PROCEDURE FindLT(VAR FileControl : FileControlBlock;
  76. VAR KeyBuffer : ARRAY OF BYTE;
  77. KeyID : SHORTCARD);
  78. (* Find record with key value lower than given key (#60) *)
  79. PROCEDURE FindLE(VAR FileControl : FileControlBlock;
  80. VAR KeyBuffer : ARRAY OF BYTE;
  81. KeyID : SHORTCARD);
  82. (* Find record with key value less than or equal to given key (#61) *)
  83. PROCEDURE FindFirst(VAR FileControl : FileControlBlock;
  84. VAR KeyBuffer : ARRAY OF BYTE;
  85. KeyID : SHORTCARD);
  86. (* Find record with lowest key value for given key (#62) *)
  87. PROCEDURE FindNext(VAR FileControl : FileControlBlock;
  88. VAR KeyBuffer : ARRAY OF BYTE;
  89. KeyID : SHORTCARD);
  90. (* Find record with next key value for given key (#56) *)
  91. PROCEDURE FindPrev(VAR FileControl : FileControlBlock;
  92. VAR KeyBuffer : ARRAY OF BYTE;
  93. KeyID : SHORTCARD);
  94. (* Find record with previous key value for given key (#57) *)
  95. PROCEDURE GetDirect(VAR FileControl : FileControlBlock;
  96. VAR DataBuffer : ARRAY OF BYTE;
  97. VAR BufferLength : CARDINAL;
  98. VAR KeyBuffer : ARRAY OF BYTE;
  99. KeyID : SHORTCARD);
  100. (* Get a record by physical address (#23) *)
  101. PROCEDURE GetDir(Drive : SHORTCARD; VAR DirName : ARRAY OF CHAR);
  102. (* Get current directory for drive (#28) *)
  103. PROCEDURE GetEQ(VAR FileControl : FileControlBlock;
  104. VAR DataBuffer : ARRAY OF BYTE;
  105. VAR BufferLength : CARDINAL;
  106. VAR KeyBuffer : ARRAY OF BYTE;
  107. KeyID : SHORTCARD);
  108. (* Get record with key value equal to given key (#5) *)
  109. PROCEDURE GetGT(VAR FileControl : FileControlBlock;
  110. VAR DataBuffer : ARRAY OF BYTE;
  111. VAR BufferLength : CARDINAL;
  112. VAR KeyBuffer : ARRAY OF BYTE;
  113. KeyID : SHORTCARD);
  114. (* Get record with key value greater than given key (#8) *)
  115. PROCEDURE GetGE(VAR FileControl : FileControlBlock;
  116. VAR DataBuffer : ARRAY OF BYTE;
  117. VAR BufferLength : CARDINAL;
  118. VAR KeyBuffer : ARRAY OF BYTE;
  119. KeyID : SHORTCARD);
  120. (* Get record with key value greater than or equal to given key (#9) *)
  121. PROCEDURE GetLast(VAR FileControl : FileControlBlock;
  122. VAR DataBuffer : ARRAY OF BYTE;
  123. VAR BufferLength : CARDINAL;
  124. VAR KeyBuffer : ARRAY OF BYTE;
  125. KeyID : SHORTCARD);
  126. (* Get record with highest key value for given key (#13) *)
  127. PROCEDURE GetLT(VAR FileControl : FileControlBlock;
  128. VAR DataBuffer : ARRAY OF BYTE;
  129. VAR BufferLength : CARDINAL;
  130. VAR KeyBuffer : ARRAY OF BYTE;
  131. KeyID : SHORTCARD);
  132. (* Get record with key value lower than given key (#10) *)
  133. PROCEDURE GetLE(VAR FileControl : FileControlBlock;
  134. VAR DataBuffer : ARRAY OF BYTE;
  135. VAR BufferLength : CARDINAL;
  136. VAR KeyBuffer : ARRAY OF BYTE;
  137. KeyID : SHORTCARD);
  138. (* Get record with key value less than or equal to given key (#11) *)
  139. PROCEDURE GetFirst(VAR FileControl : FileControlBlock;
  140. VAR DataBuffer : ARRAY OF BYTE;
  141. VAR BufferLength : CARDINAL;
  142. VAR KeyBuffer : ARRAY OF BYTE;
  143. KeyID : SHORTCARD);
  144. (* Get record with lowest key value for given key (#12) *)
  145. PROCEDURE GetNext(VAR FileControl : FileControlBlock;
  146. VAR DataBuffer : ARRAY OF BYTE;
  147. VAR BufferLength : CARDINAL;
  148. VAR KeyBuffer : ARRAY OF BYTE;
  149. KeyID : SHORTCARD);
  150. (* Get record with next key value for given key (#6) *)
  151. PROCEDURE GetPosition(VAR FileControl :FileControlBlock;
  152. VAR pos : ARRAY OF BYTE);
  153. (* Return physical record position in given file (#22) *)
  154. PROCEDURE GetPrev(VAR FileControl : FileControlBlock;
  155. VAR DataBuffer : ARRAY OF BYTE;
  156. VAR BufferLength : CARDINAL;
  157. VAR KeyBuffer : ARRAY OF BYTE;
  158. KeyID : SHORTCARD);
  159. (* Get record with previous key value for given key (#7) *)
  160. PROCEDURE Insert(VAR FileControl : FileControlBlock;
  161. VAR DataBuffer : ARRAY OF BYTE;
  162. VAR BufferLength : CARDINAL;
  163. VAR KeyBuffer : ARRAY OF BYTE;
  164. KeyID : SHORTCARD);
  165. (* Add record with given key value (#2) *)
  166. PROCEDURE Open(VAR FileControl : FileControlBlock;
  167. FileName,OwnerName : ARRAY OF CHAR;
  168. OpenMode : SHORTCARD);
  169. (* Open a file with given file name in given mode (#0) *)
  170. PROCEDURE Reset;
  171. (* Release all resources and close all open files (#28) *)
  172. PROCEDURE SetDirectory(DirName : ARRAY OF CHAR);
  173. (* Set current directory to given name (#17) *)
  174. PROCEDURE SetOwner(VAR FileControl : FileControlBlock;
  175. OwnerName : ARRAY OF CHAR;
  176. AccessMode : SHORTCARD);
  177. (* Set owner name and subsequent access rights on given file (#29) *)
  178. PROCEDURE Status(VAR FileControl : FileControlBlock;
  179. VAR DataBuffer : ARRAY OF BYTE;
  180. VAR BufferLength : CARDINAL;
  181. VAR KeyBuffer : ARRAY OF BYTE;
  182. KeyID : SHORTCARD);
  183. (* Return file information for given file (#15) *)
  184. PROCEDURE StepDirect(VAR FileControl : FileControlBlock;
  185. VAR DataBuffer : ARRAY OF BYTE;
  186. VAR BufferLength : CARDINAL);
  187. (* Move to next physical record in file (#24) *)
  188. PROCEDURE Stop;
  189. (* Remove Btrieve file manager from memory (#25) *)
  190. PROCEDURE Update(VAR FileControl : FileControlBlock;
  191. VAR DataBuffer : ARRAY OF BYTE;
  192. VAR BufferLength : CARDINAL;
  193. VAR KeyBuffer : ARRAY OF BYTE;
  194. KeyID : SHORTCARD);
  195. (* Update a previously retrieved record (#3) *)
  196. PROCEDURE Version(VAR DataBuffer : ARRAY OF BYTE);
  197. (* Return Btrieve version number (#26) *)
  198. (* Low level interface to btree *)
  199. CONST
  200. opOpen = 0; opClose = 1; opInsert = 2;
  201. opUpdate = 3; opDelete = 4; opGetEQ = 5;
  202. opGetNext = 6; opGetPrev = 7; opGetGT = 8;
  203. opGetGE = 9; opGetLT = 10; opGetLE = 11;
  204. opGetFirst = 12; opGetLast = 13; opCreate = 14;
  205. opStat = 15; opExtend = 16; opSetDir = 17;
  206. opGetDir = 18; opBeginTrans = 19; opEndTrans = 20;
  207. opAbortTrans = 21; opGetPos = 22; opGetDirect = 23;
  208. opStepDirect = 24; opStop = 25; opVersion = 26;
  209. opUnlock = 27; opReset = 28; opSetOwner = 29;
  210. opClearOwner = 30; opCreateSupp = 31; opDropSupp = 32;
  211. opKeyOnly = 50; (* 'Get???? + opKeyOnly': Add ops 5..13 only ! *)
  212. PROCEDURE BTRV ( op: CARDINAL; (* Operation *)
  213. VAR pos: FileControlBlock; (* Position Block *)
  214. VAR data: ARRAY OF BYTE; (* Data Buffer *)
  215. VAR datalen: CARDINAL; (* Data Length *)
  216. VAR kbuf: ARRAY OF BYTE; (* Key Buffer *)
  217. key: SHORTCARD (* Key Number *)
  218. ): StatusCodes ; (* Btrieve error code *)
  219. END TSBTRV.
  220.