Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
csz_inflate.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for csz_inflate.cc:

Go to the source code of this file.

Classes

struct  huft
 

Macros

#define WSIZE   0x8000 /* window size--must be a power of two, and at least */
 
#define NEXTBYTE   csz__ReadByte()
 
#define FPRINTF   fprintf
 
#define FLUSH(n)   csz__WriteData(n) /* return value not used */
 
#define Trace(x)
 
#define CHECK_EOF
 
#define NEEDBITS(n)   {while(k<(n)){if(ibufcnt-- <= 0)return 1;b|=((ulg) *ibufptr++)<<k;k+=8;}}
 
#define DUMPBITS(n)   {b>>=(n);k-=(n);}
 
#define BMAX   16 /* maximum bit length of any code (16 for explode) */
 
#define N_MAX   288 /* maximum number of codes in any set */
 
#define NEEDBITS_free_tl(n)   {while(k<(n)){if(ibufcnt-- <= 0){csz__huft_free(tl);return 1;} b|=((ulg) *ibufptr++)<<k;k+=8;}}
 

Typedefs

typedef char boolean
 
typedef unsigned char uch
 
typedef unsigned short ush
 
typedef unsigned long ulg
 

Functions

int csz__huft_build (unsigned *, unsigned, unsigned, ush *, ush *, struct huft **, int *)
 
int csz__huft_free (struct huft *)
 
int csz__Inflate_codes (struct huft *, struct huft *, int, int)
 
int csz__Inflate_stored (void)
 
int csz__Inflate_fixed (void)
 
int csz__Inflate_dynamic (void)
 
int csz__Inflate_block (int *)
 
int csz__Inflate (void)
 
int csz__Inflate_free (void)
 
static void csz__WriteData (int)
 
void csz__Init_Inflate (long a_ibufcnt, unsigned char *a_ibufptr, long a_obufcnt, unsigned char *a_obufptr)
 
unsigned char * csz__obufptr ()
 

Variables

static uch csz__slide [32768]
 
static unsigned wp
 
static unsigned border []
 
static ush cplens []
 
static ush cplext []
 
static ush cpdist []
 
static ush cpdext []
 
static ush mask []
 
static ulg bb
 
static unsigned bk
 
static uchibufptr
 
static uchobufptr
 
static long ibufcnt
 
static long obufcnt
 
static int lbits = 9
 
static int dbits = 6
 
static unsigned hufts
 
struct huftcsz__fixed_tl = (struct huft *)NULL
 
struct huftcsz__fixed_td
 
int csz__fixed_bl
 
int csz__fixed_bd
 

Macro Definition Documentation

#define BMAX   16 /* maximum bit length of any code (16 for explode) */

Definition at line 403 of file csz_inflate.cc.

#define CHECK_EOF

Definition at line 349 of file csz_inflate.cc.

#define DUMPBITS (   n)    {b>>=(n);k-=(n);}

Definition at line 362 of file csz_inflate.cc.

#define FLUSH (   n)    csz__WriteData(n) /* return value not used */

Definition at line 226 of file csz_inflate.cc.

#define FPRINTF   fprintf

Definition at line 222 of file csz_inflate.cc.

#define N_MAX   288 /* maximum number of codes in any set */

Definition at line 404 of file csz_inflate.cc.

#define NEEDBITS (   n)    {while(k<(n)){if(ibufcnt-- <= 0)return 1;b|=((ulg) *ibufptr++)<<k;k+=8;}}

Definition at line 359 of file csz_inflate.cc.

#define NEEDBITS_free_tl (   n)    {while(k<(n)){if(ibufcnt-- <= 0){csz__huft_free(tl);return 1;} b|=((ulg) *ibufptr++)<<k;k+=8;}}
#define NEXTBYTE   csz__ReadByte()

Definition at line 218 of file csz_inflate.cc.

#define Trace (   x)

Definition at line 235 of file csz_inflate.cc.

#define WSIZE   0x8000 /* window size--must be a power of two, and at least */

Definition at line 214 of file csz_inflate.cc.

Typedef Documentation

typedef char boolean

Definition at line 208 of file csz_inflate.cc.

typedef unsigned char uch

Definition at line 209 of file csz_inflate.cc.

typedef unsigned long ulg

Definition at line 211 of file csz_inflate.cc.

typedef unsigned short ush

Definition at line 210 of file csz_inflate.cc.

Function Documentation

int csz__huft_build ( unsigned *  b,
unsigned  n,
unsigned  s,
ush d,
ush e,
struct huft **  t,
int m 
)

