home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / zkuste / delphi / kompon / d5 / CAKDIR.ZIP / Fci.pas < prev    next >
Pascal/Delphi Source File  |  2000-07-02  |  19KB  |  608 lines

  1. {++
  2.  
  3. f c i . p a s
  4. Copyright (c) 1997 Alexander Staubo, all rights reserved.
  5.  
  6. Abstract:
  7.  
  8.   Translation of fci.h, part of the Cabinet SDK.
  9.  
  10. Revision history:
  11.  
  12.   06/07/1997 20:17  alexs  1.0
  13.     Autogenerated by htrans
  14.   26/12/1997 02:55  alexs  1.1
  15.     Fixed declarations of function callbacks, other minor stuff
  16.  
  17. --}
  18.  
  19. unit Fci;
  20.  
  21. {$A+}
  22. {$MINENUMSIZE 4}
  23. {$WEAKPACKAGEUNIT ON}
  24.  
  25. interface
  26.  
  27. uses
  28.   SysUtils, Windows;
  29.  
  30. type
  31.   PVoid = Pointer;
  32.   USHORT = Word;
  33.  
  34. (*
  35.  *  FCI.H -- File Compression Interface
  36.  *
  37.  *  Copyright (C) Microsoft Corporation 1993-1997
  38.  *  All Rights Reserved.
  39.  *)
  40.  
  41. type
  42.                                        { f }
  43.   TBYTE = Char;
  44.  
  45.                                        { b }
  46.   TUINT = Integer;
  47.   
  48.                                        { ui }
  49.   TUSHORT = Smallint;
  50.   
  51.                                        { us }
  52.   TULONG = Longint;
  53.   
  54.                                        { ul }
  55.  
  56. type
  57.   TCHECKSUM = Longint;
  58.   
  59.                                        { csum }
  60.   TUOFF = Longint;
  61.  
  62.                                        { uoff - uncompressed offset }
  63.   TCOFF = Longint;
  64.   
  65.                                        { coff - cabinet file offset }
  66.  
  67. {**    ERF - Error structure
  68.  *
  69.  *  This structure returns error information from FCI/FDI.  The caller should
  70.  *  not modify this structure.
  71.  }
  72.  
  73. type
  74.   TERF =     
  75.     record
  76.       erfOper : Integer;  // FCI/FDI error code -- see FDIERROR_XXX
  77.         //  and FCIERR_XXX equates for details.
  78.       erfType : Integer;  // Optional error value filled in by FCI/FDI.
  79.         // For FCI, this is usually the C run-time
  80.         // *errno* value.
  81.       fError : Bool;  // TRUE => error present
  82.     end;
  83.  
  84.                                        { erf }
  85.   PERF = ^TERF;
  86.  
  87.                                        { perf }
  88.  
  89. const
  90.   CB_MAX_CHUNK = 32768;
  91.   CB_MAX_DISK = $7fffffff;
  92.   CB_MAX_FILENAME = 256;
  93.   CB_MAX_CABINET_NAME = 256;
  94.   CB_MAX_CAB_PATH = 256;
  95.   CB_MAX_DISK_NAME = 256;
  96.  
  97.  
  98. {**    tcompXXX - Compression types
  99.  *
  100.  *  These are passed to FCIAddFile(), and are also stored in the CFFOLDER
  101.  *  structures in cabinet files.
  102.  *
  103.  *  NOTE: We reserve bits for the TYPE, QUANTUM_LEVEL, and QUANTUM_MEM
  104.  *        to provide room for future expansion.  Since this value is stored
  105.  *        in the CFDATA records in the cabinet file, we don't want to
  106.  *        have to change the format for existing compression configurations
  107.  *        if we add new ones in the future.  This will allows us to read
  108.  *        old cabinet files in the future.
  109.  }
  110.  
  111. type
  112.   TCOMP = Smallint;
  113.   
  114.                                        { tcomp }
  115.  
  116. const
  117.   tcompMASK_TYPE = $000F;
  118.   tcompTYPE_NONE = $0000;
  119.   tcompTYPE_MSZIP = $0001;
  120.   tcompTYPE_QUANTUM = $0002;
  121.   tcompTYPE_LZX = $0003;
  122.   tcompBAD = $000F;
  123.   tcompMASK_LZX_WINDOW = $1F00;
  124.   tcompLZX_WINDOW_LO = $0F00;
  125.   tcompLZX_WINDOW_HI = $1500;
  126.   tcompSHIFT_LZX_WINDOW = 8;
  127.   tcompMASK_QUANTUM_LEVEL = $00F0;
  128.   tcompQUANTUM_LEVEL_LO = $0010;
  129.   tcompQUANTUM_LEVEL_HI = $0070;
  130.   tcompSHIFT_QUANTUM_LEVEL = 4;
  131.   tcompMASK_QUANTUM_MEM = $1F00;
  132.   tcompQUANTUM_MEM_LO = $0A00;
  133.   tcompQUANTUM_MEM_HI = $1500;
  134.   tcompSHIFT_QUANTUM_MEM = 8;
  135.   tcompMASK_RESERVED = $E000;
  136.  
  137. {**    FCIERROR - Error codes returned in erf.erfOper field
  138.  *
  139.  }
  140.  
  141. type
  142.   TFCIERROR =
  143.     (
  144.       FCIERR_NONE,             // No error
  145.       FCIERR_OPEN_SRC,         // Failure opening file to be stored in cabinet
  146.                                //  erf.erfTyp has C run-time *errno* value
  147.       FCIERR_READ_SRC,         // Failure reading file to be stored in cabinet
  148.                                //  erf.erfTyp has C run-time *errno* value
  149.       FCIERR_ALLOC_FAIL,       // Out of memory in FCI
  150.       FCIERR_TEMP_FILE,        // Could not create a temporary file
  151.                                //  erf.erfTyp has C run-time *errno* value
  152.       FCIERR_BAD_COMPR_TYPE,   // Unknown compression type
  153.       FCIERR_CAB_FILE,         // Could not create cabinet file
  154.                                //  erf.erfTyp has C run-time *errno* value
  155.       FCIERR_USER_ABORT,       // Client requested abort
  156.       FCIERR_MCI_FAIL          // Failure compressing data
  157.     );
  158.  
  159. (*
  160.  * FAT file attribute flag used by FCI/FDI to indicate that
  161.  * the filename in the CAB is a UTF string
  162.  *)
  163.  
  164. const
  165.   _A_NAME_IS_UTF = $80;
  166.  
  167. (*
  168.  * FAT file attribute flag used by FCI/FDI to indicate that
  169.  * the file should be executed after extraction
  170.  *)
  171.  
  172. const
  173.   _A_EXEC = $40;
  174.  
  175. {**    HFCI - Handle to an FCI Context
  176.  *
  177.  }
  178.  
  179. type
  180.   HFCI = PVoid;
  181.  
  182. {**    CCAB - Current Cabinet
  183.  *
  184.  *  This structure is used for passing in the cabinet parameters to FCI,
  185.  *  and is passed back on certain FCI callbacks to provide cabinet
  186.  *  information to the client.
  187.  }
  188.  
  189. type
  190.   TCCAB =
  191.     packed record
  192.         // longs first
  193.       cb : TULONG;  // size available for cabinet on this media
  194.       cbFolderThresh : TULONG;  // Thresshold for forcing a new Folder
  195.         // then ints
  196.       cbReserveCFHeader : TUINT;  // Space to reserve in CFHEADER
  197.       cbReserveCFFolder : TUINT;  // Space to reserve in CFFOLDER
  198.       cbReserveCFData : TUINT;  // Space to reserve in CFDATA
  199.       iCab : Integer;  // sequential numbers for cabinets
  200.       iDisk : Integer;  // Disk number
  201.  
  202.       {$IFNDEF REMOVE_CHICAGO_M6_HACK}
  203.       fFailOnIncompressible : Integer;  // TRUE => Fail if a block is incompressible
  204.       {$ENDIF}
  205.       
  206.         //  then shorts
  207.       setID : TUSHORT;  // Cabinet set ID
  208.         // then chars
  209.       szDisk : array[0..256 - 1] of Char;  // current disk name
  210.       szCab : array[0..256 - 1] of Char;  // current cabinet name
  211.       szCabPath : array[0..256 - 1] of Char;  // path for creating cabinet
  212.     end;
  213.     
  214.                                        { ccab }
  215.   PCCAB = ^TCCAB;
  216.   
  217.                                        { pccab }
  218.  
  219. {**    FNFCIALLOC - Memory Allocation
  220.  *      FNFCIFREE  - Memory Free
  221.  *
  222.  *  These are modeled after the C run-time routines malloc() and free()
  223.  *  FCI expects error handling to be identical to these C run-time routines.
  224.  *
  225.  *  As long as you faithfully copy the semantics of malloc() and free(),
  226.  *  you can supply any functions you like!
  227.  *
  228.  *  WARNING: You should never assume anything about the sequence of
  229.  *           FNFCIALLOC and FNFCIFREE calls -- incremental releases of
  230.  *           FCI may have radically different numbers of
  231.  *           FNFCIALLOC calls and allocation sizes!
  232.  }
  233.  
  234.   //** Memory functions for FCI
  235.  
  236. type
  237.   TFNFCIALLOC = function (cb : TULONG) : PVoid; cdecl;
  238.   PFNFCIALLOC = TFNFCIALLOC;
  239.   
  240.                                        { pfna }
  241.   TFNFCIFREE = function (memory : PVoid) : Pointer; cdecl;
  242.   PFNFCIFREE = TFNFCIFREE;
  243.   
  244.                                        { pfnf }
  245.  
  246. {**    PFNFCIOPEN  - File I/O callbacks for FCI
  247.  *      PFNFCIREAD
  248.  *      PFNFCIWRITE
  249.  *      PFNFCICLOSE
  250.  *      PFNFCISEEK
  251.  *
  252.  *  These are modeled after the C run-time routines _open, _read,
  253.  *  _write, _close, and _lseek.  The values for the PFNFCIOPEN oflag
  254.  *  and pmode calls are those defined for _open.  FCI expects error
  255.  *  handling to be identical to these C run-time routines, except that
  256.  *  the value of errno should be returned via *err.
  257.  *
  258.  *  As long as you faithfully copy these aspects, you can supply
  259.  *  any functions you like!
  260.  *
  261.  *  WARNING: You should never assume you know what file is being
  262.  *           opened at any one point in time!  It is possible
  263.  *           that in a future implementations it may open temporary
  264.  *           files or cabinet files in a different order.
  265.  }
  266.  
  267.   //** File I/O functions for FCI
  268.  
  269. type        
  270.   TFNFCIOPEN = function (pszFile : PChar; oflag : Integer; pmode : Integer;
  271.     err : PInteger; pv : Pointer) : Integer; cdecl;
  272.   PFNFCIOPEN = TFNFCIOPEN;
  273.  
  274.   TFNFCIREAD = function (hf : Integer; memory : PVoid; cb : TUINT; 
  275.     err : PInteger; pv : Pointer) : TUINT; cdecl;
  276.   PFNFCIREAD = TFNFCIREAD;
  277.   
  278.   TFNFCIWRITE = function (hf : Integer; memory : PVoid; cb : TUINT;
  279.     err : PInteger; pv : Pointer) : TUINT; cdecl;
  280.   PFNFCIWRITE = TFNFCIWRITE;
  281.   
  282.   TFNFCICLOSE = function (hf : Integer; err : PInteger; pv : Pointer) : 
  283.     Integer; cdecl;
  284.   PFNFCICLOSE = TFNFCICLOSE;
  285.   
  286.   TFNFCISEEK = function (hf : Integer; dist : Longint; seektype : Integer; 
  287.     err : PInteger; pv : Pointer) : Longint; cdecl;
  288.   PFNFCISEEK = TFNFCISEEK;
  289.   
  290.   TFNFCIDELETE = function (pszFile : PChar; err : PInteger; pv : Pointer) : 
  291.     Integer; cdecl;
  292.   PFNFCIDELETE = TFNFCIDELETE;
  293.   
  294. {**    FNFCIGETNEXTCABINET - Callback used to request new cabinet info
  295.  *
  296.  *  Entry:
  297.  *      pccab     - Points to copy of old ccab structure to modify
  298.  *      cbPrevCab - Estimate of size of previous cabinet
  299.  *      pv        - Has the caller's context pointer
  300.  *
  301.  *  Exit-Success:
  302.  *      returns TRUE;
  303.  *
  304.  *  Exit-Failure:
  305.  *      returns FALSE;
  306.  }
  307.  
  308. type
  309.   TFNFCIGETNEXTCABINET = function (pccab : PCCAB; cbPrevCab : TULONG; 
  310.     pv : Pointer) : Bool; cdecl;
  311.   PFNFCIGETNEXTCABINET = TFNFCIGETNEXTCABINET;
  312.   
  313.                                        { pfnfcignc }
  314.  
  315. {**    FNFCIFILEPLACED - Notify FCI client that file was placed
  316.  *
  317.  *  Entry:
  318.  *      pccab         - cabinet structure to fill in, with copy of previous one
  319.  *      pszFile       - name of file, from cabinet
  320.  *      cbFile        - length of file
  321.  *      fContinuation - true if this is a later segment of a continued file
  322.  *      pv            - the context of the client
  323.  *
  324.  *  Exit-Success:
  325.  *      return value anything but -1
  326.  *
  327.  *  Exit-Failure:
  328.  *      return value -1 means to abort
  329.  }
  330.  
  331. type
  332.   TFNFCIFILEPLACED = function (pccab : PCCAB; pszFile : PChar; 
  333.     cbFile : Longint; fContinuation : Bool; pv : Pointer) : Integer; cdecl;
  334.   PFNFCIFILEPLACED = TFNFCIFILEPLACED;
  335.   
  336.                                        { pfnfcifp }
  337.  
  338. {**    FNCDIGETOPENINFO - Open source file, get date/time/attribs
  339.  *
  340.  *  Entry:
  341.  *      pszName  -- complete path to filename
  342.  *      pdate    -- location to return FAT-style date code
  343.  *      ptime    -- location to return FAT-style time code
  344.  *      pattribs -- location to return FAT-style attributes
  345.  *      pv       -- client's context
  346.  *
  347.  *  Exit-Success:
  348.  *      Return value is file handle of open file to read
  349.  *
  350.  *  Exit-Failure:
  351.  *      Return value is -1
  352.  }
  353.  
  354. type
  355.   TFNFCIGETOPENINFO = function (pszName : PChar; var pdate : TUSHORT; 
  356.     var ptime : TUSHORT; var pattribs : TUSHORT; err : PInteger; pv : Pointer) : 
  357.     Integer; cdecl;
  358.   PFNFCIGETOPENINFO = TFNFCIGETOPENINFO;
  359.   
  360.                                        { pfnfcigoi }
  361.  
  362. {**    FNFCISTATUS - Status/Cabinet Size callback
  363.  *
  364.  *  Entry:
  365.  *      typeStatus == statusFile if compressing a block into a folder
  366.  *                      cb1 = Size of compressed block
  367.  *                      cb2 = Size of uncompressed block
  368.  *
  369.  *      typeStatus == statusFolder if adding a folder to a cabinet
  370.  *                      cb1 = Amount of folder copied to cabinet so far
  371.  *                      cb2 = Total size of folder
  372.  *
  373.  *      typeStatus == statusCabinet if writing out a complete cabinet
  374.  *                      cb1 = Estimated cabinet size that was previously
  375.  *                              passed to fnfciGetNextCabinet().
  376.  *                      cb2 = Actual cabinet size
  377.  *                    NOTE: Return value is desired client size for cabinet
  378.  *                          file.  FCI updates the maximum cabinet size
  379.  *                          remaining using this value.  This allows a client
  380.  *                          to generate multiple cabinets per disk, and have
  381.  *                          FCI limit the size correctly -- the client can do
  382.  *                          cluster size rounding on the cabinet size!
  383.  *                          The client should either return cb2, or round cb2
  384.  *                          up to some larger value and return that.
  385.  *  Exit-Success:
  386.  *      Returns anything other than -1;
  387.  *      NOTE: See statusCabinet for special return values!
  388.  *
  389.  *  Exit-Failure:
  390.  *      Returns -1 to signal that FCI should abort;
  391.  }
  392.  
  393. const
  394.   statusFile = 0;
  395.   statusFolder = 1;
  396.   statusCabinet = 2;
  397.  
  398. type
  399.   TFNFCISTATUS = function (typeStatus : TUINT; cb1 : TULONG; cb2 : TULONG; 
  400.     pv : Pointer) : Longint; cdecl;
  401.   PFNFCISTATUS = TFNFCISTATUS;
  402.   
  403.                                        { pfnfcis }
  404.  
  405. {**    FNFCIGETTEMPFILE - Callback, requests temporary file name
  406.  *
  407.  *  Entry:
  408.  *      pszTempName - Buffer to receive complete tempfile name
  409.  *      cbTempName  - Size of pszTempName buffer
  410.  *
  411.  *  Exit-Success:
  412.  *      return TRUE
  413.  *
  414.  *  Exit-Failure:
  415.  *      return FALSE; could not create tempfile, or buffer too small
  416.  *
  417.  *  Note:
  418.  *      It is conceivable that this function may return a filename
  419.  *      that will already exist by the time it is opened.  For this
  420.  *      reason, the caller should make several attempts to create
  421.  *      temporary files before giving up.
  422.  }
  423.  
  424. type
  425.   TFNFCIGETTEMPFILE = function (pszTempName : PChar; cbTempName : Integer; 
  426.     pv : Pointer) : Bool; cdecl;
  427.   PFNFCIGETTEMPFILE = TFNFCIGETTEMPFILE;
  428.  
  429.                                        { pfnfcigtf }
  430.  
  431. {**    FCICreate -- create an FCI context (an open CAB, an open FOL)
  432.  *
  433.  *  Entry:
  434.  *      perf      - structure where we return error codes
  435.  *      pfnfcifp  - callback to inform caller of eventual dest of files
  436.  *      pfna      - memory allocation function callback
  437.  *      pfnf      - memory free function callback
  438.  *      pfnfcigtf - temp file name generator callback
  439.  *      pccab     - pointer to cabinet/disk name & size structure
  440.  *
  441.  *  Notes:
  442.  *  (1) The alloc/free callbacks must remain valid throughout
  443.  *      the life of the context, up to and including the call to
  444.  *      FCIDestroy.
  445.  *  (2) The perf pointer is stored in the compression context (HCI),
  446.  *      and any errors from subsequent FCI calls are stored in the
  447.  *      erf that was passed in on *this* call.
  448.  *
  449.  *  Exit-Success:
  450.  *      Returns non-NULL handle to an FCI context.
  451.  *
  452.  *  Exit-Failure:
  453.  *      Returns NULL, perf filled in.
  454.  }
  455.  
  456.   function FCICreate (perf : PERF; pfnfcifp : PFNFCIFILEPLACED; 
  457.     pfna : PFNFCIALLOC; pfnf : PFNFCIFREE; pfnopen : PFNFCIOPEN; 
  458.     pfnread : PFNFCIREAD; pfnwrite : PFNFCIWRITE; pfnclose : PFNFCICLOSE; 
  459.     pfnseek : PFNFCISEEK; pfndelete : PFNFCIDELETE; 
  460.   pfnfcigtf : PFNFCIGETTEMPFILE; pccab : PCCAB; pv : Pointer) : HFCI; cdecl;
  461.  
  462. {**   FCIAddFile - Add a disk file to a folder/cabinet
  463.  *
  464.  *  Entry:
  465.  *      hfci          - FCI context handle
  466.  *      pszSourceFile - Name of file to add to folder
  467.  *      pszFileName   - Name to store into folder/cabinet
  468.  *      fExecute      - Flag indicating execute on extract
  469.  *      pfn_progress  - Progress callback
  470.  *      pfnfcignc     - GetNextCabinet callback
  471.  *      pfnfcis       - Status callback
  472.  *      pfnfcigoi     - OpenInfo callback
  473.  *      typeCompress  - Type of compression to use for this file
  474.  *      pv            - pointer to caller's internal context
  475.  *
  476.  *  Exit-Success:
  477.  *      returns TRUE
  478.  *
  479.  *  Exit-Failure:
  480.  *      returns FALSE, error filled in
  481.  *    
  482.  *    This is the main function used to add file(s) to a cabinet
  483.  *    or series of cabinets.  If the current file causes the current
  484.  *    folder/cabinet to overflow the disk image currently being built,
  485.  *    the cabinet will be terminated, and a new cabinet/disk name will
  486.  *    be prompted for via a callback.  The pending folder will be trimmed
  487.  *    of the data which has already been generated in the finished cabinet.
  488.  }
  489.  
  490.   function FCIAddFile (hfci : HFCI; pszSourceFile : PChar; pszFileName : PChar;
  491.     fExecute : Bool; pfnfcignc : PFNFCIGETNEXTCABINET; pfnfcis : PFNFCISTATUS;
  492.   pfnfcigoi : PFNFCIGETOPENINFO; typeCompress : TCOMP) : Bool; cdecl;
  493.  
  494. {**   FCIFlushCabinet - Complete the current cabinet under construction
  495.  *
  496.  *  This will cause the current cabinet (assuming it is not empty) to
  497.  *  be gathered together and written to disk.
  498.  *
  499.  *  Entry:
  500.  *      hfci        - FCI context
  501.  *      fGetNextCab - TRUE  => Call GetNextCab to get continuation info;
  502.  *                    FALSE => Don't call GetNextCab unless this cabinet
  503.  *                             overflows.
  504.  *      pfnfcignc   - callback function to get continuation cabinets
  505.  *      pfnfcis     - callback function for progress reporting
  506.  *      pv          - caller's internal context for callbacks
  507.  *
  508.  *  Exit-Success:
  509.  *      return code TRUE
  510.  *
  511.  *  Exit-Failure:
  512.  *      return code FALSE, error structure filled in
  513.  }
  514.  
  515.   function FCIFlushCabinet (hfci : HFCI; fGetNextCab : Bool; 
  516.   pfnfcignc : PFNFCIGETNEXTCABINET; pfnfcis : PFNFCISTATUS) : Bool; cdecl;
  517.  
  518. {**   FCIFlushFolder - Complete the current folder under construction
  519.  *
  520.  *  This will force the termination of the current folder, which may or
  521.  *  may not cause one or more cabinet files to be completed.
  522.  *
  523.  *  Entry:
  524.  *      hfci        - FCI context
  525.  *      GetNextCab  - callback function to get continuation cabinets
  526.  *      pfnProgress - callback function for progress reporting
  527.  *      pv          - caller's internal context for callbacks
  528.  *
  529.  *  Exit-Success:
  530.  *      return code TRUE
  531.  *
  532.  *  Exit-Failure:
  533.  *      return code FALSE, error structure filled in
  534.  }
  535.  
  536.   function FCIFlushFolder (hfci : HFCI; pfnfcignc : PFNFCIGETNEXTCABINET; 
  537.   pfnfcis : PFNFCISTATUS) : Bool; cdecl;
  538.  
  539. {**    FCIDestroy - Destroy a FCI context and delete temp files
  540.  *
  541.  *  Entry:
  542.  *      hfci - FCI context
  543.  *
  544.  *  Exit-Success:
  545.  *      return code TRUE
  546.  *
  547.  *  Exit-Failure:
  548.  *      return code FALSE, error structure filled in
  549.  }
  550.  
  551. function FCIDestroy (hfci : HFCI) : Bool; cdecl;
  552.  
  553. function CompressionTypeFromTCOMP (tc : TCOMP) : Integer;
  554.  
  555. function CompressionLevelFromTCOMP (tc : TCOMP) : Integer;
  556.  
  557. function CompressionMemoryFromTCOMP (tc : TCOMP) : Integer;
  558.  
  559. function TCOMPfromTypeLevelMemory (t : Integer; l : Integer; m : Integer) : Integer;
  560.  
  561. function LZXCompressionWindowFromTCOMP (tc : TCOMP) : Integer;
  562.  
  563. function TCOMPfromLZXWindow (w : Integer) : Integer;
  564.  
  565. implementation
  566.  
  567. const
  568.   CabinetDll = 'cabinet.dll';
  569.  
  570. function FCICreate; external CabinetDll name 'FCICreate';
  571. function FCIAddFile; external CabinetDll name 'FCIAddFile';
  572. function FCIFlushCabinet; external CabinetDll name 'FCIFlushCabinet';
  573. function FCIFlushFolder; external CabinetDll name 'FCIFlushFolder';
  574. function FCIDestroy; external CabinetDll name 'FCIDestroy';
  575.  
  576. function CompressionTypeFromTCOMP (tc : TCOMP) : Integer;
  577. begin
  578.   Result:=((tc) and $000F);
  579. end;
  580.  
  581. function CompressionLevelFromTCOMP (tc : TCOMP) : Integer;
  582. begin
  583.   Result:=(((tc) and $00F0) shr 4);
  584. end;
  585.  
  586. function CompressionMemoryFromTCOMP (tc : TCOMP) : Integer;
  587. begin
  588.   Result:=(((tc) and $1F00) shr 8);
  589. end;
  590.  
  591. function TCOMPfromTypeLevelMemory (t : Integer; l : Integer; m : Integer) : Integer;
  592. begin
  593.   Result:=(((m) shl 8) or ((l) shl 4) or (t));
  594. end;
  595.  
  596. function LZXCompressionWindowFromTCOMP (tc : TCOMP) : Integer;
  597. begin
  598.   Result:=(((tc) and $1F00) shr 8);
  599. end;
  600.  
  601. function TCOMPfromLZXWindow (w : Integer) : Integer;
  602. begin
  603.   Result:=(((w) shl 8) or ($0003));
  604. end;
  605.  
  606. end.
  607.  
  608.