/*
* @(#)UncompressInputStream.java0.3-2 18/06/1999
*
* This file is part of the HTTPClient package
* Copyright (C) 1996-1999 Ronald Tschalr
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA
*
* For questions, suggestions, bug-reports, enhancement-requests etc.
* I may be contacted at:
*
* ronald@innovation.ch
*
*/
package HTTPClient;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FilterInputStream;
/**
* This class decompresses an input stream containing data compressed with
* the unix "compress" utility (LZC, a LZW variant). This code is based
* heavily on the unlzw.c code in gzip-1.2.4 (written
* by Peter Jannesen) and the original compress code.
*
* @version0.3-2 18/06/1999
* @authorRonald Tschalr
*/
class UncompressInputStream extends FilterInputStream
{
/**
* @param is the input stream to decompress
* @exception IOException if the header is malformed
*/
public UncompressInputStream(InputStream is) throws IOException
{
super(is);
parse_header();
}
byte[] one = new byte[1];
public synchronized int read() throws IOException
{
int b = in.read(one, 0, 1);
if (b == 1)
return (one[0] & 0xff);
else
return -1;
}
// string table stuff
private static final int TBL_CLEAR = 0x100;
private static final int TBL_FIRST = TBL_CLEAR + 1;