Пример #1
0
        // Token: 0x0600065C RID: 1628 RVA: 0x00024ACC File Offset: 0x00022CCC
        private bool UULineGood()
        {
            this.encodedBytes = 0;
            int num = this.encodedSize;

            while (this.encodedSize > 0 && ByteEncoder.IsWhiteSpace(this.encoded[this.encodedSize - 1]))
            {
                this.encodedSize--;
            }
            if (this.encodedSize == 0)
            {
                return(true);
            }
            if (this.state == UUDecoder.State.Prologue)
            {
                if (ByteEncoder.BeginsWithNI(this.encoded, 0, UUDecoder.Prologue, this.encodedSize))
                {
                    int num2 = this.encodedSize - 6;
                    int num3 = 6;
                    while (num2 != 0 && ByteEncoder.IsWhiteSpace(this.encoded[num3]))
                    {
                        num3++;
                        num2--;
                    }
                    if (num2 == 0 || this.encoded[num3] < 48 || this.encoded[num3] > 55)
                    {
                        return(true);
                    }
                    do
                    {
                        num3++;
                        num2--;
                    }while (num2 != 0 && this.encoded[num3] >= 48 && this.encoded[num3] <= 55);
                    if (num2 == 0 || !ByteEncoder.IsWhiteSpace(this.encoded[num3]))
                    {
                        return(true);
                    }
                    do
                    {
                        num3++;
                        num2--;
                    }while (num2 != 0 && ByteEncoder.IsWhiteSpace(this.encoded[num3]));
                    if (num2 <= 128)
                    {
                        this.fileName = new byte[num2];
                        ByteEncoder.BlockCopy(this.encoded, num3, this.fileName, 0, num2);
                    }
                    return(true);
                }
            }
            else
            {
                if (this.state == UUDecoder.State.Ending)
                {
                    return(true);
                }
                if (ByteEncoder.BeginsWithNI(this.encoded, 0, UUDecoder.Prologue, this.encodedSize))
                {
                    return(true);
                }
            }
            if (true)
            {
                int num4 = (int)UUDecoder.UUDecode(this.encoded[0]);
                int num5 = 0;
                int num6 = num4 % 3;
                if (num6 != 0)
                {
                    num6++;
                    num5 = 4 - num6;
                }
                int num7 = 4 * (num4 / 3) + num6 + 1;
                if (this.encodedSize < num7)
                {
                    if (num < num7)
                    {
                        goto IL_285;
                    }
                    this.encodedSize = num7;
                }
                if (num7 != this.encodedSize && num7 + num5 != this.encodedSize)
                {
                    if (num7 + 1 == this.encodedSize || num7 + num5 + 1 == this.encodedSize)
                    {
                        this.encodedSize--;
                    }
                    else
                    {
                        if (num7 - 1 != this.encodedSize && num7 + num5 - 1 == this.encodedSize)
                        {
                            goto IL_285;
                        }
                        goto IL_285;
                    }
                }
                this.encodedBytes = num4;
                if (num5 != 0 && num7 == this.encodedSize)
                {
                    this.encoded[num7] = 32;
                    if (num5 > 1)
                    {
                        this.encoded[num7 + 1] = 32;
                    }
                    this.encodedSize += num5;
                }
                this.encodedSize--;
                this.encodedIndex = 1;
                if (this.encodedBytes == 0)
                {
                    this.state = UUDecoder.State.Ending;
                }
                else
                {
                    this.state = UUDecoder.State.Data;
                }
                return(true);
            }
IL_285:
            if (ByteEncoder.BeginsWithNI(this.encoded, 0, UUDecoder.Epilogue, this.encodedSize))
            {
                this.state = UUDecoder.State.Ending;
                return(true);
            }
            return(false);
        }
