Unit Fci

++ 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 --

Classes

Functions

CompressionLevelFromTCOMP -
CompressionMemoryFromTCOMP -
CompressionTypeFromTCOMP -
FCIAddFile - FCIAddFile - Add a disk file to a folder/cabinet * * Entry: * hfci - FCI context handle * pszSourceFile - Name of file to add to folder * pszFileName - Name to store into folder/cabinet * fExecute - Flag indicating execute on extract * pfn_progress - Progress callback * pfnfcignc - GetNextCabinet callback * pfnfcis - Status callback * pfnfcigoi - OpenInfo callback * typeCompress - Type of compression to use for this file * pv - pointer to caller's internal context * * Exit-Success: * returns TRUE * * Exit-Failure: * returns FALSE, error filled in * * This is the main function used to add file(s) to a cabinet * or series of cabinets.
FCICreate - pfnfcigtf } {** FCICreate -- create an FCI context (an open CAB, an open FOL) * * Entry: * perf - structure where we return error codes * pfnfcifp - callback to inform caller of eventual dest of files * pfna - memory allocation function callback * pfnf - memory free function callback * pfnfcigtf - temp file name generator callback * pccab - pointer to cabinet/disk name & size structure * * Notes: * (1) The alloc/free callbacks must remain valid throughout * the life of the context, up to and including the call to * FCIDestroy.
FCIDestroy - FCIDestroy - Destroy a FCI context and delete temp files * * Entry: * hfci - FCI context * * Exit-Success: * return code TRUE * * Exit-Failure: * return code FALSE, error structure filled in
FCIFlushCabinet - FCIFlushCabinet - Complete the current cabinet under construction * * This will cause the current cabinet (assuming it is not empty) to * be gathered together and written to disk.
FCIFlushFolder - FCIFlushFolder - Complete the current folder under construction * * This will force the termination of the current folder, which may or * may not cause one or more cabinet files to be completed.
LZXCompressionWindowFromTCOMP -
TCOMPfromLZXWindow -
TCOMPfromTypeLevelMemory -

Types

HFCI
PCCAB
PERF
PFNFCIALLOC
PFNFCICLOSE
PFNFCIDELETE
PFNFCIFILEPLACED
PFNFCIFREE
PFNFCIGETNEXTCABINET
PFNFCIGETOPENINFO
PFNFCIGETTEMPFILE
PFNFCIOPEN
PFNFCIREAD
PFNFCISEEK
PFNFCISTATUS
PFNFCIWRITE
PVoid
TBYTE
TCCAB
TCHECKSUM
TCOFF
TCOMP
TERF
TFCIERROR
TFNFCIALLOC
TFNFCICLOSE
TFNFCIDELETE
TFNFCIFILEPLACED
TFNFCIFREE
TFNFCIGETNEXTCABINET
TFNFCIGETOPENINFO
TFNFCIGETTEMPFILE
TFNFCIOPEN
TFNFCIREAD
TFNFCISEEK
TFNFCISTATUS
TFNFCIWRITE
TUINT
TULONG
TUOFF
TUSHORT
USHORT

Constants

CB_MAX_CABINET_NAME
CB_MAX_CAB_PATH
CB_MAX_CHUNK
CB_MAX_DISK
CB_MAX_DISK_NAME
CB_MAX_FILENAME
statusCabinet
statusFile
statusFolder
tcompBAD
tcompLZX_WINDOW_HI
tcompLZX_WINDOW_LO
tcompMASK_LZX_WINDOW
tcompMASK_QUANTUM_LEVEL
tcompMASK_QUANTUM_MEM
tcompMASK_RESERVED
tcompMASK_TYPE
tcompQUANTUM_LEVEL_HI
tcompQUANTUM_LEVEL_LO
tcompQUANTUM_MEM_HI
tcompQUANTUM_MEM_LO
tcompSHIFT_LZX_WINDOW
tcompSHIFT_QUANTUM_LEVEL
tcompSHIFT_QUANTUM_MEM
tcompTYPE_LZX
tcompTYPE_MSZIP
tcompTYPE_NONE
tcompTYPE_QUANTUM
_A_EXEC
_A_NAME_IS_UTF

Variables


Functions


function CompressionLevelFromTCOMP (tc : TCOMP) : Integer;


function CompressionMemoryFromTCOMP (tc : TCOMP) : Integer;


function CompressionTypeFromTCOMP (tc : TCOMP) : Integer;


function FCIAddFile (hfci : HFCI; pszSourceFile : PChar; pszFileName : PChar; fExecute : Bool; pfnfcignc : PFNFCIGETNEXTCABINET; pfnfcis : PFNFCISTATUS; pfnfcigoi : PFNFCIGETOPENINFO; typeCompress : TCOMP) : Bool;

FCIAddFile - Add a disk file to a folder/cabinet * * Entry: * hfci - FCI context handle * pszSourceFile - Name of file to add to folder * pszFileName - Name to store into folder/cabinet * fExecute - Flag indicating execute on extract * pfn_progress - Progress callback * pfnfcignc - GetNextCabinet callback * pfnfcis - Status callback * pfnfcigoi - OpenInfo callback * typeCompress - Type of compression to use for this file * pv - pointer to caller's internal context * * Exit-Success: * returns TRUE * * Exit-Failure: * returns FALSE, error filled in * * This is the main function used to add file(s) to a cabinet * or series of cabinets. If the current file causes the current * folder/cabinet to overflow the disk image currently being built, * the cabinet will be terminated, and a new cabinet/disk name will * be prompted for via a callback. The pending folder will be trimmed * of the data which has already been generated in the finished cabinet.

function FCICreate (perf : PERF; pfnfcifp : PFNFCIFILEPLACED; pfna : PFNFCIALLOC; pfnf : PFNFCIFREE; pfnopen : PFNFCIOPEN; pfnread : PFNFCIREAD; pfnwrite : PFNFCIWRITE; pfnclose : PFNFCICLOSE; pfnseek : PFNFCISEEK; pfndelete : PFNFCIDELETE; pfnfcigtf : PFNFCIGETTEMPFILE; pccab : PCCAB; pv : Pointer) : HFCI;

pfnfcigtf } {** FCICreate -- create an FCI context (an open CAB, an open FOL) * * Entry: * perf - structure where we return error codes * pfnfcifp - callback to inform caller of eventual dest of files * pfna - memory allocation function callback * pfnf - memory free function callback * pfnfcigtf - temp file name generator callback * pccab - pointer to cabinet/disk name & size structure * * Notes: * (1) The alloc/free callbacks must remain valid throughout * the life of the context, up to and including the call to * FCIDestroy. * (2) The perf pointer is stored in the compression context (HCI), * and any errors from subsequent FCI calls are stored in the * erf that was passed in on *this* call. * * Exit-Success: * Returns non-NULL handle to an FCI context. * * Exit-Failure: * Returns NULL, perf filled in.

function FCIDestroy (hfci : HFCI) : Bool;

FCIDestroy - Destroy a FCI context and delete temp files * * Entry: * hfci - FCI context * * Exit-Success: * return code TRUE * * Exit-Failure: * return code FALSE, error structure filled in

function FCIFlushCabinet (hfci : HFCI; fGetNextCab : Bool; pfnfcignc : PFNFCIGETNEXTCABINET; pfnfcis : PFNFCISTATUS) : Bool;

FCIFlushCabinet - Complete the current cabinet under construction * * This will cause the current cabinet (assuming it is not empty) to * be gathered together and written to disk. * * Entry: * hfci - FCI context * fGetNextCab - TRUE => Call GetNextCab to get continuation info; * FALSE => Don't call GetNextCab unless this cabinet * overflows. * pfnfcignc - callback function to get continuation cabinets * pfnfcis - callback function for progress reporting * pv - caller's internal context for callbacks * * Exit-Success: * return code TRUE * * Exit-Failure: * return code FALSE, error structure filled in

function FCIFlushFolder (hfci : HFCI; pfnfcignc : PFNFCIGETNEXTCABINET; pfnfcis : PFNFCISTATUS) : Bool;

FCIFlushFolder - Complete the current folder under construction * * This will force the termination of the current folder, which may or * may not cause one or more cabinet files to be completed. * * Entry: * hfci - FCI context * GetNextCab - callback function to get continuation cabinets * pfnProgress - callback function for progress reporting * pv - caller's internal context for callbacks * * Exit-Success: * return code TRUE * * Exit-Failure: * return code FALSE, error structure filled in

function LZXCompressionWindowFromTCOMP (tc : TCOMP) : Integer;


function TCOMPfromLZXWindow (w : Integer) : Integer;


function TCOMPfromTypeLevelMemory (t : Integer; l : Integer; m : Integer) : Integer;


Types


HFCI = PVoid
HFCI - Handle to an FCI Context *
PCCAB = ^TCCAB
ccab
PERF = ^TERF
erf
PFNFCIALLOC = TFNFCIALLOC

PFNFCICLOSE = TFNFCICLOSE

PFNFCIDELETE = TFNFCIDELETE

PFNFCIFILEPLACED = TFNFCIFILEPLACED

PFNFCIFREE = TFNFCIFREE

PFNFCIGETNEXTCABINET = TFNFCIGETNEXTCABINET

PFNFCIGETOPENINFO = TFNFCIGETOPENINFO

PFNFCIGETTEMPFILE = TFNFCIGETTEMPFILE

PFNFCIOPEN = TFNFCIOPEN

PFNFCIREAD = TFNFCIREAD

PFNFCISEEK = TFNFCISEEK

PFNFCISTATUS = TFNFCISTATUS

PFNFCIWRITE = TFNFCIWRITE

PVoid = Pointer

TBYTE = Char
f
TCCAB = record
cb : TULONG;
cbFolderThresh : TULONG;
cbReserveCFHeader : TUINT;
cbReserveCFFolder : TUINT;
cbReserveCFData : TUINT;
iCab : Integer;
iDisk : Integer;
fFailOnIncompressible : Integer;
setID : TUSHORT;
szDisk : array[0..256 - 1] of Char;
szCab : array[0..256 - 1] of Char;
szCabPath : array[0..256 - 1] of Char;
end;
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.
TCHECKSUM = Longint
ul
TCOFF = Longint
uoff - uncompressed offset
TCOMP = Smallint
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.
TERF = record
erfOper : Integer;
erfType : Integer;
fError : Bool;
end;
coff - cabinet file offset } {** ERF - Error structure * * This structure returns error information from FCI/FDI. The caller should * not modify this structure.
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
    );
