当前位置: 首页>>代码示例>>C#>>正文


C# InflateManagerMode类代码示例

本文整理汇总了C#中InflateManagerMode的典型用法代码示例。如果您正苦于以下问题:C# InflateManagerMode类的具体用法?C# InflateManagerMode怎么用?C# InflateManagerMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InflateManagerMode类属于命名空间,在下文中一共展示了InflateManagerMode类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Reset

 internal int Reset()
 {
     _codec.TotalBytesIn = _codec.TotalBytesOut = 0;
     _codec.Message = null;
     mode = HandleRfc1950HeaderBytes ? InflateManagerMode.METHOD : InflateManagerMode.BLOCKS;
     blocks.Reset();
     return ZlibConstants.Z_OK;
 }
开发者ID:nzdunic,项目名称:ravendb,代码行数:8,代码来源:InflateManager.cs

示例2: Sync

        internal int Sync()
        {
            int n; // number of bytes to look at
            int p; // pointer to bytes
            int m; // number of marker bytes found in a row
            long r, w; // temporaries to save total_in and total_out

            // set up
            if (mode != InflateManagerMode.BAD)
            {
                mode = InflateManagerMode.BAD;
                marker = 0;
            }
            if ((n = _codec.AvailableBytesIn) == 0)
                return ZlibConstants.Z_BUF_ERROR;
            p = _codec.NextIn;
            m = marker;

            // search
            while (n != 0 && m < 4)
            {
                if (_codec.InputBuffer[p] == mark[m])
                {
                    m++;
                }
                else if (_codec.InputBuffer[p] != 0)
                {
                    m = 0;
                }
                else
                {
                    m = 4 - m;
                }
                p++; n--;
            }

            // restore
            _codec.TotalBytesIn += p - _codec.NextIn;
            _codec.NextIn = p;
            _codec.AvailableBytesIn = n;
            marker = m;

            // return no joy or set up to restart on a new block
            if (m != 4)
            {
                return ZlibConstants.Z_DATA_ERROR;
            }
            r = _codec.TotalBytesIn;
            w = _codec.TotalBytesOut;
            Reset();
            _codec.TotalBytesIn = r;
            _codec.TotalBytesOut = w;
            mode = InflateManagerMode.BLOCKS;
            return ZlibConstants.Z_OK;
        }
开发者ID:Cardanis,项目名称:MonoGame,代码行数:55,代码来源:ZlibStream.cs

示例3: SetDictionary

        internal int SetDictionary(byte[] dictionary)
        {
            int index = 0;
            int length = dictionary.Length;
            if (mode != InflateManagerMode.DICT0)
                throw new ZlibException("Stream error.");

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

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

            if (length >= (1 << wbits))
            {
                length = (1 << wbits) - 1;
                index = dictionary.Length - length;
            }
            blocks.SetDictionary(dictionary, index, length);
            mode = InflateManagerMode.BLOCKS;
            return ZlibConstants.Z_OK;
        }
开发者ID:Cardanis,项目名称:MonoGame,代码行数:23,代码来源:ZlibStream.cs

