⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fci.pas

📁 fci
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{++

f c i . p a s
Copyright (c) 1997 Alexander Staubo, all rights reserved.

Abstract:

  Translation of fci.h, part of the Cabinet SDK.

Revision history:

  06/07/1997 20:17  alexs  1.0
    Autogenerated by htrans
  26/12/1997 02:55  alexs  1.1
    Fixed declarations of function callbacks, other minor stuff

--}

unit Fci;

{$A+}
{$MINENUMSIZE 4}
{$WEAKPACKAGEUNIT ON}

interface

uses
  SysUtils, Windows;

type
  PVoid = Pointer;
  USHORT = Word;

(*
 *  FCI.H -- File Compression Interface
 *
 *  Copyright (C) Microsoft Corporation 1993-1997
 *  All Rights Reserved.
 *)

type
                                       { f }
  TBYTE = Char;

                                       { b }
  TUINT = Integer;
  
                                       { ui }
  TUSHORT = Smallint;
  
                                       { us }
  TULONG = Longint;
  
                                       { ul }

type
  TCHECKSUM = Longint;
  
                                       { csum }
  TUOFF = Longint;

                                       { uoff - uncompressed offset }
  TCOFF = Longint;
  
                                       { coff - cabinet file offset }

{**    ERF - Error structure
 *
 *  This structure returns error information from FCI/FDI.  The caller should
 *  not modify this structure.
 }

type
  TERF =     
    record
      erfOper : Integer;  // FCI/FDI error code -- see FDIERROR_XXX
        //  and FCIERR_XXX equates for details.
      erfType : Integer;  // Optional error value filled in by FCI/FDI.
        // For FCI, this is usually the C run-time
        // *errno* value.
      fError : Bool;  // TRUE => error present
    end;

                                       { erf }
  PERF = ^TERF;

                                       { perf }

const
  CB_MAX_CHUNK = 32768;
  CB_MAX_DISK = $7fffffff;
  CB_MAX_FILENAME = 256;
  CB_MAX_CABINET_NAME = 256;
  CB_MAX_CAB_PATH = 256;
  CB_MAX_DISK_NAME = 256;


{**    tcompXXX - Compression types
 *
 *  These are passed to FCIAddFile(), and are also stored in the CFFOLDER
 *  structures in cabinet files.
 *
 *  NOTE: We reserve bits for the TYPE, QUANTUM_LEVEL, and QUANTUM_MEM
 *        to provide room for future expansion.  Since this value is stored
 *        in the CFDATA records in the cabinet file, we don't want to
 *        have to change the format for existing compression configurations
 *        if we add new ones in the future.  This will allows us to read
 *        old cabinet files in the future.
 }

type
  TCOMP = Smallint;
  
                                       { tcomp }

const
  tcompMASK_TYPE = $000F;
  tcompTYPE_NONE = $0000;
  tcompTYPE_MSZIP = $0001;
  tcompTYPE_QUANTUM = $0002;
  tcompTYPE_LZX = $0003;
  tcompBAD = $000F;
  tcompMASK_LZX_WINDOW = $1F00;
  tcompLZX_WINDOW_LO = $0F00;
  tcompLZX_WINDOW_HI = $1500;
  tcompSHIFT_LZX_WINDOW = 8;
  tcompMASK_QUANTUM_LEVEL = $00F0;
  tcompQUANTUM_LEVEL_LO = $0010;
  tcompQUANTUM_LEVEL_HI = $0070;
  tcompSHIFT_QUANTUM_LEVEL = 4;
  tcompMASK_QUANTUM_MEM = $1F00;
  tcompQUANTUM_MEM_LO = $0A00;
  tcompQUANTUM_MEM_HI = $1500;
  tcompSHIFT_QUANTUM_MEM = 8;
  tcompMASK_RESERVED = $E000;

{**    FCIERROR - Error codes returned in erf.erfOper field
 *
 }

type
  TFCIERROR =
    (
      FCIERR_NONE,             // No error
      FCIERR_OPEN_SRC,         // Failure opening file to be stored in cabinet
                               //  erf.erfTyp has C run-time *errno* value
      FCIERR_READ_SRC,         // Failure reading file to be stored in cabinet
                               //  erf.erfTyp has C run-time *errno* value
      FCIERR_ALLOC_FAIL,       // Out of memory in FCI
      FCIERR_TEMP_FILE,        // Could not create a temporary file
                               //  erf.erfTyp has C run-time *errno* value
      FCIERR_BAD_COMPR_TYPE,   // Unknown compression type
      FCIERR_CAB_FILE,         // Could not create cabinet file
                               //  erf.erfTyp has C run-time *errno* value
      FCIERR_USER_ABORT,       // Client requested abort
      FCIERR_MCI_FAIL          // Failure compressing data
    );

(*
 * FAT file attribute flag used by FCI/FDI to indicate that
 * the filename in the CAB is a UTF string
 *)

const
  _A_NAME_IS_UTF = $80;

(*
 * FAT file attribute flag used by FCI/FDI to indicate that
 * the file should be executed after extraction
 *)

