Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Compress.hpp

Go to the documentation of this file.
00001 /*
00002 This product contains certain software code or other information
00003 ("AT&T Software") proprietary to AT&T Corp. ("AT&T").  The AT&T
00004 Software is provided to you "AS IS".  YOU ASSUME TOTAL RESPONSIBILITY
00005 AND RISK FOR USE OF THE AT&T SOFTWARE.  AT&T DOES NOT MAKE, AND
00006 EXPRESSLY DISCLAIMS, ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND
00007 WHATSOEVER, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00008 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, WARRANTIES OF
00009 TITLE OR NON-INFRINGEMENT OF ANY INTELLECTUAL PROPERTY RIGHTS, ANY
00010 WARRANTIES ARISING BY USAGE OF TRADE, COURSE OF DEALING OR COURSE OF
00011 PERFORMANCE, OR ANY WARRANTY THAT THE AT&T SOFTWARE IS "ERROR FREE" OR
00012 WILL MEET YOUR REQUIREMENTS.
00013 
00014 Unless you accept a license to use the AT&T Software, you shall not
00015 reverse compile, disassemble or otherwise reverse engineer this
00016 product to ascertain the source code for any AT&T Software.
00017 
00018 (c) AT&T Corp. All rights reserved.  AT&T is a registered trademark of AT&T Corp.
00019 
00020 ***********************************************************************
00021 
00022 History:
00023 
00024       24/11/99  - initial release by Hartmut Liefke, liefke@seas.upenn.edu
00025                                      Dan Suciu,      suciu@research.att.com
00026 */
00027 
00028 //**************************************************************************
00029 //**************************************************************************
00030 
00031 // This module implements 'Compressor' and 'Uncompressor' -
00032 // the interfaces to the ZLIB (either gzip or bzip) libary
00033 
00034 
00035 #ifndef COMPRESS_HPP
00036 #define COMPRESS_HPP
00037 
00038 #ifdef USE_BZIP
00039 #include <bzlib.h>
00040 #else
00041 #include <zlib.h>
00042 #endif
00043 
00044 class Output;
00045 class MemStreamer;
00046 class Input;
00047 
00048 //************************************************************************
00049 
00050 // The Compressor
00051 
00052 #ifdef XMILL
00053 
00054 class Compressor
00055 {
00056    // We store the state for the zlib compressor
00057 #ifdef USE_BZIP
00058    bz_stream      state;
00059 #else
00060    z_stream       state;
00061 #endif
00062    Output         *output;
00063    unsigned char  isinitialized:1;
00064 
00065 public:
00066    Compressor(Output *myoutput);
00067    ~Compressor();
00068    void CompressMemStream(MemStreamer *memstream);
00069       // Reads the data from 'memstream' and sends
00070       // it to the compressor
00071 
00072    void CompressData(unsigned char *ptr,unsigned len);
00073       // Compresses the data at position 'ptr' of length 'len'
00074 
00075    void FinishCompress(unsigned long *uncompressedsize,unsigned long *compressedsize);
00076       // Finishes the compression and stores the input data size and
00077       // the output data size in 'uncompressedsize' and 'compressedsize'
00078 };
00079 #endif
00080 
00081 //************************************************************************
00082 
00083 // The Decompressor
00084 
00085 #ifdef XDEMILL
00086 
00087 class Uncompressor
00088 {
00089    // We store the states for the zlib compressor
00090 #ifdef USE_BZIP
00091    bz_stream      state;
00092 #else
00093    z_stream       state;
00094 #endif
00095 
00096 public:
00097    unsigned char     isinitialized:1;
00098 
00099 public:
00100 
00101    Uncompressor() {  isinitialized=0;  }
00102 
00103    char Uncompress(Input *input,unsigned char *dataptr,unsigned long *len);
00104       // Decompresses the data from 'input' and stores
00105       // the result in 'dataptr'. It decompresses at most *len
00106       // bytes. Afterwards, '*len' is set to the actual number
00107       // of bytes uncompressed.
00108       // The function returns 1, if output buffer is full and
00109       // there is more data to read. Otherwise, the function returns 0.
00110 };
00111 #endif
00112 
00113 #endif

Generated on Sat Oct 13 16:08:34 2001 for XMILL by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001