(*****************************************************************************)
(* MODULE: BTRTYPES                                                          *)
(* RIGHTS: Reggatta Systems, Inc. - COPYRIGHT 1995 - 2000                    *)
(* DESCR.: This module contains general type and constant definitions        *)
(*****************************************************************************)
Unit BtrTypes;
{$I BSE.INC}
{$I BAPI.INC}
Interface
Uses
  BseTypes;

Const
  BtrFileVariableRecords   : SmallInt = 1;
  BtrFileBlankTruncation   : SmallInt = 2;
  BtrFilePagePreAllocation : SmallInt = 4;
  BtrFileDataCompression   : SmallInt = 8;
  BtrFileKeyOnlyFile       : SmallInt = 16;
  BtrFileBalancedIndex     : SmallInt = 32;
  BtrFile10PctFreeSpace    : SmallInt = 64;
  BtrFile20PctFreeSpace    : SmallInt = 128;
  BtrFile30PctFreeSpace    : SmallInt = 192;
  BtrFileRsvDupPointers    : SmallInt = 256;
  BtrFileIncSystemData     : SmallInt = 512;
  BtrFileUseKeyNums        : SmallInt = 1024;
  BtrFileUseVATs           : SmallInt = 2048;
  BtrFileNoSystemData      : SmallInt = 4608;

  BtrIdxDuplicates         : SmallInt = 1;
  BtrIdxModifiable         : SmallInt = 2;
  BtrIdxSegmented          : SmallInt = 16;
  BtrIdxHasACS             : SmallInt = 32;
  BtrIdxDescending         : SmallInt = 64;
  BtrIdxSupplemental       : SmallInt = 128;
  BtrIdxExtendedType       : SmallInt = 256;
  BtrIdxNullKey            : SmallInt = 512;
  BtrIdxCaseInsensitive    : SmallInt = 1024;
  BtrIdxMultipleACS        : SmallInt = 1056;

  BtrKeyNoSpecBias         = 128;

  btrFldSTRING             = 0;
  btrFldINTEGER            = 1;
  btrFldFLOAT              = 2;
  btrFldDATE               = 3;
  btrFldTIME               = 4;
  btrFldDECIMAL            = 5;
  btrFldMONEY              = 6;
  btrFldLOGICAL            = 7;
  btrFldNUMERIC            = 8;
  btrFldBFLOAT             = 9;
  btrFldLSTRING            = 10;
  btrFldZSTRING            = 11;
  btrFldNOTE               = 12;
  btrFldLVAR               = 13;
  btrFldUBINARY            = 14;
  btrFldAUTOINC            = 15;
  btrFldBIT                = 16;
  btrFldNUMERICSTS         = 17;
  btrFldNUMERICSA          = 18;
  btrFldCURRENCY           = 19;
  btrFldTIMESTAMP          = 20;
  btrfldBLOB               = 21;
  btrfldNAMEDINDEX         = 255;

  btrFldUNKNOWN            = 99;