Definition at line 410 of file csz_inflate.cc.

426 {
427  unsigned a; /* counter for codes of length k */
428  unsigned c[BMAX+1]; /* bit length count table */
429  unsigned el; /* length of EOB code (value 256) */
430  unsigned f; /* i repeats in table every f entries */
431  int g; /* maximum code length */
432  int h; /* table level */
433  /*G.Barrand : comment out register keyword.*/
434  /*register*/ unsigned i; /* counter, current code */
435  /*register*/ unsigned j; /* counter */
436  /*register*/ int k; /* number of bits in current code */
437  int lx[BMAX+1]; /* memory for l[-1..BMAX-1] */
438  int *l = lx+1; /* stack of bits per table */
439  /*register*/ unsigned *p; /* pointer into c[], b[], or v[] */
440  /*register*/ struct huft *q; /* points to current table */
441  struct huft r; /* table entry for structure assignment */
442  struct huft *u[BMAX]; /* table stack */
443  static unsigned v[N_MAX]; /* values in order of bit length */
444  /*register*/ int w; /* bits before this table == (l * h) */
445  unsigned x[BMAX+1]; /* bit offsets, then code stack */
446  unsigned *xp; /* pointer into x */
447  int y; /* number of dummy codes added */
448  unsigned z; /* number of entries in current table */
449 
450 
451  /* Generate counts for each bit length */
452  el = n > 256 ? b[256] : BMAX; /* set length of EOB code, if any */
453  memset((char *)c,0,sizeof(c));
454  p = b; i = n;
455  do {
456  c[*p]++; p++; /* assume all entries <= BMAX */
457  } while (--i);
458  if (c[0] == n) /* null input--all zero length codes */
459  {
460  *t = (struct huft *)NULL;
461  *m = 0;
462  return 0;
463  }
464 
465 
466  /* Find minimum and maximum length, bound *m by those */
467  for (j = 1; j <= BMAX; j++)
468  if (c[j])
469  break;
470  k = j; /* minimum code length */
471  if ((unsigned)*m < j)
472  *m = j;
473  for (i = BMAX; i; i--)
474  if (c[i])
475  break;
476  g = i; /* maximum code length */
477  if ((unsigned)*m > i)
478  *m = i;
479 
480 
481  /* Adjust last length count to fill out codes, if needed */
482  for (y = 1 << j; j < i; j++, y <<= 1)
483  if ((y -= c[j]) < 0)
484  return 2; /* bad input: more codes than bits */
485  if ((y -= c[i]) < 0)
486  return 2;
487  c[i] += y;
488 
489 
490  /* Generate starting offsets into the value table for each length */
491  x[1] = j = 0;
492  p = c + 1; xp = x + 2;
493  while (--i) { /* note that i == g from above */
494  *xp++ = (j += *p++);
495  }
496 
497 
498  /* Make a table of values in order of bit lengths */
499  p = b; i = 0;
500  do {
501  if ((j = *p++) != 0)
502  v[x[j]++] = i;
503  } while (++i < n);
504 
505 
506  /* Generate the Huffman codes and for each, make the table entries */
507  x[0] = i = 0; /* first Huffman code is zero */
508  p = v; /* grab values in bit order */
509  h = -1; /* no tables yet--level -1 */
510  w = l[-1] = 0; /* no bits decoded yet */
511  u[0] = (struct huft *)NULL; /* just to keep compilers happy */
512  q = (struct huft *)NULL; /* ditto */
513  z = 0; /* ditto */
514 
515  /* go through the bit lengths (k already is bits in shortest code) */
516  for (; k <= g; k++)
517  {
518  a = c[k];
519  while (a--)
520  {
521  /* here i is the Huffman code of length k bits for value *p */
522  /* make tables up to required level */
523  while (k > w + l[h])
524  {
525  w += l[h++]; /* add bits already decoded */
526 
527  /* compute minimum size table less than or equal to *m bits */
528  z = (z = g - w) > (unsigned)*m ? (unsigned) *m : z; /* upper limit */
529  if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
530  { /* too few codes for k-w bit table */
531  f -= a + 1; /* deduct codes from patterns left */
532  xp = c + k;
533  while (++j < z) /* try smaller tables up to z bits */
534  {
535  if ((f <<= 1) <= *++xp)
536  break; /* enough codes to use up j bits */
537  f -= *xp; /* else deduct codes from patterns */
538  }
539  }
540  if ((unsigned)w + j > el && (unsigned)w < el)
541  j = el - w; /* make EOB code end at table */
542  z = 1 << j; /* table entries for j-bit table */
543  l[h] = j; /* set table size in stack */
544 
545  /* allocate and link in new table */
546  if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) ==
547  (struct huft *)NULL)
548  {
549  if (h)
550  csz__huft_free(u[0]);
551  return 3; /* not enough memory */
552  }
553  hufts += z + 1; /* track memory usage */
554  *t = q + 1; /* link to list for huft_free() */
555  *(t = &(q->v.t)) = (struct huft *)NULL;
556  u[h] = ++q; /* table starts after link */
557 
558  /* connect to last table, if there is one */
559  if (h)
560  {
561  x[h] = i; /* save pattern for backing up */
562  r.b = (uch)l[h-1]; /* bits to dump before this table */
563  r.e = (uch)(16 + j); /* bits in this table */
564  r.v.t = q; /* pointer to this table */
565  j = (i & ((1 << w) - 1)) >> (w - l[h-1]);
566  u[h-1][j] = r; /* connect to last table */
567  }
568  }
569 
570  /* set up table entry in r */
571  r.b = (uch)(k - w);
572  if (p >= v + n)
573  r.e = 99; /* out of values--invalid code */
574  else if (*p < s) {
575  r.e = (uch)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */
576  r.v.n = *p++; /* simple code is just the value */
577  } else if(e && d) {
578  r.e = (uch)e[*p - s]; /* non-simple--look up in lists */
579  r.v.n = d[*p++ - s];
580  } else return 1;
581 
582  /* fill code-like entries with r */
583  f = 1 << (k - w);
584  for (j = i >> w; j < z; j += f)
585  q[j] = r;
586 
587  /* backwards increment the k-bit code i */
588  for (j = 1 << (k - 1); i & j; j >>= 1)
589  i ^= j;
590  i ^= j;
591 
592  /* backup over finished tables */
593  while ((i & ((1 << w) - 1)) != x[h])
594  w -= l[--h]; /* don't need to update q */
595  }
596  }
597 
598 
599  /* return actual size of base table */
600  *m = l[0];
601 
602 
603  /* Return true (1) if we were given an incomplete table */
604  return y != 0 && g != 1;
605 }
uch e
Definition: csz_inflate.cc:248
const char * p
Definition: xmltok.h:285
#define BMAX
Definition: csz_inflate.cc:403
static constexpr double g
Definition: G4SIunits.hh:183
#define N_MAX
Definition: csz_inflate.cc:404
const XML_Char * s
Definition: expat.h:262
static constexpr double m
Definition: G4SIunits.hh:129
uch b
Definition: csz_inflate.cc:249
static unsigned hufts
Definition: csz_inflate.cc:407
union huft::@0 v
unsigned char uch
Definition: csz_inflate.cc:209
struct huft * t
Definition: csz_inflate.cc:252
int csz__huft_free(struct huft *)
Definition: csz_inflate.cc:609

