Exemple #1
0
        public Decompressor(InputBuffer input, OutputBuffer output)
            : base(input, output)
        {
            /* Check the magic number */
            if (((input.ReadByte() & 0xFF) != (Compress.magic_header [0] & 0xFF)) || ((input.ReadByte() & 0xFF) != (Compress.magic_header [1] & 0xFF)))
            {
                Console.Error.WriteLine("stdin: not in compressed format");
            }

            maxBits       = input.ReadByte(); /* set -b from file */
            blockCompress = maxBits & Compress.BLOCK_MASK;
            maxBits      &= Compress.BIT_MASK;
            maxMaxCode    = 1 << maxBits;
            if (maxBits > Compress.BITS)
            {
                Console.Error.WriteLine("stdin: compressed with " + maxBits + " bits, can only handle " + Compress.BITS + " bits");
            }
            bitsNumber = Compress.INIT_BITS;
            maxCode    = MaxCode;

            offset    = 0;
            size      = 0;
            clearFlag = 0;
            freeEntry = ((blockCompress != 0) ? Compress.FIRST : 256);

            tabPrefix = new CodeTable();
            tabSuffix = new SuffixTable();
            deStack   = new DeStack();

            /*
             * As above, initialize the first 256 entries in the table.
             */
            tabPrefix.Clear(256);
            tabSuffix.Init(256);
        }
Exemple #2
0
        public Compressor(InputBuffer input, OutputBuffer output)
            : base(input, output)
        {
            if (maxBits < Benchmark.Compress.INIT_BITS)
            {
                maxBits = Benchmark.Compress.INIT_BITS;
            }
            if (maxBits > Benchmark.Compress.BITS)
            {
                maxBits = Benchmark.Compress.BITS;
            }
            maxMaxCode = 1 << maxBits;
            bitsNumber = Benchmark.Compress.INIT_BITS;
            maxCode    = MaxCode;

            offset     = 0;
            bytesOut   = 3;   /* includes 3-byte header mojo */
            outCount   = 0;
            clearFlag  = 0;
            ratio      = 0;
            inCount    = 1;
            checkpoint = CHECK_GAP;
            freeEntry  = ((blockCompress != 0) ? Benchmark.Compress.FIRST : 256);

            htab    = new HashTable();   // dm/kmd 4/10/98
            codetab = new CodeTable();

            output.WriteByte(Benchmark.Compress.magic_header [0]);
            output.WriteByte(Benchmark.Compress.magic_header [1]);
            output.WriteByte((byte)(maxBits | blockCompress));
        }
Exemple #3
0
 public CompBase(InputBuffer input, OutputBuffer output)
 {
     this.input    = input;
     this.output   = output;
     maxBits       = Compress.BITS;
     blockCompress = Compress.BLOCK_MASK;
     buf           = new byte [Compress.BITS];
 }
Exemple #4
0
        public static OutputBuffer PerformAction(byte [] src, int srcLength, int action, byte [] dst)
        {
            InputBuffer  input  = new InputBuffer(srcLength, src);
            OutputBuffer output = new OutputBuffer(dst);

            if (action == COMPRESS)
            {
                new Compressor(input, output).Compress();
            }
            else
            {
                new Decompressor(input, output).Decompress();
            }
            return(output);
        }
Exemple #5
0
	public Decompressor (InputBuffer input, OutputBuffer output)
	: base (input, output)
	{
		/* Check the magic number */
		if (((input.ReadByte () & 0xFF) != (Compress.magic_header [0] & 0xFF)) || ((input.ReadByte () & 0xFF) != (Compress.magic_header [1] & 0xFF)))
			Console.Error.WriteLine ("stdin: not in compressed format");

		maxBits = input.ReadByte (); /* set -b from file */
		blockCompress = maxBits & Compress.BLOCK_MASK;
		maxBits &= Compress.BIT_MASK;
		maxMaxCode = 1 << maxBits;
		if (maxBits > Compress.BITS)
			Console.Error.WriteLine ("stdin: compressed with " + maxBits + " bits, can only handle " + Compress.BITS + " bits");
		bitsNumber = Compress.INIT_BITS;
		maxCode = MaxCode;

		offset = 0;
		size = 0;
		clearFlag = 0;
		freeEntry = ((blockCompress != 0) ? Compress.FIRST : 256);

		tabPrefix = new CodeTable ();
		tabSuffix = new SuffixTable ();
		deStack = new DeStack ();

		/*
		 * As above, initialize the first 256 entries in the table.
		 */
		tabPrefix.Clear (256);
		tabSuffix.Init (256);
	}
Exemple #6
0
	public Compressor (InputBuffer input, OutputBuffer output)
	: base (input, output)
	{
		if (maxBits < Benchmark.Compress.INIT_BITS)
			maxBits = Benchmark.Compress.INIT_BITS;
		if (maxBits > Benchmark.Compress.BITS)
			maxBits = Benchmark.Compress.BITS;
		maxMaxCode = 1 << maxBits;
		bitsNumber = Benchmark.Compress.INIT_BITS;
		maxCode = MaxCode;

		offset = 0;
		bytesOut = 3; /* includes 3-byte header mojo */
		outCount = 0;
		clearFlag = 0;
		ratio = 0;
		inCount = 1;
		checkpoint = CHECK_GAP;
		freeEntry = ((blockCompress != 0) ? Benchmark.Compress.FIRST : 256);

		htab = new HashTable (); // dm/kmd 4/10/98
		codetab = new CodeTable ();

		output.WriteByte (Benchmark.Compress.magic_header [0]);
		output.WriteByte (Benchmark.Compress.magic_header [1]);
		output.WriteByte ((byte) (maxBits | blockCompress));
	}
Exemple #7
0
	public CompBase (InputBuffer input, OutputBuffer output)
	{
		this.input = input;
		this.output = output;
		maxBits = Compress.BITS;
		blockCompress = Compress.BLOCK_MASK;
		buf = new byte [Compress.BITS];
	}
Exemple #8
0
	public static OutputBuffer PerformAction (byte [] src, int srcLength, int action, byte [] dst)
	{
		InputBuffer input = new InputBuffer (srcLength, src);
		OutputBuffer output = new OutputBuffer (dst);
		if (action == COMPRESS)
		{
			new Compressor (input, output).Compress ();
		}
		else
		{
			new Decompressor (input, output).Decompress ();
		}
		return output;
	}