' ########################################################################################
' File: TRM.INC
' Contents: Include file for the Tsunami Record Manager (TRM.DLL), version 2.5
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_TRM_PBI)
#DEFINE PBX_TRM_PBI
%EQUATE `TRM_INC = 1
%EQUATE `CASE_SENSITIVE = 1
%EQUATE `NO_DUPLICATES = 2
%EQUATE `NO_COMPRESSION = 4
%EQUATE `BINARY_KEY = 8
%EQUATE `KEY_ONLY = 4096
%EQUATE `REBUILD_IDS = 2
' ========================================================================================
' Error codes
' ========================================================================================
%EQUATE `TRM_SUCCESSFUL = 0 ' // No error
%EQUATE `TRM_NOTTSUNAMIFILE = 1 ' // Not a Tsunami file
%EQUATE `TRM_IOERROR = 2 ' // I/O error
%EQUATE `TRM_FILENOTOPEN = 3 ' // File not open
%EQUATE `TRM_KEYNOTFOUND = 4 ' // Key not found
%EQUATE `TRM_DUPLICATEKEY = 5 ' // Duplicate key
%EQUATE `TRM_INVALIDKEY = 6 ' // Invalid key
%EQUATE `TRM_FILECORRUPT = 7 ' // File corrupt
%EQUATE `TRM_NOCURRENTPOS = 8 ' // No current position
%EQUATE `TRM_ENDOFFILE = 9 ' // End of file
%EQUATE `TRM_INVPAGESIZE = 10 ' // Invalid page size
%EQUATE `TRM_INVNOKEYSEGS = 11 ' // Invalid number of key segments
%EQUATE `TRM_INVFILEDEFSTR = 12 ' // Invalid file definition string
%EQUATE `TRM_INVKEYSEGPOS = 13 ' // Invalid key segment position
%EQUATE `TRM_INVKEYSEGLEN = 14 ' // Invalid key segment length
%EQUATE `TRM_INCKEYSEGDEF = 15 ' // Inconsistent key segment definitions
%EQUATE `TRM_INVRECORDLEN = 20 ' // Invalid record length
%EQUATE `TRM_INVRECORDADDR = 21 ' // Invalid record address
%EQUATE `TRM_LOSTRECORDPOS = 22 ' // Lost record position
%EQUATE `TRM_ACCESSDENIED = 30 ' // Access denied
%EQUATE `TRM_FILEEXISTS = 31 ' // File already exists
%EQUATE `TRM_NOMOREFILEHDLS = 32 ' // No more file handles
%EQUATE `TRM_MAXFILESOPEN = 33 ' // Maximum files opened
%EQUATE `TRM_ACCELACCDENIED = 40 ' // Acceleration access denied
%EQUATE `TRM_ACCELCACHEERR = 41 ' // Acceration cache error
%EQUATE `TRM_ACCESSFILEDEN = 46 ' // Access to file denied
%EQUATE `TRM_DATABUFTOSMALL = 50 ' // Data buffer too small
%EQUATE `TRM_TIMEOUT = 99 ' // Timeout
' ========================================================================================
' Tsunami 2.5 offers three APIs: A string-based API and two pointer-based APIs.
' The following 38 declarations represent the string-based API...
' ========================================================================================
DECLARE FUNCTION trm_Accelerate LIB "trm.dll" ALIAS "trm_Accelerate" (FileHandle AS LONG, CacheSize AS LONG) AS LONG
DECLARE FUNCTION trm_Close LIB "trm.dll" ALIAS "trm_Close" (FileHandle AS LONG) AS LONG
DECLARE FUNCTION trm_CloseAll LIB "trm.dll" ALIAS "trm_CloseAll" () AS LONG
DECLARE FUNCTION trm_Count LIB "trm.dll" ALIAS "trm_Count" (FileHandle AS LONG) AS LONG
DECLARE FUNCTION trm_Create LIB "trm.dll" ALIAS "trm_Create" (PathFileName AS STRING, FileDef AS STRING, OverWrite AS LONG) AS LONG
DECLARE FUNCTION trm_CurrKeyPos LIB "trm.dll" ALIAS "trm_CurrKeyPos" (FileHandle AS LONG) AS LONG
DECLARE FUNCTION trm_Delete LIB "trm.dll" ALIAS "trm_Delete" (FileHandle AS LONG) AS LONG
DECLARE FUNCTION trm_FileIsOpen LIB "trm.dll" ALIAS "trm_FileIsOpen" (FileHandle AS LONG) AS LONG
DECLARE FUNCTION trm_FileSize LIB "trm.dll" ALIAS "trm_FileSize" (FileHandle AS LONG) AS LONG
DECLARE FUNCTION trm_Flush LIB "trm.dll" ALIAS "trm_Flush" () AS LONG
DECLARE FUNCTION trm_GetByKeyPos LIB "trm.dll" ALIAS "trm_GetByKeyPos" (FileHandle AS LONG, KeyPos AS LONG) AS STRING
DECLARE FUNCTION trm_GetDirect LIB "trm.dll" ALIAS "trm_GetDirect" (FileHandle AS LONG, RecordPtr AS STRING) AS STRING
DECLARE FUNCTION trm_GetEqual LIB "trm.dll" ALIAS "trm_GetEqual" (FileHandle AS LONG, KeyNo AS LONG, KeyVal AS STRING) AS STRING
DECLARE FUNCTION trm_GetEqualOrGreater LIB "trm.dll" ALIAS "trm_GetEqualOrGreater" (FileHandle AS LONG, KeyNo AS LONG, KeyVal AS STRING) AS STRING
DECLARE FUNCTION trm_GetEqualOrLess LIB "trm.dll" ALIAS "trm_GetEqualOrLess" (FileHandle AS LONG, KeyNo AS LONG, KeyVal AS STRING) AS STRING
DECLARE FUNCTION trm_GetFileDef LIB "trm.dll" ALIAS "trm_GetFileDef" (FileHandle AS LONG) AS STRING
DECLARE FUNCTION trm_GetFileVer LIB "trm.dll" ALIAS "trm_GetFileVer" (FileHandle AS LONG) AS STRING
DECLARE FUNCTION trm_GetFirst LIB "trm.dll" ALIAS "trm_GetFirst" (FileHandle AS LONG, KeyNo AS LONG) AS STRING
DECLARE FUNCTION trm_GetGreater LIB "trm.dll" ALIAS "trm_GetGreater" (FileHandle AS LONG, KeyNo AS LONG, KeyVal AS STRING) AS STRING
DECLARE FUNCTION trm_GetLast LIB "trm.dll" ALIAS "trm_GetLast" (FileHandle AS LONG, KeyNo AS LONG) AS STRING
DECLARE FUNCTION trm_GetLess LIB "trm.dll" ALIAS "trm_GetLess" (FileHandle AS LONG, KeyNo AS LONG, KeyVal AS STRING) AS STRING
DECLARE FUNCTION trm_GetNext LIB "trm.dll" ALIAS "trm_GetNext" (FileHandle AS LONG) AS STRING
DECLARE FUNCTION trm_GetPosition LIB "trm.dll" ALIAS "trm_GetPosition" (FileHandle AS LONG, Direction AS LONG) AS STRING
DECLARE FUNCTION trm_GetPrev LIB "trm.dll" ALIAS "trm_GetPrev" (FileHandle AS LONG) AS STRING
DECLARE FUNCTION trm_Insert LIB "trm.dll" ALIAS "trm_Insert" (FileHandle AS LONG, Record AS STRING) AS LONG
DECLARE FUNCTION trm_Integrity LIB "trm.dll" ALIAS "trm_Integrity" (FileHandle AS LONG) AS LONG
DECLARE FUNCTION trm_Open LIB "trm.dll" ALIAS "trm_Open" (PathFileName AS STRING, MultiUser AS LONG) AS LONG
DECLARE FUNCTION trm_Rebuild LIB "trm.dll" ALIAS "trm_Rebuild" (PathFileName AS STRING, SaveFile AS STRING, FileDef AS STRING) AS LONG
DECLARE FUNCTION trm_Recover LIB "trm.dll" ALIAS "trm_Recover" (PathFileName AS STRING, OutFile AS STRING, PageSize AS LONG, Compression AS LONG) AS LONG
DECLARE FUNCTION trm_Result LIB "trm.dll" ALIAS "trm_Result" (FileHandle AS LONG) AS LONG
DECLARE FUNCTION trm_SetKeyPath LIB "trm.dll" ALIAS "trm_SetKeyPath" (FileHandle AS LONG, KeyNo AS LONG) AS LONG
DECLARE FUNCTION trm_StepFirst LIB "trm.dll" ALIAS "trm_StepFirst" (FileHandle AS LONG) AS STRING
DECLARE FUNCTION trm_StepLast LIB "trm.dll" ALIAS "trm_StepLast" (FileHandle AS LONG) AS STRING
DECLARE FUNCTION trm_StepNext LIB "trm.dll" ALIAS "trm_StepNext" (FileHandle AS LONG) AS STRING
DECLARE FUNCTION trm_StepPrev LIB "trm.dll" ALIAS "trm_StepPrev" (FileHandle AS LONG) AS STRING
DECLARE FUNCTION trm_TimeOut LIB "trm.dll" ALIAS "trm_TimeOut" (Limit AS LONG) AS LONG
DECLARE FUNCTION trm_Update LIB "trm.dll" ALIAS "trm_Update" (FileHandle AS LONG, Record AS STRING) AS LONG
DECLARE FUNCTION trm_Version LIB "trm.dll" ALIAS "trm_Version" () AS LONG
' The following two declarations represent Tsunami's two pointer-based APIs.
' They both accomplish the same thing... one passes seven long integers as parameters,
' while the other passes a seven-element UDT (structured variable) as it's sole parameter.
DECLARE FUNCTION trm LIB "trm.dll" ALIAS "trm" (Op AS LONG, File AS LONG, DataPtr AS LONG, DataLen AS LONG, KeyPtr AS LONG, KeyLen AS LONG, KeyNo AS LONG) AS LONG
DECLARE FUNCTION trm_udt LIB "trm.dll" ALIAS "trm_udt" (TRMudt AS ANY) AS LONG
' The following User Defined Type (structured) variable is only used
' with the pointer-based API that passes parameters in the UDT...
TYPE TRMtype
 op AS LONG ' Tsunami operation number
 file AS LONG ' Tsunami file handle
 dataptr AS LONG ' Address of data buffer
 datalen AS LONG ' Length of data buffer
 keyptr AS LONG ' Address of key buffer
 keylen AS LONG ' Length of key buffer
 keyno AS LONG ' Key number
END TYPE
' The following EQUATES (constants) represent the Tsunami
' operation codes (Op) used with the pointer-based APIs...
%EQUATE `Tsu_Accelerate = 32
%EQUATE `Tsu_Close = 1
%EQUATE `Tsu_CloseAll = 28
%EQUATE `Tsu_Count = 17
%EQUATE `Tsu_Create = 14
%EQUATE `Tsu_CurrKeyPos = 45
%EQUATE `Tsu_Delete = 4
%EQUATE `Tsu_FileIsOpen = 16
%EQUATE `Tsu_FileSize = 18
%EQUATE `Tsu_Flush = 29
%EQUATE `Tsu_GetByKeyPos = 44
%EQUATE `Tsu_GetDirect = 23
%EQUATE `Tsu_GetEqual = 5
%EQUATE `Tsu_GetEqualOrGreater = 9
%EQUATE `Tsu_GetEqualOrLess = 11
%EQUATE `Tsu_GetFileDef = 36
%EQUATE `Tsu_GetFileVer = 25
%EQUATE `Tsu_GetFirst = 12
%EQUATE `Tsu_GetGreater = 8
%EQUATE `Tsu_GetLast = 13
%EQUATE `Tsu_GetLess = 10
%EQUATE `Tsu_GetNext = 6
%EQUATE `Tsu_GetPosition = 22
%EQUATE `Tsu_GetPrev = 7
%EQUATE `Tsu_Insert = 2
%EQUATE `Tsu_Integrity = 37
%EQUATE `Tsu_Open = 0
%EQUATE `Tsu_Rebuild = 38
%EQUATE `Tsu_Recover = 39
%EQUATE `Tsu_SetKeyPath = 30
%EQUATE `Tsu_StepFirst = 33
%EQUATE `Tsu_StepLast = 34
%EQUATE `Tsu_StepNext = 24
%EQUATE `Tsu_StepPrev = 35
%EQUATE `Tsu_TimeOut = 31
%EQUATE `Tsu_Update = 3
%EQUATE `Tsu_Version = 26
#ENDIF