{$IFDEF SMITHWARE_EXTENDED}
  btrExtFldLONGDATE        = 228;
  btrExtFldINTEL           = 229;
  btrExtFldBINRL           = 230;
  btrExtFldBINLR           = 231;
  btrExtFldNUMERICASCII    = 232;
  btrExtFldMAGICDATE_0001  = 233;
  btrExtFldCTIME           = 234;
  btrExtFldMAGICNUM100     = 235;
  btrExtFldTASPROTIME      = 236;
  btrExtFldTASPROUNS       = 237;
  btrExtFldBCD10           = 238;
  btrExtFldMAGICPCNUMERIC  = 239;
  btrExtFldMAGICPCTIME     = 240;
  btrExtFldMAGICPCDATE     = 241;
  btrExtFldYMD             = 242;
  btrExtFldYYMMDD          = 243;
  btrExtFldYYYYMMDD        = 244;
  btrExtFldTASPRO3DATE     = 245;
  btrExtFldTASPRO3NUMERIC  = 246;
  btrExtFldCOBOLCOMP6      = 247;
  btrExtFldVBDATE          = 253;
  btrExtFldVBCURRENCY      = 254;
  btrExtFldDELPHIREAL      = 255;
{$ENDIF SMITHWARE_EXTENDED}


  MAXBTRIEVEFILES          = 50;
  MAXBTRIEVERECSIZE        = 4096;
  MAXKEYSPECS              = 119; {24 in Btrieve pre 6.15}
  MAXBTRIEVEPERCENT        : Longint = 10000;

  WBTRV_SYS_FILE_SIGNATURE = 'X$';
  WBTRV_DICTIONARY_FLAG    = 16;

  WBTRV_NAME_LENGTH        = 20;
  WBTRV_PATH_LENGTH        = 64;
  WBTRV_OWNER_LENGTH       = 8;
  WBTRV_DEFAULT_KEY        : ShortInt = 0;

  WBTRV_DDF_OWNER          : PChar = '..SC....';
  WBTRV_TABLE_FILE         : PChar = 'FILE.DDF';
  WBTRV_FIELD_FILE         : PChar = 'FIELD.DDF';
  WBTRV_INDEX_FILE         : PChar = 'INDEX.DDF';
{$IFDEF SMITHWARE_EXTENDED}
  WBTRV_EXTFIELD_FILE      : PChar = 'FIELDEXT.DDF';
{$ENDIF SMITHWARE_EXTENDED}

  WBTRV_TABLE_NAME         : PChar = 'X$FILE';
  WBTRV_FIELD_NAME         : PChar = 'X$FIELD';
  WBTRV_INDEX_NAME         : PChar = 'X$INDEX';

  WBTRV_DEFAULT_DIRECTORY  : PChar = '';
  WBTRV_DATABASE_NAME      : PChar = 'Btrieve (FILE.DDF)';
  WBTRV_FIELD_TABLE_KEY    = 1;
  WBTRV_INDEX_TABLE_KEY    = 0;

  WBTRV_LIBRARY_DLL        : PChar = 'WBTRCALL.DLL';
  WBTRV_CONVERSION_DLL     : PChar = 'SEDTCONV.DLL';

  BTRIEVE_DRIVER_DESC      : PChar = 'BTRIEVE';

  WBTRV_USER_FILE          : PChar = 'USER.DDF';
  WBTRV_PROCTABLE_FILE     : PChar = 'PROC.DDF';
  WBTRV_PROCNAME_LENGTH    = 30;

  BTRIEVESQL_DRIVER_DESC   : PChar = 'BTRIEVE';
  SCALABLE_ROW_LENGTH_SIZE = 2;
  SCALABLE_DB_NAME_SIZE    = 20;
  SCALABLE_PROC_EXEC       : PChar = 'EXEC ';