示例4: Inflate

        internal int Inflate(FlushType flush)
        {
            int b;

            if (_codec.InputBuffer == null)
                throw new ZlibException("InputBuffer is null. ");

            //             int f = (flush == FlushType.Finish)
            //                 ? ZlibConstants.Z_BUF_ERROR
            //                 : ZlibConstants.Z_OK;

            // workitem 8870
            int f = ZlibConstants.Z_OK;
            int r = ZlibConstants.Z_BUF_ERROR;

            while (true)
            {
                switch (mode)
                {
                    case InflateManagerMode.METHOD:
                        if (_codec.AvailableBytesIn == 0) return r;
                        r = f;
                        _codec.AvailableBytesIn--;
                        _codec.TotalBytesIn++;
                        if (((method = _codec.InputBuffer[_codec.NextIn++]) & 0xf) != Z_DEFLATED)
                        {
                            mode = InflateManagerMode.BAD;
                            _codec.Message = String.Format("unknown compression method (0x{0:X2})", method);
                            marker = 5; // can't try inflateSync
                            break;
                        }
                        if ((method >> 4) + 8 > wbits)
                        {
                            mode = InflateManagerMode.BAD;
                            _codec.Message = String.Format("invalid window size ({0})", (method >> 4) + 8);
                            marker = 5; // can't try inflateSync
                            break;
                        }
                        mode = InflateManagerMode.FLAG;
                        break;


                    case InflateManagerMode.FLAG:
                        if (_codec.AvailableBytesIn == 0) return r;
                        r = f;
                        _codec.AvailableBytesIn--;
                        _codec.TotalBytesIn++;
                        b = (_codec.InputBuffer[_codec.NextIn++]) & 0xff;

                        if ((((method << 8) + b) % 31) != 0)
                        {
                            mode = InflateManagerMode.BAD;
                            _codec.Message = "incorrect header check";
                            marker = 5; // can't try inflateSync
                            break;
                        }

                        mode = ((b & PRESET_DICT) == 0)
                            ? InflateManagerMode.BLOCKS
                            : InflateManagerMode.DICT4;
                        break;

                    case InflateManagerMode.DICT4:
                        if (_codec.AvailableBytesIn == 0) return r;
                        r = f;
                        _codec.AvailableBytesIn--;
                        _codec.TotalBytesIn++;
                        expectedCheck = (uint)((_codec.InputBuffer[_codec.NextIn++] << 24) & 0xff000000);
                        mode = InflateManagerMode.DICT3;
                        break;

                    case InflateManagerMode.DICT3:
                        if (_codec.AvailableBytesIn == 0) return r;
                        r = f;
                        _codec.AvailableBytesIn--;
                        _codec.TotalBytesIn++;
                        expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 16) & 0x00ff0000);
                        mode = InflateManagerMode.DICT2;
                        break;

                    case InflateManagerMode.DICT2:

                        if (_codec.AvailableBytesIn == 0) return r;
                        r = f;
                        _codec.AvailableBytesIn--;
                        _codec.TotalBytesIn++;
                        expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 8) & 0x0000ff00);
                        mode = InflateManagerMode.DICT1;
                        break;


                    case InflateManagerMode.DICT1:
                        if (_codec.AvailableBytesIn == 0) return r;
                        r = f;
                        _codec.AvailableBytesIn--; _codec.TotalBytesIn++;
                        expectedCheck += (uint)(_codec.InputBuffer[_codec.NextIn++] & 0x000000ff);
                        _codec._Adler32 = expectedCheck;
                        mode = InflateManagerMode.DICT0;
                        return ZlibConstants.Z_NEED_DICT;

//.........这里部分代码省略.........
开发者ID:Cardanis,项目名称:MonoGame,代码行数:101,代码来源:ZlibStream.cs

示例5: Reset

 /// <returns>
 /// </returns>
 private int Reset()
 {
     this.codec.TotalBytesIn = this.codec.TotalBytesOut = 0;
     this.codec.Message = null;
     this.mode = this.HandleRfc1950HeaderBytes ? InflateManagerMode.Method : InflateManagerMode.Blocks;
     this.blocks.Reset();
     return ZlibConstants.Zok;
 }
开发者ID:robertbaker,项目名称:SevenUpdate,代码行数:10,代码来源:InflateManager.cs

