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

Initialize() private method

private Initialize ( ZlibCodec z, int w ) : int
z ZlibCodec
w int
return int
        internal int Initialize(ZlibCodec z, int w)
        {
            z.Message = null;
            blocks = null;

            // handle undocumented nowrap option (no zlib header or check)
            //nowrap = 0;
            //if (w < 0)
            //{
            //    w = - w;
            //    nowrap = 1;
            //}

            // set window size
            if (w < 8 || w > 15) {
                End (z);
                throw new ZlibException ("Bad window size.");

                //return ZlibConstants.Z_STREAM_ERROR;
            }
            wbits = w;

            z.istate.blocks = new InflateBlocks (z,
                z.istate.HandleRfc1950HeaderBytes ? this : null,
                1 << w);

            // reset state
            Reset (z);
            return ZlibConstants.Z_OK;
        }

Usage Example

Example #1
0
 /// <summary>
 /// Initialize the inflation state with an explicit flag to govern the handling of RFC1950 header bytes. 
 /// </summary>
 /// <remarks>
 /// If you want to read a zlib stream 
 /// you should specify true for expectRfc1950Header.  If you have a deflate stream, you will
 /// want to specify false. 
 /// </remarks>
 /// <param name="expectRfc1950Header">whether to expect an RFC1950 header byte pair when reading 
 /// the stream of data to be inflated.</param>
 /// <param name="windowBits">The number of window bits to use. If you need to ask what that is, 
 /// then you shouldn't be calling this initializer.</param>
 /// <returns>Z_OK if everything goes well.</returns>
 public int InitializeInflate(int windowBits, bool expectRfc1950Header)
 {
     if (dstate != null) throw new ZlibException("You may not call InitializeInflate() after calling InitializeDeflate().");
     istate = new InflateManager(expectRfc1950Header);
     return istate.Initialize(this, windowBits);
 }