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