Пример #2
0
 // Token: 0x06000663 RID: 1635 RVA: 0x00024E74 File Offset: 0x00023074
 public sealed override void Convert(byte[] input, int inputIndex, int inputSize, byte[] output, int outputIndex, int outputSize, bool flush, out int inputUsed, out int outputUsed, out bool completed)
 {
     if (inputSize != 0)
     {
         if (input == null)
         {
             throw new ArgumentNullException("input");
         }
         if (inputIndex < 0 || inputIndex >= input.Length)
         {
             throw new ArgumentOutOfRangeException("inputIndex");
         }
         if (inputSize < 0 || inputSize > input.Length - inputIndex)
         {
             throw new ArgumentOutOfRangeException("inputSize");
         }
     }
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     if (outputIndex < 0 || outputIndex >= output.Length)
     {
         throw new ArgumentOutOfRangeException("outputIndex");
     }
     if (outputSize < 1 || outputSize > output.Length - outputIndex)
     {
         throw new ArgumentOutOfRangeException("outputSize");
     }
     if (this.numLines == 0)
     {
         this.outLineReady = false;
         this.bufferSize   = 0;
         Array.Clear(this.chunk, 0, this.chunk.Length);
         this.chunkIndex = 0;
         if (this.fileName != null)
         {
             ByteEncoder.BlockCopy(UUEncoder.Prologue, 0, this.buffer, 0, UUEncoder.Prologue.Length);
             this.bufferSize = UUEncoder.Prologue.Length;
             ByteEncoder.BlockCopy(this.fileName, 0, this.buffer, this.bufferSize, this.fileName.Length);
             this.bufferSize += this.fileName.Length;
             ByteEncoder.BlockCopy(ByteEncoder.LineWrap, 0, this.buffer, this.bufferSize, ByteEncoder.LineWrap.Length);
             this.bufferSize  += ByteEncoder.LineWrap.Length;
             this.bufferIndex  = 0;
             this.outLineReady = true;
             this.numLines++;
         }
     }
     inputUsed  = inputIndex;
     outputUsed = outputIndex;
     do
     {
         if (this.outLineReady)
         {
             int num = Math.Min(this.bufferSize, outputSize);
             ByteEncoder.BlockCopy(this.buffer, this.bufferIndex, output, outputIndex, num);
             outputSize       -= num;
             outputIndex      += num;
             this.bufferSize  -= num;
             this.bufferIndex += num;
             if (this.bufferSize != 0)
             {
                 break;
             }
             this.outLineReady = false;
             if (3 == this.bufferIndex)
             {
                 if (this.fileName != null)
                 {
                     ByteEncoder.BlockCopy(UUEncoder.Epilogue, 0, this.buffer, 0, UUEncoder.Epilogue.Length);
                     this.bufferSize   = UUEncoder.Epilogue.Length;
                     this.bufferIndex  = 0;
                     this.outLineReady = true;
                     continue;
                 }
                 break;
             }
             else
             {
                 if (5 == this.bufferIndex && this.fileName != null && this.buffer[0] == 101)
                 {
                     break;
                 }
                 this.bufferIndex = 0;
             }
         }
         if (this.bufferSize == 0)
         {
             this.buffer[this.bufferSize++] = 0;
             this.bufferIndex = 0;
             this.rawCount    = 0;
             this.numLines++;
         }
         while (inputSize != 0 || flush)
         {
             if (inputSize != 0)
             {
                 int num2 = Math.Min(3 - this.chunkIndex, inputSize);
                 if ((num2 & 2) != 0)
                 {
                     this.chunk[this.chunkIndex++] = input[inputIndex++];
                     this.chunk[this.chunkIndex++] = input[inputIndex++];
                 }
                 if ((num2 & 1) != 0)
                 {
                     this.chunk[this.chunkIndex++] = input[inputIndex++];
                 }
                 inputSize -= num2;
                 if (this.chunkIndex != 3)
                 {
                     continue;
                 }
             }
             if (this.chunkIndex != 0)
             {
                 if (3 != this.chunkIndex)
                 {
                     Array.Clear(this.chunk, this.chunkIndex, 3 - this.chunkIndex);
                 }
                 this.buffer[this.bufferSize++] = UUEncoder.UUEncode(this.chunk[0] >> 2);
                 this.buffer[this.bufferSize++] = UUEncoder.UUEncode((int)this.chunk[0] << 4 | this.chunk[1] >> 4);
                 this.buffer[this.bufferSize++] = UUEncoder.UUEncode((int)this.chunk[1] << 2 | this.chunk[2] >> 6);
                 this.buffer[this.bufferSize++] = UUEncoder.UUEncode((int)this.chunk[2]);
                 this.rawCount  += this.chunkIndex;
                 this.chunkIndex = 0;
             }
             if (this.bufferSize == 61 || (flush && inputSize == 0))
             {
                 this.buffer[0] = UUEncoder.UUEncode(this.rawCount);
                 this.buffer[this.bufferSize++] = 13;
                 this.buffer[this.bufferSize++] = 10;
                 this.outLineReady = true;
                 break;
             }
         }
     }while (this.outLineReady);
     inputUsed  = inputIndex - inputUsed;
     outputUsed = outputIndex - outputUsed;
     completed  = (inputSize == 0 && (!flush || 0 == this.bufferSize));
     if (flush && completed)
     {
         this.numLines = 0;
     }
 }
