📄 fdi.h
字号:
};
} FDIDECRYPT; /* fdid */
typedef FDIDECRYPT FAR *PFDIDECRYPT; /* pfdid */
/*** FNALLOC - Memory Allocation
* FNFREE - Memory Free
*
* These are modeled after the C run-time routines malloc() and free()
* FDI 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
* PFNALLOC and PFNFREE calls -- incremental releases of
* FDI may have radically different numbers of
* PFNALLOC calls and allocation sizes!
*/
//** Memory functions for FDI
typedef void HUGE * (FAR DIAMONDAPI *PFNALLOC)(ULONG cb); /* pfna */
#define FNALLOC(fn) void HUGE * FAR DIAMONDAPI fn(ULONG cb)
typedef void (FAR DIAMONDAPI *PFNFREE)(void HUGE *pv); /* pfnf */
#define FNFREE(fn) void FAR DIAMONDAPI fn(void HUGE *pv)
/*** PFNOPEN - File I/O callbacks for FDI
* PFNREAD
* PFNWRITE
* PFNCLOSE
* PFNSEEK
*
* These are modeled after the C run-time routines _open, _read,
* _write, _close, and _lseek. The values for the PFNOPEN oflag
* and pmode calls are those defined for _open. FDI expects error
* handling to be identical to these C run-time routines.
*
* 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! FDI will usually
* stick to opening cabinet files, but it is possible
* that in a future implementation it may open temporary
* files or open cabinet files in a different order.
*
* Notes for Memory Mapped File fans:
* You can write wrapper routines to allow FDI to work on memory
* mapped files. You'll have to create your own "handle" type so that
* you can store the base memory address of the file and the current
* seek position, and then you'll allocate and fill in one of these
* structures and return a pointer to it in response to the PFNOPEN
* call and the fdintCOPY_FILE call. Your PFNREAD and PFNWRITE
* functions will do memcopy(), and update the seek position in your
* "handle" structure. PFNSEEK will just change the seek position
* in your "handle" structure.
*/
//** File I/O functions for FDI
typedef int (FAR DIAMONDAPI *PFNOPEN) (char FAR *pszFile, int oflag, int pmode);
typedef UINT (FAR DIAMONDAPI *PFNREAD) (int hf, void FAR *pv, UINT cb);
typedef UINT (FAR DIAMONDAPI *PFNWRITE)(int hf, void FAR *pv, UINT cb);
typedef int (FAR DIAMONDAPI *PFNCLOSE)(int hf);
typedef long (FAR DIAMONDAPI *PFNSEEK) (int hf, long dist, int seektype);
#define FNOPEN(fn) int FAR DIAMONDAPI fn(char FAR *pszFile, int oflag, int pmode)
#define FNREAD(fn) UINT FAR DIAMONDAPI fn(int hf, void FAR *pv, UINT cb)
#define FNWRITE(fn) UINT FAR DIAMONDAPI fn(int hf, void FAR *pv, UINT cb)
#define FNCLOSE(fn) int FAR DIAMONDAPI fn(int hf)
#define FNSEEK(fn) long FAR DIAMONDAPI fn(int hf, long dist, int seektype)
/*** PFNFDIDECRYPT - FDI Decryption callback
*
* If this function is passed on the FDICopy() call, then FDI calls it
* at various times to update the decryption state and to decrypt FCDATA
* blocks.
*
* Common Entry Conditions:
* pfdid->fdidt - Command type
* pfdid->pvUser - pvUser value from FDICopy() call
*
* fdidtNEW_CABINET: //** Notification of a new cabinet
* Entry:
* pfdid->cabinet.
* pHeaderReserve - RESERVE section from CFHEADER
* cbHeaderReserve - Size of pHeaderReserve
* setID - Cabinet set ID
* iCabinet - Cabinet number in set (0 based)
* Exit-Success:
* returns anything but -1;
* Exit-Failure:
* returns -1; FDICopy() is aborted.
* Notes:
* (1) This call allows the decryption code to pick out any information
* from the cabinet header reserved area (placed there by DIACRYPT)
* needed to perform decryption. If there is no such information,
* this call would presumably be ignored.
* (2) This call is made very soon after fdintCABINET_INFO.
*
* fdidtNEW_FOLDER: //** Notification of a new folder
* Entry:
* pfdid->folder.
* pFolderReserve - RESERVE section from CFFOLDER
* cbFolderReserve - Size of pFolderReserve
* iFolder - Folder number in cabinet (0 based)
* Exit-Success:
* returns anything but -1;
* Exit-Failure:
* returns -1; FDICopy() is aborted.
* Notes:
* This call allows the decryption code to pick out any information
* from the folder reserved area (placed there by DIACRYPT) needed
* to perform decryption. If there is no such information, this
* call would presumably be ignored.
*
* fdidtDECRYPT: //** Decrypt a data buffer
* Entry:
* pfdid->folder.
* pDataReserve - RESERVE section for this CFDATA block
* cbDataReserve - Size of pDataReserve
* pbData - Data buffer
* cbData - Size of data buffer
* fSplit - TRUE if this is a split data block
* cbPartial - 0 if this is not a split block, or the first
* piece of a split block; Greater than 0 if
* this is the second piece of a split block.
* Exit-Success:
* returns TRUE;
* Exit-Failure:
* returns FALSE; error during decrypt
* returns -1; FDICopy() is aborted.
* Notes:
* FCI will split CFDATA blocks across cabinet boundaries if
* necessary. To provide maximum flexibility, FDI will call the
* fdidtDECRYPT function twice on such split blocks, once when
* the first portion is read, and again when the second portion
* is read. And, of course, most data blocks will not be split.
* So, there are three cases:
*
* 1) fSplit == FALSE
* You have the entire data block, so decrypt it.
*
* 2) fSplit == TRUE, cbPartial == 0
* This is the first portion of a split data block, so cbData
* is the size of this portion. You can either choose to decrypt
* this piece, or ignore this call and decrypt the full CFDATA
* block on the next (second) fdidtDECRYPT call.
*
* 3) fSplit == TRUE, cbPartial > 0
* This is the second portion of a split data block (indeed,
* cbPartial will have the same value as cbData did on the
* immediately preceeding fdidtDECRYPT call!). If you decrypted
* the first portion on the first call, then you can decrypt the
* second portion now. If you ignored the first call, then you
* can decrypt the entire buffer.
* NOTE: pbData points to the second portion of the split data
* block in this case, *not* the entire data block. If
* you want to wait until the second piece to decrypt the
* *entire* block, pbData-cbPartial is the address of the
* start of the whole block, and cbData+cbPartial is its
* size.
*/
typedef int (FAR DIAMONDAPI *PFNFDIDECRYPT)(PFDIDECRYPT pfdid); /* pfnfdid */
#define FNFDIDECRYPT(fn) int FAR DIAMONDAPI fn(PFDIDECRYPT pfdid)
/*** FDINOTIFICATION - Notification structure for PFNFDINOTIFY
*
* See the FDINOTIFICATIONTYPE definition for information on usage and
* meaning of these fields.
*/
typedef struct {
// long fields
long cb;
char FAR *psz1;
char FAR *psz2;
char FAR *psz3; // Points to a 256 character buffer
void FAR *pv; // Value for client
// int fields
int hf;
// short fields
USHORT date;
USHORT time;
USHORT attribs;
USHORT setID; // Cabinet set ID
USHORT iCabinet; // Cabinet number (0-based)
USHORT iFolder; // Folder number (0-based)
FDIERROR fdie;
} FDINOTIFICATION, FAR *PFDINOTIFICATION; /* fdin, pfdin */
/*** FDINOTIFICATIONTYPE - FDICopy notification types
*
* The notification function for FDICopy can be called with the following
* values for the fdint parameter. In all cases, the pfdin->pv field is
* filled in with the value of the pvUser argument passed in to FDICopy().
*
* A typical sequence of calls will be something like this:
* fdintCABINET_INFO // Info about the cabinet
* fdintENUMERATE // Starting enumeration
* fdintPARTIAL_FILE // Only if this is not the first cabinet, and
* // one or more files were continued from the
* // previous cabinet.
* ...
* fdintPARTIAL_FILE
* fdintCOPY_FILE // The first file that starts in this cabinet
* ...
* fdintCOPY_FILE // Now let's assume you want this file...
* // PFNWRITE called multiple times to write to this file.
* fdintCLOSE_FILE_INFO // File done, set date/time/attributes
*
* fdintCOPY_FILE // Now let's assume you want this file...
* // PFNWRITE called multiple times to write to this file.
* fdintNEXT_CABINET // File was continued to next cabinet!
* fdintCABINET_INFO // Info about the new cabinet
* // PFNWRITE called multiple times to write to this file.
* fdintCLOSE_FILE_INFO // File done, set date/time/attributes
* ...
* fdintENUMERATE // Ending enumeration
*
* fdintCABINET_INFO:
* Called exactly once for each cabinet opened by FDICopy(), including
* continuation cabinets opened due to file(s) spanning cabinet
* boundaries. Primarily intended to permit EXTRACT.EXE to
* automatically select the next cabinet in a cabinet sequence even if
* not copying files that span cabinet boundaries.
* Entry:
* pfdin->psz1 = name of next cabinet
* pfdin->psz2 = name of next disk
* pfdin->psz3 = cabinet path name
* pfdin->setID = cabinet set ID (a random 16-bit number)
* pfdin->iCabinet = Cabinet number within cabinet set (0-based)
* Exit-Success:
* Return anything but -1
* Exit-Failure:
* Returns -1 => Abort FDICopy() call
* Notes:
* This call is made *every* time a new cabinet is examined by
* FDICopy(). So if "foo2.cab" is examined because a file is
* continued from "foo1.cab", and then you call FDICopy() again
* on "foo2.cab", you will get *two* fdintCABINET_INFO calls all
* told.
*
* fdintCOPY_FILE:
* Called for each file that *starts* in the current cabinet, giving
* the client the opportunity to request that the file be copied or
* skipped.
* Entry:
* pfdin->psz1 = file name in cabinet
* pfdin->cb = uncompressed size of file
* pfdin->date = file date
* pfdin->time = file time
* pfdin->attribs = file attributes
* pfdin->iFolder = file's folder index
* Exit-Success:
* Return non-zero file handle for destination file; FDI writes
* data to this file use the PFNWRITE function supplied to FDICreate,
* and then calls fdintCLOSE_FILE_INFO to close the file and set
* the date, time, and attributes. NOTE: This file handle returned
* must also be closeable by the PFNCLOSE function supplied to
* FDICreate, since if an error occurs while writing to this handle,
* FDI will use the PFNCLOSE function to close the file so that the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -