本文整理汇总了C#中FlushType类的典型用法代码示例。如果您正苦于以下问题:C# FlushType类的具体用法?C# FlushType怎么用?C# FlushType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlushType类属于命名空间,在下文中一共展示了FlushType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: addHeaders
private static void addHeaders(string fileName, long fileLength, object response, FlushType flushType)
{
var addHeader = response.GetType().GetMethod("AddHeader");
addHeader.Invoke(response, new object[] { "Content-Length", fileLength.ToString(CultureInfo.InvariantCulture) });
var contentDisposition = flushType == FlushType.Inline ? "inline;filename=" : "attachment;filename=";
addHeader.Invoke(response, new object[] { "content-disposition", contentDisposition + fileName });
}
开发者ID:VahidN,项目名称:PdfReport,代码行数:7,代码来源:SoftHttpContext.cs
示例2: Inflate
public int Inflate(FlushType flush)
{
if (this.istate == null)
throw new ZlibException("No Inflate State!");
else
return this.istate.Inflate(flush);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:ZlibCodec.cs
示例3: deflate
public ZLibStatus deflate(FlushType flush)
{
if (dstate == null)
{
return ZLibStatus.Z_STREAM_ERROR;
}
return dstate.deflate(this, flush);
}
开发者ID:eried,项目名称:RPiCustomizer,代码行数:8,代码来源:ZStream.cs
示例4: ZlibBaseStream
public ZlibBaseStream(Stream stream, ZlibStreamFlavor flavor, bool leaveOpen)
{
this._flushMode = FlushType.None;
this._stream = stream;
this._leaveOpen = leaveOpen;
this._flavor = flavor;
if (flavor != ZlibStreamFlavor.GZIP)
return;
this.crc = new Crc32();
}
开发者ID:liwq-net,项目名称:cocos2d-for-xna-windows,代码行数:10,代码来源:ZlibBaseStream.cs
示例5: ZlibBaseStream
public ZlibBaseStream( Stream stream,
CompressionMode compressionMode,
CompressionLevel level,
bool leaveOpen)
: base()
{
this.flushMode = FlushType.None;
this.stream = stream;
this.leaveOpen = leaveOpen;
this.compressionMode = compressionMode;
this.level = level;
}
开发者ID:Daramkun,项目名称:ProjectLiqueur,代码行数:12,代码来源:ZlibBaseStream.cs
示例6: ZlibBaseStream
public ZlibBaseStream(System.IO.Stream stream, ZlibStreamFlavor flavor, bool leaveOpen)
: base()
{
this._flushMode = FlushType.None;
//this._workingBuffer = new byte[WORKING_BUFFER_SIZE_DEFAULT];
this._stream = stream;
this._leaveOpen = leaveOpen;
this._flavor = flavor;
// workitem 7159
if (flavor == ZlibStreamFlavor.GZIP)
{
crc = new CRC32();
}
}
开发者ID:Kaidence,项目名称:ExchangeLINQ,代码行数:14,代码来源:ZLibStream.cs
示例7: FlushInBrowser
/// <summary>
/// Flushes the fileData into the user's browser.
/// It's designed for the ASP.NET Applications.
/// </summary>
/// <param name="fileName">name of the file</param>
/// <param name="fileData">byte array containing the file's data</param>
/// <param name="flushType">How to flush an in memory PDF file</param>
public static void FlushInBrowser(string fileName, byte[] fileData, FlushType flushType = FlushType.Attachment)
{
var fileLength = fileData.Length;
var context = getCurrentHttpContext();
var response = getCurrentResponse(context);
setNoCache(response);
setContentType(response);
addHeaders(fileName, fileLength, response, flushType);
setBufferTrue(response);
clearResponse(response);
writeToOutputStream(fileData, fileLength, response);
responseEnd(response);
}
开发者ID:VahidN,项目名称:PdfReport,代码行数:21,代码来源:SoftHttpContext.cs
示例8: ZlibBaseStream
public ZlibBaseStream(Stream stream,
CompressionMode compressionMode,
CompressionLevel level,
ZlibStreamFlavor flavor,
bool leaveOpen)
{
this._flushMode = FlushType.None;
//this._workingBuffer = new byte[WORKING_BUFFER_SIZE_DEFAULT];
this._stream = stream;
this._leaveOpen = leaveOpen;
this._compressionMode = compressionMode;
this._flavor = flavor;
this._level = level;
// workitem 7159
if (flavor == ZlibStreamFlavor.GZIP) {
this.crc = new CRC32();
}
}
开发者ID:virmitio,项目名称:coapp,代码行数:18,代码来源:ZlibBaseStream.cs
示例9: ZlibBaseStream
public ZlibBaseStream(System.IO.Stream stream,
CompressionMode compressionMode,
CompressionLevel level,
ZlibStreamFlavor flavor,
bool leaveOpen,
int windowBits)
: base()
{
this._flushMode = FlushType.None;
//this._workingBuffer = new byte[WORKING_BUFFER_SIZE_DEFAULT];
this._stream = stream;
this._leaveOpen = leaveOpen;
this._compressionMode = compressionMode;
this._flavor = flavor;
this._level = level;
this.windowBitsMax = windowBits;
// workitem 7159
if (flavor == ZlibStreamFlavor.GZIP)
{
this.crc = new BestHTTP.Decompression.Crc.CRC32();
}
}
开发者ID:JohnMalmsteen,项目名称:mobile-apps-tower-defense,代码行数:22,代码来源:ZlibBaseStream.cs
示例10: Inflate
/// <summary>
/// Inflate the data in the InputBuffer, placing the result in the OutputBuffer.
/// </summary>
/// <remarks>
/// You must have set InputBuffer and OutputBuffer, NextIn and NextOut, and AvailableBytesIn and
/// AvailableBytesOut before calling this method.
/// </remarks>
/// <example>
/// <code>
/// private void InflateBuffer()
/// {
/// int bufferSize = 1024;
/// byte[] buffer = new byte[bufferSize];
/// ZlibCodec decompressor = new ZlibCodec();
///
/// Console.WriteLine("\n============================================");
/// Console.WriteLine("Size of Buffer to Inflate: {0} bytes.", CompressedBytes.Length);
/// MemoryStream ms = new MemoryStream(DecompressedBytes);
///
/// int rc = decompressor.InitializeInflate();
///
/// decompressor.InputBuffer = CompressedBytes;
/// decompressor.NextIn = 0;
/// decompressor.AvailableBytesIn = CompressedBytes.Length;
///
/// decompressor.OutputBuffer = buffer;
///
/// // pass 1: inflate
/// do
/// {
/// decompressor.NextOut = 0;
/// decompressor.AvailableBytesOut = buffer.Length;
/// rc = decompressor.Inflate(FlushType.None);
///
/// if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
/// throw new Exception("inflating: " + decompressor.Message);
///
/// ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut);
/// }
/// while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0);
///
/// // pass 2: finish and flush
/// do
/// {
/// decompressor.NextOut = 0;
/// decompressor.AvailableBytesOut = buffer.Length;
/// rc = decompressor.Inflate(FlushType.Finish);
///
/// if (rc != ZlibConstants.Z_STREAM_END && rc != ZlibConstants.Z_OK)
/// throw new Exception("inflating: " + decompressor.Message);
///
/// if (buffer.Length - decompressor.AvailableBytesOut > 0)
/// ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut);
/// }
/// while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0);
///
/// decompressor.EndInflate();
/// }
///
/// </code>
/// </example>
/// <param name="flush">The flush to use when inflating.</param>
/// <returns>Z_OK if everything goes well.</returns>
internal int Inflate(FlushType flush)
{
if (istate == null)
throw new ZlibException("No Inflate State!");
return istate.Inflate(flush);
}
开发者ID:Cardanis,项目名称:MonoGame,代码行数:69,代码来源:ZlibStream.cs
示例11: deflate
public ZLibStatus deflate(byte[] bufer, int offset, int count, byte[] p1, int p2, int p3, FlushType flushType)
{
throw new NotImplementedException();
}
开发者ID:imbavirus,项目名称:TrinityCoreAdmin,代码行数:4,代码来源:Inflate.cs
示例12: inflate
public ZLibStatus inflate(FlushType ff)
{
ZLibStatus r;
int b;
if (base.next_in == null)
return ZLibStatus.Z_STREAM_ERROR;
var f = ff == FlushType.Z_FINISH ? ZLibStatus.Z_BUF_ERROR : ZLibStatus.Z_OK;
r = ZLibStatus.Z_BUF_ERROR;
while (true)
{
//System.out.println("mode: "+this.mode);
switch (this._mode)
{
case InflateMode.METHOD:
if (base.avail_in == 0) return r; r = f;
base.avail_in--; base.total_in++;
if (((this.method = base.next_in[base.next_in_index++]) & 0xf) != Z_DEFLATED)
{
this._mode = InflateMode.BAD;
base.msg = "unknown compression method";
this._marker = 5; // can't try inflateSync
break;
}
if ((this.method >> 4) + 8 > this._wbits)
{
this._mode = InflateMode.BAD;
base.msg = "invalid window size";
this._marker = 5; // can't try inflateSync
break;
}
this._mode = InflateMode.FLAG;
goto case InflateMode.FLAG;
case InflateMode.FLAG:
if (base.avail_in == 0) return r; r = f;
base.avail_in--; base.total_in++;
b = (base.next_in[base.next_in_index++]) & 0xff;
if ((((this.method << 8) + b) % 31) != 0)
{
this._mode = InflateMode.BAD;
base.msg = "incorrect header check";
this._marker = 5; // can't try inflateSync
break;
}
if ((b & PRESET_DICT) == 0)
{
this._mode = InflateMode.BLOCKS;
break;
}
this._mode = InflateMode.DICT4;
goto case InflateMode.DICT4;
case InflateMode.DICT4:
if (base.avail_in == 0) return r; r = f;
base.avail_in--; base.total_in++;
this._need = ((base.next_in[base.next_in_index++] & 0xff) << 24) & 0xff000000L;
this._mode = InflateMode.DICT3;
goto case InflateMode.DICT3;
case InflateMode.DICT3:
if (base.avail_in == 0) return r; r = f;
base.avail_in--; base.total_in++;
this._need += ((base.next_in[base.next_in_index++] & 0xff) << 16) & 0xff0000L;
this._mode = InflateMode.DICT2;
goto case InflateMode.DICT2;
case InflateMode.DICT2:
if (base.avail_in == 0) return r; r = f;
base.avail_in--; base.total_in++;
this._need += ((base.next_in[base.next_in_index++] & 0xff) << 8) & 0xff00L;
this._mode = InflateMode.DICT1;
goto case InflateMode.DICT1;
case InflateMode.DICT1:
if (base.avail_in == 0) return r; r = f;
base.avail_in--; base.total_in++;
this._need += (base.next_in[base.next_in_index++] & 0xffL);
base.adler = this._need;
this._mode = InflateMode.DICT0;
return ZLibStatus.Z_NEED_DICT;
case InflateMode.DICT0:
this._mode = InflateMode.BAD;
base.msg = "need dictionary";
this._marker = 0; // can try inflateSync
return ZLibStatus.Z_STREAM_ERROR;
case InflateMode.BLOCKS:
r = this._blocks.proc(this, r);
if (r == ZLibStatus.Z_DATA_ERROR)
{
//.........这里部分代码省略.........
开发者ID:imbavirus,项目名称:TrinityCoreAdmin,代码行数:101,代码来源:Inflate.cs
示例13: Deflate
internal int Deflate(FlushType flush)
{
int old_flush;
if (_codec.OutputBuffer == null ||
(_codec.InputBuffer == null && _codec.AvailableBytesIn != 0) ||
(status == FINISH_STATE && flush != FlushType.Finish))
{
_codec.Message = _ErrorMessage[ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_STREAM_ERROR)];
throw new ZlibException(String.Format("Something is fishy. [{0}]", _codec.Message));
}
if (_codec.AvailableBytesOut == 0)
{
_codec.Message = _ErrorMessage[ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_BUF_ERROR)];
throw new ZlibException("OutputBuffer is full (AvailableBytesOut == 0)");
}
old_flush = last_flush;
last_flush = (int)flush;
// Write the zlib (rfc1950) header bytes
if (status == INIT_STATE)
{
int header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8;
int level_flags = (((int)compressionLevel - 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);
unchecked
{
pending[pendingCount++] = (byte)(header >> 8);
pending[pendingCount++] = (byte)header;
}
// Save the adler32 of the preset dictionary:
if (strstart != 0)
{
pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF000000) >> 24);
pending[pendingCount++] = (byte)((_codec._Adler32 & 0x00FF0000) >> 16);
pending[pendingCount++] = (byte)((_codec._Adler32 & 0x0000FF00) >> 8);
pending[pendingCount++] = (byte)(_codec._Adler32 & 0x000000FF);
}
_codec._Adler32 = Adler.Adler32(0, null, 0, 0);
}
// Flush as much pending output as possible
if (pendingCount != 0)
{
_codec.flush_pending();
if (_codec.AvailableBytesOut == 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 ZlibConstants.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 (_codec.AvailableBytesIn == 0 &&
(int)flush <= old_flush &&
flush != FlushType.Finish)
{
// workitem 8557
//
// Not sure why this needs to be an error. pendingCount == 0, which
// means there's nothing to deflate. And the caller has not asked
// for a FlushType.Finish, but... that seems very non-fatal. We
// can just say "OK" and do nothing.
// _codec.Message = z_errmsg[ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_BUF_ERROR)];
// throw new ZlibException("AvailableBytesIn == 0 && flush<=old_flush && flush != FlushType.Finish");
return ZlibConstants.Z_OK;
}
// User must not provide more input after the first FINISH:
if (status == FINISH_STATE && _codec.AvailableBytesIn != 0)
{
_codec.Message = _ErrorMessage[ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_BUF_ERROR)];
throw new ZlibException("status == FINISH_STATE && _codec.AvailableBytesIn != 0");
}
// Start a new block or continue the current one.
if (_codec.AvailableBytesIn != 0 || lookahead != 0 || (flush != FlushType.None && status != FINISH_STATE))
{
BlockState bstate = DeflateFunction(flush);
//.........这里部分代码省略.........
开发者ID:JohnMalmsteen,项目名称:mobile-apps-tower-defense,代码行数:101,代码来源:Deflate.cs
示例14: deflate_stored
// Copy without compression as much as possible from the input stream, return
// the current block state.
// This function does not insert new strings in the dictionary since
// uncompressible data is probably not useful. This function is used
// only for the level=0 compression option.
// NOTE: this function should be optimized to avoid extra copying from
// window to pending_buf.
private int deflate_stored(FlushType flush)
{
// Stored blocks are limited to 0xffff bytes, pending_buf is limited
// to pending_buf_size, and each stored block has a 5 byte header:
int max_block_size = 0xffff;
int max_start;
if (max_block_size > _pendingBufferSize - 5)
{
max_block_size = _pendingBufferSize - 5;
}
// Copy as much as possible from input to output:
while (true)
{
// Fill the window as much as possible:
if (_validBytesAhead <= 1)
{
fill_window();
if (_validBytesAhead == 0 && flush == FlushType.Z_NO_FLUSH) return NeedMore;
if (_validBytesAhead == 0) break; // flush the current block
}
_startInsertString += _validBytesAhead;
_validBytesAhead = 0;
// Emit a stored block if pending_buf will be full:
max_start = _blockStart + max_block_size;
if (_startInsertString == 0 || _startInsertString >= max_start)
{
// strstart == 0 is possible when wraparound on 16-bit machine
_validBytesAhead = (int)(_startInsertString - max_start);
_startInsertString = (int)max_start;
flush_block_only(false);
if (base.avail_out == 0) return NeedMore;
}
// Flush if we may have to slide, otherwise block_start may become
// negative and the data will be gone:
if (_startInsertString - _blockStart >= _windowSize - MIN_LOOKAHEAD)
{
flush_block_only(false);
if (base.avail_out == 0) return NeedMore;
}
}
flush_block_only(flush == FlushType.Z_FINISH);
if (base.avail_out == 0)
return (flush == FlushType.Z_FINISH) ? FinishStarted : NeedMore;
return flush == FlushType.Z_FINISH ? FinishDone : BlockDone;
}
开发者ID:imbavirus,项目名称:TrinityCoreAdmin,代码行数:62,代码来源:Deflate.cs
示例15: Inflate
///<summary>
/// Inflate the data in the InputBuffer, placing the result in the OutputBuffer.
///</summary>
///<remarks>
/// You must have set InputBuffer and OutputBuffer, NextIn and NextOut, and AvailableBytesIn and AvailableBytesOut before calling this method.
///</remarks>
///<example>
/// <code>private void InflateBuffer()
/// {
/// int bufferSize = 1024;
/// byte[] buffer = new byte[bufferSize];
/// ZlibCodec decompressor = new ZlibCodec();
///
/// Console.WriteLine("\n============================================");
/// Console.WriteLine("Size of Buffer to Inflate: {0} bytes.", CompressedBytes.Length);
/// MemoryStream ms = new MemoryStream(DecompressedBytes);
///
/// int rc = decompressor.InitializeInflate();
///
/// decompressor.InputBuffer = CompressedBytes;
/// decompressor.NextIn = 0;
/// decompressor.AvailableBytesIn = CompressedBytes.Length;
///
/// decompressor.OutputBuffer = buffer;
///
/// // pass 1: inflate
/// do
/// {
/// decompressor.NextOut = 0;
/// decompressor.AvailableBytesOut = buffer.Length;
/// rc = decompressor.Inflate(FlushType.None);
///
/// if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
/// throw new Exception("inflating: " + decompressor.Message);
///
/// ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut);
/// }
/// while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0);
///
/// // pass 2: finish and flush
/// do
/// {
/// decompressor.NextOut = 0;
/// decompressor.AvailableBytesOut = buffer.Length;
/// rc = decompressor.Inflate(FlushType.Finish);
///
/// if (rc != ZlibConstants.Z_STREAM_END && rc != ZlibConstants.Z_OK)
/// throw new Exception("inflating: " + decompressor.Message);
///
/// if (buffer.Length - decompressor.AvailableBytesOut > 0)
/// ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut);
/// }
/// while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0);
///
/// decompressor.EndInflate();
/// }</code>
///</example>
///<param name="flush"> The flush to use when inflating. </param>
///<returns> Z_OK if everything goes well. </returns>
public int Inflate(FlushType flush) {
if (istate == null) {
throw new ZlibException("No Inflate State!");
}
return istate.Inflate(flush);
}
开发者ID:virmitio,项目名称:coapp,代码行数:65,代码来源:ZlibCodec.cs
示例16: DeflateFast
// Compress as much as possible from the input stream, return the current
// block state.
// This function does not perform lazy evaluation of matches and inserts
// new strings in the dictionary only for unmatched strings or for short
// matches. It is used only for the fast compression options.
internal BlockState DeflateFast(FlushType flush)
{
// short hash_head = 0; // head of the hash chain
int hash_head = 0; // head of the hash chain
bool bflush; // set if current block must be flushed
while (true)
{
// Make sure that we always have enough lookahead, except
// at the end of the input file. We need MAX_MATCH bytes
// for the next match, plus MIN_MATCH bytes to insert the
// string following the next match.
if (lookahead < MIN_LOOKAHEAD)
{
_fillWindow();
if (lookahead < MIN_LOOKAHEAD && flush == FlushType.None)
{
return BlockState.NeedMore;
}
if (lookahead == 0)
break; // flush the current block
}
// Insert the string window[strstart .. strstart+2] in the
// dictionary, and set hash_head to the head of the hash chain:
if (lookahead >= MIN_MATCH)
{
ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;
// prev[strstart&w_mask]=hash_head=head[ins_h];
hash_head = (head[ins_h] & 0xffff);
prev[strstart & w_mask] = head[ins_h];
head[ins_h] = unchecked((short)strstart);
}
// Find the longest match, discarding those <= prev_length.
// At this point we have always match_length < MIN_MATCH
if (hash_head != 0L && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD)
{
// To simplify the code, we prevent matches with the string
// of window index 0 (in particular we have to avoid a match
// of the string with itself at the start of the input file).
if (compressionStrategy != CompressionStrategy.HuffmanOnly)
{
match_length = longest_match(hash_head);
}
// longest_match() sets match_start
}
if (match_length >= MIN_MATCH)
{
// check_match(strstart, match_start, match_length);
bflush = _tr_tally(strstart - match_start, match_length - MIN_MATCH);
lookahead -= match_length;
// Insert new strings in the hash table only if the match length
// is not too large. This saves time but degrades compression.
if (match_length <= config.MaxLazy && lookahead >= MIN_MATCH)
{
match_length--; // string at strstart already in hash table
do
{
strstart++;
ins_h = ((ins_h << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;
// prev[strstart&w_mask]=hash_head=head[ins_h];
hash_head = (head[ins_h] & 0xffff);
prev[strstart & w_mask] = head[ins_h];
head[ins_h] = unchecked((short)strstart);
// strstart never exceeds WSIZE-MAX_MATCH, so there are
// always MIN_MATCH bytes ahead.
}
while (--match_length != 0);
strstart++;
}
else
{
strstart += match_length;
match_length = 0;
ins_h = window[strstart] & 0xff;
ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask;
// If lookahead < MIN_MATCH, ins_h is garbage, but it does not
// matter since it will be recomputed at next deflate call.
}
}
else
{
// No match, output a literal byte
bflush = _tr_tally(0, window[strstart] & 0xff);
lookahead--;
//.........这里部分代码省略.........
开发者ID:JohnMalmsteen,项目名称:mobile-apps-tower-defense,代码行数:101,代码来源:Deflate.cs
示例17: deflateReset
private ZLibStatus deflateReset()
{
base.total_in = base.total_out = 0;
base.msg = null; //
base.data_type = BlockType.Z_UNKNOWN;
pending = 0;
pending_out = 0;
if (noheader < 0)
{
noheader = 0; // was set to -1 by deflate(..., FlushType.Z_FINISH);
}
_status = (noheader != 0) ? BUSY_STATE : INIT_STATE;
base.adler = Adler32.adler32(0, null, 0, 0);
last_flush = FlushType.Z_NO_FLUSH;
tr_init();
lm_init();
return ZLibStatus.Z_OK;
}
开发者ID:imbavirus,项目名称:TrinityCoreAdmin,代码行数:22,代码来源:Deflate.cs
示例18: inflate
public ZLibStatus inflate(byte[] outputBuffer, int outputOffset, int outputCount, FlushType flushType)
{
throw new NotImplementedException();
}
开发者ID:imbavirus,项目名称:TrinityCoreAdmin,代码行数:4,代码来源:Deflate.cs
示例19: deflate
public ZLibStatus deflate(FlushType flush)
{
FlushType old_flush;
if (flush > FlushType.Z_FINISH || flush < 0)
{
return ZLibStatus.Z_STREAM_ERROR;
}
if (base.next_out == null ||
(base.next_in == null && base.avail_in != 0) ||
(_status == FINISH_STATE && flush != FlushType.Z_FINISH))
{
base.msg = z_errmsg[ZLibStatus.Z_NEED_DICT - (ZLibStatus.Z_STREAM_ERROR)];
return ZLibStatus.Z_STREAM_ERROR;
}
if (base.avail_out == 0)
{
base.msg = z_errmsg[ZLibStatus.Z_NEED_DICT - (ZLibStatus.Z_BUF_ERROR)];
return ZLibStatus.Z_BUF_ERROR;
}
old_flush = last_flush;
last_flush = flush;
// Write the zlib header
if (_status == INIT_STATE)
{
int header = (Z_DEFLATED + ((this._windowBits - 8) << 4)) << 8;
int level_flags = (((int)this.level - 1) & 0xff) >> 1;
if (level_flags > 3) level_flags = 3;
header |= (level_flags << 6);
if (this._startInsertString != 0) header |= PRESET_DICT;
header += 31 - (header % 31);
_status = BUSY_STATE;
putShortMSB(header);
// Save the adler32 of the preset dictionary:
if (this._startInsertString != 0)
{
putShortMSB((int)(base.adler >> 16));
putShortMSB((int)(base.adler & 0xffff));
}
base.adler = Adler32.adler32(0, null, 0, 0);
}
// Flush as much pending output as possible
if (pending != 0)
{
this.flush_pending();
if (base.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 = (FlushType)(-1);
return ZLibStatus.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 (base.avail_in == 0 && flush <= old_flush &&
flush != FlushType.Z_FINISH)
{
base.msg = z_errmsg[ZLibStatus.Z_NEED_DICT - (ZLibStatus.Z_BUF_ERROR)];
return ZLibStatus.Z_BUF_ERROR;
}
// User must not provide more input after the first FINISH:
if (_status == FINISH_STATE && base.avail_in != 0)
{
base.msg = z_errmsg[ZLibStatus.Z_NEED_DICT - (ZLibStatus.Z_BUF_ERROR)];
return ZLibStatus.Z_BUF_ERROR;
}
// Start a new block or continue the current one.
if (base.avail_in != 0 || this._validBytesAhead != 0 ||
(flush != FlushType.Z_NO_FLUSH && _status != FINISH_STATE))
{
int bstate = -1;
switch (config_table[level].Function)
{
case DefalteFlavor.STORED:
bstate = deflate_stored(flush);
break;
case DefalteFlavor.FAST:
bstate = deflate_fast(flush);
break;
case DefalteFlavor.SLOW:
bstate = deflate_slow(flush);
break;
default:
//.........这里部分代码省略.........
开发者ID:imbavirus,项目名称:TrinityCoreAdmin,代码行数:101,代码来源:Deflate.cs
示例20: deflate_slow
// Same as above, but achieves better compression. We use a lazy
// evaluation for matches: a match is finally adopted only if there is
// no better match at the next window position.
private int deflate_slow(FlushType flush)
{
// short hash_head = 0; // head of hash chain
int hash_head = 0; // head of hash chain
bool bflush; // set if current block must be flushed
// Process the input block.
while (true)
{
// Make sure that we always have enough lookahead, except
// at the end of the input file. We need MAX_MATCH bytes
// for the next match, plus MIN_MATCH bytes to insert the
// string following the next match.
if (_validBytesAhead < MIN_LOOKAHEAD)
{
fill_window();
if (_validBytesAhead < MIN_LOOKAHEAD && flush == FlushType.Z_NO_FLUSH)
{
return NeedMore;
}
if (_validBytesAhead == 0) break; // flush the current block
}
// Insert the string window[strstart .. strstart+2] in the
// dictionary, and set hash_head to the head of the hash chain:
if (_validBytesAhead >= MIN_MATCH)
{
_insertedHashIndex = (((_insertedHashIndex) << _hashShift) ^ (_window[(_startInsertString) + (MIN_MATCH - 1)] & 0xff)) & _hashMask;
// prev[strstart&w_mask]=hash_head=head[ins_h];
hash_head = (_head[_insertedHashIndex] & 0xffff);
_previous[_startInsertString & _windowMask] = _head[_insertedHashIndex];
_head[_insertedHashIndex] = (short)_startInsertString;
}
// Find the longest match, discarding those <= prev_length.
_previousLength = _matchLength; _previousMatch = _startMatchString;
_matchLength = MIN_MATCH - 1;
if (hash_head != 0 && _previousLength < _maxLazyMatch &&
((_startInsertString - hash_head) & 0xffff) <= _windowSize - MIN_LOOKAHEAD
)
{
// To simplify the code, we prevent matches with the string
// of window index 0 (in particular we have to avoid a match
// of the string with itself at the start of the input file).
if (strategy != CompressionStrategy.Z_HUFFMAN_ONLY)
{
_matchLength = longest_match(hash_head);
}
// longest_match() sets match_start
if (_matchLength <= 5 && (strategy == CompressionStrategy.Z_FILTERED ||
(_matchLength == MIN_MATCH &&
_startInsertString - _startMatchString > 4096)))
{
// If prev_match is also MIN_MATCH, match_start is garbage
// but we will ignore the current match anyway.
_matchLength = MIN_MATCH - 1;
}
}
// If there was a match at the previous step and the current
// match is not better, output the previous match:
if (_previousLength >= MIN_MATCH && _matchLength <= _previousLength)
{
int max_insert = _startInsertString + _validBytesAhead - MIN_MATCH;
// Do not insert strings in hash table beyond this.
// check_match(strstart-1, prev_match, prev_length);
bflush = _tr_tally(_startInsertString - 1 - _previousMatch, _previousLength - MIN_MATCH);
// Insert in hash table all strings up to the end of the match.
// strstart-1 and strstart are already inserted. If there is not
// enough lookahead, the last two strings are not inserted in
// the hash table.
_validBytesAhead -= _previousLength - 1;
_previousLength -= 2;
do
{
if (++_startInsertString <= max_insert)
{
_insertedHashIndex = (((_insertedHashIndex) << _hashShift) ^ (_window[(_startInsertString) + (MIN_MATCH - 1)] & 0xff)) & _hashMask;
//prev[strstart&w_mask]=hash_head=head[ins_h];
hash_head
|
请发表评论