Here is the call graph for this function:

Here is the caller graph for this function:

int csz__huft_free ( struct huft t)

Definition at line 609 of file csz_inflate.cc.

614 {
615  /*register*/ struct huft *p, *q;
616 
617 
618  /* Go through linked list, freeing from the malloced (t[-1]) address. */
619  p = t;
620  while (p != (struct huft *)NULL)
621  {
622  q = (--p)->v.t;
623  free(p);
624  p = q;
625  }
626  return 0;
627 }
const char * p
Definition: xmltok.h:285
union huft::@0 v
struct huft * t
Definition: csz_inflate.cc:252

Here is the caller graph for this function:

int csz__Inflate ( void  )

Definition at line 1076 of file csz_inflate.cc.

1078 {
1079  int e; /* last block flag */
1080  int r; /* result code */
1081  unsigned h; /* maximum struct huft's malloc'ed */
1082 
1083 
1084  /* initialize window, bit buffer */
1085  wp = 0;
1086  bk = 0;
1087  bb = 0;
1088 
1089 
1090  /* decompress until the last block */
1091  h = 0;
1092  do {
1093  hufts = 0;
1094  if ((r = csz__Inflate_block(&e)) != 0)
1095  return r;
1096  if (hufts > h)
1097  h = hufts;
1098  } while (!e);
1099 
1100 
1101  /* flush out slide */
1102  FLUSH(wp);
1103 
1104 
1105  /* return success */
1106  Trace((stderr, "\n%lu bytes in Huffman tables (%lu/entry)\n",
1107  h * sizeof(struct huft), sizeof(struct huft)));
1108  return 0;
1109 }
uch e
Definition: csz_inflate.cc:248
#define Trace(x)
Definition: csz_inflate.cc:235
static unsigned wp
Definition: csz_inflate.cc:294
static ulg bb
Definition: csz_inflate.cc:344
static unsigned hufts
Definition: csz_inflate.cc:407
int csz__Inflate_block(int *)
static unsigned bk
Definition: csz_inflate.cc:345
#define FLUSH(n)
Definition: csz_inflate.cc:226