Type
  BtrieveBitSet = Set of 0..7;

  PBtrieveDateType = ^BtrieveDateType;
  BtrieveDateType =
  Packed Record
    Day   : Byte;
    Month : Byte;
    Year  : Word;
  end;

  DateValRec = BtrieveDateType;

  BtrieveTimeType =
  Packed Record
    Hundredth : Byte;
    Second    : Byte;
    Minute    : Byte;
    Hour      : Byte;
  end;

  TimeValRec = BtrieveTimeType;

  file_fcb_type =
  Packed Record
    fcb : array[1..38] of byte;
    pos : array[1..90] of byte;
  end;

  PKeySpecs = ^TKeySpecs;
  TKeySpecs =
  Packed Record
    Key_position  : SmallInt;
    Key_length    : SmallInt;
    Key_flags     : SmallInt;
    UniqueKeys    : Longint;
    Extended_key  : Byte;
    Null_value    : Byte;
    Reserved      : SmallInt;
    Key_Number    : Byte;
    ACS_Number    : Byte;
  end;

  PACSSpec = ^TACSSpec;
  TACSSpec =
  Packed Record
    Signature : Byte;  { Can be AC or AD }
    Case Integer of
      1: (
           CountryID  : Word;
           CodePageID : Word;
           Filler     : Array[1..260] of Char;
         );
      2: (
           Name       : Array[1..8] of Char;
           Table      : Array[0..255] of Char;
         )
  end;

  PFileHeader = ^TFileHeader;
  TFileHeader =
  Packed Record
    record_length : SmallInt;
    page_size     : SmallInt;
    Case Integer of
      1: (
           no_of_indexes : SmallInt;
           records       : longint;
           file_flags    : SmallInt;
           reserved_word : SmallInt;
           allocation    : SmallInt;
         );
      2: (
           NumIndexes    : Byte;
           FileVersion   : Byte;
           RecCount      : longint;
           FileFlags     : SmallInt;
           UnusedDups    : Byte;
           ReservedByte  : Byte;
           UnusedPages   : SmallInt;
         )
  end;

  PFileSpecs = ^TFileSpecs;
  TFileSpecs =
  Packed Record
    Header        : TFileHeader;
    Keys          : Array[0..Pred( MAXKEYSPECS ) ] of TKeySpecs;
  end;

  ExtOPHeader =
  Packed Record
    buffer_len    : word;
    signature     : array[1..2] of Char;
  end;


  ExtOPFilterHeader =
  Packed Record
    max_rec_skip  : SmallInt;
    num_of_terms  : SmallInt;
  end;


  ExtOpTerm =
  Packed Record
    data_type       : byte;
    field_length    : word;
    field_offset    : word;
    comparison_code : byte;
    logic_type      : byte;
    offset2         : word;
  end;


  ExtOpExtractor =
  Packed Record
    recs_to_get   : word;
    num_of_fields : word;
  end;


  ExtOpExtractRepeat =
  Packed Record
    field_length : word;
    field_offset : word;
  end;


  Name_Array      = Array[ 1..WBTRV_NAME_LENGTH     ] of Char;
  Path_Array      = Array[ 1..WBTRV_PATH_LENGTH     ] of Char;

  ProcName_Array  = Array[ 1..WBTRV_PROCNAME_LENGTH ] of Char;


  PFileDDF = ^TFileDDF;
  TFileDDF =
  Packed Record
    Xf_ID        : SmallInt;
    Xf_Name      : Name_Array;
    Xf_Location  : Path_Array;
    Xf_Flags     : Byte;
    Filler       : Array[1..10] of Byte;
  end;


  PFieldDDF = ^TFieldDDF;
  TFieldDDF =
  Packed Record
    Xe_ID        : SmallInt;
    Xe_File      : SmallInt;
    Xe_Name      : Name_Array;
    Xe_DataType  : Byte;
    Xe_Offset    : SmallInt;
    Xe_Size      : Word;
    Xe_Dec       : Byte;
    Xe_Flags     : SmallInt;
  end;


{$IFDEF SMITHWARE_EXTENDED}
  PExtFieldDDF = ^TExtFieldDDF;
  TExtFieldDDF =
  Packed Record
    Xx_File      : SmallInt;
    Xx_ID        : SmallInt;
    Xx_DataType  : SmallInt;
  end;
{$ENDIF SMITHWARE_EXTENDED}


  PIndexDDF = ^TIndexDDF;
  TIndexDDF =
  Packed Record
    Xi_File      : SmallInt;
    Xi_Field     : SmallInt;
    Xi_Number    : SmallInt;
    Xi_Part      : SmallInt;
    Xi_Flags     : SmallInt;
  end;

  PProcDDF = ^TProcDDF;
  TProcDDF =
  Packed Record
    Xp_Name      : ProcName_Array;
    Xp_Version   : SmallInt;
    Xp_ID        : SmallInt;
    Xp_Flags     : SmallInt;
    Xp_Misc      : Array[0..1024] of Char; { This is actually an Lvar }
  end;

  PDDFFileInfo = ^TDDFFileInfo; { For Named Databases }
  TDDFFileInfo =
  Packed Record
    Flags        : Word;
    DOSPath      : Array[0..63] of Char;
    TableName    : Array[0..19] of Char;
  end;

  PDDFField = ^TDDFField; { For Named Databases }
  TDDFField =
  Packed Record
    Xe_Offset    : SmallInt;
    Xe_DataType  : Byte;
    Xe_Flags     : SmallInt;
    Xe_Size      : Word;
    Xe_Dec       : Byte;
    Xe_Name      : Name_Array;
  end;

  PVersionInfo = ^TVersionInfo;
  TVersionInfo =
  Packed Record
    Version  : SmallInt;
    Revision : SmallInt;
    EngType  : Char;
  end;



Implementation

end.