const
  _A_EXEC = $40;

{**    HFCI - Handle to an FCI Context
 *
 }

type
  HFCI = PVoid;

{**    CCAB - Current Cabinet
 *
 *  This structure is used for passing in the cabinet parameters to FCI,
 *  and is passed back on certain FCI callbacks to provide cabinet
 *  information to the client.
 }

type
  TCCAB =
    packed record
        // longs first
      cb : TULONG;  // size available for cabinet on this media
      cbFolderThresh : TULONG;  // Thresshold for forcing a new Folder
        // then ints
      cbReserveCFHeader : TUINT;  // Space to reserve in CFHEADER
      cbReserveCFFolder : TUINT;  // Space to reserve in CFFOLDER
      cbReserveCFData : TUINT;  // Space to reserve in CFDATA
      iCab : Integer;  // sequential numbers for cabinets
      iDisk : Integer;  // Disk number

      {$IFNDEF REMOVE_CHICAGO_M6_HACK}
      fFailOnIncompressible : Integer;  // TRUE => Fail if a block is incompressible
      {$ENDIF}
      
        //  then shorts
      setID : TUSHORT;  // Cabinet set ID
        // then chars
      szDisk : array[0..256 - 1] of Char;  // current disk name
      szCab : array[0..256 - 1] of Char;  // current cabinet name
      szCabPath : array[0..256 - 1] of Char;  // path for creating cabinet
    end;
    
                                       { ccab }
  PCCAB = ^TCCAB;
  
                                       { pccab }

{**    FNFCIALLOC - Memory Allocation
 *      FNFCIFREE  - Memory Free
 *
 *  These are modeled after the C run-time routines malloc() and free()
 *  FCI expects error handling to be identical to these C run-time routines.
 *
 *  As long as you faithfully copy the semantics of malloc() and free(),
 *  you can supply any functions you like!
 *
 *  WARNING: You should never assume anything about the sequence of
 *           FNFCIALLOC and FNFCIFREE calls -- incremental releases of
 *           FCI may have radically different numbers of
 *           FNFCIALLOC calls and allocation sizes!
 }

  //** Memory functions for FCI

type
  TFNFCIALLOC = function (cb : TULONG) : PVoid; cdecl;
  PFNFCIALLOC = TFNFCIALLOC;
  
                                       { pfna }
  TFNFCIFREE = function (memory : PVoid) : Pointer; cdecl;
  PFNFCIFREE = TFNFCIFREE;
  
                                       { pfnf }

{**    PFNFCIOPEN  - File I/O callbacks for FCI
 *      PFNFCIREAD
 *      PFNFCIWRITE
 *      PFNFCICLOSE
 *      PFNFCISEEK
 *
 *  These are modeled after the C run-time routines _open, _read,
 *  _write, _close, and _lseek.  The values for the PFNFCIOPEN oflag
 *  and pmode calls are those defined for _open.  FCI expects error
 *  handling to be identical to these C run-time routines, except that
 *  the value of errno should be returned via *err.
 *
 *  As long as you faithfully copy these aspects, you can supply
 *  any functions you like!
 *
 *  WARNING: You should never assume you know what file is being
 *           opened at any one point in time!  It is possible
 *           that in a future implementations it may open temporary
 *           files or cabinet files in a different order.
 }

  //** File I/O functions for FCI

type        
  TFNFCIOPEN = function (pszFile : PChar; oflag : Integer; pmode : Integer;
    err : PInteger; pv : Pointer) : Integer; cdecl;
  PFNFCIOPEN = TFNFCIOPEN;

  TFNFCIREAD = function (hf : Integer; memory : PVoid; cb : TUINT; 
    err : PInteger; pv : Pointer) : TUINT; cdecl;
  PFNFCIREAD = TFNFCIREAD;
  
  TFNFCIWRITE = function (hf : Integer; memory : PVoid; cb : TUINT;
    err : PInteger; pv : Pointer) : TUINT; cdecl;
  PFNFCIWRITE = TFNFCIWRITE;
  
  TFNFCICLOSE = function (hf : Integer; err : PInteger; pv : Pointer) : 
    Integer; cdecl;
  PFNFCICLOSE = TFNFCICLOSE;
  
  TFNFCISEEK = function (hf : Integer; dist : Longint; seektype : Integer; 
    err : PInteger; pv : Pointer) : Longint; cdecl;
  PFNFCISEEK = TFNFCISEEK;
  
  TFNFCIDELETE = function (pszFile : PChar; err : PInteger; pv : Pointer) : 
    Integer; cdecl;
  PFNFCIDELETE = TFNFCIDELETE;
  
{**    FNFCIGETNEXTCABINET - Callback used to request new cabinet info
 *
 *  Entry:
 *      pccab     - Points to copy of old ccab structure to modify
 *      cbPrevCab - Estimate of size of previous cabinet
 *      pv        - Has the caller's context pointer
 *
 *  Exit-Success:
 *      returns TRUE;
 *
 *  Exit-Failure:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -