Beispiel #1
0
        internal static ZlibCompressionState Inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z)
        {
            ZlibCompressionState r;
            var hn = new int[1];   // hufts used in space
            var v  = new int[288]; // work area for huft_build

            // build literal/length tree
            r = Huft_build(c, 0, nl, 257, Cplens, Cplext, tl, bl, hp, hn, v);
            if (r != ZlibCompressionState.ZOK || bl[0] == 0)
            {
                if (r == ZlibCompressionState.ZDATAERROR)
                {
                    z.Msg = "oversubscribed literal/length tree";
                }
                else if (r != ZlibCompressionState.ZMEMERROR)
                {
                    z.Msg = "incomplete literal/length tree";
                    r     = ZlibCompressionState.ZDATAERROR;
                }

                return(r);
            }

            // build distance tree
            r = Huft_build(c, nl, nd, 0, Cpdist, Cpdext, td, bd, hp, hn, v);

            if (r != ZlibCompressionState.ZOK || (bd[0] == 0 && nl > 257))
            {
                if (r == ZlibCompressionState.ZDATAERROR)
                {
                    z.Msg = "oversubscribed distance tree";
                }
                else if (r == ZlibCompressionState.ZBUFERROR)
                {
                    z.Msg = "incomplete distance tree";
                    r     = ZlibCompressionState.ZDATAERROR;
                }
                else if (r != ZlibCompressionState.ZMEMERROR)
                {
                    z.Msg = "empty distance tree with lengths";
                    r     = ZlibCompressionState.ZDATAERROR;
                }

                return(r);
            }

            return(ZlibCompressionState.ZOK);
        }
Beispiel #2
0
        internal static ZlibCompressionState Inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z)
        {
            ZlibCompressionState r;
            var hn = new int[1];  // hufts used in space
            var v  = new int[19]; // work area for huft_build

            r = Huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);

            if (r == ZlibCompressionState.ZDATAERROR)
            {
                z.Msg = "oversubscribed dynamic bit lengths tree";
            }
            else if (r == ZlibCompressionState.ZBUFERROR || bb[0] == 0)
            {
                z.Msg = "incomplete dynamic bit lengths tree";
                r     = ZlibCompressionState.ZDATAERROR;
            }

            return(r);
        }