FCIERROR - Error codes returned in erf.erfOper field *
TFNFCIALLOC = function (cb : TULONG) : PVoid
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
TFNFCICLOSE = function (hf : Integer; err : PInteger; pv : Pointer) : 
    Integer

TFNFCIDELETE = function (pszFile : PChar; err : PInteger; pv : Pointer) : 
    Integer

TFNFCIFILEPLACED = function (pccab : PCCAB; pszFile : PChar; 
    cbFile : Longint; fContinuation : Bool; pv : Pointer) : Integer
pfnfcignc } {** FNFCIFILEPLACED - Notify FCI client that file was placed * * Entry: * pccab - cabinet structure to fill in, with copy of previous one * pszFile - name of file, from cabinet * cbFile - length of file * fContinuation - true if this is a later segment of a continued file * pv - the context of the client * * Exit-Success: * return value anything but -1 * * Exit-Failure: * return value -1 means to abort
TFNFCIFREE = function (memory : PVoid) : Pointer
pfna
TFNFCIGETNEXTCABINET = function (pccab : PCCAB; cbPrevCab : TULONG; 
    pv : Pointer) : Bool
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: * returns FALSE;
TFNFCIGETOPENINFO = function (pszName : PChar; var pdate : TUSHORT; 
    var ptime : TUSHORT; var pattribs : TUSHORT; err : PInteger; pv : Pointer) : 
    Integer
pfnfcifp } {** FNCDIGETOPENINFO - Open source file, get date/time/attribs * * Entry: * pszName -- complete path to filename * pdate -- location to return FAT-style date code * ptime -- location to return FAT-style time code * pattribs -- location to return FAT-style attributes * pv -- client's context * * Exit-Success: * Return value is file handle of open file to read * * Exit-Failure: * Return value is -1
TFNFCIGETTEMPFILE = function (pszTempName : PChar; cbTempName : Integer; 
    pv : Pointer) : Bool
pfnfcis } {** FNFCIGETTEMPFILE - Callback, requests temporary file name * * Entry: * pszTempName - Buffer to receive complete tempfile name * cbTempName - Size of pszTempName buffer * * Exit-Success: * return TRUE * * Exit-Failure: * return FALSE; could not create tempfile, or buffer too small * * Note: * It is conceivable that this function may return a filename * that will already exist by the time it is opened. For this * reason, the caller should make several attempts to create * temporary files before giving up.
TFNFCIOPEN = function (pszFile : PChar; oflag : Integer; pmode : Integer;
    err : PInteger; pv : Pointer) : Integer
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
TFNFCIREAD = function (hf : Integer; memory : PVoid; cb : TUINT; 
    err : PInteger; pv : Pointer) : TUINT

TFNFCISEEK = function (hf : Integer; dist : Longint; seektype : Integer; 
    err : PInteger; pv : Pointer) : Longint

TFNFCISTATUS = function (typeStatus : TUINT; cb1 : TULONG; cb2 : TULONG; 
    pv : Pointer) : Longint

TFNFCIWRITE = function (hf : Integer; memory : PVoid; cb : TUINT;
    err : PInteger; pv : Pointer) : TUINT

TUINT = Integer
b
TULONG = Longint
us
TUOFF = Longint
csum
TUSHORT = Smallint
ui
USHORT = Word

Constants

CB_MAX_CABINET_NAME = 256

CB_MAX_CAB_PATH = 256

CB_MAX_CHUNK = 32768

perf

CB_MAX_DISK = $7ffffff

CB_MAX_DISK_NAME = 256

CB_MAX_FILENAME = 256

statusCabinet = 2

statusFile = 0

pfnfcigoi } {** FNFCISTATUS - Status/Cabinet Size callback * * Entry: * typeStatus == statusFile if compressing a block into a folder * cb1 = Size of compressed block * cb2 = Size of uncompressed block * * typeStatus == statusFolder if adding a folder to a cabinet * cb1 = Amount of folder copied to cabinet so far * cb2 = Total size of folder * * typeStatus == statusCabinet if writing out a complete cabinet * cb1 = Estimated cabinet size that was previously * passed to fnfciGetNextCabinet(). * cb2 = Actual cabinet size * NOTE: Return value is desired client size for cabinet * file. FCI updates the maximum cabinet size * remaining using this value. This allows a client * to generate multiple cabinets per disk, and have * FCI limit the size correctly -- the client can do * cluster size rounding on the cabinet size! * The client should either return cb2, or round cb2 * up to some larger value and return that. * Exit-Success: * Returns anything other than -1; * NOTE: See statusCabinet for special return values! * * Exit-Failure: * Returns -1 to signal that FCI should abort;

statusFolder = 1

tcompBAD = $000F

tcompLZX_WINDOW_HI = $1500

tcompLZX_WINDOW_LO = $0F00

tcompMASK_LZX_WINDOW = $1F00

tcompMASK_QUANTUM_LEVEL = $00F0

tcompMASK_QUANTUM_MEM = $1F00

tcompMASK_RESERVED = $E000

tcompMASK_TYPE = $000F

tcomp

tcompQUANTUM_LEVEL_HI = $0070

tcompQUANTUM_LEVEL_LO = $0010

tcompQUANTUM_MEM_HI = $1500

tcompQUANTUM_MEM_LO = $0A00

tcompSHIFT_LZX_WINDOW = 8

tcompSHIFT_QUANTUM_LEVEL = 4

tcompSHIFT_QUANTUM_MEM = 8

tcompTYPE_LZX = $0003

tcompTYPE_MSZIP = $0001

tcompTYPE_NONE = $0000

tcompTYPE_QUANTUM = $0002

_A_EXEC = $40

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

_A_NAME_IS_UTF = $80

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

Variables