Here is the call graph for this function:

int csz__Inflate_block ( int e)

Definition at line 1028 of file csz_inflate.cc.

1031 {
1032  unsigned t; /* block type */
1033  /*register*/ ulg b; /* bit buffer */
1034  /*register*/ unsigned k; /* number of bits in bit buffer */
1035 
1036 
1037  /* make local bit buffer */
1038  b = bb;
1039  k = bk;
1040 
1041 
1042  /* read in last block bit */
1043  NEEDBITS(1)
1044  *e = (int)b & 1;
1045  DUMPBITS(1)
1046 
1047 
1048  /* read in block type */
1049  NEEDBITS(2)
1050  t = (unsigned)b & 3;
1051  DUMPBITS(2)
1052 
1053 
1054  /* restore the global bit buffer */
1055  bb = b;
1056  bk = k;
1057 
1058 
1059  /* inflate that block type */
1060  if (t == 2)
1061  return csz__Inflate_dynamic();
1062  if (t == 0)
1063  return csz__Inflate_stored();
1064  if (t == 1)
1065  return csz__Inflate_fixed();
1066 
1067 
1068  /* bad block type */
1069  return 2;
1070 }
unsigned long ulg
Definition: csz_inflate.cc:211
uch e
Definition: csz_inflate.cc:248
if(nIso!=0)
static ulg bb
Definition: csz_inflate.cc:344
#define NEEDBITS(n)
Definition: csz_inflate.cc:359
uch b
Definition: csz_inflate.cc:249
int csz__Inflate_dynamic(void)
Definition: csz_inflate.cc:854
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
int csz__Inflate_fixed(void)
Definition: csz_inflate.cc:806
#define DUMPBITS(n)
Definition: csz_inflate.cc:362
struct huft * t
Definition: csz_inflate.cc:252
static unsigned bk
Definition: csz_inflate.cc:345
int csz__Inflate_stored(void)
Definition: csz_inflate.cc:748

Here is the call graph for this function:

Here is the caller graph for this function:

int csz__Inflate_codes ( struct huft tl,
struct huft td,
int  bl,
int  bd 
)

Definition at line 638 of file csz_inflate.cc.