Пример #3
0
        // Token: 0x06000643 RID: 1603 RVA: 0x000235DC File Offset: 0x000217DC
        public sealed override void Convert(byte[] input, int inputIndex, int inputSize, byte[] output, int outputIndex, int outputSize, bool flush, out int inputUsed, out int outputUsed, out bool completed)
        {
            if (inputSize != 0)
            {
                if (input == null)
                {
                    throw new ArgumentNullException("input");
                }
                if (inputIndex < 0 || inputIndex >= input.Length)
                {
                    throw new ArgumentOutOfRangeException("inputIndex");
                }
                if (inputSize < 0 || inputSize > input.Length - inputIndex)
                {
                    throw new ArgumentOutOfRangeException("inputSize");
                }
            }
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (outputIndex < 0 || outputIndex >= output.Length)
            {
                throw new ArgumentOutOfRangeException("outputIndex");
            }
            if (outputSize < 1 || outputSize > output.Length - outputIndex)
            {
                throw new ArgumentOutOfRangeException("outputSize");
            }
            outputUsed = outputIndex;
            inputUsed  = inputIndex;
            int num = inputIndex + inputSize;

            while (inputIndex != num && outputSize != 0)
            {
                if (this.encodedIndex != 0)
                {
                    for (;;)
                    {
                        byte b = input[inputIndex++];
                        if (32 != b && 9 != b)
                        {
                            this.encoded[this.encodedIndex++] = b;
                            if (this.encodedIndex == 3)
                            {
                                break;
                            }
                        }
                        if (inputIndex == num)
                        {
                            goto IL_164;
                        }
                    }
                    this.encodedIndex = 0;
                    byte b2 = this.encoded[1];
                    byte b3 = this.encoded[2];
                    if (b2 != 13 || b3 != 10)
                    {
                        byte b4 = ByteEncoder.Tables.NumFromHex[(int)b2];
                        byte b5 = ByteEncoder.Tables.NumFromHex[(int)b3];
                        byte b  = (b4 == byte.MaxValue || b5 == byte.MaxValue) ? 61 : ((byte)((int)b4 << 4 | (int)b5));
                        output[outputIndex++] = b;
                        if (--outputSize == 0)
                        {
                            inputUsed  = inputIndex - inputUsed;
                            outputUsed = outputIndex - outputUsed;
                            completed  = (inputIndex == num);
                            return;
                        }
                    }
                }
IL_164:
                if (inputIndex != num)
                {
                    int num2 = Math.Min(num - inputIndex, outputSize);
                    int num3 = ByteString.IndexOf(input, 61, inputIndex, num2);
                    if (input.GetLowerBound(0) - 1 == num3)
                    {
                        num3 = inputIndex + num2;
                    }
                    else
                    {
                        num2 = num3 - inputIndex;
                        this.encoded[this.encodedIndex++] = 61;
                        num3++;
                    }
                    if (0 < num2)
                    {
                        ByteEncoder.BlockCopy(input, inputIndex, output, outputIndex, num2);
                        outputSize  -= num2;
                        outputIndex += num2;
                    }
                    inputIndex = num3;
                }
            }
            if (flush && this.encodedIndex != 0 && inputIndex == num)
            {
                if ((this.encodedIndex == 1 && 61 == this.encoded[0]) || this.encoded[1] == 13)
                {
                    this.encodedIndex = 0;
                }
                else if (0 < outputSize)
                {
                    output[outputIndex++] = this.encoded[0];
                    if (0 < --outputSize)
                    {
                        if (1 < this.encodedIndex)
                        {
                            output[outputIndex++] = this.encoded[1];
                        }
                        this.encodedIndex = 0;
                    }
                    else if (1 < this.encodedIndex)
                    {
                        this.encoded[0] = this.encoded[1];
                        this.encodedIndex--;
                    }
                }
            }
            inputUsed  = inputIndex - inputUsed;
            outputUsed = outputIndex - outputUsed;
            completed  = (inputIndex == num && (!flush || 0 == this.encodedIndex));
        }