1*c2c66affSColin Finck /* 2*c2c66affSColin Finck * Copyright (C) 2002 Patrik Stridvall 3*c2c66affSColin Finck * 4*c2c66affSColin Finck * This library is free software; you can redistribute it and/or 5*c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public 6*c2c66affSColin Finck * License as published by the Free Software Foundation; either 7*c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version. 8*c2c66affSColin Finck * 9*c2c66affSColin Finck * This library is distributed in the hope that it will be useful, 10*c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of 11*c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12*c2c66affSColin Finck * Lesser General Public License for more details. 13*c2c66affSColin Finck * 14*c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public 15*c2c66affSColin Finck * License along with this library; if not, write to the Free Software 16*c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17*c2c66affSColin Finck */ 18*c2c66affSColin Finck 19*c2c66affSColin Finck #ifndef __WINE_FDI_H 20*c2c66affSColin Finck #define __WINE_FDI_H 21*c2c66affSColin Finck 22*c2c66affSColin Finck #ifdef __cplusplus 23*c2c66affSColin Finck extern "C" { 24*c2c66affSColin Finck #endif /* defined(__cplusplus) */ 25*c2c66affSColin Finck 26*c2c66affSColin Finck #include <pshpack4.h> 27*c2c66affSColin Finck 28*c2c66affSColin Finck #ifndef INCLUDED_TYPES_FCI_FDI 29*c2c66affSColin Finck #define INCLUDED_TYPES_FCI_FDI 1 30*c2c66affSColin Finck 31*c2c66affSColin Finck /*********************************************************************** 32*c2c66affSColin Finck * Common FCI/TDI declarations 33*c2c66affSColin Finck */ 34*c2c66affSColin Finck 35*c2c66affSColin Finck typedef ULONG CHECKSUM; 36*c2c66affSColin Finck 37*c2c66affSColin Finck typedef ULONG UOFF; 38*c2c66affSColin Finck typedef ULONG COFF; 39*c2c66affSColin Finck 40*c2c66affSColin Finck /**********************************************************************/ 41*c2c66affSColin Finck 42*c2c66affSColin Finck typedef struct { 43*c2c66affSColin Finck int erfOper; /* FCI/FDI error code - see {FCI,FDI}ERROR_XXX for details. */ 44*c2c66affSColin Finck int erfType; /* Optional error value filled in by FCI/FDI. */ 45*c2c66affSColin Finck BOOL fError; /* TRUE => error present */ 46*c2c66affSColin Finck } ERF, *PERF; 47*c2c66affSColin Finck 48*c2c66affSColin Finck /**********************************************************************/ 49*c2c66affSColin Finck 50*c2c66affSColin Finck #define CB_MAX_CHUNK 32768U 51*c2c66affSColin Finck #define CB_MAX_DISK 0x7fffffffL 52*c2c66affSColin Finck #define CB_MAX_FILENAME 256 53*c2c66affSColin Finck #define CB_MAX_CABINET_NAME 256 54*c2c66affSColin Finck #define CB_MAX_CAB_PATH 256 55*c2c66affSColin Finck #define CB_MAX_DISK_NAME 256 56*c2c66affSColin Finck 57*c2c66affSColin Finck /**********************************************************************/ 58*c2c66affSColin Finck 59*c2c66affSColin Finck typedef unsigned short TCOMP; 60*c2c66affSColin Finck 61*c2c66affSColin Finck #define tcompMASK_TYPE 0x000F /* Mask for compression type */ 62*c2c66affSColin Finck #define tcompTYPE_NONE 0x0000 /* No compression */ 63*c2c66affSColin Finck #define tcompTYPE_MSZIP 0x0001 /* MSZIP */ 64*c2c66affSColin Finck #define tcompTYPE_QUANTUM 0x0002 /* Quantum */ 65*c2c66affSColin Finck #define tcompTYPE_LZX 0x0003 /* LZX */ 66*c2c66affSColin Finck #define tcompBAD 0x000F /* Unspecified compression type */ 67*c2c66affSColin Finck 68*c2c66affSColin Finck #define tcompMASK_LZX_WINDOW 0x1F00 /* Mask for LZX Compression Memory */ 69*c2c66affSColin Finck #define tcompLZX_WINDOW_LO 0x0F00 /* Lowest LZX Memory (15) */ 70*c2c66affSColin Finck #define tcompLZX_WINDOW_HI 0x1500 /* Highest LZX Memory (21) */ 71*c2c66affSColin Finck #define tcompSHIFT_LZX_WINDOW 8 /* Amount to shift over to get int */ 72*c2c66affSColin Finck 73*c2c66affSColin Finck #define tcompMASK_QUANTUM_LEVEL 0x00F0 /* Mask for Quantum Compression Level */ 74*c2c66affSColin Finck #define tcompQUANTUM_LEVEL_LO 0x0010 /* Lowest Quantum Level (1) */ 75*c2c66affSColin Finck #define tcompQUANTUM_LEVEL_HI 0x0070 /* Highest Quantum Level (7) */ 76*c2c66affSColin Finck #define tcompSHIFT_QUANTUM_LEVEL 4 /* Amount to shift over to get int */ 77*c2c66affSColin Finck 78*c2c66affSColin Finck #define tcompMASK_QUANTUM_MEM 0x1F00 /* Mask for Quantum Compression Memory */ 79*c2c66affSColin Finck #define tcompQUANTUM_MEM_LO 0x0A00 /* Lowest Quantum Memory (10) */ 80*c2c66affSColin Finck #define tcompQUANTUM_MEM_HI 0x1500 /* Highest Quantum Memory (21) */ 81*c2c66affSColin Finck #define tcompSHIFT_QUANTUM_MEM 8 /* Amount to shift over to get int */ 82*c2c66affSColin Finck 83*c2c66affSColin Finck #define tcompMASK_RESERVED 0xE000 /* Reserved bits (high 3 bits) */ 84*c2c66affSColin Finck 85*c2c66affSColin Finck /**********************************************************************/ 86*c2c66affSColin Finck 87*c2c66affSColin Finck #define CompressionTypeFromTCOMP(tc) \ 88*c2c66affSColin Finck ((tc) & tcompMASK_TYPE) 89*c2c66affSColin Finck 90*c2c66affSColin Finck #define CompressionLevelFromTCOMP(tc) \ 91*c2c66affSColin Finck (((tc) & tcompMASK_QUANTUM_LEVEL) >> tcompSHIFT_QUANTUM_LEVEL) 92*c2c66affSColin Finck 93*c2c66affSColin Finck #define CompressionMemoryFromTCOMP(tc) \ 94*c2c66affSColin Finck (((tc) & tcompMASK_QUANTUM_MEM) >> tcompSHIFT_QUANTUM_MEM) 95*c2c66affSColin Finck 96*c2c66affSColin Finck #define TCOMPfromTypeLevelMemory(t, l, m) \ 97*c2c66affSColin Finck (((m) << tcompSHIFT_QUANTUM_MEM ) | \ 98*c2c66affSColin Finck ((l) << tcompSHIFT_QUANTUM_LEVEL) | \ 99*c2c66affSColin Finck ( t )) 100*c2c66affSColin Finck 101*c2c66affSColin Finck #define LZXCompressionWindowFromTCOMP(tc) \ 102*c2c66affSColin Finck (((tc) & tcompMASK_LZX_WINDOW) >> tcompSHIFT_LZX_WINDOW) 103*c2c66affSColin Finck 104*c2c66affSColin Finck #define TCOMPfromLZXWindow(w) \ 105*c2c66affSColin Finck (((w) << tcompSHIFT_LZX_WINDOW) | \ 106*c2c66affSColin Finck ( tcompTYPE_LZX )) 107*c2c66affSColin Finck 108*c2c66affSColin Finck #endif /* !defined(INCLUDED_TYPES_FCI_FDI) */ 109*c2c66affSColin Finck 110*c2c66affSColin Finck /*********************************************************************** 111*c2c66affSColin Finck * FDI declarations 112*c2c66affSColin Finck */ 113*c2c66affSColin Finck 114*c2c66affSColin Finck typedef enum { 115*c2c66affSColin Finck FDIERROR_NONE, 116*c2c66affSColin Finck FDIERROR_CABINET_NOT_FOUND, 117*c2c66affSColin Finck FDIERROR_NOT_A_CABINET, 118*c2c66affSColin Finck FDIERROR_UNKNOWN_CABINET_VERSION, 119*c2c66affSColin Finck FDIERROR_CORRUPT_CABINET, 120*c2c66affSColin Finck FDIERROR_ALLOC_FAIL, 121*c2c66affSColin Finck FDIERROR_BAD_COMPR_TYPE, 122*c2c66affSColin Finck FDIERROR_MDI_FAIL, 123*c2c66affSColin Finck FDIERROR_TARGET_FILE, 124*c2c66affSColin Finck FDIERROR_RESERVE_MISMATCH, 125*c2c66affSColin Finck FDIERROR_WRONG_CABINET, 126*c2c66affSColin Finck FDIERROR_USER_ABORT, 127*c2c66affSColin Finck } FDIERROR; 128*c2c66affSColin Finck 129*c2c66affSColin Finck /**********************************************************************/ 130*c2c66affSColin Finck 131*c2c66affSColin Finck #ifndef _A_NAME_IS_UTF 132*c2c66affSColin Finck #define _A_NAME_IS_UTF 0x80 133*c2c66affSColin Finck #endif 134*c2c66affSColin Finck 135*c2c66affSColin Finck #ifndef _A_EXEC 136*c2c66affSColin Finck #define _A_EXEC 0x40 137*c2c66affSColin Finck #endif 138*c2c66affSColin Finck 139*c2c66affSColin Finck /**********************************************************************/ 140*c2c66affSColin Finck 141*c2c66affSColin Finck typedef void *HFDI; 142*c2c66affSColin Finck 143*c2c66affSColin Finck /**********************************************************************/ 144*c2c66affSColin Finck 145*c2c66affSColin Finck typedef struct { 146*c2c66affSColin Finck LONG cbCabinet; /* Total length of cabinet file */ 147*c2c66affSColin Finck USHORT cFolders; /* Count of folders in cabinet */ 148*c2c66affSColin Finck USHORT cFiles; /* Count of files in cabinet */ 149*c2c66affSColin Finck USHORT setID; /* Cabinet set ID */ 150*c2c66affSColin Finck USHORT iCabinet; /* Cabinet number in set (0 based) */ 151*c2c66affSColin Finck BOOL fReserve; /* TRUE => RESERVE present in cabinet */ 152*c2c66affSColin Finck BOOL hasprev; /* TRUE => Cabinet is chained prev */ 153*c2c66affSColin Finck BOOL hasnext; /* TRUE => Cabinet is chained next */ 154*c2c66affSColin Finck } FDICABINETINFO, *PFDICABINETINFO; /* pfdici */ 155*c2c66affSColin Finck 156*c2c66affSColin Finck /**********************************************************************/ 157*c2c66affSColin Finck 158*c2c66affSColin Finck typedef enum { 159*c2c66affSColin Finck fdidtNEW_CABINET, /* New cabinet */ 160*c2c66affSColin Finck fdidtNEW_FOLDER, /* New folder */ 161*c2c66affSColin Finck fdidtDECRYPT, /* Decrypt a data block */ 162*c2c66affSColin Finck } FDIDECRYPTTYPE; 163*c2c66affSColin Finck 164*c2c66affSColin Finck /**********************************************************************/ 165*c2c66affSColin Finck 166*c2c66affSColin Finck typedef struct { 167*c2c66affSColin Finck FDIDECRYPTTYPE fdidt; /* Command type (selects union below) */ 168*c2c66affSColin Finck 169*c2c66affSColin Finck void *pvUser; /* Decryption context */ 170*c2c66affSColin Finck 171*c2c66affSColin Finck union { 172*c2c66affSColin Finck struct { /* fdidtNEW_CABINET */ 173*c2c66affSColin Finck void *pHeaderReserve; /* RESERVE section from CFHEADER */ 174*c2c66affSColin Finck USHORT cbHeaderReserve; /* Size of pHeaderReserve */ 175*c2c66affSColin Finck USHORT setID; /* Cabinet set ID */ 176*c2c66affSColin Finck int iCabinet; /* Cabinet number in set (0 based) */ 177*c2c66affSColin Finck } cabinet; 178*c2c66affSColin Finck 179*c2c66affSColin Finck struct { /* fdidtNEW_FOLDER */ 180*c2c66affSColin Finck void *pFolderReserve; /* RESERVE section from CFFOLDER */ 181*c2c66affSColin Finck USHORT cbFolderReserve; /* Size of pFolderReserve */ 182*c2c66affSColin Finck USHORT iFolder; /* Folder number in cabinet (0 based) */ 183*c2c66affSColin Finck } folder; 184*c2c66affSColin Finck 185*c2c66affSColin Finck struct { /* fdidtDECRYPT */ 186*c2c66affSColin Finck void *pDataReserve; /* RESERVE section from CFDATA */ 187*c2c66affSColin Finck USHORT cbDataReserve; /* Size of pDataReserve */ 188*c2c66affSColin Finck void *pbData; /* Data buffer */ 189*c2c66affSColin Finck USHORT cbData; /* Size of data buffer */ 190*c2c66affSColin Finck BOOL fSplit; /* TRUE if this is a split data block */ 191*c2c66affSColin Finck USHORT cbPartial; /* 0 if this is not a split block, or 192*c2c66affSColin Finck * the first piece of a split block; 193*c2c66affSColin Finck * Greater than 0 if this is the 194*c2c66affSColin Finck * second piece of a split block. 195*c2c66affSColin Finck */ 196*c2c66affSColin Finck } decrypt; 197*c2c66affSColin Finck } DUMMYUNIONNAME; 198*c2c66affSColin Finck } FDIDECRYPT, *PFDIDECRYPT; 199*c2c66affSColin Finck 200*c2c66affSColin Finck /**********************************************************************/ 201*c2c66affSColin Finck 202*c2c66affSColin Finck typedef void * (__cdecl *PFNALLOC)(ULONG cb); 203*c2c66affSColin Finck #define FNALLOC(fn) void * __cdecl fn(ULONG cb) 204*c2c66affSColin Finck 205*c2c66affSColin Finck typedef void (__cdecl *PFNFREE)(void *pv); 206*c2c66affSColin Finck #define FNFREE(fn) void __cdecl fn(void *pv) 207*c2c66affSColin Finck 208*c2c66affSColin Finck typedef INT_PTR (__cdecl *PFNOPEN) (char *pszFile, int oflag, int pmode); 209*c2c66affSColin Finck #define FNOPEN(fn) INT_PTR __cdecl fn(char *pszFile, int oflag, int pmode) 210*c2c66affSColin Finck 211*c2c66affSColin Finck typedef UINT (__cdecl *PFNREAD) (INT_PTR hf, void *pv, UINT cb); 212*c2c66affSColin Finck #define FNREAD(fn) UINT __cdecl fn(INT_PTR hf, void *pv, UINT cb) 213*c2c66affSColin Finck 214*c2c66affSColin Finck typedef UINT (__cdecl *PFNWRITE)(INT_PTR hf, void *pv, UINT cb); 215*c2c66affSColin Finck #define FNWRITE(fn) UINT __cdecl fn(INT_PTR hf, void *pv, UINT cb) 216*c2c66affSColin Finck 217*c2c66affSColin Finck typedef int (__cdecl *PFNCLOSE)(INT_PTR hf); 218*c2c66affSColin Finck #define FNCLOSE(fn) int __cdecl fn(INT_PTR hf) 219*c2c66affSColin Finck 220*c2c66affSColin Finck typedef LONG (__cdecl *PFNSEEK) (INT_PTR hf, LONG dist, int seektype); 221*c2c66affSColin Finck #define FNSEEK(fn) LONG __cdecl fn(INT_PTR hf, LONG dist, int seektype) 222*c2c66affSColin Finck 223*c2c66affSColin Finck typedef int (__cdecl *PFNFDIDECRYPT)(PFDIDECRYPT pfdid); 224*c2c66affSColin Finck #define FNFDIDECRYPT(fn) int __cdecl fn(PFDIDECRYPT pfdid) 225*c2c66affSColin Finck 226*c2c66affSColin Finck typedef struct { 227*c2c66affSColin Finck LONG cb; 228*c2c66affSColin Finck char *psz1; 229*c2c66affSColin Finck char *psz2; 230*c2c66affSColin Finck char *psz3; /* Points to a 256 character buffer */ 231*c2c66affSColin Finck void *pv; /* Value for client */ 232*c2c66affSColin Finck 233*c2c66affSColin Finck INT_PTR hf; 234*c2c66affSColin Finck 235*c2c66affSColin Finck USHORT date; 236*c2c66affSColin Finck USHORT time; 237*c2c66affSColin Finck USHORT attribs; 238*c2c66affSColin Finck 239*c2c66affSColin Finck USHORT setID; /* Cabinet set ID */ 240*c2c66affSColin Finck USHORT iCabinet; /* Cabinet number (0-based) */ 241*c2c66affSColin Finck USHORT iFolder; /* Folder number (0-based) */ 242*c2c66affSColin Finck 243*c2c66affSColin Finck FDIERROR fdie; 244*c2c66affSColin Finck } FDINOTIFICATION, *PFDINOTIFICATION; 245*c2c66affSColin Finck 246*c2c66affSColin Finck typedef enum { 247*c2c66affSColin Finck fdintCABINET_INFO, /* General information about cabinet */ 248*c2c66affSColin Finck fdintPARTIAL_FILE, /* First file in cabinet is continuation */ 249*c2c66affSColin Finck fdintCOPY_FILE, /* File to be copied */ 250*c2c66affSColin Finck fdintCLOSE_FILE_INFO, /* Close the file, set relevant info */ 251*c2c66affSColin Finck fdintNEXT_CABINET, /* File continued to next cabinet */ 252*c2c66affSColin Finck fdintENUMERATE, /* Enumeration status */ 253*c2c66affSColin Finck } FDINOTIFICATIONTYPE; 254*c2c66affSColin Finck 255*c2c66affSColin Finck typedef INT_PTR (__cdecl *PFNFDINOTIFY)(FDINOTIFICATIONTYPE fdint, 256*c2c66affSColin Finck PFDINOTIFICATION pfdin); 257*c2c66affSColin Finck #define FNFDINOTIFY(fn) INT_PTR __cdecl fn(FDINOTIFICATIONTYPE fdint, \ 258*c2c66affSColin Finck PFDINOTIFICATION pfdin) 259*c2c66affSColin Finck 260*c2c66affSColin Finck #include <pshpack1.h> 261*c2c66affSColin Finck 262*c2c66affSColin Finck typedef struct { 263*c2c66affSColin Finck char ach[2]; /* Set to { '*', '\0' } */ 264*c2c66affSColin Finck LONG cbFile; /* Required spill file size */ 265*c2c66affSColin Finck } FDISPILLFILE, *PFDISPILLFILE; 266*c2c66affSColin Finck 267*c2c66affSColin Finck #include <poppack.h> 268*c2c66affSColin Finck 269*c2c66affSColin Finck #define cpuUNKNOWN (-1) /* FDI does detection */ 270*c2c66affSColin Finck #define cpu80286 (0) /* '286 opcodes only */ 271*c2c66affSColin Finck #define cpu80386 (1) /* '386 opcodes used */ 272*c2c66affSColin Finck 273*c2c66affSColin Finck /**********************************************************************/ 274*c2c66affSColin Finck 275*c2c66affSColin Finck HFDI __cdecl FDICreate(PFNALLOC, PFNFREE, PFNOPEN, PFNREAD, PFNWRITE, 276*c2c66affSColin Finck PFNCLOSE, PFNSEEK, int, PERF); 277*c2c66affSColin Finck BOOL __cdecl FDIIsCabinet(HFDI, INT_PTR, PFDICABINETINFO); 278*c2c66affSColin Finck BOOL __cdecl FDICopy(HFDI, char *, char *, int, PFNFDINOTIFY, 279*c2c66affSColin Finck PFNFDIDECRYPT, void *pvUser); 280*c2c66affSColin Finck BOOL __cdecl FDIDestroy(HFDI); 281*c2c66affSColin Finck BOOL __cdecl FDITruncateCabinet(HFDI, char *, USHORT); 282*c2c66affSColin Finck 283*c2c66affSColin Finck /**********************************************************************/ 284*c2c66affSColin Finck 285*c2c66affSColin Finck #include <poppack.h> 286*c2c66affSColin Finck 287*c2c66affSColin Finck #ifdef __cplusplus 288*c2c66affSColin Finck } /* extern "C" */ 289*c2c66affSColin Finck #endif /* defined(__cplusplus) */ 290*c2c66affSColin Finck 291*c2c66affSColin Finck #endif /* __WINE_FDI_H */ 292