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


C# ZStream.flush_pending方法代码示例

本文整理汇总了C#中zlib.ZStream.flush_pending方法的典型用法代码示例。如果您正苦于以下问题:C# ZStream.flush_pending方法的具体用法?C# ZStream.flush_pending怎么用?C# ZStream.flush_pending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zlib.ZStream的用法示例。


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

示例1: deflate

		internal int deflate(ZStream strm, int flush)
		{
			int old_flush;
			
			if (flush > Z_FINISH || flush < 0)
			{
				return Z_STREAM_ERROR;
			}
			
			if (strm.next_out == null || (strm.next_in == null && strm.avail_in != 0) || (status == FINISH_STATE && flush != Z_FINISH))
			{
				strm.msg = z_errmsg[Z_NEED_DICT - (Z_STREAM_ERROR)];
				return Z_STREAM_ERROR;
			}
			if (strm.avail_out == 0)
			{
				strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)];
				return Z_BUF_ERROR;
			}
			
			this.strm = strm; // just in case
			old_flush = last_flush;
			last_flush = flush;
			
			// Write the zlib header
			if (status == INIT_STATE)
			{
				int header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8;
				int level_flags = ((level - 1) & 0xff) >> 1;
				
				if (level_flags > 3)
					level_flags = 3;
				header |= (level_flags << 6);
				if (strstart != 0)
					header |= PRESET_DICT;
				header += 31 - (header % 31);
				
				status = BUSY_STATE;
				putShortMSB(header);
				
				
				// Save the adler32 of the preset dictionary:
				if (strstart != 0)
				{
					putShortMSB((int) (SupportClass.URShift(strm.adler, 16)));
					putShortMSB((int) (strm.adler & 0xffff));
				}
				strm.adler = strm._adler.adler32(0, null, 0, 0);
			}
			
			// Flush as much pending output as possible
			if (pending != 0)
			{
				strm.flush_pending();
				if (strm.avail_out == 0)
				{
					//System.out.println("  avail_out==0");
					// Since avail_out is 0, deflate will be called again with
					// more output space, but possibly with both pending and
					// avail_in equal to zero. There won't be anything to do,
					// but this is not an error situation so make sure we
					// return OK instead of BUF_ERROR at next call of deflate:
					last_flush = - 1;
					return Z_OK;
				}
				
				// Make sure there is something to do and avoid duplicate consecutive
				// flushes. For repeated and useless calls with Z_FINISH, we keep
				// returning Z_STREAM_END instead of Z_BUFF_ERROR.
			}
			else if (strm.avail_in == 0 && flush <= old_flush && flush != Z_FINISH)
			{
				strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)];
				return Z_BUF_ERROR;
			}
			
			// User must not provide more input after the first FINISH:
			if (status == FINISH_STATE && strm.avail_in != 0)
			{
				strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)];
				return Z_BUF_ERROR;
			}
			
			// Start a new block or continue the current one.
			if (strm.avail_in != 0 || lookahead != 0 || (flush != Z_NO_FLUSH && status != FINISH_STATE))
			{
				int bstate = - 1;
				switch (config_table[level].func)
				{
					
					case STORED: 
						bstate = deflate_stored(flush);
						break;
					
					case FAST: 
						bstate = deflate_fast(flush);
						break;
					
					case SLOW: 
						bstate = deflate_slow(flush);
//.........这里部分代码省略.........
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:Deflate.cs

示例2: deflate

        internal int deflate(ZStream strm, int flush)
        {
            if ((flush > 4) || (flush < 0))
            {
                return -2;
            }
            if (((strm.next_out == null) || ((strm.next_in == null) && (strm.avail_in != 0))) || ((this.status == 0x29a) && (flush != 4)))
            {
                strm.msg = Deflate.z_errmsg[4];
                return -2;
            }
            if (strm.avail_out == 0)
            {
                strm.msg = Deflate.z_errmsg[7];
                return -5;
            }
            this.strm = strm;
            int num1 = this.last_flush;
            this.last_flush = flush;
            if (this.status == 0x2a)
            {
                int num2 = (8 + ((this.w_bits - 8) << 4)) << 8;
                int num3 = ((this.level - 1) & 0xff) >> 1;
                if (num3 > 3)
                {
                    num3 = 3;
                }
                num2 |= num3 << 6;
                if (this.strstart != 0)
                {
                    num2 |= 0x20;
                }
                num2 += 0x1f - (num2 % 0x1f);
                this.status = 0x71;
                this.putShortMSB(num2);
                if (this.strstart != 0)
                {
                    this.putShortMSB((int) SupportClass.URShift(strm.adler, 0x10));
                    this.putShortMSB(((int) strm.adler) & 0xffff);
                }
                strm.adler = strm._adler.adler32((long) 0, null, 0, 0);
            }
            if (this.pending != 0)
            {
                strm.flush_pending();
                if (strm.avail_out == 0)
                {
                    this.last_flush = -1;
                    return 0;
                }
            }
            else if (((strm.avail_in == 0) && (flush <= num1)) && (flush != 4))
            {
                strm.msg = Deflate.z_errmsg[7];
                return -5;
            }
            if ((this.status == 0x29a) && (strm.avail_in != 0))
            {
                strm.msg = Deflate.z_errmsg[7];
                return -5;
            }
            if (((strm.avail_in != 0) || (this.lookahead != 0)) || ((flush != 0) && (this.status != 0x29a)))
            {
                int num4 = -1;
                switch (Deflate.config_table[this.level].func)
                {
                    case 0:
                        num4 = this.deflate_stored(flush);
                        break;

                    case 1:
                        num4 = this.deflate_fast(flush);
                        break;

                    case 2:
                        num4 = this.deflate_slow(flush);
                        break;
                }
                switch (num4)
                {
                    case 2:
                    case 3:
                        this.status = 0x29a;
                        break;
                }
                switch (num4)
                {
                    case 0:
                    case 2:
                        if (strm.avail_out == 0)
                        {
                            this.last_flush = -1;
                        }
                        return 0;

                    default:
                        if (num4 == 1)
                        {
                            if (flush == 1)
                            {
//.........这里部分代码省略.........
开发者ID:justwee,项目名称:WPF-Projects,代码行数:101,代码来源:Deflate.cs


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