209 typedef unsigned char uch;
210 typedef unsigned short ush;
211 typedef unsigned long ulg;
214 # define WSIZE 0x8000
218 # define NEXTBYTE csz__ReadByte()
222 # define FPRINTF fprintf
226 # define FLUSH(n) csz__WriteData(n)
233 # define Trace(x) fprintf x
268 struct huft **,
int *);
299 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
301 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
302 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
305 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
306 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99};
308 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
309 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
310 8193, 12289, 16385, 24577};
312 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
313 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
319 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
320 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
352 static int csz__ReadByte();
357 # define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE)<<k;k+=8;}}
359 # define NEEDBITS(n) {while(k<(n)){if(ibufcnt-- <= 0)return 1;b|=((ulg) *ibufptr++)<<k;k+=8;}}
362 #define DUMPBITS(n) {b>>=(n);k-=(n);}
452 el = n > 256 ? b[256] :
BMAX;
453 memset((
char *)c,0,
sizeof(c));
460 *t = (
struct huft *)NULL;
467 for (j = 1; j <=
BMAX; j++)
471 if ((
unsigned)*m < j)
473 for (i =
BMAX; i; i--)
477 if ((
unsigned)*m > i)
482 for (y = 1 << j; j < i; j++, y <<= 1)
492 p = c + 1; xp = x + 2;
511 u[0] = (
struct huft *)NULL;
512 q = (
struct huft *)NULL;
528 z = (z = g - w) > (
unsigned)*m ? (unsigned) *m : z;
529 if ((f = 1 << (j = k - w)) > a + 1)
535 if ((f <<= 1) <= *++xp)
540 if ((
unsigned)w + j > el && (unsigned)w < el)
546 if ((q = (
struct huft *)malloc((z + 1)*
sizeof(
struct huft))) ==
555 *(t = &(q->
v.
t)) = (
struct huft *)NULL;
565 j = (i & ((1 << w) - 1)) >> (w - l[h-1]);
575 r.
e = (
uch)(*p < 256 ? 16 : 15);
578 r.
e = (
uch)e[*p - s];
584 for (j = i >> w; j < z; j += f)
588 for (j = 1 << (k - 1); i & j; j >>= 1)
593 while ((i & ((1 << w) - 1)) != x[h])
604 return y != 0 && g != 1;
620 while (p != (
struct huft *)NULL)
665 if ((e = (t = tl + ((
unsigned)b & ml))->e) > 16)
672 }
while ((e = (t = t->
v.
t + ((
unsigned)b &
mask[e]))->e) > 16);
691 n = t->
v.
n + ((unsigned)b &
mask[e]);
696 if ((e = (t = td + ((
unsigned)b & md))->e) > 16)
703 }
while ((e = (t = t->
v.
t + ((
unsigned)b &
mask[e]))->e) > 16);
706 d = w - t->
v.
n - ((unsigned)b &
mask[e]);
711 n -= (e = (e =
WSIZE - ((d &=
WSIZE-1) > w ? d : w)) > n ? n : e);
758 Trace((stderr,
"\nstored block"));
771 n = ((unsigned)b & 0xffff);
774 if (n != (
unsigned)((~b) & 0xffff))
812 Trace((stderr,
"\nliteral block"));
813 if (csz__fixed_tl == (
struct huft *)NULL)
816 static unsigned l[288];
819 for (i = 0; i < 144; i++)
831 csz__fixed_tl = (
struct huft *)NULL;
836 for (i = 0; i < 30; i++)
842 csz__fixed_tl = (
struct huft *)NULL;
869 #ifdef PKZIP_BUG_WORKAROUND
870 static unsigned ll[288+32];
872 static unsigned ll[286+30];
877 static int qflag = 0;
880 Trace((stderr,
"\ndynamic block"));
887 nl = 257 + ((unsigned)b & 0x1f);
890 nd = 1 + ((unsigned)b & 0x1f);
893 nb = 4 + ((unsigned)b & 0xf);
895 #ifdef PKZIP_BUG_WORKAROUND
896 if (nl > 288 || nd > 32)
898 if (nl > 286 || nd > 30)
904 for (j = 0; j < nb; j++)
907 ll[
border[j]] = (unsigned)b & 7;
924 #define NEEDBITS_free_tl(n) {while(k<(n)){if(ibufcnt-- <= 0){csz__huft_free(tl);return 1;} b|=((ulg) *ibufptr++)<<k;k+=8;}}
930 while ((
unsigned)i < n)
933 j = (td = tl + ((unsigned)b & m))->b;
941 j = 3 + ((unsigned)b & 3);
943 if ((
unsigned)i + j > n) {
953 j = 3 + ((unsigned)b & 7);
955 if ((
unsigned)i + j > n){
966 j = 11 + ((unsigned)b & 0x7f);
968 if ((
unsigned)i + j > n) {
992 if (i == 1 && !qflag) {
993 FPRINTF(stderr,
"(incomplete l-tree) ");
1001 if (i == 1 && !qflag) {
1002 FPRINTF(stderr,
"(incomplete d-tree) ");
1003 #ifdef PKZIP_BUG_WORKAROUND
1050 t = (unsigned)b & 3;
1106 Trace((stderr,
"\n%lu bytes in Huffman tables (%lu/entry)\n",
1107 h *
sizeof(
struct huft),
sizeof(
struct huft)));
1113 if (csz__fixed_tl != (
struct huft *)NULL)
1117 csz__fixed_td = csz__fixed_tl = (
struct huft *)NULL;
1124 long a_obufcnt,
unsigned char* a_obufptr) {
1138 static int csz__ReadByte ()
struct huft * csz__fixed_td
static constexpr double s
struct huft * csz__fixed_tl
int csz__Inflate_free(void)
std::vector< ExP01TrackerHit * > a
int csz__Inflate_codes(struct huft *, struct huft *, int, int)
void csz__Init_Inflate(long a_ibufcnt, unsigned char *a_ibufptr, long a_obufcnt, unsigned char *a_obufptr)
static constexpr double g
#define NEEDBITS_free_tl(n)
static constexpr double m
static uch csz__slide[32768]
int csz__Inflate_dynamic(void)
int csz__Inflate_block(int *)
int csz__Inflate_fixed(void)
int csz__huft_build(unsigned *, unsigned, unsigned, ush *, ush *, struct huft **, int *)
unsigned char * csz__obufptr()
static void csz__WriteData(int)
int csz__Inflate_stored(void)
int csz__huft_free(struct huft *)