NetWrok.HTTP.Zlib.InflateManager.SetDictionary C# (CSharp) Method

SetDictionary() private method

private SetDictionary ( ZlibCodec z, byte dictionary ) : int
z ZlibCodec
dictionary byte
return int
        internal int SetDictionary(ZlibCodec z, byte[] dictionary)
        {
            int index = 0;
            int length = dictionary.Length;
            if (z == null || z.istate == null || z.istate.mode != DICT0)
                throw new ZlibException ("Stream error.");

            if (Adler.Adler32 (1L, dictionary, 0, dictionary.Length) != z._Adler32) {
                return ZlibConstants.Z_DATA_ERROR;
            }

            z._Adler32 = Adler.Adler32 (0, null, 0, 0);

            if (length >= (1 << z.istate.wbits)) {
                length = (1 << z.istate.wbits) - 1;
                index = dictionary.Length - length;
            }
            z.istate.blocks.SetDictionary (dictionary, index, length);
            z.istate.mode = BLOCKS;
            return ZlibConstants.Z_OK;
        }