本文整理汇总了C#中zlib.ZStream类的典型用法代码示例。如果您正苦于以下问题:C# ZStream类的具体用法?C# ZStream怎么用?C# ZStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZStream类属于zlib命名空间,在下文中一共展示了ZStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ZlibStream
public ZlibStream(Stream innerStream)
{
_innerStream = innerStream;
if(_innerStream.CanRead)
{
_in = new ZStream();
int ret = _in.inflateInit();
if (ret != zlibConst.Z_OK)
throw new ZStreamException("Unable to initialize inflate");
_inBuff = new byte[_buffSize];
_in.avail_in = 0;
_in.next_in = _inBuff;
_in.next_in_index = 0;
}
if(_innerStream.CanWrite)
{
_out = new ZStream();
int ret = _out.deflateInit(zlibConst.Z_DEFAULT_COMPRESSION);
if (ret != zlibConst.Z_OK)
throw new ZStreamException("Unable to initialize deflate");
_outBuff = new byte[_buffSize];
_out.next_out = _outBuff;
}
}
开发者ID:nickwhaley,项目名称:ubiety,代码行数:26,代码来源:ZlibStream.cs
示例2: inflateEnd
internal int inflateEnd(ZStream z)
{
if (blocks != null)
blocks.free(z);
blocks = null;
// ZFREE(z, z->state);
return Z_OK;
}
开发者ID:yonglehou,项目名称:Pomelo.Data.MySql,代码行数:8,代码来源:Inflate.cs
示例3: InfBlocks
internal long check; // check on output
internal InfBlocks(ZStream z, System.Object checkfn, int w)
{
hufts = new int[MANY * 3];
window = new byte[w];
end = w;
this.checkfn = checkfn;
mode = TYPE;
reset(z, null);
}
开发者ID:yonglehou,项目名称:Pomelo.Data.MySql,代码行数:11,代码来源:InfBlocks.cs
示例4: InfCodes
internal InfCodes(int bl, int bd, int[] tl, int[] td, ZStream z)
{
mode = START;
lbits = (byte) bl;
dbits = (byte) bd;
ltree = tl;
ltree_index = 0;
dtree = td;
dtree_index = 0;
}
开发者ID:yonglehou,项目名称:Pomelo.Data.MySql,代码行数:10,代码来源:InfCodes.cs
示例5: InfCodes
internal InfCodes(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, ZStream z)
{
this.mode = 0;
this.lbits = (byte) bl;
this.dbits = (byte) bd;
this.ltree = tl;
this.ltree_index = tl_index;
this.dtree = td;
this.dtree_index = td_index;
}
开发者ID:justwee,项目名称:WPF-Projects,代码行数:10,代码来源:InfCodes.cs
示例6: inflateReset
internal InfBlocks blocks; // current inflate_blocks state
internal int inflateReset(ZStream z)
{
if (z == null || z.istate == null)
return Z_STREAM_ERROR;
z.total_in = z.total_out = 0;
z.msg = null;
z.istate.mode = z.istate.nowrap != 0?BLOCKS:METHOD;
z.istate.blocks.reset(z, null);
return Z_OK;
}
开发者ID:yonglehou,项目名称:Pomelo.Data.MySql,代码行数:13,代码来源:Inflate.cs
示例7: InfBlocks
internal InfBlocks(ZStream z, object checkfn, int w)
{
this.bb = new int[1];
this.tb = new int[1];
this.hufts = new int[0x10e0];
this.window = new byte[w];
this.end = w;
this.checkfn = checkfn;
this.mode = 0;
this.reset(z, null);
}
开发者ID:justwee,项目名称:WPF-Projects,代码行数:11,代码来源:InfBlocks.cs
示例8: inflate_flush
internal int inflate_flush(ZStream z, int r)
{
int num2 = z.next_out_index;
int num3 = this.read;
int num1 = ((num3 <= this.write) ? this.write : this.end) - num3;
if (num1 > z.avail_out)
{
num1 = z.avail_out;
}
if ((num1 != 0) && (r == -5))
{
r = 0;
}
z.avail_out -= num1;
z.total_out += num1;
if (this.checkfn != null)
{
z.adler = this.check = z._adler.adler32(this.check, this.window, num3, num1);
}
Array.Copy(this.window, num3, z.next_out, num2, num1);
num2 += num1;
num3 += num1;
if (num3 == this.end)
{
num3 = 0;
if (this.write == this.end)
{
this.write = 0;
}
num1 = this.write - num3;
if (num1 > z.avail_out)
{
num1 = z.avail_out;
}
if ((num1 != 0) && (r == -5))
{
r = 0;
}
z.avail_out -= num1;
z.total_out += num1;
if (this.checkfn != null)
{
z.adler = this.check = z._adler.adler32(this.check, this.window, num3, num1);
}
Array.Copy(this.window, num3, z.next_out, num2, num1);
num2 += num1;
num3 += num1;
}
z.next_out_index = num2;
this.read = num3;
return r;
}
开发者ID:justwee,项目名称:WPF-Projects,代码行数:52,代码来源:InfBlocks.cs
示例9: reset
internal void reset(ZStream z, long[] c)
{
if (c != null)
c[0] = check;
if (mode == BTREE || mode == DTREE)
{
blens = null;
}
if (mode == CODES)
{
codes.free(z);
}
mode = TYPE;
bitk = 0;
bitb = 0;
read = write = 0;
if (checkfn != null)
z.adler = check = z._adler.adler32(0L, null, 0, 0);
}
开发者ID:yonglehou,项目名称:Pomelo.Data.MySql,代码行数:20,代码来源:InfBlocks.cs
示例10: inflate_fast
// Called with number of bytes left to write in window at least 258
// (the maximum string length) and number of input bytes available
// at least ten. The ten bytes are six bytes for the longest length/
// distance pair plus four bytes for overloading the bit buffer.
internal int inflate_fast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InfBlocks s, ZStream z)
{
int t; // temporary pointer
int[] tp; // temporary pointer
int tp_index; // temporary pointer
int e; // extra bits or operation
int b; // bit buffer
int k; // bits in bit buffer
int p; // input data pointer
int n; // bytes available there
int q; // output window write pointer
int m; // bytes to end of window or read pointer
int ml; // mask for literal/length tree
int md; // mask for distance tree
int c; // bytes to copy
int d; // distance back to copy from
int r; // copy source pointer
// load input, output, bit values
p = z.next_in_index; n = z.avail_in; b = s.bitb; k = s.bitk;
q = s.write; m = q < s.read ? s.read - q - 1 : s.end - q;
// initialize masks
ml = inflate_mask[bl];
md = inflate_mask[bd];
// do until not enough input or output space for fast loop
do
{
// assume called with m >= 258 && n >= 10
// get literal/length code
while (k < (20))
{
// max bits for literal/length code
n--;
b |= (z.next_in[p++] & 0xff) << k; k += 8;
}
t = b & ml;
tp = tl;
tp_index = tl_index;
if ((e = tp[(tp_index + t) * 3]) == 0)
{
b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);
s.window[q++] = (byte)tp[(tp_index + t) * 3 + 2];
m--;
continue;
}
do
{
b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);
if ((e & 16) != 0)
{
e &= 15;
c = tp[(tp_index + t) * 3 + 2] + ((int)b & inflate_mask[e]);
b >>= e; k -= e;
// decode distance base of block to copy
while (k < (15))
{
// max bits for distance code
n--;
b |= (z.next_in[p++] & 0xff) << k; k += 8;
}
t = b & md;
tp = td;
tp_index = td_index;
e = tp[(tp_index + t) * 3];
do
{
b >>= (tp[(tp_index + t) * 3 + 1]); k -= (tp[(tp_index + t) * 3 + 1]);
if ((e & 16) != 0)
{
// get extra bits to add to distance base
e &= 15;
while (k < (e))
{
// get extra bits (up to 13)
n--;
b |= (z.next_in[p++] & 0xff) << k; k += 8;
}
d = tp[(tp_index + t) * 3 + 2] + (b & inflate_mask[e]);
b >>= (e); k -= (e);
// do the copy
m -= c;
if (q >= d)
{
//.........这里部分代码省略.........
开发者ID:noahvans,项目名称:mariadb-connector-net,代码行数:101,代码来源:InfCodes.cs
示例11: BufferStream
IEnumerable<WebSocketsFrame> IExtension.ApplyIncoming(NetContext context, WebSocketConnection connection, WebSocketsFrame frame)
{
if (frame.Reserved1 && !frame.IsControlFrame)
{
BufferStream tmp = null;
var payload = frame.Payload;
payload.Position = 0;
byte[] inBuffer = null, outBuffer = null;
try
{
outBuffer = context.GetBuffer();
inBuffer = context.GetBuffer();
tmp = new BufferStream(context, 0);
if (inbound == null)
{
inbound = new ZStream();
inbound.inflateInit();
// fake a zlib header with:
// CMF:
// CM = 8 (deflate)
// CINFO = 7 (32k window)
// FLG:
// FCHECK: 26 (checksum of other bits)
// FDICT: 0 (no dictionary)
// FLEVEL: 3 (maximum)
inBuffer[0] = 120;
inBuffer[1] = 218;
inbound.next_in = inBuffer;
int chk = Inflate(tmp, outBuffer, 2);
if (chk != 0) throw new InvalidOperationException("Spoofed zlib header suggested data");
}
inbound.next_in = inBuffer;
int remaining = frame.PayloadLength;
//bool first = true;
while (remaining > 0)
{
int readCount = payload.Read(inBuffer, 0, inBuffer.Length);
if (readCount <= 0) break;
remaining -= readCount;
//if (first)
//{ // kill the BFINAL flag from the first block, if set; we don't want zlib
// // trying to verify the ADLER checksum; unfortunately, a frame can contain
// // multiple blocks, and a *later* block could have BFINAL set. That sucks.
// inBuffer[0] &= 254;
// first = false;
//}
Inflate(tmp, outBuffer, readCount);
}
if (remaining != 0) throw new EndOfStreamException();
// spoof the missing 4 bytes from the tail
inBuffer[0] = inBuffer[1] = 0x00;
inBuffer[2] = inBuffer[3] = 0xFF;
Inflate(tmp, outBuffer, 4);
// set our final output
tmp.Position = 0;
frame.Payload = tmp;
long bytesSaved = tmp.Length - frame.PayloadLength;
frame.PayloadLength = (int)tmp.Length;
frame.Reserved1 = false;
tmp = payload as BufferStream;
parent.RegisterInboundBytesSaved(bytesSaved);
}
#if DEBUG
catch (Exception ex)
{
Debug.WriteLine(ex);
throw;
}
#endif
finally
{
if (inbound != null)
{
inbound.next_out = null;
inbound.next_in = null;
}
if (tmp != null) tmp.Dispose();
if (inBuffer != null) context.Recycle(inBuffer);
if (outBuffer != null) context.Recycle(outBuffer);
if (parent.disableContextTakeover) ClearContext(true, false);
}
}
yield return frame;
}
开发者ID:ReinhardHsu,项目名称:NetGain,代码行数:92,代码来源:PerFrameDeflate.cs
示例12: InvalidOperationException
IEnumerable<WebSocketsFrame> IExtension.ApplyOutgoing(NetContext context, WebSocketConnection connection, WebSocketsFrame frame)
{
if (!frame.IsControlFrame && frame.PayloadLength > parent.compressMessagesLargerThanBytes)
{
if (frame.Reserved1)
{
throw new InvalidOperationException("Reserved1 flag is already set; extension conflict?");
}
int headerBytes = 0;
if (outbound == null)
{
outbound = new ZStream();
const int BITS = 12; // 4096 byte outbound buffer (instead of full 32k=15)
outbound.deflateInit(zlibConst.Z_BEST_COMPRESSION, BITS);
headerBytes = 2;
}
BufferStream tmp = null;
var payload = frame.Payload;
payload.Position = 0;
byte[] inBuffer = null, outBuffer = null;
try
{
inBuffer = context.GetBuffer();
outBuffer = context.GetBuffer();
tmp = new BufferStream(context, 0);
outbound.next_out = outBuffer;
outbound.next_in = inBuffer;
int remaining = frame.PayloadLength;
while (remaining > 0)
{
int readCount = payload.Read(inBuffer, 0, inBuffer.Length);
if (readCount <= 0) break;
remaining -= readCount;
outbound.next_in_index = 0;
outbound.avail_in = readCount;
do
{
outbound.next_out_index = 0;
outbound.avail_out = outBuffer.Length;
long priorOut = outbound.total_out;
int err = outbound.deflate(remaining == 0 ? zlibConst.Z_SYNC_FLUSH : zlibConst.Z_NO_FLUSH);
if (err != zlibConst.Z_OK && err != zlibConst.Z_STREAM_END)
throw new ZStreamException("deflating: " + outbound.msg);
int outCount = (int)(outbound.total_out - priorOut);
if (outCount > 0)
{
if (headerBytes == 0)
{
tmp.Write(outBuffer, 0, outCount);
}
else
{
if (outCount < headerBytes)
{
throw new InvalidOperationException("Failed to write entire header");
}
// check the generated header meets our expectations
// CMF is very specific - CM must be 8, and CINFO must be <=7 (for 32k window)
if ((outBuffer[0] & 15) != 8)
{
throw new InvalidOperationException("Zlib CM header was incorrect");
}
if ((outBuffer[0] & 128) != 0) // if msb set, is > 7 - invalid
{
throw new InvalidOperationException("Zlib CINFO header was incorrect");
}
// FLG is less important; FCHECK is irrelevent, FLEVEL doesn't matter; but
// FDICT must be zero, to ensure that we aren't expecting a an initialization dictionary
if ((outBuffer[1] & 32) != 0)
{
throw new InvalidOperationException("Zlib FLG.FDICT header was set (must not be)");
}
// skip the header, and write anything else
outCount -= headerBytes;
if (outCount > 0)
{
tmp.Write(outBuffer, headerBytes, outCount);
}
headerBytes = 0; // all written now
}
}
} while (outbound.avail_in > 0 || outbound.avail_out == 0);
}
if (remaining != 0) throw new EndOfStreamException();
if (headerBytes != 0) throw new InvalidOperationException("Zlib header was not written");
// verify the last 4 bytes, then drop them
tmp.Position = tmp.Length - 4;
NetContext.Fill(tmp, outBuffer, 4);
if (!(outBuffer[0] == 0x00 && outBuffer[1] == 0x00 && outBuffer[2] == 0xFF && outBuffer[3] == 0xFF))
{
throw new InvalidOperationException("expectation failed: 0000FFFF in the tail");
//.........这里部分代码省略.........
开发者ID:ReinhardHsu,项目名称:NetGain,代码行数:101,代码来源:PerFrameDeflate.cs
示例13: inflate_trees_dynamic
internal static int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZStream z)
{
int r;
int[] hn = new int[1]; // hufts used in space
int[] v = new int[288]; // work area for huft_build
// build literal/length tree
r = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
if (r != Z_OK || bl[0] == 0)
{
if (r == Z_DATA_ERROR)
{
z.msg = "oversubscribed literal/length tree";
}
else if (r != Z_MEM_ERROR)
{
z.msg = "incomplete literal/length tree";
r = Z_DATA_ERROR;
}
return r;
}
// build distance tree
r = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);
if (r != Z_OK || (bd[0] == 0 && nl > 257))
{
if (r == Z_DATA_ERROR)
{
z.msg = "oversubscribed distance tree";
}
else if (r == Z_BUF_ERROR)
{
z.msg = "incomplete distance tree";
r = Z_DATA_ERROR;
}
else if (r != Z_MEM_ERROR)
{
z.msg = "empty distance tree with lengths";
r = Z_DATA_ERROR;
}
return r;
}
return Z_OK;
}
开发者ID:noahvans,项目名称:mariadb-connector-net,代码行数:46,代码来源:InfTree.cs
示例14: 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
示例15: deflateParams
internal int deflateParams(ZStream strm, int _level, int _strategy)
{
int err = Z_OK;
if (_level == Z_DEFAULT_COMPRESSION)
{
_level = 6;
}
if (_level < 0 || _level > 9 || _strategy < 0 || _strategy > Z_HUFFMAN_ONLY)
{
return Z_STREAM_ERROR;
}
if (config_table[level].func != config_table[_level].func && strm.total_in != 0)
{
// Flush the last buffer:
err = strm.deflate(Z_PARTIAL_FLUSH);
}
if (level != _level)
{
level = _level;
max_lazy_match = config_table[level].max_lazy;
good_match = config_table[level].good_length;
nice_match = config_table[level].nice_length;
max_chain_length = config_table[level].max_chain;
}
strategy = _strategy;
return err;
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:30,代码来源:Deflate.cs
示例16: deflateInit2
internal int deflateInit2(ZStream strm, int level, int method, int windowBits, int memLevel, int strategy)
{
int noheader = 0;
// byte[] my_version=ZLIB_VERSION;
//
// if (version == null || version[0] != my_version[0]
// || stream_size != sizeof(z_stream)) {
// return Z_VERSION_ERROR;
// }
strm.msg = null;
if (level == Z_DEFAULT_COMPRESSION)
level = 6;
if (windowBits < 0)
{
// undocumented feature: suppress zlib header
noheader = 1;
windowBits = - windowBits;
}
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY)
{
return Z_STREAM_ERROR;
}
strm.dstate = (Deflate) this;
this.noheader = noheader;
w_bits = windowBits;
w_size = 1 << w_bits;
w_mask = w_size - 1;
hash_bits = memLevel + 7;
hash_size = 1 << hash_bits;
hash_mask = hash_size - 1;
hash_shift = ((hash_bits + MIN_MATCH - 1) / MIN_MATCH);
window = new byte[w_size * 2];
prev = new short[w_size];
head = new short[hash_size];
lit_bufsize = 1 << (memLevel + 6); // 16K elements by default
// We overlay pending_buf and d_buf+l_buf. This works since the average
// output size for (length,distance) codes is <= 24 bits.
pending_buf = new byte[lit_bufsize * 4];
pending_buf_size = lit_bufsize * 4;
d_buf = lit_bufsize / 2;
l_buf = (1 + 2) * lit_bufsize;
this.level = level;
//System.out.println("level="+level);
this.strategy = strategy;
this.method = (byte) method;
return deflateReset(strm);
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:63,代码来源:Deflate.cs
示例17: deflateReset
internal int deflateReset(ZStream strm)
{
strm.total_in = strm.total_out = 0;
strm.msg = null; //
strm.data_type = Z_UNKNOWN;
pending = 0;
pending_out = 0;
if (noheader < 0)
{
noheader = 0; // was set to -1 by deflate(..., Z_FINISH);
}
status = (noheader != 0)?BUSY_STATE:INIT_STATE;
strm.adler = strm._adler.adler32(0, null, 0, 0);
last_flush = Z_NO_FLUSH;
tr_init();
lm_init();
return Z_OK;
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:22,代码来源:Deflate.cs
示例18: deflateSetDictionary
internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLength)
{
int num1 = dictLength;
int num2 = 0;
if ((dictionary == null) || (this.status != 0x2a))
{
return -2;
}
strm.adler = strm._adler.adler32(strm.adler, dictionary, 0, dictLength);
if (num1 >= 3)
{
if (num1 > (this.w_size - Deflate.MIN_LOOKAHEAD))
{
num1 = this.w_size - Deflate.MIN_LOOKAHEAD;
num2 = dictLength - num1;
}
Array.Copy(dictionary, num2, this.window, 0, num1);
this.strstart = num1;
this.block_start = num1;
this.ins_h = this.window[0] & 0xff;
this.ins_h = ((this.ins_h << (this.hash_shift & 0x1f)) ^ (this.window[1] & 0xff)) & this.hash_mask;
for (int num3 = 0; num3 <= (num1 - 3); num3++)
{
this.ins_h = ((this.ins_h << (this.hash_shift & 0x1f)) ^ (this.window[num3 + 2] & 0xff)) & this.hash_mask;
this.prev[num3 & this.w_mask] = this.head[this.ins_h];
this.head[this.ins_h] = (short) num3;
}
}
return 0;
}
开发者ID:justwee,项目名称:WPF-Projects,代码行数:30,代码来源:Deflate.cs
示例19: deflateSetDictionary
internal int deflateSetDictionary(ZStream strm, byte[] dictionary, int dictLength)
{
int length = dictLength;
int index = 0;
if (dictionary == null || status != INIT_STATE)
return Z_STREAM_ERROR;
strm.adler = strm._adler.adler32(strm.adler, dictionary, 0, dictLength);
if (length < MIN_MATCH)
return Z_OK;
if (length > w_size - MIN_LOOKAHEAD)
{
length = w_size - MIN_LOOKAHEAD;
index = dictLength - length; // use the tail of the dictionary
}
Array.Copy(dictionary, index, window, 0, length);
strstart = length;
block_start = length;
// Insert all strings in the hash table (except for the last two bytes).
// s->lookahead stays null, so s->ins_h will be recomputed at the next
// call of fill_window.
ins_h = window[0] & 0xff;
ins_h = (((ins_h) << hash_shift) ^ (window[1] & 0xff)) & hash_mask;
for (int n = 0; n <= length - MIN_MATCH; n++)
{
ins_h = (((ins_h) << hash_shift) ^ (window[(n) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;
prev[n & w_mask] = head[ins_h];
head[ins_h] = (short) n;
}
return Z_OK;
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:36,代码来源:Deflate.cs
示例20: inflate_trees_bits
internal static int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZStream z)
{
int r;
int[] hn = new int[1]; // hufts used in space
int[] v = new int[19]; // work area for huft_build
r = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);
if (r == Z_DATA_ERROR)
{
z.msg = "oversubscribed dynamic bit lengths tree";
}
else if (r == Z_BUF_ERROR || bb[0] == 0)
{
z.msg = "incomplete dynamic bit lengths tree";
r = Z_DATA_ERROR;
}
return r;
}
开发者ID:noahvans,项目名称:mariadb-connector-net,代码行数:19,代码来源:InfTree.cs
注:本文中的zlib.ZStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论