Added some stubs.
[wine/wine64.git] / dlls / cabinet / cabinet.h
blob934d152062c1c43131d85a2138362967f7de258c
1 /*
2 * cabinet.h
4 * Copyright 2002 Greg Turner
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef __WINE_CABINET_H
21 #define __WINE_CABINET_H
23 #include "winnt.h"
24 #include "fdi.h"
25 #include "fci.h"
27 #define CAB_SPLITMAX (10)
29 #define CAB_SEARCH_SIZE (32*1024)
31 typedef unsigned char cab_UBYTE; /* 8 bits */
32 typedef UINT16 cab_UWORD; /* 16 bits */
33 typedef UINT32 cab_ULONG; /* 32 bits */
34 typedef INT32 cab_LONG; /* 32 bits */
36 typedef UINT32 cab_off_t;
38 /* number of bits in a ULONG */
39 #ifndef CHAR_BIT
40 # define CHAR_BIT (8)
41 #endif
42 #define CAB_ULONG_BITS (sizeof(cab_ULONG) * CHAR_BIT)
44 /* structure offsets */
45 #define cfhead_Signature (0x00)
46 #define cfhead_CabinetSize (0x08)
47 #define cfhead_FileOffset (0x10)
48 #define cfhead_MinorVersion (0x18)
49 #define cfhead_MajorVersion (0x19)
50 #define cfhead_NumFolders (0x1A)
51 #define cfhead_NumFiles (0x1C)
52 #define cfhead_Flags (0x1E)
53 #define cfhead_SetID (0x20)
54 #define cfhead_CabinetIndex (0x22)
55 #define cfhead_SIZEOF (0x24)
56 #define cfheadext_HeaderReserved (0x00)
57 #define cfheadext_FolderReserved (0x02)
58 #define cfheadext_DataReserved (0x03)
59 #define cfheadext_SIZEOF (0x04)
60 #define cffold_DataOffset (0x00)
61 #define cffold_NumBlocks (0x04)
62 #define cffold_CompType (0x06)
63 #define cffold_SIZEOF (0x08)
64 #define cffile_UncompressedSize (0x00)
65 #define cffile_FolderOffset (0x04)
66 #define cffile_FolderIndex (0x08)
67 #define cffile_Date (0x0A)
68 #define cffile_Time (0x0C)
69 #define cffile_Attribs (0x0E)
70 #define cffile_SIZEOF (0x10)
71 #define cfdata_CheckSum (0x00)
72 #define cfdata_CompressedSize (0x04)
73 #define cfdata_UncompressedSize (0x06)
74 #define cfdata_SIZEOF (0x08)
76 /* flags */
77 #define cffoldCOMPTYPE_MASK (0x000f)
78 #define cffoldCOMPTYPE_NONE (0x0000)
79 #define cffoldCOMPTYPE_MSZIP (0x0001)
80 #define cffoldCOMPTYPE_QUANTUM (0x0002)
81 #define cffoldCOMPTYPE_LZX (0x0003)
82 #define cfheadPREV_CABINET (0x0001)
83 #define cfheadNEXT_CABINET (0x0002)
84 #define cfheadRESERVE_PRESENT (0x0004)
85 #define cffileCONTINUED_FROM_PREV (0xFFFD)
86 #define cffileCONTINUED_TO_NEXT (0xFFFE)
87 #define cffileCONTINUED_PREV_AND_NEXT (0xFFFF)
88 #define cffile_A_RDONLY (0x01)
89 #define cffile_A_HIDDEN (0x02)
90 #define cffile_A_SYSTEM (0x04)
91 #define cffile_A_ARCH (0x20)
92 #define cffile_A_EXEC (0x40)
93 #define cffile_A_NAME_IS_UTF (0x80)
95 /****************************************************************************/
96 /* our archiver information / state */
98 /* MSZIP stuff */
99 #define ZIPWSIZE 0x8000 /* window size */
100 #define ZIPLBITS 9 /* bits in base literal/length lookup table */
101 #define ZIPDBITS 6 /* bits in base distance lookup table */
102 #define ZIPBMAX 16 /* maximum bit length of any code */
103 #define ZIPN_MAX 288 /* maximum number of codes in any set */
105 struct Ziphuft {
106 cab_UBYTE e; /* number of extra bits or operation */
107 cab_UBYTE b; /* number of bits in this code or subcode */
108 union {
109 cab_UWORD n; /* literal, length base, or distance base */
110 struct Ziphuft *t; /* pointer to next level of table */
111 } v;
114 struct ZIPstate {
115 cab_ULONG window_posn; /* current offset within the window */
116 cab_ULONG bb; /* bit buffer */
117 cab_ULONG bk; /* bits in bit buffer */
118 cab_ULONG ll[288+32]; /* literal/length and distance code lengths */
119 cab_ULONG c[ZIPBMAX+1]; /* bit length count table */
120 cab_LONG lx[ZIPBMAX+1]; /* memory for l[-1..ZIPBMAX-1] */
121 struct Ziphuft *u[ZIPBMAX]; /* table stack */
122 cab_ULONG v[ZIPN_MAX]; /* values in order of bit length */
123 cab_ULONG x[ZIPBMAX+1]; /* bit offsets, then code stack */
124 cab_UBYTE *inpos;
127 /* Quantum stuff */
129 struct QTMmodelsym {
130 cab_UWORD sym, cumfreq;
133 struct QTMmodel {
134 int shiftsleft, entries;
135 struct QTMmodelsym *syms;
136 cab_UWORD tabloc[256];
139 struct QTMstate {
140 cab_UBYTE *window; /* the actual decoding window */
141 cab_ULONG window_size; /* window size (1Kb through 2Mb) */
142 cab_ULONG actual_size; /* window size when it was first allocated */
143 cab_ULONG window_posn; /* current offset within the window */
145 struct QTMmodel model7;
146 struct QTMmodelsym m7sym[7+1];
148 struct QTMmodel model4, model5, model6pos, model6len;
149 struct QTMmodelsym m4sym[0x18 + 1];
150 struct QTMmodelsym m5sym[0x24 + 1];
151 struct QTMmodelsym m6psym[0x2a + 1], m6lsym[0x1b + 1];
153 struct QTMmodel model00, model40, model80, modelC0;
154 struct QTMmodelsym m00sym[0x40 + 1], m40sym[0x40 + 1];
155 struct QTMmodelsym m80sym[0x40 + 1], mC0sym[0x40 + 1];
158 /* LZX stuff */
160 /* some constants defined by the LZX specification */
161 #define LZX_MIN_MATCH (2)
162 #define LZX_MAX_MATCH (257)
163 #define LZX_NUM_CHARS (256)
164 #define LZX_BLOCKTYPE_INVALID (0) /* also blocktypes 4-7 invalid */
165 #define LZX_BLOCKTYPE_VERBATIM (1)
166 #define LZX_BLOCKTYPE_ALIGNED (2)
167 #define LZX_BLOCKTYPE_UNCOMPRESSED (3)
168 #define LZX_PRETREE_NUM_ELEMENTS (20)
169 #define LZX_ALIGNED_NUM_ELEMENTS (8) /* aligned offset tree #elements */
170 #define LZX_NUM_PRIMARY_LENGTHS (7) /* this one missing from spec! */
171 #define LZX_NUM_SECONDARY_LENGTHS (249) /* length tree #elements */
173 /* LZX huffman defines: tweak tablebits as desired */
174 #define LZX_PRETREE_MAXSYMBOLS (LZX_PRETREE_NUM_ELEMENTS)
175 #define LZX_PRETREE_TABLEBITS (6)
176 #define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 50*8)
177 #define LZX_MAINTREE_TABLEBITS (12)
178 #define LZX_LENGTH_MAXSYMBOLS (LZX_NUM_SECONDARY_LENGTHS+1)
179 #define LZX_LENGTH_TABLEBITS (12)
180 #define LZX_ALIGNED_MAXSYMBOLS (LZX_ALIGNED_NUM_ELEMENTS)
181 #define LZX_ALIGNED_TABLEBITS (7)
183 #define LZX_LENTABLE_SAFETY (64) /* we allow length table decoding overruns */
185 #define LZX_DECLARE_TABLE(tbl) \
186 cab_UWORD tbl##_table[(1<<LZX_##tbl##_TABLEBITS) + (LZX_##tbl##_MAXSYMBOLS<<1)];\
187 cab_UBYTE tbl##_len [LZX_##tbl##_MAXSYMBOLS + LZX_LENTABLE_SAFETY]
189 struct LZXstate {
190 cab_UBYTE *window; /* the actual decoding window */
191 cab_ULONG window_size; /* window size (32Kb through 2Mb) */
192 cab_ULONG actual_size; /* window size when it was first allocated */
193 cab_ULONG window_posn; /* current offset within the window */
194 cab_ULONG R0, R1, R2; /* for the LRU offset system */
195 cab_UWORD main_elements; /* number of main tree elements */
196 int header_read; /* have we started decoding at all yet? */
197 cab_UWORD block_type; /* type of this block */
198 cab_ULONG block_length; /* uncompressed length of this block */
199 cab_ULONG block_remaining; /* uncompressed bytes still left to decode */
200 cab_ULONG frames_read; /* the number of CFDATA blocks processed */
201 cab_LONG intel_filesize; /* magic header value used for transform */
202 cab_LONG intel_curpos; /* current offset in transform space */
203 int intel_started; /* have we seen any translatable data yet? */
205 LZX_DECLARE_TABLE(PRETREE);
206 LZX_DECLARE_TABLE(MAINTREE);
207 LZX_DECLARE_TABLE(LENGTH);
208 LZX_DECLARE_TABLE(ALIGNED);
211 struct lzx_bits {
212 cab_ULONG bb;
213 int bl;
214 cab_UBYTE *ip;
217 /* CAB data blocks are <= 32768 bytes in uncompressed form. Uncompressed
218 * blocks have zero growth. MSZIP guarantees that it won't grow above
219 * uncompressed size by more than 12 bytes. LZX guarantees it won't grow
220 * more than 6144 bytes.
222 #define CAB_BLOCKMAX (32768)
223 #define CAB_INPUTMAX (CAB_BLOCKMAX+6144)
225 struct cab_file {
226 struct cab_file *next; /* next file in sequence */
227 struct cab_folder *folder; /* folder that contains this file */
228 LPCSTR filename; /* output name of file */
229 HANDLE fh; /* open file handle or NULL */
230 cab_ULONG length; /* uncompressed length of file */
231 cab_ULONG offset; /* uncompressed offset in folder */
232 cab_UWORD index; /* magic index number of folder */
233 cab_UWORD time, date, attribs; /* MS-DOS time/date/attributes */
237 struct cab_folder {
238 struct cab_folder *next;
239 struct cabinet *cab[CAB_SPLITMAX]; /* cabinet(s) this folder spans */
240 cab_off_t offset[CAB_SPLITMAX]; /* offset to data blocks */
241 cab_UWORD comp_type; /* compression format/window size */
242 cab_ULONG comp_size; /* compressed size of folder */
243 cab_UBYTE num_splits; /* number of split blocks + 1 */
244 cab_UWORD num_blocks; /* total number of blocks */
245 struct cab_file *contfile; /* the first split file */
248 struct cabinet {
249 struct cabinet *next; /* for making a list of cabinets */
250 LPCSTR filename; /* input name of cabinet */
251 HANDLE *fh; /* open file handle or NULL */
252 cab_off_t filelen; /* length of cabinet file */
253 cab_off_t blocks_off; /* offset to data blocks in file */
254 struct cabinet *prevcab, *nextcab; /* multipart cabinet chains */
255 char *prevname, *nextname; /* and their filenames */
256 char *previnfo, *nextinfo; /* and their visible names */
257 struct cab_folder *folders; /* first folder in this cabinet */
258 struct cab_file *files; /* first file in this cabinet */
259 cab_UBYTE block_resv; /* reserved space in datablocks */
260 cab_UBYTE flags; /* header flags */
263 typedef struct cds_forward {
264 struct cab_folder *current; /* current folder we're extracting from */
265 cab_ULONG offset; /* uncompressed offset within folder */
266 cab_UBYTE *outpos; /* (high level) start of data to use up */
267 cab_UWORD outlen; /* (high level) amount of data to use up */
268 cab_UWORD split; /* at which split in current folder? */
269 int (*decompress)(int, int, struct cds_forward *); /* chosen compress fn */
270 cab_UBYTE inbuf[CAB_INPUTMAX+2]; /* +2 for lzx bitbuffer overflows! */
271 cab_UBYTE outbuf[CAB_BLOCKMAX];
272 union {
273 struct ZIPstate zip;
274 struct QTMstate qtm;
275 struct LZXstate lzx;
276 } methods;
277 } cab_decomp_state;
279 /* _Int as in "Internal" fyi */
281 typedef struct {
282 unsigned int FCI_Intmagic;
283 } FCI_Int, *PFCI_Int;
285 typedef struct {
286 unsigned int FDI_Intmagic;
287 PFNALLOC pfnalloc;
288 PFNFREE pfnfree;
289 PFNOPEN pfnopen;
290 PFNREAD pfnread;
291 PFNWRITE pfnwrite;
292 PFNCLOSE pfnclose;
293 PFNSEEK pfnseek;
294 PERF perf;
295 } FDI_Int, *PFDI_Int;
297 /* cast an HFCI into a PFCI_Int */
298 #define PFCI_INT(hfci) ((PFDI_Int)(hfci))
300 /* cast an HFDI into a PFDI_Int */
301 #define PFDI_INT(hfdi) ((PFDI_Int)(hfdi))
303 /* quickie pfdi method invokers */
304 #define PFDI_ALLOC(hfdi, size) ((*PFDI_INT(hfdi)->pfnalloc) (size))
305 #define PFDI_FREE(hfdi, ptr) ((*PFDI_INT(hfdi)->pfnfree) (ptr))
306 #define PFDI_OPEN(hfdi, file, flag, mode) ((*PFDI_INT(hfdi)->pfnopen) (file, flag, mode))
307 #define PFDI_READ(hfdi, hf, pv, cb) ((*PFDI_INT(hfdi)->pfnread) (hf, pv, cb))
308 #define PFDI_WRITE(hfdi, hf, pv, cb) ((*PFDI_INT(hfdi)->pfnwrite) (hf, pv, cb))
309 #define PFDI_CLOSE(hfdi, hf) ((*PFDI_INT(hfdi)->pfnclose) (hf))
310 #define PFDI_SEEK(hfdi, hf, dist, type) ((*PFDI_INT(hfdi)->pfnseek) (hf, dist, type))
312 #define FCI_INT_MAGIC 0xfcfcfc05
313 #define FDI_INT_MAGIC 0xfdfdfd05
315 #define REALLY_IS_FCI(hfci) ( \
316 (((void *) hfci) != NULL) && \
317 (PFCI_INT(hfci)->FCI_Intmagic == FCI_INT_MAGIC) )
319 #define REALLY_IS_FDI(hfdi) ( \
320 (((void *) hfdi) != NULL) && \
321 (PFDI_INT(hfdi)->FDI_Intmagic == FDI_INT_MAGIC) )
324 * the rest of these are somewhat kludgy macros which are shared between fdi.c
325 * and cabextract.c.
328 #define ZIPNEEDBITS(n) {while(k<(n)){cab_LONG c=*(ZIP(inpos)++);\
329 b|=((cab_ULONG)c)<<k;k+=8;}}
330 #define ZIPDUMPBITS(n) {b>>=(n);k-=(n);}
332 /* endian-neutral reading of little-endian data */
333 #define EndGetI32(a) ((((a)[3])<<24)|(((a)[2])<<16)|(((a)[1])<<8)|((a)[0]))
334 #define EndGetI16(a) ((((a)[1])<<8)|((a)[0]))
336 #define CAB(x) (decomp_state->x)
337 #define ZIP(x) (decomp_state->methods.zip.x)
338 #define QTM(x) (decomp_state->methods.qtm.x)
339 #define LZX(x) (decomp_state->methods.lzx.x)
340 #define DECR_OK (0)
341 #define DECR_DATAFORMAT (1)
342 #define DECR_ILLEGALDATA (2)
343 #define DECR_NOMEMORY (3)
344 #define DECR_CHECKSUM (4)
345 #define DECR_INPUT (5)
346 #define DECR_OUTPUT (6)
348 /* Bitstream reading macros (Quantum / normal byte order)
350 * Q_INIT_BITSTREAM should be used first to set up the system
351 * Q_READ_BITS(var,n) takes N bits from the buffer and puts them in var.
352 * unlike LZX, this can loop several times to get the
353 * requisite number of bits.
354 * Q_FILL_BUFFER adds more data to the bit buffer, if there is room
355 * for another 16 bits.
356 * Q_PEEK_BITS(n) extracts (without removing) N bits from the bit
357 * buffer
358 * Q_REMOVE_BITS(n) removes N bits from the bit buffer
360 * These bit access routines work by using the area beyond the MSB and the
361 * LSB as a free source of zeroes. This avoids having to mask any bits.
362 * So we have to know the bit width of the bitbuffer variable. This is
363 * defined as ULONG_BITS.
365 * ULONG_BITS should be at least 16 bits. Unlike LZX's Huffman decoding,
366 * Quantum's arithmetic decoding only needs 1 bit at a time, it doesn't
367 * need an assured number. Retrieving larger bitstrings can be done with
368 * multiple reads and fills of the bitbuffer. The code should work fine
369 * for machines where ULONG >= 32 bits.
371 * Also note that Quantum reads bytes in normal order; LZX is in
372 * little-endian order.
375 #define Q_INIT_BITSTREAM do { bitsleft = 0; bitbuf = 0; } while (0)
377 #define Q_FILL_BUFFER do { \
378 if (bitsleft <= (CAB_ULONG_BITS - 16)) { \
379 bitbuf |= ((inpos[0]<<8)|inpos[1]) << (CAB_ULONG_BITS-16 - bitsleft); \
380 bitsleft += 16; inpos += 2; \
382 } while (0)
384 #define Q_PEEK_BITS(n) (bitbuf >> (CAB_ULONG_BITS - (n)))
385 #define Q_REMOVE_BITS(n) ((bitbuf <<= (n)), (bitsleft -= (n)))
387 #define Q_READ_BITS(v,n) do { \
388 (v) = 0; \
389 for (bitsneed = (n); bitsneed; bitsneed -= bitrun) { \
390 Q_FILL_BUFFER; \
391 bitrun = (bitsneed > bitsleft) ? bitsleft : bitsneed; \
392 (v) = ((v) << bitrun) | Q_PEEK_BITS(bitrun); \
393 Q_REMOVE_BITS(bitrun); \
395 } while (0)
397 #define Q_MENTRIES(model) (QTM(model).entries)
398 #define Q_MSYM(model,symidx) (QTM(model).syms[(symidx)].sym)
399 #define Q_MSYMFREQ(model,symidx) (QTM(model).syms[(symidx)].cumfreq)
401 /* GET_SYMBOL(model, var) fetches the next symbol from the stated model
402 * and puts it in var. it may need to read the bitstream to do this.
404 #define GET_SYMBOL(m, var) do { \
405 range = ((H - L) & 0xFFFF) + 1; \
406 symf = ((((C - L + 1) * Q_MSYMFREQ(m,0)) - 1) / range) & 0xFFFF; \
408 for (i=1; i < Q_MENTRIES(m); i++) { \
409 if (Q_MSYMFREQ(m,i) <= symf) break; \
411 (var) = Q_MSYM(m,i-1); \
413 range = (H - L) + 1; \
414 H = L + ((Q_MSYMFREQ(m,i-1) * range) / Q_MSYMFREQ(m,0)) - 1; \
415 L = L + ((Q_MSYMFREQ(m,i) * range) / Q_MSYMFREQ(m,0)); \
416 while (1) { \
417 if ((L & 0x8000) != (H & 0x8000)) { \
418 if ((L & 0x4000) && !(H & 0x4000)) { \
419 /* underflow case */ \
420 C ^= 0x4000; L &= 0x3FFF; H |= 0x4000; \
422 else break; \
424 L <<= 1; H = (H << 1) | 1; \
425 Q_FILL_BUFFER; \
426 C = (C << 1) | Q_PEEK_BITS(1); \
427 Q_REMOVE_BITS(1); \
430 QTMupdatemodel(&(QTM(m)), i); \
431 } while (0)
433 /* Bitstream reading macros (LZX / intel little-endian byte order)
435 * INIT_BITSTREAM should be used first to set up the system
436 * READ_BITS(var,n) takes N bits from the buffer and puts them in var
438 * ENSURE_BITS(n) ensures there are at least N bits in the bit buffer.
439 * it can guarantee up to 17 bits (i.e. it can read in
440 * 16 new bits when there is down to 1 bit in the buffer,
441 * and it can read 32 bits when there are 0 bits in the
442 * buffer).
443 * PEEK_BITS(n) extracts (without removing) N bits from the bit buffer
444 * REMOVE_BITS(n) removes N bits from the bit buffer
446 * These bit access routines work by using the area beyond the MSB and the
447 * LSB as a free source of zeroes. This avoids having to mask any bits.
448 * So we have to know the bit width of the bitbuffer variable.
451 #define INIT_BITSTREAM do { bitsleft = 0; bitbuf = 0; } while (0)
453 /* Quantum reads bytes in normal order; LZX is little-endian order */
454 #define ENSURE_BITS(n) \
455 while (bitsleft < (n)) { \
456 bitbuf |= ((inpos[1]<<8)|inpos[0]) << (CAB_ULONG_BITS-16 - bitsleft); \
457 bitsleft += 16; inpos+=2; \
460 #define PEEK_BITS(n) (bitbuf >> (CAB_ULONG_BITS - (n)))
461 #define REMOVE_BITS(n) ((bitbuf <<= (n)), (bitsleft -= (n)))
463 #define READ_BITS(v,n) do { \
464 if (n) { \
465 ENSURE_BITS(n); \
466 (v) = PEEK_BITS(n); \
467 REMOVE_BITS(n); \
469 else { \
470 (v) = 0; \
472 } while (0)
474 /* Huffman macros */
476 #define TABLEBITS(tbl) (LZX_##tbl##_TABLEBITS)
477 #define MAXSYMBOLS(tbl) (LZX_##tbl##_MAXSYMBOLS)
478 #define SYMTABLE(tbl) (LZX(tbl##_table))
479 #define LENTABLE(tbl) (LZX(tbl##_len))
481 /* BUILD_TABLE(tablename) builds a huffman lookup table from code lengths.
482 * In reality, it just calls make_decode_table() with the appropriate
483 * values - they're all fixed by some #defines anyway, so there's no point
484 * writing each call out in full by hand.
486 #define BUILD_TABLE(tbl) \
487 if (make_decode_table( \
488 MAXSYMBOLS(tbl), TABLEBITS(tbl), LENTABLE(tbl), SYMTABLE(tbl) \
489 )) { return DECR_ILLEGALDATA; }
491 /* READ_HUFFSYM(tablename, var) decodes one huffman symbol from the
492 * bitstream using the stated table and puts it in var.
494 #define READ_HUFFSYM(tbl,var) do { \
495 ENSURE_BITS(16); \
496 hufftbl = SYMTABLE(tbl); \
497 if ((i = hufftbl[PEEK_BITS(TABLEBITS(tbl))]) >= MAXSYMBOLS(tbl)) { \
498 j = 1 << (CAB_ULONG_BITS - TABLEBITS(tbl)); \
499 do { \
500 j >>= 1; i <<= 1; i |= (bitbuf & j) ? 1 : 0; \
501 if (!j) { return DECR_ILLEGALDATA; } \
502 } while ((i = hufftbl[i]) >= MAXSYMBOLS(tbl)); \
504 j = LENTABLE(tbl)[(var) = i]; \
505 REMOVE_BITS(j); \
506 } while (0)
508 /* READ_LENGTHS(tablename, first, last) reads in code lengths for symbols
509 * first to last in the given table. The code lengths are stored in their
510 * own special LZX way.
512 #define READ_LENGTHS(tbl,first,last,fn) do { \
513 lb.bb = bitbuf; lb.bl = bitsleft; lb.ip = inpos; \
514 if (fn(LENTABLE(tbl),(first),(last),&lb,decomp_state)) { \
515 return DECR_ILLEGALDATA; \
517 bitbuf = lb.bb; bitsleft = lb.bl; inpos = lb.ip; \
518 } while (0)
520 /* Tables for deflate from PKZIP's appnote.txt. */
522 #define THOSE_ZIP_CONSTS \
523 static const cab_UBYTE Zipborder[] = /* Order of the bit length code lengths */ \
524 { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; \
525 static const cab_UWORD Zipcplens[] = /* Copy lengths for literal codes 257..285 */ \
526 { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, \
527 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; \
528 static const cab_UWORD Zipcplext[] = /* Extra bits for literal codes 257..285 */ \
529 { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, \
530 4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */ \
531 static const cab_UWORD Zipcpdist[] = /* Copy offsets for distance codes 0..29 */ \
532 { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, \
533 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; \
534 static const cab_UWORD Zipcpdext[] = /* Extra bits for distance codes */ \
535 { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, \
536 10, 11, 11, 12, 12, 13, 13}; \
537 /* And'ing with Zipmask[n] masks the lower n bits */ \
538 static const cab_UWORD Zipmask[17] = { \
539 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, \
540 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff \
543 /* from cabextract.c */
544 BOOL process_cabinet(LPCSTR cabname, LPCSTR dir, BOOL fix, BOOL lower);
545 void QTMupdatemodel(struct QTMmodel *model, int sym);
546 int make_decode_table(cab_ULONG nsyms, cab_ULONG nbits, cab_UBYTE *length, cab_UWORD *table);
547 cab_ULONG checksum(cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum);
549 #endif /* __WINE_CABINET_H */