ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

cabinet.h
Go to the documentation of this file.
00001 /*
00002  * cabinet.h
00003  *
00004  * Copyright 2002 Greg Turner
00005  * Copyright 2005 Gerold Jens Wucherpfennig
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00020  */
00021 #ifndef __WINE_CABINET_H
00022 #define __WINE_CABINET_H
00023 
00024 #include <stdarg.h>
00025 
00026 #include "windef.h"
00027 #include "winbase.h"
00028 #include "winnt.h"
00029 #include "fdi.h"
00030 #include "fci.h"
00031 
00032 /* from msvcrt/sys/stat.h */
00033 #define _S_IWRITE 0x0080
00034 #define _S_IREAD  0x0100
00035 
00036 /* from msvcrt/fcntl.h */
00037 #define _O_RDONLY      0
00038 #define _O_WRONLY      1
00039 #define _O_RDWR        2
00040 #define _O_ACCMODE     (_O_RDONLY|_O_WRONLY|_O_RDWR)
00041 #define _O_APPEND      0x0008
00042 #define _O_RANDOM      0x0010
00043 #define _O_SEQUENTIAL  0x0020
00044 #define _O_TEMPORARY   0x0040
00045 #define _O_NOINHERIT   0x0080
00046 #define _O_CREAT       0x0100
00047 #define _O_TRUNC       0x0200
00048 #define _O_EXCL        0x0400
00049 #define _O_SHORT_LIVED 0x1000
00050 #define _O_TEXT        0x4000
00051 #define _O_BINARY      0x8000
00052 
00053 #define CAB_SPLITMAX (10)
00054 
00055 #define CAB_SEARCH_SIZE (32*1024)
00056 
00057 typedef unsigned char cab_UBYTE; /* 8 bits  */
00058 typedef UINT16        cab_UWORD; /* 16 bits */
00059 typedef UINT32        cab_ULONG; /* 32 bits */
00060 typedef INT32         cab_LONG;  /* 32 bits */
00061 
00062 typedef UINT32        cab_off_t;
00063 
00064 /* number of bits in a ULONG */
00065 #ifndef CHAR_BIT
00066 # define CHAR_BIT (8)
00067 #endif
00068 #define CAB_ULONG_BITS (sizeof(cab_ULONG) * CHAR_BIT)
00069 
00070 /* structure offsets */
00071 #define cfhead_Signature         (0x00)
00072 #define cfhead_CabinetSize       (0x08)
00073 #define cfhead_FileOffset        (0x10)
00074 #define cfhead_MinorVersion      (0x18)
00075 #define cfhead_MajorVersion      (0x19)
00076 #define cfhead_NumFolders        (0x1A)
00077 #define cfhead_NumFiles          (0x1C)
00078 #define cfhead_Flags             (0x1E)
00079 #define cfhead_SetID             (0x20)
00080 #define cfhead_CabinetIndex      (0x22)
00081 #define cfhead_SIZEOF            (0x24)
00082 #define cfheadext_HeaderReserved (0x00)
00083 #define cfheadext_FolderReserved (0x02)
00084 #define cfheadext_DataReserved   (0x03)
00085 #define cfheadext_SIZEOF         (0x04)
00086 #define cffold_DataOffset        (0x00)
00087 #define cffold_NumBlocks         (0x04)
00088 #define cffold_CompType          (0x06)
00089 #define cffold_SIZEOF            (0x08)
00090 #define cffile_UncompressedSize  (0x00)
00091 #define cffile_FolderOffset      (0x04)
00092 #define cffile_FolderIndex       (0x08)
00093 #define cffile_Date              (0x0A)
00094 #define cffile_Time              (0x0C)
00095 #define cffile_Attribs           (0x0E)
00096 #define cffile_SIZEOF            (0x10)
00097 #define cfdata_CheckSum          (0x00)
00098 #define cfdata_CompressedSize    (0x04)
00099 #define cfdata_UncompressedSize  (0x06)
00100 #define cfdata_SIZEOF            (0x08)
00101 
00102 /* flags */
00103 #define cffoldCOMPTYPE_MASK            (0x000f)
00104 #define cffoldCOMPTYPE_NONE            (0x0000)
00105 #define cffoldCOMPTYPE_MSZIP           (0x0001)
00106 #define cffoldCOMPTYPE_QUANTUM         (0x0002)
00107 #define cffoldCOMPTYPE_LZX             (0x0003)
00108 #define cfheadPREV_CABINET             (0x0001)
00109 #define cfheadNEXT_CABINET             (0x0002)
00110 #define cfheadRESERVE_PRESENT          (0x0004)
00111 #define cffileCONTINUED_FROM_PREV      (0xFFFD)
00112 #define cffileCONTINUED_TO_NEXT        (0xFFFE)
00113 #define cffileCONTINUED_PREV_AND_NEXT  (0xFFFF)
00114 #define cffile_A_RDONLY                (0x01)
00115 #define cffile_A_HIDDEN                (0x02)
00116 #define cffile_A_SYSTEM                (0x04)
00117 #define cffile_A_ARCH                  (0x20)
00118 #define cffile_A_EXEC                  (0x40)
00119 #define cffile_A_NAME_IS_UTF           (0x80)
00120 
00121 /****************************************************************************/
00122 /* our archiver information / state */
00123 
00124 /* MSZIP stuff */
00125 #define ZIPWSIZE    0x8000  /* window size */
00126 #define ZIPLBITS    9   /* bits in base literal/length lookup table */
00127 #define ZIPDBITS    6   /* bits in base distance lookup table */
00128 #define ZIPBMAX     16      /* maximum bit length of any code */
00129 #define ZIPN_MAX    288     /* maximum number of codes in any set */
00130 
00131 struct Ziphuft {
00132   cab_UBYTE e;                /* number of extra bits or operation */
00133   cab_UBYTE b;                /* number of bits in this code or subcode */
00134   union {
00135     cab_UWORD n;              /* literal, length base, or distance base */
00136     struct Ziphuft *t;        /* pointer to next level of table */
00137   } v;
00138 };
00139 
00140 struct ZIPstate {
00141     cab_ULONG window_posn;      /* current offset within the window        */
00142     cab_ULONG bb;               /* bit buffer */
00143     cab_ULONG bk;               /* bits in bit buffer */
00144     cab_ULONG ll[288+32];       /* literal/length and distance code lengths */
00145     cab_ULONG c[ZIPBMAX+1];     /* bit length count table */
00146     cab_LONG  lx[ZIPBMAX+1];    /* memory for l[-1..ZIPBMAX-1] */
00147     struct Ziphuft *u[ZIPBMAX]; /* table stack */
00148     cab_ULONG v[ZIPN_MAX];      /* values in order of bit length */
00149     cab_ULONG x[ZIPBMAX+1];     /* bit offsets, then code stack */
00150     cab_UBYTE *inpos;
00151 };
00152   
00153 /* Quantum stuff */
00154 
00155 struct QTMmodelsym {
00156   cab_UWORD sym, cumfreq;
00157 };
00158 
00159 struct QTMmodel {
00160   int shiftsleft, entries; 
00161   struct QTMmodelsym *syms;
00162   cab_UWORD tabloc[256];
00163 };
00164 
00165 struct QTMstate {
00166     cab_UBYTE *window;         /* the actual decoding window              */
00167     cab_ULONG window_size;     /* window size (1Kb through 2Mb)           */
00168     cab_ULONG actual_size;     /* window size when it was first allocated */
00169     cab_ULONG window_posn;     /* current offset within the window        */
00170 
00171     struct QTMmodel model7;
00172     struct QTMmodelsym m7sym[7+1];
00173 
00174     struct QTMmodel model4, model5, model6pos, model6len;
00175     struct QTMmodelsym m4sym[0x18 + 1];
00176     struct QTMmodelsym m5sym[0x24 + 1];
00177     struct QTMmodelsym m6psym[0x2a + 1], m6lsym[0x1b + 1];
00178 
00179     struct QTMmodel model00, model40, model80, modelC0;
00180     struct QTMmodelsym m00sym[0x40 + 1], m40sym[0x40 + 1];
00181     struct QTMmodelsym m80sym[0x40 + 1], mC0sym[0x40 + 1];
00182 };
00183 
00184 /* LZX stuff */
00185 
00186 /* some constants defined by the LZX specification */
00187 #define LZX_MIN_MATCH                (2)
00188 #define LZX_MAX_MATCH                (257)
00189 #define LZX_NUM_CHARS                (256)
00190 #define LZX_BLOCKTYPE_INVALID        (0)   /* also blocktypes 4-7 invalid */
00191 #define LZX_BLOCKTYPE_VERBATIM       (1)
00192 #define LZX_BLOCKTYPE_ALIGNED        (2)
00193 #define LZX_BLOCKTYPE_UNCOMPRESSED   (3)
00194 #define LZX_PRETREE_NUM_ELEMENTS     (20)
00195 #define LZX_ALIGNED_NUM_ELEMENTS     (8)   /* aligned offset tree #elements */
00196 #define LZX_NUM_PRIMARY_LENGTHS      (7)   /* this one missing from spec! */
00197 #define LZX_NUM_SECONDARY_LENGTHS    (249) /* length tree #elements */
00198 
00199 /* LZX huffman defines: tweak tablebits as desired */
00200 #define LZX_PRETREE_MAXSYMBOLS  (LZX_PRETREE_NUM_ELEMENTS)
00201 #define LZX_PRETREE_TABLEBITS   (6)
00202 #define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 50*8)
00203 #define LZX_MAINTREE_TABLEBITS  (12)
00204 #define LZX_LENGTH_MAXSYMBOLS   (LZX_NUM_SECONDARY_LENGTHS+1)
00205 #define LZX_LENGTH_TABLEBITS    (12)
00206 #define LZX_ALIGNED_MAXSYMBOLS  (LZX_ALIGNED_NUM_ELEMENTS)
00207 #define LZX_ALIGNED_TABLEBITS   (7)
00208 
00209 #define LZX_LENTABLE_SAFETY (64) /* we allow length table decoding overruns */
00210 
00211 #define LZX_DECLARE_TABLE(tbl) \
00212   cab_UWORD tbl##_table[(1<<LZX_##tbl##_TABLEBITS) + (LZX_##tbl##_MAXSYMBOLS<<1)];\
00213   cab_UBYTE tbl##_len  [LZX_##tbl##_MAXSYMBOLS + LZX_LENTABLE_SAFETY]
00214 
00215 struct LZXstate {
00216     cab_UBYTE *window;         /* the actual decoding window              */
00217     cab_ULONG window_size;     /* window size (32Kb through 2Mb)          */
00218     cab_ULONG actual_size;     /* window size when it was first allocated */
00219     cab_ULONG window_posn;     /* current offset within the window        */
00220     cab_ULONG R0, R1, R2;      /* for the LRU offset system               */
00221     cab_UWORD main_elements;   /* number of main tree elements            */
00222     int   header_read;         /* have we started decoding at all yet?    */
00223     cab_UWORD block_type;      /* type of this block                      */
00224     cab_ULONG block_length;    /* uncompressed length of this block       */
00225     cab_ULONG block_remaining; /* uncompressed bytes still left to decode */
00226     cab_ULONG frames_read;     /* the number of CFDATA blocks processed   */
00227     cab_LONG  intel_filesize;  /* magic header value used for transform   */
00228     cab_LONG  intel_curpos;    /* current offset in transform space       */
00229     int   intel_started;       /* have we seen any translatable data yet? */
00230 
00231     LZX_DECLARE_TABLE(PRETREE);
00232     LZX_DECLARE_TABLE(MAINTREE);
00233     LZX_DECLARE_TABLE(LENGTH);
00234     LZX_DECLARE_TABLE(ALIGNED);
00235 };
00236 
00237 struct lzx_bits {
00238   cab_ULONG bb;
00239   int bl;
00240   cab_UBYTE *ip;
00241 };
00242 
00243 /* CAB data blocks are <= 32768 bytes in uncompressed form. Uncompressed
00244  * blocks have zero growth. MSZIP guarantees that it won't grow above
00245  * uncompressed size by more than 12 bytes. LZX guarantees it won't grow
00246  * more than 6144 bytes.
00247  */
00248 #define CAB_BLOCKMAX (32768)
00249 #define CAB_INPUTMAX (CAB_BLOCKMAX+6144)
00250 
00251 struct cab_file {
00252   struct cab_file *next;               /* next file in sequence          */
00253   struct cab_folder *folder;           /* folder that contains this file */
00254   LPCSTR filename;                     /* output name of file            */
00255   HANDLE fh;                           /* open file handle or NULL       */
00256   cab_ULONG length;                    /* uncompressed length of file    */
00257   cab_ULONG offset;                    /* uncompressed offset in folder  */
00258   cab_UWORD index;                     /* magic index number of folder   */
00259   cab_UWORD time, date, attribs;       /* MS-DOS time/date/attributes    */
00260 };
00261 
00262 
00263 struct cab_folder {
00264   struct cab_folder *next;
00265   struct cabinet *cab[CAB_SPLITMAX];   /* cabinet(s) this folder spans   */
00266   cab_off_t offset[CAB_SPLITMAX];      /* offset to data blocks          */
00267   cab_UWORD comp_type;                 /* compression format/window size */
00268   cab_ULONG comp_size;                 /* compressed size of folder      */
00269   cab_UBYTE num_splits;                /* number of split blocks + 1     */
00270   cab_UWORD num_blocks;                /* total number of blocks         */
00271   struct cab_file *contfile;           /* the first split file           */
00272 };
00273 
00274 struct cabinet {
00275   struct cabinet *next;                /* for making a list of cabinets  */
00276   LPCSTR filename;                     /* input name of cabinet          */
00277   HANDLE *fh;                          /* open file handle or NULL       */
00278   cab_off_t filelen;                   /* length of cabinet file         */
00279   cab_off_t blocks_off;                /* offset to data blocks in file  */
00280   struct cabinet *prevcab, *nextcab;   /* multipart cabinet chains       */
00281   char *prevname, *nextname;           /* and their filenames            */
00282   char *previnfo, *nextinfo;           /* and their visible names        */
00283   struct cab_folder *folders;          /* first folder in this cabinet   */
00284   struct cab_file *files;              /* first file in this cabinet     */
00285   cab_UBYTE block_resv;                /* reserved space in datablocks   */
00286   cab_UBYTE flags;                     /* header flags                   */
00287 };
00288 
00289 typedef struct cds_forward {
00290   struct cab_folder *current;      /* current folder we're extracting from  */
00291   cab_ULONG offset;                /* uncompressed offset within folder     */
00292   cab_UBYTE *outpos;               /* (high level) start of data to use up  */
00293   cab_UWORD outlen;                /* (high level) amount of data to use up */
00294   cab_UWORD split;                 /* at which split in current folder?     */
00295   int (*decompress)(int, int, struct cds_forward *); /* chosen compress fn  */
00296   cab_UBYTE inbuf[CAB_INPUTMAX+2]; /* +2 for lzx bitbuffer overflows!       */
00297   cab_UBYTE outbuf[CAB_BLOCKMAX];
00298   cab_UBYTE q_length_base[27], q_length_extra[27], q_extra_bits[42];
00299   cab_ULONG q_position_base[42];
00300   cab_ULONG lzx_position_base[51];
00301   cab_UBYTE extra_bits[51];
00302   union {
00303     struct ZIPstate zip;
00304     struct QTMstate qtm;
00305     struct LZXstate lzx;
00306   } methods;
00307 } cab_decomp_state;
00308 
00309 /*
00310  * the rest of these are somewhat kludgy macros which are shared between fdi.c
00311  * and cabextract.c.
00312  */
00313 
00314 /* Bitstream reading macros (Quantum / normal byte order)
00315  *
00316  * Q_INIT_BITSTREAM    should be used first to set up the system
00317  * Q_READ_BITS(var,n)  takes N bits from the buffer and puts them in var.
00318  *                     unlike LZX, this can loop several times to get the
00319  *                     requisite number of bits.
00320  * Q_FILL_BUFFER       adds more data to the bit buffer, if there is room
00321  *                     for another 16 bits.
00322  * Q_PEEK_BITS(n)      extracts (without removing) N bits from the bit
00323  *                     buffer
00324  * Q_REMOVE_BITS(n)    removes N bits from the bit buffer
00325  *
00326  * These bit access routines work by using the area beyond the MSB and the
00327  * LSB as a free source of zeroes. This avoids having to mask any bits.
00328  * So we have to know the bit width of the bitbuffer variable. This is
00329  * defined as ULONG_BITS.
00330  *
00331  * ULONG_BITS should be at least 16 bits. Unlike LZX's Huffman decoding,
00332  * Quantum's arithmetic decoding only needs 1 bit at a time, it doesn't
00333  * need an assured number. Retrieving larger bitstrings can be done with
00334  * multiple reads and fills of the bitbuffer. The code should work fine
00335  * for machines where ULONG >= 32 bits.
00336  *
00337  * Also note that Quantum reads bytes in normal order; LZX is in
00338  * little-endian order.
00339  */
00340 
00341 #define Q_INIT_BITSTREAM do { bitsleft = 0; bitbuf = 0; } while (0)
00342 
00343 #define Q_FILL_BUFFER do {                                                  \
00344   if (bitsleft <= (CAB_ULONG_BITS - 16)) {                                  \
00345     bitbuf |= ((inpos[0]<<8)|inpos[1]) << (CAB_ULONG_BITS-16 - bitsleft);   \
00346     bitsleft += 16; inpos += 2;                                             \
00347   }                                                                         \
00348 } while (0)
00349 
00350 #define Q_PEEK_BITS(n)   (bitbuf >> (CAB_ULONG_BITS - (n)))
00351 #define Q_REMOVE_BITS(n) ((bitbuf <<= (n)), (bitsleft -= (n)))
00352 
00353 #define Q_READ_BITS(v,n) do {                                           \
00354   (v) = 0;                                                              \
00355   for (bitsneed = (n); bitsneed; bitsneed -= bitrun) {                  \
00356     Q_FILL_BUFFER;                                                      \
00357     bitrun = (bitsneed > bitsleft) ? bitsleft : bitsneed;               \
00358     (v) = ((v) << bitrun) | Q_PEEK_BITS(bitrun);                        \
00359     Q_REMOVE_BITS(bitrun);                                              \
00360   }                                                                     \
00361 } while (0)
00362 
00363 #define Q_MENTRIES(model) (QTM(model).entries)
00364 #define Q_MSYM(model,symidx) (QTM(model).syms[(symidx)].sym)
00365 #define Q_MSYMFREQ(model,symidx) (QTM(model).syms[(symidx)].cumfreq)
00366 
00367 /* GET_SYMBOL(model, var) fetches the next symbol from the stated model
00368  * and puts it in var. it may need to read the bitstream to do this.
00369  */
00370 #define GET_SYMBOL(m, var) do {                                         \
00371   range =  ((H - L) & 0xFFFF) + 1;                                      \
00372   symf = ((((C - L + 1) * Q_MSYMFREQ(m,0)) - 1) / range) & 0xFFFF;      \
00373                                                                         \
00374   for (i=1; i < Q_MENTRIES(m); i++) {                                   \
00375     if (Q_MSYMFREQ(m,i) <= symf) break;                                 \
00376   }                                                                     \
00377   (var) = Q_MSYM(m,i-1);                                                \
00378                                                                         \
00379   range = (H - L) + 1;                                                  \
00380   H = L + ((Q_MSYMFREQ(m,i-1) * range) / Q_MSYMFREQ(m,0)) - 1;          \
00381   L = L + ((Q_MSYMFREQ(m,i)   * range) / Q_MSYMFREQ(m,0));              \
00382   while (1) {                                                           \
00383     if ((L & 0x8000) != (H & 0x8000)) {                                 \
00384       if ((L & 0x4000) && !(H & 0x4000)) {                              \
00385         /* underflow case */                                            \
00386         C ^= 0x4000; L &= 0x3FFF; H |= 0x4000;                          \
00387       }                                                                 \
00388       else break;                                                       \
00389     }                                                                   \
00390     L <<= 1; H = (H << 1) | 1;                                          \
00391     Q_FILL_BUFFER;                                                      \
00392     C  = (C << 1) | Q_PEEK_BITS(1);                                     \
00393     Q_REMOVE_BITS(1);                                                   \
00394   }                                                                     \
00395                                                                         \
00396   QTMupdatemodel(&(QTM(m)), i);                                         \
00397 } while (0)
00398 
00399 /* Bitstream reading macros (LZX / intel little-endian byte order)
00400  *
00401  * INIT_BITSTREAM    should be used first to set up the system
00402  * READ_BITS(var,n)  takes N bits from the buffer and puts them in var
00403  *
00404  * ENSURE_BITS(n)    ensures there are at least N bits in the bit buffer.
00405  *                   it can guarantee up to 17 bits (i.e. it can read in
00406  *                   16 new bits when there is down to 1 bit in the buffer,
00407  *                   and it can read 32 bits when there are 0 bits in the
00408  *                   buffer).
00409  * PEEK_BITS(n)      extracts (without removing) N bits from the bit buffer
00410  * REMOVE_BITS(n)    removes N bits from the bit buffer
00411  *
00412  * These bit access routines work by using the area beyond the MSB and the
00413  * LSB as a free source of zeroes. This avoids having to mask any bits.
00414  * So we have to know the bit width of the bitbuffer variable.
00415  */
00416 
00417 #define INIT_BITSTREAM do { bitsleft = 0; bitbuf = 0; } while (0)
00418 
00419 /* Quantum reads bytes in normal order; LZX is little-endian order */
00420 #define ENSURE_BITS(n)                                                    \
00421   while (bitsleft < (n)) {                                                \
00422     bitbuf |= ((inpos[1]<<8)|inpos[0]) << (CAB_ULONG_BITS-16 - bitsleft); \
00423     bitsleft += 16; inpos+=2;                                             \
00424   }
00425 
00426 #define PEEK_BITS(n)   (bitbuf >> (CAB_ULONG_BITS - (n)))
00427 #define REMOVE_BITS(n) ((bitbuf <<= (n)), (bitsleft -= (n)))
00428 
00429 #define READ_BITS(v,n) do {                                             \
00430   if (n) {                                                              \
00431     ENSURE_BITS(n);                                                     \
00432     (v) = PEEK_BITS(n);                                                 \
00433     REMOVE_BITS(n);                                                     \
00434   }                                                                     \
00435   else {                                                                \
00436     (v) = 0;                                                            \
00437   }                                                                     \
00438 } while (0)
00439 
00440 /* Huffman macros */
00441 
00442 #define TABLEBITS(tbl)   (LZX_##tbl##_TABLEBITS)
00443 #define MAXSYMBOLS(tbl)  (LZX_##tbl##_MAXSYMBOLS)
00444 #define SYMTABLE(tbl)    (LZX(tbl##_table))
00445 #define LENTABLE(tbl)    (LZX(tbl##_len))
00446 
00447 /* BUILD_TABLE(tablename) builds a huffman lookup table from code lengths.
00448  * In reality, it just calls make_decode_table() with the appropriate
00449  * values - they're all fixed by some #defines anyway, so there's no point
00450  * writing each call out in full by hand.
00451  */
00452 #define BUILD_TABLE(tbl)                                                \
00453   if (make_decode_table(                                                \
00454     MAXSYMBOLS(tbl), TABLEBITS(tbl), LENTABLE(tbl), SYMTABLE(tbl)       \
00455   )) { return DECR_ILLEGALDATA; }
00456 
00457 /* READ_HUFFSYM(tablename, var) decodes one huffman symbol from the
00458  * bitstream using the stated table and puts it in var.
00459  */
00460 #define READ_HUFFSYM(tbl,var) do {                                      \
00461   ENSURE_BITS(16);                                                      \
00462   hufftbl = SYMTABLE(tbl);                                              \
00463   if ((i = hufftbl[PEEK_BITS(TABLEBITS(tbl))]) >= MAXSYMBOLS(tbl)) {    \
00464     j = 1 << (CAB_ULONG_BITS - TABLEBITS(tbl));                         \
00465     do {                                                                \
00466       j >>= 1; i <<= 1; i |= (bitbuf & j) ? 1 : 0;                      \
00467       if (!j) { return DECR_ILLEGALDATA; }                              \
00468     } while ((i = hufftbl[i]) >= MAXSYMBOLS(tbl));                      \
00469   }                                                                     \
00470   j = LENTABLE(tbl)[(var) = i];                                         \
00471   REMOVE_BITS(j);                                                       \
00472 } while (0)
00473 
00474 /* READ_LENGTHS(tablename, first, last) reads in code lengths for symbols
00475  * first to last in the given table. The code lengths are stored in their
00476  * own special LZX way.
00477  */
00478 #define READ_LENGTHS(tbl,first,last,fn) do { \
00479   lb.bb = bitbuf; lb.bl = bitsleft; lb.ip = inpos; \
00480   if (fn(LENTABLE(tbl),(first),(last),&lb,decomp_state)) { \
00481     return DECR_ILLEGALDATA; \
00482   } \
00483   bitbuf = lb.bb; bitsleft = lb.bl; inpos = lb.ip; \
00484 } while (0)
00485 
00486 /* Tables for deflate from PKZIP's appnote.txt. */
00487 
00488 #define THOSE_ZIP_CONSTS                                                           \
00489 static const cab_UBYTE Zipborder[] = /* Order of the bit length code lengths */    \
00490 { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};               \
00491 static const cab_UWORD Zipcplens[] = /* Copy lengths for literal codes 257..285 */ \
00492 { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51,             \
00493  59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};                              \
00494 static const cab_UWORD Zipcplext[] = /* Extra bits for literal codes 257..285 */   \
00495 { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,             \
00496   4, 5, 5, 5, 5, 0, 99, 99}; /* 99==invalid */                                     \
00497 static const cab_UWORD Zipcpdist[] = /* Copy offsets for distance codes 0..29 */   \
00498 { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385,             \
00499 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};          \
00500 static const cab_UWORD Zipcpdext[] = /* Extra bits for distance codes */           \
00501 { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10,            \
00502 10, 11, 11, 12, 12, 13, 13};                                                       \
00503 /* And'ing with Zipmask[n] masks the lower n bits */                               \
00504 static const cab_UWORD Zipmask[17] = {                                             \
00505  0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,           \
00506  0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff                    \
00507 }
00508 
00509 /* SESSION Operation */
00510 #define EXTRACT_FILLFILELIST  0x00000001
00511 #define EXTRACT_EXTRACTFILES  0x00000002
00512 
00513 struct FILELIST{
00514     LPSTR FileName;
00515     struct FILELIST *next;
00516     BOOL DoExtract;
00517 };
00518 
00519 typedef struct {
00520     INT FileSize;
00521     ERF Error;
00522     struct FILELIST *FileList;
00523     INT FileCount;
00524     INT Operation;
00525     CHAR Destination[MAX_PATH];
00526     CHAR CurrentFile[MAX_PATH];
00527     CHAR Reserved[MAX_PATH];
00528     struct FILELIST *FilterList;
00529 } SESSION;
00530 
00531 #endif /* __WINE_CABINET_H */

Generated on Sun May 27 2012 04:17:57 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.