Example #1
0
 private void SetupRandPartA()
 {
     if (this.su_i2 <= this.last)
     {
         this.su_chPrev = this.su_ch2;
         int num = (int)(this.data.ll8[this.su_tPos] & 255);
         this.su_tPos = this.data.tt[this.su_tPos];
         if (this.su_rNToGo == 0)
         {
             this.su_rNToGo = Rand.Rnums(this.su_rTPos) - 1;
             if (++this.su_rTPos == 512)
             {
                 this.su_rTPos = 0;
             }
         }
         else
         {
             this.su_rNToGo--;
         }
         num = (this.su_ch2 = (num ^ ((this.su_rNToGo != 1) ? 0 : 1)));
         this.su_i2++;
         this.currentChar  = num;
         this.currentState = BZip2InputStream.CState.RAND_PART_B;
         this.crc.UpdateCRC((byte)num);
     }
     else
     {
         this.EndBlock();
         this.InitBlock();
         this.SetupBlock();
     }
 }
Example #2
0
        private void InitBlock()
        {
            char c  = this.bsGetUByte();
            char c2 = this.bsGetUByte();
            char c3 = this.bsGetUByte();
            char c4 = this.bsGetUByte();
            char c5 = this.bsGetUByte();
            char c6 = this.bsGetUByte();

            if (c == '\u0017' && c2 == 'r' && c3 == 'E' && c4 == '8' && c5 == 'P' && c6 == '\u0090')
            {
                this.complete();
            }
            else
            {
                if (c != '1' || c2 != 'A' || c3 != 'Y' || c4 != '&' || c5 != 'S' || c6 != 'Y')
                {
                    this.currentState = BZip2InputStream.CState.EOF;
                    string message = string.Format("bad block header at offset 0x{0:X}", this.input.Position);
                    throw new IOException(message);
                }
                this.storedBlockCRC  = this.bsGetInt();
                this.blockRandomised = (this.GetBits(1) == 1);
                if (this.data == null)
                {
                    this.data = new BZip2InputStream.DecompressionState(this.blockSize100k);
                }
                this.getAndMoveToFrontDecode();
                this.crc.Reset();
                this.currentState = BZip2InputStream.CState.START_BLOCK;
            }
        }
Example #3
0
 private void complete()
 {
     this.storedCombinedCRC = this.bsGetInt();
     this.currentState      = BZip2InputStream.CState.EOF;
     this.data = null;
     if (this.storedCombinedCRC != this.computedCombinedCRC)
     {
         string message = string.Format("BZip2 CRC error (expected {0:X8}, computed {1:X8})", this.storedCombinedCRC, this.computedCombinedCRC);
         throw new IOException(message);
     }
 }
Example #4
0
 private void SetupRandPartC()
 {
     if (this.su_j2 < (int)this.su_z)
     {
         this.currentChar = this.su_ch2;
         this.crc.UpdateCRC((byte)this.su_ch2);
         this.su_j2++;
     }
     else
     {
         this.currentState = BZip2InputStream.CState.RAND_PART_A;
         this.su_i2++;
         this.su_count = 0;
         this.SetupRandPartA();
     }
 }
Example #5
0
 private void SetupNoRandPartC()
 {
     if (this.su_j2 < (int)this.su_z)
     {
         int num = this.su_ch2;
         this.currentChar = num;
         this.crc.UpdateCRC((byte)num);
         this.su_j2++;
         this.currentState = BZip2InputStream.CState.NO_RAND_PART_C;
     }
     else
     {
         this.su_i2++;
         this.su_count = 0;
         this.SetupNoRandPartA();
     }
 }
Example #6
0
 private void SetupNoRandPartA()
 {
     if (this.su_i2 <= this.last)
     {
         this.su_chPrev = this.su_ch2;
         int num = (int)(this.data.ll8[this.su_tPos] & 255);
         this.su_ch2  = num;
         this.su_tPos = this.data.tt[this.su_tPos];
         this.su_i2++;
         this.currentChar  = num;
         this.currentState = BZip2InputStream.CState.NO_RAND_PART_B;
         this.crc.UpdateCRC((byte)num);
     }
     else
     {
         this.currentState = BZip2InputStream.CState.NO_RAND_PART_A;
         this.EndBlock();
         this.InitBlock();
         this.SetupBlock();
     }
 }
Example #7
0
 private void SetupRandPartB()
 {
     if (this.su_ch2 != this.su_chPrev)
     {
         this.currentState = BZip2InputStream.CState.RAND_PART_A;
         this.su_count     = 1;
         this.SetupRandPartA();
     }
     else if (++this.su_count >= 4)
     {
         this.su_z    = (char)(this.data.ll8[this.su_tPos] & 255);
         this.su_tPos = this.data.tt[this.su_tPos];
         if (this.su_rNToGo == 0)
         {
             this.su_rNToGo = Rand.Rnums(this.su_rTPos) - 1;
             if (++this.su_rTPos == 512)
             {
                 this.su_rTPos = 0;
             }
         }
         else
         {
             this.su_rNToGo--;
         }
         this.su_j2        = 0;
         this.currentState = BZip2InputStream.CState.RAND_PART_C;
         if (this.su_rNToGo == 1)
         {
             this.su_z ^= '\u0001';
         }
         this.SetupRandPartC();
     }
     else
     {
         this.currentState = BZip2InputStream.CState.RAND_PART_A;
         this.SetupRandPartA();
     }
 }