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