public bool ReadFooter(InputBuffer input) { input.SkipToByteBoundary(); if (gzipFooterSubstate == GzipHeaderState.ReadingCRC) { while (loopCounter < 4) { int bits = input.GetBits(8); if (bits < 0) { return(false); } expectedCrc32 |= ((uint)bits << (8 * loopCounter)); loopCounter++; } gzipFooterSubstate = GzipHeaderState.ReadingFileSize; loopCounter = 0; } if (gzipFooterSubstate == GzipHeaderState.ReadingFileSize) { if (loopCounter == 0) { expectedOutputStreamSizeModulo = 0; } while (loopCounter < 4) { int bits = input.GetBits(8); if (bits < 0) { return(false); } expectedOutputStreamSizeModulo |= ((uint)bits << (8 * loopCounter)); loopCounter++; } } return(true); }
public bool ReadFooter(InputBuffer input) { input.SkipToByteBoundary(); if (this.gzipFooterSubstate == GzipHeaderState.ReadingCRC) { while (this.loopCounter < 4) { int bits = input.GetBits(8); if (bits < 0) { return(false); } this.expectedCrc32 |= (uint)(bits << (8 * this.loopCounter)); this.loopCounter++; } this.gzipFooterSubstate = GzipHeaderState.ReadingFileSize; this.loopCounter = 0; } if (this.gzipFooterSubstate == GzipHeaderState.ReadingFileSize) { if (this.loopCounter == 0) { this.expectedOutputStreamSize = 0; } while (this.loopCounter < 4) { int num2 = input.GetBits(8); if (num2 < 0) { return(false); } this.expectedOutputStreamSize |= (uint)(num2 << (8 * this.loopCounter)); this.loopCounter++; } } return(true); }
public bool ReadFooter(InputBuffer input) { input.SkipToByteBoundary(); if (this.gzipFooterSubstate == GzipHeaderState.ReadingCRC) { while (this.loopCounter < 4) { int bits = input.GetBits(8); if (bits < 0) { return false; } this.expectedCrc32 |= (uint) (bits << (8 * this.loopCounter)); this.loopCounter++; } this.gzipFooterSubstate = GzipHeaderState.ReadingFileSize; this.loopCounter = 0; } if (this.gzipFooterSubstate == GzipHeaderState.ReadingFileSize) { if (this.loopCounter == 0) { this.expectedOutputStreamSize = 0; } while (this.loopCounter < 4) { int num2 = input.GetBits(8); if (num2 < 0) { return false; } this.expectedOutputStreamSize |= (uint) (num2 << (8 * this.loopCounter)); this.loopCounter++; } } return true; }
public bool ReadHeader(InputBuffer input) { while (true) { int bits; switch (gzipHeaderSubstate) { case GzipHeaderState.ReadingID1: bits = input.GetBits(8); if (bits < 0) { return false; } if (bits != GZipConstants.ID1) { throw new InvalidDataException(SR.GetString(SR.CorruptedGZipHeader)); } gzipHeaderSubstate = GzipHeaderState.ReadingID2; goto case GzipHeaderState.ReadingID2; case GzipHeaderState.ReadingID2: bits = input.GetBits(8); if (bits < 0) { return false; } if (bits != GZipConstants.ID2) { throw new InvalidDataException(SR.GetString(SR.CorruptedGZipHeader)); } gzipHeaderSubstate = GzipHeaderState.ReadingCM; goto case GzipHeaderState.ReadingCM; case GzipHeaderState.ReadingCM: bits = input.GetBits(8); if (bits < 0) { return false; } if (bits != GZipConstants.Deflate) { // compression mode must be 8 (deflate) throw new InvalidDataException(SR.GetString(SR.UnknownCompressionMode)); } gzipHeaderSubstate = GzipHeaderState.ReadingFLG; ; goto case GzipHeaderState.ReadingFLG; case GzipHeaderState.ReadingFLG: bits = input.GetBits(8); if (bits < 0) { return false; } gzip_header_flag = bits; gzipHeaderSubstate = GzipHeaderState.ReadingMMTime; loopCounter = 0; // 4 MMTIME bytes goto case GzipHeaderState.ReadingMMTime; case GzipHeaderState.ReadingMMTime: bits = 0; while (loopCounter < 4) { bits = input.GetBits(8); if (bits < 0) { return false; } loopCounter++; } gzipHeaderSubstate = GzipHeaderState.ReadingXFL; loopCounter = 0; goto case GzipHeaderState.ReadingXFL; case GzipHeaderState.ReadingXFL: // ignore XFL bits = input.GetBits(8); if (bits < 0) { return false; } gzipHeaderSubstate = GzipHeaderState.ReadingOS; goto case GzipHeaderState.ReadingOS; case GzipHeaderState.ReadingOS: // ignore OS bits = input.GetBits(8); if (bits < 0) { return false; } gzipHeaderSubstate = GzipHeaderState.ReadingXLen1; goto case GzipHeaderState.ReadingXLen1; case GzipHeaderState.ReadingXLen1: if ((gzip_header_flag & (int)GZipOptionalHeaderFlags.ExtraFieldsFlag) == 0) { goto case GzipHeaderState.ReadingFileName; } bits = input.GetBits(8); if (bits < 0) { return false; } gzip_header_xlen = bits; gzipHeaderSubstate = GzipHeaderState.ReadingXLen2; goto case GzipHeaderState.ReadingXLen2; case GzipHeaderState.ReadingXLen2: bits = input.GetBits(8); if (bits < 0) { return false; } gzip_header_xlen |= (bits << 8); gzipHeaderSubstate = GzipHeaderState.ReadingXLenData; loopCounter = 0; // 0 bytes of XLEN data read so far goto case GzipHeaderState.ReadingXLenData; case GzipHeaderState.ReadingXLenData: bits = 0; while (loopCounter < gzip_header_xlen) { bits = input.GetBits(8); if (bits < 0) { return false; } loopCounter++; } gzipHeaderSubstate = GzipHeaderState.ReadingFileName; loopCounter = 0; goto case GzipHeaderState.ReadingFileName; case GzipHeaderState.ReadingFileName: if ((gzip_header_flag & (int)GZipOptionalHeaderFlags.FileNameFlag) == 0) { gzipHeaderSubstate = GzipHeaderState.ReadingComment; goto case GzipHeaderState.ReadingComment; } do { bits = input.GetBits(8); if (bits < 0) { return false; } if (bits == 0) { // see '\0' in the file name string break; } } while (true); gzipHeaderSubstate = GzipHeaderState.ReadingComment; goto case GzipHeaderState.ReadingComment; case GzipHeaderState.ReadingComment: if ((gzip_header_flag & (int)GZipOptionalHeaderFlags.CommentFlag) == 0) { gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part1; goto case GzipHeaderState.ReadingCRC16Part1; } do { bits = input.GetBits(8); if (bits < 0) { return false; } if (bits == 0) { // see '\0' in the file name string break; } } while (true); gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part1; goto case GzipHeaderState.ReadingCRC16Part1; case GzipHeaderState.ReadingCRC16Part1: if ((gzip_header_flag & (int)GZipOptionalHeaderFlags.CRCFlag) == 0) { gzipHeaderSubstate = GzipHeaderState.Done; goto case GzipHeaderState.Done; } bits = input.GetBits(8); // ignore crc if (bits < 0) { return false; } gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part2; goto case GzipHeaderState.ReadingCRC16Part2; case GzipHeaderState.ReadingCRC16Part2: bits = input.GetBits(8); // ignore crc if (bits < 0) { return false; } gzipHeaderSubstate = GzipHeaderState.Done; goto case GzipHeaderState.Done; case GzipHeaderState.Done: return true; default: Debug.Assert(false, "We should not reach unknown state!"); throw new InvalidDataException(SR.GetString(SR.UnknownState)); } } }
public bool ReadFooter(InputBuffer input) { input.SkipToByteBoundary(); if (gzipFooterSubstate == GzipHeaderState.ReadingCRC) { while (loopCounter < 4) { int bits = input.GetBits(8); if (bits < 0) { return false; } expectedCrc32 |= ((uint)bits << (8 * loopCounter)); loopCounter++; } gzipFooterSubstate = GzipHeaderState.ReadingFileSize; loopCounter = 0; } if (gzipFooterSubstate == GzipHeaderState.ReadingFileSize) { if (loopCounter == 0) expectedOutputStreamSizeModulo = 0; while (loopCounter < 4) { int bits = input.GetBits(8); if (bits < 0) { return false; } expectedOutputStreamSizeModulo |= ((uint) bits << (8 * loopCounter)); loopCounter++; } } return true; }
//Each block of compressed data begins with 3 header bits // containing the following data: // first bit BFINAL // next 2 bits BTYPE // Note that the header bits do not necessarily begin on a byte // boundary, since a block does not necessarily occupy an integral // number of bytes. // BFINAL is set if and only if this is the last block of the data // set. // BTYPE specifies how the data are compressed, as follows: // 00 - no compression // 01 - compressed with fixed Huffman codes // 10 - compressed with dynamic Huffman codes // 11 - reserved (error) // The only difference between the two compressed cases is how the // Huffman codes for the literal/length and distance alphabets are // defined. // // This function returns true for success (end of block or output window is full,) // false if we are short of input // private bool Decode() { bool eob = false; bool result = false; if (Finished()) { return(true); } if (using_gzip) { if (state == InflaterState.ReadingGZIPHeader) { if (!gZipDecoder.ReadGzipHeader()) { return(false); } state = InflaterState.ReadingBFinal; } else if (state == InflaterState.StartReadingGZIPFooter || state == InflaterState.ReadingGZIPFooter) { if (!gZipDecoder.ReadGzipFooter()) { return(false); } state = InflaterState.VerifyingGZIPFooter; return(true); } } if (state == InflaterState.ReadingBFinal) // reading bfinal bit // Need 1 bit { if (!input.EnsureBitsAvailable(1)) { return(false); } bfinal = input.GetBits(1); state = InflaterState.ReadingBType; } if (state == InflaterState.ReadingBType) { // Need 2 bits if (!input.EnsureBitsAvailable(2)) { state = InflaterState.ReadingBType; return(false); } blockType = (BlockType)input.GetBits(2); if (blockType == BlockType.Dynamic) { Debug.WriteLineIf(CompressionTracingSwitch.Informational, "Decoding Dynamic Block", "Compression"); state = InflaterState.ReadingNumLitCodes; } else if (blockType == BlockType.Static) { Debug.WriteLineIf(CompressionTracingSwitch.Informational, "Decoding Static Block", "Compression"); literalLengthTree = HuffmanTree.StaticLiteralLengthTree; distanceTree = HuffmanTree.StaticDistanceTree; state = InflaterState.DecodeTop; } else if (blockType == BlockType.Uncompressed) { Debug.WriteLineIf(CompressionTracingSwitch.Informational, "Decoding UnCompressed Block", "Compression"); state = InflaterState.UncompressedAligning; } else { throw new InvalidDataException(SR.GetString(SR.UnknownBlockType)); } } if (blockType == BlockType.Dynamic) { if (state < InflaterState.DecodeTop) // we are reading the header { result = DecodeDynamicBlockHeader(); } else { result = DecodeBlock(out eob); // this can returns true when output is full } } else if (blockType == BlockType.Static) { result = DecodeBlock(out eob); } else if (blockType == BlockType.Uncompressed) { result = DecodeUncompressedBlock(out eob); } else { throw new InvalidDataException(SR.GetString(SR.UnknownBlockType)); } // // If we reached the end of the block and the block we were decoding had // bfinal=1 (final block) // if (eob && (bfinal != 0)) { if (using_gzip) { state = InflaterState.StartReadingGZIPFooter; } else { state = InflaterState.Done; } } return(result); }
//Each block of compressed data begins with 3 header bits // containing the following data: // first bit BFINAL // next 2 bits BTYPE // Note that the header bits do not necessarily begin on a byte // boundary, since a block does not necessarily occupy an integral // number of bytes. // BFINAL is set if and only if this is the last block of the data // set. // BTYPE specifies how the data are compressed, as follows: // 00 - no compression // 01 - compressed with fixed Huffman codes // 10 - compressed with dynamic Huffman codes // 11 - reserved (error) // The only difference between the two compressed cases is how the // Huffman codes for the literal/length and distance alphabets are // defined. // // This function returns true for success (end of block or output window is full,) // false if we are short of input // private bool Decode() { bool eob = false; bool result; if (Finished()) { return(true); } if (_state == InflaterState.ReadingBFinal) { // reading bfinal bit // Need 1 bit if (!_input.EnsureBitsAvailable(1)) { return(false); } _bfinal = _input.GetBits(1); _state = InflaterState.ReadingBType; } if (_state == InflaterState.ReadingBType) { // Need 2 bits if (!_input.EnsureBitsAvailable(2)) { _state = InflaterState.ReadingBType; return(false); } _blockType = (BlockType)_input.GetBits(2); if (_blockType == BlockType.Dynamic) { _state = InflaterState.ReadingNumLitCodes; } else if (_blockType == BlockType.Static) { _literalLengthTree = HuffmanTree.StaticLiteralLengthTree; _distanceTree = HuffmanTree.StaticDistanceTree; _state = InflaterState.DecodeTop; } else if (_blockType == BlockType.Uncompressed) { _state = InflaterState.UncompressedAligning; } else { throw new InvalidDataException(SR.UnknownBlockType); } } if (_blockType == BlockType.Dynamic) { if (_state < InflaterState.DecodeTop) { // we are reading the header result = DecodeDynamicBlockHeader(); } else { result = DecodeBlock(out eob); // this can returns true when output is full } } else if (_blockType == BlockType.Static) { result = DecodeBlock(out eob); } else if (_blockType == BlockType.Uncompressed) { result = DecodeUncompressedBlock(out eob); } else { throw new InvalidDataException(SR.UnknownBlockType); } // // If we reached the end of the block and the block we were decoding had // bfinal=1 (final block) // if (eob && (_bfinal != 0)) { _state = InflaterState.Done; } return(result); }
public bool ReadHeader(InputBuffer input) { while (true) { int bits; switch (gzipHeaderSubstate) { case GzipHeaderState.ReadingID1: bits = input.GetBits(8); if (bits < 0) { return(false); } if (bits != GZipConstants.ID1) { throw new InvalidDataException(SR.GetString(SR.CorruptedGZipHeader)); } gzipHeaderSubstate = GzipHeaderState.ReadingID2; goto case GzipHeaderState.ReadingID2; case GzipHeaderState.ReadingID2: bits = input.GetBits(8); if (bits < 0) { return(false); } if (bits != GZipConstants.ID2) { throw new InvalidDataException(SR.GetString(SR.CorruptedGZipHeader)); } gzipHeaderSubstate = GzipHeaderState.ReadingCM; goto case GzipHeaderState.ReadingCM; case GzipHeaderState.ReadingCM: bits = input.GetBits(8); if (bits < 0) { return(false); } if (bits != GZipConstants.Deflate) // compression mode must be 8 (deflate) { throw new InvalidDataException(SR.GetString(SR.UnknownCompressionMode)); } gzipHeaderSubstate = GzipHeaderState.ReadingFLG;; goto case GzipHeaderState.ReadingFLG; case GzipHeaderState.ReadingFLG: bits = input.GetBits(8); if (bits < 0) { return(false); } gzip_header_flag = bits; gzipHeaderSubstate = GzipHeaderState.ReadingMMTime; loopCounter = 0; // 4 MMTIME bytes goto case GzipHeaderState.ReadingMMTime; case GzipHeaderState.ReadingMMTime: bits = 0; while (loopCounter < 4) { bits = input.GetBits(8); if (bits < 0) { return(false); } loopCounter++; } gzipHeaderSubstate = GzipHeaderState.ReadingXFL; loopCounter = 0; goto case GzipHeaderState.ReadingXFL; case GzipHeaderState.ReadingXFL: // ignore XFL bits = input.GetBits(8); if (bits < 0) { return(false); } gzipHeaderSubstate = GzipHeaderState.ReadingOS; goto case GzipHeaderState.ReadingOS; case GzipHeaderState.ReadingOS: // ignore OS bits = input.GetBits(8); if (bits < 0) { return(false); } gzipHeaderSubstate = GzipHeaderState.ReadingXLen1; goto case GzipHeaderState.ReadingXLen1; case GzipHeaderState.ReadingXLen1: if ((gzip_header_flag & (int)GZipOptionalHeaderFlags.ExtraFieldsFlag) == 0) { goto case GzipHeaderState.ReadingFileName; } bits = input.GetBits(8); if (bits < 0) { return(false); } gzip_header_xlen = bits; gzipHeaderSubstate = GzipHeaderState.ReadingXLen2; goto case GzipHeaderState.ReadingXLen2; case GzipHeaderState.ReadingXLen2: bits = input.GetBits(8); if (bits < 0) { return(false); } gzip_header_xlen |= (bits << 8); gzipHeaderSubstate = GzipHeaderState.ReadingXLenData; loopCounter = 0; // 0 bytes of XLEN data read so far goto case GzipHeaderState.ReadingXLenData; case GzipHeaderState.ReadingXLenData: bits = 0; while (loopCounter < gzip_header_xlen) { bits = input.GetBits(8); if (bits < 0) { return(false); } loopCounter++; } gzipHeaderSubstate = GzipHeaderState.ReadingFileName; loopCounter = 0; goto case GzipHeaderState.ReadingFileName; case GzipHeaderState.ReadingFileName: if ((gzip_header_flag & (int)GZipOptionalHeaderFlags.FileNameFlag) == 0) { gzipHeaderSubstate = GzipHeaderState.ReadingComment; goto case GzipHeaderState.ReadingComment; } do { bits = input.GetBits(8); if (bits < 0) { return(false); } if (bits == 0) // see '\0' in the file name string { break; } } while (true); gzipHeaderSubstate = GzipHeaderState.ReadingComment; goto case GzipHeaderState.ReadingComment; case GzipHeaderState.ReadingComment: if ((gzip_header_flag & (int)GZipOptionalHeaderFlags.CommentFlag) == 0) { gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part1; goto case GzipHeaderState.ReadingCRC16Part1; } do { bits = input.GetBits(8); if (bits < 0) { return(false); } if (bits == 0) // see '\0' in the file name string { break; } } while (true); gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part1; goto case GzipHeaderState.ReadingCRC16Part1; case GzipHeaderState.ReadingCRC16Part1: if ((gzip_header_flag & (int)GZipOptionalHeaderFlags.CRCFlag) == 0) { gzipHeaderSubstate = GzipHeaderState.Done; goto case GzipHeaderState.Done; } bits = input.GetBits(8); // ignore crc if (bits < 0) { return(false); } gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part2; goto case GzipHeaderState.ReadingCRC16Part2; case GzipHeaderState.ReadingCRC16Part2: bits = input.GetBits(8); // ignore crc if (bits < 0) { return(false); } gzipHeaderSubstate = GzipHeaderState.Done; goto case GzipHeaderState.Done; case GzipHeaderState.Done: return(true); default: Debug.Assert(false, "We should not reach unknown state!"); throw new InvalidDataException(SR.GetString(SR.UnknownState)); } } }
public bool ReadHeader(InputBuffer input) { int bits; switch (this.gzipHeaderSubstate) { case GzipHeaderState.ReadingID1: bits = input.GetBits(8); if (bits >= 0) { if (bits != 0x1f) { throw new InvalidDataException(SR.GetString("CorruptedGZipHeader")); } this.gzipHeaderSubstate = GzipHeaderState.ReadingID2; break; } return(false); case GzipHeaderState.ReadingID2: break; case GzipHeaderState.ReadingCM: goto Label_00A5; case GzipHeaderState.ReadingFLG: goto Label_00CE; case GzipHeaderState.ReadingMMTime: goto Label_00F1; case GzipHeaderState.ReadingXFL: goto Label_0128; case GzipHeaderState.ReadingOS: goto Label_013D; case GzipHeaderState.ReadingXLen1: goto Label_0152; case GzipHeaderState.ReadingXLen2: goto Label_017B; case GzipHeaderState.ReadingXLenData: goto Label_01A8; case GzipHeaderState.ReadingFileName: goto Label_01E5; case GzipHeaderState.ReadingComment: goto Label_0212; case GzipHeaderState.ReadingCRC16Part1: goto Label_0240; case GzipHeaderState.ReadingCRC16Part2: goto Label_026A; case GzipHeaderState.Done: goto Label_0280; default: throw new InvalidDataException(SR.GetString("UnknownState")); } bits = input.GetBits(8); if (bits < 0) { return(false); } if (bits != 0x8b) { throw new InvalidDataException(SR.GetString("CorruptedGZipHeader")); } this.gzipHeaderSubstate = GzipHeaderState.ReadingCM; Label_00A5: bits = input.GetBits(8); if (bits < 0) { return(false); } if (bits != 8) { throw new InvalidDataException(SR.GetString("UnknownCompressionMode")); } this.gzipHeaderSubstate = GzipHeaderState.ReadingFLG; Label_00CE: bits = input.GetBits(8); if (bits < 0) { return(false); } this.gzip_header_flag = bits; this.gzipHeaderSubstate = GzipHeaderState.ReadingMMTime; this.loopCounter = 0; Label_00F1: bits = 0; while (this.loopCounter < 4) { if (input.GetBits(8) < 0) { return(false); } this.loopCounter++; } this.gzipHeaderSubstate = GzipHeaderState.ReadingXFL; this.loopCounter = 0; Label_0128: if (input.GetBits(8) < 0) { return(false); } this.gzipHeaderSubstate = GzipHeaderState.ReadingOS; Label_013D: if (input.GetBits(8) < 0) { return(false); } this.gzipHeaderSubstate = GzipHeaderState.ReadingXLen1; Label_0152: if ((this.gzip_header_flag & 4) == 0) { goto Label_01E5; } bits = input.GetBits(8); if (bits < 0) { return(false); } this.gzip_header_xlen = bits; this.gzipHeaderSubstate = GzipHeaderState.ReadingXLen2; Label_017B: bits = input.GetBits(8); if (bits < 0) { return(false); } this.gzip_header_xlen |= bits << 8; this.gzipHeaderSubstate = GzipHeaderState.ReadingXLenData; this.loopCounter = 0; Label_01A8: bits = 0; while (this.loopCounter < this.gzip_header_xlen) { if (input.GetBits(8) < 0) { return(false); } this.loopCounter++; } this.gzipHeaderSubstate = GzipHeaderState.ReadingFileName; this.loopCounter = 0; Label_01E5: if ((this.gzip_header_flag & 8) == 0) { this.gzipHeaderSubstate = GzipHeaderState.ReadingComment; } else { do { bits = input.GetBits(8); if (bits < 0) { return(false); } }while (bits != 0); this.gzipHeaderSubstate = GzipHeaderState.ReadingComment; } Label_0212: if ((this.gzip_header_flag & 0x10) == 0) { this.gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part1; } else { do { bits = input.GetBits(8); if (bits < 0) { return(false); } }while (bits != 0); this.gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part1; } Label_0240: if ((this.gzip_header_flag & 2) == 0) { this.gzipHeaderSubstate = GzipHeaderState.Done; goto Label_0280; } if (input.GetBits(8) < 0) { return(false); } this.gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part2; Label_026A: if (input.GetBits(8) < 0) { return(false); } this.gzipHeaderSubstate = GzipHeaderState.Done; Label_0280: return(true); }
public bool ReadHeader(InputBuffer input) { int bits; switch (this.gzipHeaderSubstate) { case GzipHeaderState.ReadingID1: bits = input.GetBits(8); if (bits >= 0) { if (bits != 0x1f) { throw new InvalidDataException(SR.GetString("CorruptedGZipHeader")); } this.gzipHeaderSubstate = GzipHeaderState.ReadingID2; break; } return false; case GzipHeaderState.ReadingID2: break; case GzipHeaderState.ReadingCM: goto Label_00A5; case GzipHeaderState.ReadingFLG: goto Label_00CE; case GzipHeaderState.ReadingMMTime: goto Label_00F1; case GzipHeaderState.ReadingXFL: goto Label_0128; case GzipHeaderState.ReadingOS: goto Label_013D; case GzipHeaderState.ReadingXLen1: goto Label_0152; case GzipHeaderState.ReadingXLen2: goto Label_017B; case GzipHeaderState.ReadingXLenData: goto Label_01A8; case GzipHeaderState.ReadingFileName: goto Label_01E5; case GzipHeaderState.ReadingComment: goto Label_0212; case GzipHeaderState.ReadingCRC16Part1: goto Label_0240; case GzipHeaderState.ReadingCRC16Part2: goto Label_026A; case GzipHeaderState.Done: goto Label_0280; default: throw new InvalidDataException(SR.GetString("UnknownState")); } bits = input.GetBits(8); if (bits < 0) { return false; } if (bits != 0x8b) { throw new InvalidDataException(SR.GetString("CorruptedGZipHeader")); } this.gzipHeaderSubstate = GzipHeaderState.ReadingCM; Label_00A5: bits = input.GetBits(8); if (bits < 0) { return false; } if (bits != 8) { throw new InvalidDataException(SR.GetString("UnknownCompressionMode")); } this.gzipHeaderSubstate = GzipHeaderState.ReadingFLG; Label_00CE: bits = input.GetBits(8); if (bits < 0) { return false; } this.gzip_header_flag = bits; this.gzipHeaderSubstate = GzipHeaderState.ReadingMMTime; this.loopCounter = 0; Label_00F1: bits = 0; while (this.loopCounter < 4) { if (input.GetBits(8) < 0) { return false; } this.loopCounter++; } this.gzipHeaderSubstate = GzipHeaderState.ReadingXFL; this.loopCounter = 0; Label_0128: if (input.GetBits(8) < 0) { return false; } this.gzipHeaderSubstate = GzipHeaderState.ReadingOS; Label_013D: if (input.GetBits(8) < 0) { return false; } this.gzipHeaderSubstate = GzipHeaderState.ReadingXLen1; Label_0152: if ((this.gzip_header_flag & 4) == 0) { goto Label_01E5; } bits = input.GetBits(8); if (bits < 0) { return false; } this.gzip_header_xlen = bits; this.gzipHeaderSubstate = GzipHeaderState.ReadingXLen2; Label_017B: bits = input.GetBits(8); if (bits < 0) { return false; } this.gzip_header_xlen |= bits << 8; this.gzipHeaderSubstate = GzipHeaderState.ReadingXLenData; this.loopCounter = 0; Label_01A8: bits = 0; while (this.loopCounter < this.gzip_header_xlen) { if (input.GetBits(8) < 0) { return false; } this.loopCounter++; } this.gzipHeaderSubstate = GzipHeaderState.ReadingFileName; this.loopCounter = 0; Label_01E5: if ((this.gzip_header_flag & 8) == 0) { this.gzipHeaderSubstate = GzipHeaderState.ReadingComment; } else { do { bits = input.GetBits(8); if (bits < 0) { return false; } } while (bits != 0); this.gzipHeaderSubstate = GzipHeaderState.ReadingComment; } Label_0212: if ((this.gzip_header_flag & 0x10) == 0) { this.gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part1; } else { do { bits = input.GetBits(8); if (bits < 0) { return false; } } while (bits != 0); this.gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part1; } Label_0240: if ((this.gzip_header_flag & 2) == 0) { this.gzipHeaderSubstate = GzipHeaderState.Done; goto Label_0280; } if (input.GetBits(8) < 0) { return false; } this.gzipHeaderSubstate = GzipHeaderState.ReadingCRC16Part2; Label_026A: if (input.GetBits(8) < 0) { return false; } this.gzipHeaderSubstate = GzipHeaderState.Done; Label_0280: return true; }