643 {
644  /*register*/ unsigned e; /* table entry flag/number of extra bits */
645  unsigned n, d; /* length and index for copy */
646  unsigned w; /* current window position */
647  struct huft *t; /* pointer to table entry */
648  unsigned ml, md; /* masks for bl and bd bits */
649  /*register*/ ulg b; /* bit buffer */
650  /*register*/ unsigned k; /* number of bits in bit buffer */
651 
652 
653  /* make local copies of globals */
654  b = bb; /* initialize bit buffer */
655  k = bk;
656  w = wp; /* initialize window position */
657 
658 
659  /* inflate the coded data */
660  ml = mask[bl]; /* precompute masks for speed */
661  md = mask[bd];
662  while (1) /* do until end of block */
663  {
664  NEEDBITS((unsigned)bl)
665  if ((e = (t = tl + ((unsigned)b & ml))->e) > 16)
666  do {
667  if (e == 99)
668  return 1;
669  DUMPBITS(t->b)
670  e -= 16;
671  NEEDBITS(e)
672  } while ((e = (t = t->v.t + ((unsigned)b & mask[e]))->e) > 16);
673  DUMPBITS(t->b)
674  if (e == 16) /* then it's a literal */
675  {
676  csz__slide[w++] = (uch)t->v.n;
677  if (w == WSIZE)
678  {
679  FLUSH(w);
680  w = 0;
681  }
682  }
683  else /* it's an EOB or a length */
684  {
685  /* exit if end of block */
686  if (e == 15)
687  break;
688 
689  /* get length of block to copy */
690  NEEDBITS(e)
691  n = t->v.n + ((unsigned)b & mask[e]);
692  DUMPBITS(e);
693 
694  /* decode distance of block to copy */
695  NEEDBITS((unsigned)bd)
696  if ((e = (t = td + ((unsigned)b & md))->e) > 16)
697  do {
698  if (e == 99)
699  return 1;
700  DUMPBITS(t->b)
701  e -= 16;
702  NEEDBITS(e)
703  } while ((e = (t = t->v.t + ((unsigned)b & mask[e]))->e) > 16);
704  DUMPBITS(t->b)
705  NEEDBITS(e)
706  d = w - t->v.n - ((unsigned)b & mask[e]);
707  DUMPBITS(e)
708 
709  /* do the copy */
710  do {
711  n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e);
712 #ifndef NOMEMCPY
713  if (w - d >= e) /* (this test assumes unsigned comparison) */
714  {
715  memcpy(csz__slide + w, csz__slide + d, e);
716  w += e;
717  d += e;
718  }
719  else /* do it slow to avoid memcpy() overlap */
720 #endif /* !NOMEMCPY */
721  do {
722  csz__slide[w++] = csz__slide[d++];
723  } while (--e);
724  if (w == WSIZE)
725  {
726  FLUSH(w);
727  w = 0;
728  }
729  } while (n);
730  }
731  }
732 
733 
734  /* restore the globals from the locals */
735  wp = w; /* restore global window pointer */
736  bb = b; /* restore global bit buffer */
737  bk = k;
738 
739 
740  /* done */
741  return 0;
742 }
unsigned long ulg
Definition: csz_inflate.cc:211
uch e
Definition: csz_inflate.cc:248
static ush mask[]
Definition: csz_inflate.cc:317
ush n
Definition: csz_inflate.cc:251
if(nIso!=0)
static unsigned wp
Definition: csz_inflate.cc:294
#define WSIZE
Definition: csz_inflate.cc:214
static ulg bb
Definition: csz_inflate.cc:344
static uch csz__slide[32768]
Definition: csz_inflate.cc:293
#define NEEDBITS(n)
Definition: csz_inflate.cc:359
uch b
Definition: csz_inflate.cc:249
#define DUMPBITS(n)
Definition: csz_inflate.cc:362
union huft::@0 v
unsigned char uch
Definition: csz_inflate.cc:209
struct huft * t
Definition: csz_inflate.cc:252
static unsigned bk
Definition: csz_inflate.cc:345
#define FLUSH(n)
Definition: csz_inflate.cc:226

Here is the call graph for this function:

Here is the caller graph for this function:

int csz__Inflate_dynamic ( void  )

Definition at line 854 of file csz_inflate.cc.

