// Token: 0x060019AF RID: 6575 RVA: 0x000CAF5C File Offset: 0x000C915C private bool FlushCodes(int flags) { this.writeBuffer[this.writeCurrent++] = (byte)flags; this.codesCurrent = 0; this.flushCodes = true; this.crc = CRC32.ComputeCRC(this.crc, (uint)flags); return(this.FlushCodes()); }
private void SlowLoop() { this.expectedCount += this.readCurrent - this.readStart; while (this.readCurrent != this.readEnd && this.writeCurrent != this.writeEnd) { if (this.numFlags == 0) { this.flags = (int)this.readBuffer[this.readCurrent++]; this.crc = CRC32.ComputeCRC(this.crc, (uint)this.flags); this.numFlags = 8; } if (this.readCurrent != this.readEnd) { if ((this.flags & 1) != 0) { if (this.readEnd - this.readCurrent < 2) { this.match = (int)this.readBuffer[this.readCurrent++]; this.crc = CRC32.ComputeCRC(this.crc, (uint)this.match); this.pointerRead = 1; break; } this.match = (int)this.readBuffer[this.readCurrent++]; this.crc = CRC32.ComputeCRC(this.crc, (uint)this.match); int num = (int)this.readBuffer[this.readCurrent++]; this.crc = CRC32.ComputeCRC(this.crc, (uint)num); this.match = (this.match << 8 | num); this.matchLength = (this.match & 15) + 2; this.match >>= 4; if (this.match == (this.windowCurrent & 4095)) { this.pointerRead = 2; break; } if (!this.ExpandMatchWithOverflow()) { this.pointerRead = 2; break; } } else { int num = (int)this.readBuffer[this.readCurrent++]; this.crc = CRC32.ComputeCRC(this.crc, (uint)num); this.AddRawByte(num); } this.numFlags--; this.flags >>= 1; } } this.expectedCount -= this.readCurrent - this.readStart; }
// Token: 0x060019B0 RID: 6576 RVA: 0x000CAFAC File Offset: 0x000C91AC private bool FlushCodes() { while (this.writeCurrent != this.writeEnd) { byte b = this.codes[this.codesCurrent++]; this.writeBuffer[this.writeCurrent++] = b; this.crc = CRC32.ComputeCRC(this.crc, (uint)b); if (this.codesCurrent == this.codesEnd) { this.flushCodes = false; this.codesEnd = 0; return(true); } } return(false); }
private void FastLoop() { int num = this.numFlags; int num2 = this.flags; int readCurrent = this.readCurrent; byte[] readBuffer = this.readBuffer; uint seed = this.crc; this.readEnd -= 3; this.writeEnd -= 17; this.expectedCount += readCurrent - this.readStart; int num3; int num5; for (;;) { if (num == 0) { num2 = (int)readBuffer[readCurrent++]; seed = CRC32.ComputeCRC(seed, (uint)num2); num = 8; } if ((num2 & 1) != 0) { num3 = (int)readBuffer[readCurrent++]; seed = CRC32.ComputeCRC(seed, (uint)num3); int num4 = (int)readBuffer[readCurrent++]; seed = CRC32.ComputeCRC(seed, (uint)num4); num3 = (num3 << 8 | num4); num5 = (num3 & 15) + 2; num3 >>= 4; if (num3 == (this.windowCurrent & 4095)) { break; } this.ExpandMatch(num3, num5); } else { int num4 = (int)readBuffer[readCurrent++]; seed = CRC32.ComputeCRC(seed, (uint)num4); this.AddRawByte(num4); } num--; num2 >>= 1; if (readCurrent > this.readEnd || this.writeCurrent > this.writeEnd) { goto IL_128; } } this.match = num3; this.matchLength = num5; this.pointerRead = 2; IL_128: this.crc = seed; this.readCurrent = readCurrent; this.readEnd += 3; this.writeEnd += 17; this.expectedCount -= this.readCurrent - this.readStart; this.numFlags = num; this.flags = num2; }
public void Run() { if (this.endOfFile) { return; } if (this.writeCurrent == this.writeEnd && !base.GetOutputSpace()) { return; } if (this.readCurrent == this.readEnd) { if (!this.inputEndOfFile && !base.ReadMoreData()) { return; } if (this.inputEndOfFile && (this.logicalEOS || this.numFlags == 0 || (this.flags & 1) == 0 || this.pointerRead < 2)) { this.endOfFile = true; if (this.pullSink != null) { this.pullSink.ReportEndOfFile(); } else { this.pushSink.Flush(); } if (!this.uncompressed && !this.logicalEOS) { throw new TextConvertersException("data truncated"); } return; } else { if (this.logicalEOS && this.readCurrent != this.readEnd) { this.readCurrent = this.readEnd; base.ReportRead(); return; } if (!this.headerRead) { byte[] readBuffer; int num2; if (this.headerBuffer != null || this.readEnd - this.readCurrent < 16) { int num = Math.Min(16 - this.headerBufferCurrent, this.readEnd - this.readCurrent); if (this.headerBuffer == null) { this.headerBuffer = new byte[16]; } Buffer.BlockCopy(this.readBuffer, this.readCurrent, this.headerBuffer, this.headerBufferCurrent, num); this.readCurrent += num; this.headerBufferCurrent += num; if (this.headerBufferCurrent != 16) { base.ReportRead(); return; } readBuffer = this.headerBuffer; num2 = 0; } else { readBuffer = this.readBuffer; num2 = this.readCurrent; this.readCurrent += 16; } uint num3 = BitConverter.ToUInt32(readBuffer, num2 + 8); this.expectedCount = BitConverter.ToInt32(readBuffer, num2) - 12; if (num3 == 1095517517U) { this.uncompressed = true; } if ((num3 != 1095517517U && num3 != 1967544908U) || this.expectedCount > 2147483647 || this.expectedCount < 0) { this.readCurrent = this.readEnd; throw new TextConvertersException("invalid compressed RTF header"); } if (this.resultFeedback != null) { this.resultFeedback.Set(ConfigParameter.RtfCompressionMode, this.uncompressed ? RtfCompressionMode.Uncompressed : RtfCompressionMode.Compressed); } this.expectedCrc = BitConverter.ToUInt32(readBuffer, num2 + 12); this.headerRead = true; } } } if (this.uncompressed) { int num4 = Math.Min(this.readEnd - this.readCurrent, this.writeEnd - this.writeCurrent); Buffer.BlockCopy(this.readBuffer, this.readCurrent, this.writeBuffer, this.writeCurrent, num4); this.readCurrent += num4; this.writeCurrent += num4; base.ReportRead(); base.FlushOutput(); return; } if (this.numFlags != 0 && (this.flags & 1) != 0 && this.pointerRead != 0) { if (this.pointerRead == 1) { int num5 = (int)this.readBuffer[this.readCurrent++]; this.crc = CRC32.ComputeCRC(this.crc, (uint)num5); this.match = (this.match << 8 | num5); this.matchLength = (this.match & 15) + 2; this.match >>= 4; this.pointerRead++; this.expectedCount--; } if (this.match == (this.windowCurrent & 4095)) { while (this.expectedCount > 0 && this.readCurrent != this.readEnd) { int num5 = (int)this.readBuffer[this.readCurrent++]; this.crc = CRC32.ComputeCRC(this.crc, (uint)num5); this.expectedCount--; } this.readCurrent = this.readEnd; if (this.expectedCount <= 0) { this.logicalEOS = true; if (this.crc != this.expectedCrc) { throw new TextConvertersException("CRC does not match, data corrupted"); } if (this.pullSource != null) { this.endOfFile = true; this.pullSink.ReportEndOfFile(); return; } if (this.expectedCount < 0) { throw new TextConvertersException("expected count in header is smaller than actual, data corrupted"); } } else if (this.inputEndOfFile) { this.endOfFile = true; throw new TextConvertersException("data truncated"); } } else if (this.ExpandMatchWithOverflow()) { this.numFlags--; this.flags >>= 1; this.pointerRead = 0; } } if (!this.disableFastLoop && this.readCurrent + 3 <= this.readEnd && this.writeCurrent + 17 <= this.writeEnd) { this.FastLoop(); } if (this.pointerRead == 0) { this.SlowLoop(); } base.ReportRead(); if (this.pushSink == null || this.writeCurrent + 17 > this.writeEnd || this.logicalEOS) { base.FlushOutput(); } }