示例6: Inflate

        /// <returns></returns> <exception cref = "ZlibException"></exception><exception cref = "ZlibException"></exception><exception cref = "ZlibException"></exception>
        internal int Inflate()
        {
            if (this.codec.InputBuffer == null)
            {
                throw new ZlibException("InputBuffer is null. ");
            }

            // int f = (flush == FlushType.Finish) ? ZlibConstants.Z_BUF_ERROR : ZlibConstants.Z_OK;

            // workitem 8870
            const int f = ZlibConstants.Zok;
            int r = ZlibConstants.ZBufError;

            while (true)
            {
                switch (this.mode)
                {
                    case InflateManagerMode.Method:
                        if (this.codec.AvailableBytesIn == 0)
                        {
                            return r;
                        }

                        r = f;
                        this.codec.AvailableBytesIn--;
                        this.codec.TotalBytesIn++;
                        if (((this.method = this.codec.InputBuffer[this.codec.NextIn++]) & 0xf) != ZDeflated)
                        {
                            this.mode = InflateManagerMode.Bad;
                            this.codec.Message = string.Format(
                                CultureInfo.CurrentCulture, "unknown compression method (0x{0:X2})", this.method);
                            break;
                        }

                        if ((this.method >> 4) + 8 > this.wbits)
                        {
                            this.mode = InflateManagerMode.Bad;
                            this.codec.Message = string.Format(
                                CultureInfo.CurrentCulture, "invalid window size ({0})", (this.method >> 4) + 8);
                            break;
                        }

                        this.mode = InflateManagerMode.Flag;
                        break;

                    case InflateManagerMode.Flag:
                        if (this.codec.AvailableBytesIn == 0)
                        {
                            return r;
                        }

                        r = f;
                        this.codec.AvailableBytesIn--;
                        this.codec.TotalBytesIn++;
                        int b = this.codec.InputBuffer[this.codec.NextIn++] & 0xff;

                        if ((((this.method << 8) + b) % 31) != 0)
                        {
                            this.mode = InflateManagerMode.Bad;
                            this.codec.Message = "incorrect header check";
                            break;
                        }

                        this.mode = ((b & PresetDict) == 0) ? InflateManagerMode.Blocks : InflateManagerMode.DicT4;
                        break;

                    case InflateManagerMode.DicT4:
                        if (this.codec.AvailableBytesIn == 0)
                        {
                            return r;
                        }

                        r = f;
                        this.codec.AvailableBytesIn--;
                        this.codec.TotalBytesIn++;
                        this.expectedCheck = (uint)((this.codec.InputBuffer[this.codec.NextIn++] << 24) & 0xff000000);
                        this.mode = InflateManagerMode.DicT3;
                        break;

                    case InflateManagerMode.DicT3:
                        if (this.codec.AvailableBytesIn == 0)
                        {
                            return r;
                        }

                        r = f;
                        this.codec.AvailableBytesIn--;
                        this.codec.TotalBytesIn++;
                        this.expectedCheck += (uint)((this.codec.InputBuffer[this.codec.NextIn++] << 16) & 0x00ff0000);
                        this.mode = InflateManagerMode.DicT2;
                        break;

                    case InflateManagerMode.DicT2:

                        if (this.codec.AvailableBytesIn == 0)
                        {
                            return r;
                        }

//.........这里部分代码省略.........
开发者ID:robertbaker,项目名称:SevenUpdate,代码行数:101,代码来源:InflateManager.cs

示例7: Sync

        internal int Sync()
        {
            int n;
            int p;
            int m;
            long r, w;

            if ( mode != InflateManagerMode.BAD )
            {
                mode = InflateManagerMode.BAD;
                marker = 0;
            }
            if ( ( n = _codec.AvailableBytesIn ) == 0 )
                return ZlibConstants.Z_BUF_ERROR;
            p = _codec.NextIn;
            m = marker;

            while ( n != 0 && m < 4 )
            {
                if ( _codec.InputBuffer [ p ] == mark [ m ] )
                {
                    m++;
                }
                else if ( _codec.InputBuffer [ p ] != 0 )
                {
                    m = 0;
                }
                else
                {
                    m = 4 - m;
                }
                p++; n--;
            }

            _codec.TotalBytesIn += p - _codec.NextIn;
            _codec.NextIn = p;
            _codec.AvailableBytesIn = n;
            marker = m;

            if ( m != 4 )
            {
                return ZlibConstants.Z_DATA_ERROR;
            }
            r = _codec.TotalBytesIn;
            w = _codec.TotalBytesOut;
            Reset ();
            _codec.TotalBytesIn = r;
            _codec.TotalBytesOut = w;
            mode = InflateManagerMode.BLOCKS;
            return ZlibConstants.Z_OK;
        }
开发者ID:Daramkun,项目名称:ProjectLiqueur,代码行数:51,代码来源:Inflate.cs


注:本文中的InflateManagerMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。