856 {
857  int i; /* temporary variables */
858  unsigned j;
859  unsigned l; /* last length */
860  unsigned m; /* mask for bit lengths table */
861  unsigned n; /* number of lengths to get */
862  struct huft *tl; /* literal/length code table */
863  struct huft *td; /* distance code table */
864  int bl; /* lookup bits for tl */
865  int bd; /* lookup bits for td */
866  unsigned nb; /* number of bit length codes */
867  unsigned nl; /* number of literal/length codes */
868  unsigned nd; /* number of distance codes */
869 #ifdef PKZIP_BUG_WORKAROUND
870  static unsigned ll[288+32]; /* literal/length and distance code lengths */
871 #else
872  static unsigned ll[286+30]; /* literal/length and distance code lengths */
873 #endif
874  /*register*/ ulg b; /* bit buffer */
875  /*register*/ unsigned k; /* number of bits in bit buffer */
876 
877  static int qflag = 0; /*G.Barrand*/
878 
879  /* make local bit buffer */
880  Trace((stderr, "\ndynamic block"));
881  b = bb;
882  k = bk;
883 
884 
885  /* read in table lengths */
886  NEEDBITS(5)
887  nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */
888  DUMPBITS(5)
889  NEEDBITS(5)
890  nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */
891  DUMPBITS(5)
892  NEEDBITS(4)
893  nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */
894  DUMPBITS(4)
895 #ifdef PKZIP_BUG_WORKAROUND
896  if (nl > 288 || nd > 32)
897 #else
898  if (nl > 286 || nd > 30)
899 #endif
900  return 1; /* bad lengths */
901 
902 
903  /* read in bit-length-code lengths */
904  for (j = 0; j < nb; j++)
905  {
906  NEEDBITS(3)
907  ll[border[j]] = (unsigned)b & 7;
908  DUMPBITS(3)
909  }
910  for (; j < 19; j++)
911  ll[border[j]] = 0;
912 
913 
914  /* build decoding table for trees--single level, 7 bit lookup */
915  bl = 7;
916  if ((i = csz__huft_build(ll, 19, 19, NULL, NULL, &tl, &bl)) != 0)
917  {
918  if (i == 1)
919  csz__huft_free(tl);
920  return i; /* incomplete code set */
921  }
922 
923 /*G.Barrand : to quiet Coverity : */
924 #define NEEDBITS_free_tl(n) {while(k<(n)){if(ibufcnt-- <= 0){csz__huft_free(tl);return 1;} b|=((ulg) *ibufptr++)<<k;k+=8;}}
925 
926  /* read in literal and distance code lengths */
927  n = nl + nd;
928  m = mask[bl];
929  i = l = 0;
930  while ((unsigned)i < n)
931  {
932  NEEDBITS_free_tl((unsigned)bl)
933  j = (td = tl + ((unsigned)b & m))->b;
934  DUMPBITS(j)
935  j = td->v.n;
936  if (j < 16) /* length of code in bits (0..15) */
937  ll[i++] = l = j; /* save last length in l */
938  else if (j == 16) /* repeat last length 3 to 6 times */
939  {
941  j = 3 + ((unsigned)b & 3);
942  DUMPBITS(2)
943  if ((unsigned)i + j > n) {
944  csz__huft_free(tl); /*G.Barrand : quiet Coverity*/
945  return 1;
946  }
947  while (j--)
948  ll[i++] = l;
949  }
950  else if (j == 17) /* 3 to 10 zero length codes */
951  {
953  j = 3 + ((unsigned)b & 7);
954  DUMPBITS(3)
955  if ((unsigned)i + j > n){
956  csz__huft_free(tl); /*G.Barrand : quiet Coverity*/
957  return 1;
958  }
959  while (j--)
960  ll[i++] = 0;
961  l = 0;
962  }
963  else /* j == 18: 11 to 138 zero length codes */
964  {
966  j = 11 + ((unsigned)b & 0x7f);
967  DUMPBITS(7)
968  if ((unsigned)i + j > n) {
969  csz__huft_free(tl); /*G.Barrand : quiet Coverity*/
970  return 1;
971  }
972  while (j--)
973  ll[i++] = 0;
974  l = 0;
975  }
976  }
977 
978 
979  /* free decoding table for trees */
980  csz__huft_free(tl);
981 
982 
983  /* restore the global bit buffer */
984  bb = b;
985  bk = k;
986 
987 
988  /* build the decoding tables for literal/length and distance codes */
989  bl = lbits;
990  if ((i = csz__huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0)
991  {
992  if (i == 1 && !qflag) {
993  FPRINTF(stderr, "(incomplete l-tree) ");
994  csz__huft_free(tl);
995  }
996  return i; /* incomplete code set */
997  }
998  bd = dbits;
999  if ((i = csz__huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0)
1000  {
1001  if (i == 1 && !qflag) {
1002  FPRINTF(stderr, "(incomplete d-tree) ");
1003 #ifdef PKZIP_BUG_WORKAROUND
1004  i = 0;
1005  }
1006 #else
1007  csz__huft_free(td);
1008  }
1009  csz__huft_free(tl);
1010  return i; /* incomplete code set */
1011 #endif
1012  }
1013 
1014 
1015  /* decompress until an end-of-block code */
1016  if (csz__Inflate_codes(tl, td, bl, bd))
1017  return 1;
1018 
1019 
1020  /* free the decoding tables, return */
1021  csz__huft_free(tl);
1022  csz__huft_free(td);
1023  return 0;
1024 }
static ush cplens[]
Definition: csz_inflate.cc:300
unsigned long ulg
Definition: csz_inflate.cc:211
static unsigned border[]
Definition: csz_inflate.cc:298
static ush mask[]
Definition: csz_inflate.cc:317
#define FPRINTF
Definition: csz_inflate.cc:222
int csz__Inflate_codes(struct huft *, struct huft *, int, int)
Definition: csz_inflate.cc:638
#define Trace(x)
Definition: csz_inflate.cc:235
if(nIso!=0)
static ush cplext[]
Definition: csz_inflate.cc:304
#define NEEDBITS_free_tl(n)
static ulg bb
Definition: csz_inflate.cc:344
static ush cpdext[]
Definition: csz_inflate.cc:311
static int lbits
Definition: csz_inflate.cc:398
static constexpr double m
Definition: G4SIunits.hh:129
#define NEEDBITS(n)
Definition: csz_inflate.cc:359
uch b
Definition: csz_inflate.cc:249
int csz__huft_build(unsigned *, unsigned, unsigned, ush *, ush *, struct huft **, int *)
Definition: csz_inflate.cc:410
#define DUMPBITS(n)
Definition: csz_inflate.cc:362
union huft::@0 v
static ush cpdist[]
Definition: csz_inflate.cc:307
static unsigned bk
Definition: csz_inflate.cc:345
static int dbits
Definition: csz_inflate.cc:399
for(G4int i1=0;i1< theStableOnes.GetNumberOfIsotopes(static_cast< G4int >(anE->GetZ()));i1++)
int csz__huft_free(struct huft *)
Definition: csz_inflate.cc:609

Here is the call graph for this function:

Here is the caller graph for this function:

int csz__Inflate_fixed ( void  )

Definition at line 806 of file csz_inflate.cc.

810 {
811  /* if first time, set up tables for fixed blocks */
812  Trace((stderr, "\nliteral block"));
813  if (csz__fixed_tl == (struct huft *)NULL)
814  {
815  int i; /* temporary variable */
816  static unsigned l[288]; /* length list for huft_build */
817 
818  /* literal table */
819  for (i = 0; i < 144; i++)
820  l[i] = 8;
821  for (; i < 256; i++)
822  l[i] = 9;
823  for (; i < 280; i++)
824  l[i] = 7;
825  for (; i < 288; i++) /* make a complete, but wrong code set */
826  l[i] = 8;
827  csz__fixed_bl = 7;
828  if ((i = csz__huft_build(l, 288, 257, cplens, cplext,
829  &csz__fixed_tl, &csz__fixed_bl)) != 0)
830  {
831  csz__fixed_tl = (struct huft *)NULL;
832  return i;
833  }
834 
835  /* distance table */
836  for (i = 0; i < 30; i++) /* make an incomplete code set */
837  l[i] = 5;
838  csz__fixed_bd = 5;
839  if ((i = csz__huft_build(l, 30, 0, cpdist, cpdext, &csz__fixed_td, &csz__fixed_bd)) > 1)
840  {
842  csz__fixed_tl = (struct huft *)NULL;
843  return i;
844  }
845  }
846 
847 
848  /* decompress until an end-of-block code */
850 }
static ush cplens[]
Definition: csz_inflate.cc:300
struct huft * csz__fixed_td
Definition: csz_inflate.cc:803
struct huft * csz__fixed_tl
Definition: csz_inflate.cc:802
int csz__Inflate_codes(struct huft *, struct huft *, int, int)
Definition: csz_inflate.cc:638
#define Trace(x)
Definition: csz_inflate.cc:235
static ush cplext[]
Definition: csz_inflate.cc:304
static ush cpdext[]
Definition: csz_inflate.cc:311
int csz__fixed_bl
Definition: csz_inflate.cc:804
int csz__huft_build(unsigned *, unsigned, unsigned, ush *, ush *, struct huft **, int *)
Definition: csz_inflate.cc:410
int csz__fixed_bd
Definition: csz_inflate.cc:804
static ush cpdist[]
Definition: csz_inflate.cc:307
int csz__huft_free(struct huft *)
Definition: csz_inflate.cc:609

Here is the call graph for this function:

Here is the caller graph for this function:

int csz__Inflate_free ( void  )

Definition at line 1111 of file csz_inflate.cc.

1112 {
1113  if (csz__fixed_tl != (struct huft *)NULL)
1114  {
1117  csz__fixed_td = csz__fixed_tl = (struct huft *)NULL;
1118  }
1119  return 0;
1120 }
struct huft * csz__fixed_td
Definition: csz_inflate.cc:803
struct huft * csz__fixed_tl
Definition: csz_inflate.cc:802
int csz__huft_free(struct huft *)
Definition: csz_inflate.cc:609

Here is the call graph for this function:

int csz__Inflate_stored ( void  )

Definition at line 748 of file csz_inflate.cc.

750 {
751  unsigned n; /* number of bytes in block */
752  unsigned w; /* current window position */
753  /*register*/ ulg b; /* bit buffer */
754  /*register*/ unsigned k; /* number of bits in bit buffer */
755 
756 
757  /* make local copies of globals */
758  Trace((stderr, "\nstored block"));
759  b = bb; /* initialize bit buffer */
760  k = bk;
761  w = wp; /* initialize window position */
762 
763 
764  /* go to byte boundary */
765  n = k & 7;
766  DUMPBITS(n);
767 
768 
769  /* get the length and its complement */
770  NEEDBITS(16)
771  n = ((unsigned)b & 0xffff);
772  DUMPBITS(16)
773  NEEDBITS(16)
774  if (n != (unsigned)((~b) & 0xffff))
775  return 1; /* error in compressed data */
776  DUMPBITS(16)
777 
778 
779  /* read and output the compressed data */
780  while (n--)
781  {
782  NEEDBITS(8)
783  csz__slide[w++] = (uch)b;
784  if (w == WSIZE)
785  {
786  FLUSH(w);
787  w = 0;
788  }
789  DUMPBITS(8)
790  }
791 
792 
793  /* restore the globals from the locals */
794  wp = w; /* restore global window pointer */
795  bb = b; /* restore global bit buffer */
796  bk = k;
797  return 0;
798 }
unsigned long ulg
Definition: csz_inflate.cc:211
#define Trace(x)
Definition: csz_inflate.cc:235
if(nIso!=0)
static unsigned wp
Definition: csz_inflate.cc:294
#define WSIZE
Definition: csz_inflate.cc:214
static ulg bb
Definition: csz_inflate.cc:344
static uch csz__slide[32768]
Definition: csz_inflate.cc:293
#define NEEDBITS(n)
Definition: csz_inflate.cc:359
uch b
Definition: csz_inflate.cc:249
#define DUMPBITS(n)
Definition: csz_inflate.cc:362
unsigned char uch
Definition: csz_inflate.cc:209
static unsigned bk
Definition: csz_inflate.cc:345
#define FLUSH(n)
Definition: csz_inflate.cc:226

Here is the caller graph for this function:

void csz__Init_Inflate ( long  a_ibufcnt,
unsigned char *  a_ibufptr,
long  a_obufcnt,
unsigned char *  a_obufptr 
)

Definition at line 1123 of file csz_inflate.cc.

1124  {
1125  ibufcnt = a_ibufcnt;
1126  ibufptr = a_ibufptr;
1127 
1128  obufcnt = a_obufcnt;
1129  obufptr = a_obufptr;
1130 }
static long obufcnt
Definition: csz_inflate.cc:347
static long ibufcnt
Definition: csz_inflate.cc:347
static uch * obufptr
Definition: csz_inflate.cc:346
static uch * ibufptr
Definition: csz_inflate.cc:346
unsigned char* csz__obufptr ( )

Definition at line 1131 of file csz_inflate.cc.

1131 {return obufptr;}
static uch * obufptr
Definition: csz_inflate.cc:346
static void csz__WriteData ( int  n)
static

Definition at line 1149 of file csz_inflate.cc.

1150 {
1151  if( obufcnt >= n ) memcpy(obufptr, csz__slide, n);
1152  obufptr += n;
1153  obufcnt -= n;
1154 }
static long obufcnt
Definition: csz_inflate.cc:347
static uch csz__slide[32768]
Definition: csz_inflate.cc:293
static uch * obufptr
Definition: csz_inflate.cc:346

Variable Documentation

ulg bb
static

Definition at line 344 of file csz_inflate.cc.

unsigned bk
static

Definition at line 345 of file csz_inflate.cc.

unsigned border[]
static
Initial value:
= {
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}

Definition at line 298 of file csz_inflate.cc.

ush cpdext[]
static
Initial value:
= {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13}

Definition at line 311 of file csz_inflate.cc.

ush cpdist[]
static
Initial value:
= {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577}

Definition at line 307 of file csz_inflate.cc.

ush cplens[]
static
Initial value:
= {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}

Definition at line 300 of file csz_inflate.cc.

ush cplext[]
static
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99}

Definition at line 304 of file csz_inflate.cc.

int csz__fixed_bd

Definition at line 804 of file csz_inflate.cc.

int csz__fixed_bl

Definition at line 804 of file csz_inflate.cc.

struct huft* csz__fixed_td

Definition at line 803 of file csz_inflate.cc.

struct huft* csz__fixed_tl = (struct huft *)NULL

Definition at line 802 of file csz_inflate.cc.

uch csz__slide[32768]
static

Definition at line 293 of file csz_inflate.cc.

int dbits = 6
static

Definition at line 399 of file csz_inflate.cc.

unsigned hufts
static

Definition at line 407 of file csz_inflate.cc.

long ibufcnt
static

Definition at line 347 of file csz_inflate.cc.

uch* ibufptr
static

Definition at line 346 of file csz_inflate.cc.

int lbits = 9
static

Definition at line 398 of file csz_inflate.cc.

ush mask[]
static
Initial value:
= {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
}

Definition at line 317 of file csz_inflate.cc.

long obufcnt
static

Definition at line 347 of file csz_inflate.cc.

uch * obufptr
static

Definition at line 346 of file csz_inflate.cc.

unsigned wp
static

Definition at line 294 of file csz_inflate.cc.