00001 /* 00002 * HT Editor 00003 * cstream.cc 00004 * 00005 * Copyright (C) 1999-2002 Sebastian Biallas (sb@web-productions.de) 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License version 2 as 00009 * published by the Free Software Foundation. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 #ifndef __CSTREAM_H__ 00021 #define __CSTREAM_H__ 00022 00023 #include "global.h" 00024 #include "stream.h" 00025 00026 /* 00027 * NEVER use ht_compressed_stream for both reading and writing! 00028 */ 00029 00030 #define COMPRESSED_STREAM_DEFAULT_GRANULARITY 10240 00031 00032 class ht_compressed_stream: public ht_layer_stream { 00033 protected: 00034 byte *buffer; 00035 UINT buffersize; 00036 UINT bufferpos; 00037 public: 00038 void init(ht_stream *stream, bool own_stream, UINT granularity=COMPRESSED_STREAM_DEFAULT_GRANULARITY); 00039 virtual void done(); 00040 /* overwritten */ 00041 virtual UINT read(void *buf, UINT size); 00042 virtual UINT write(const void *buf, UINT size); 00043 protected: 00044 bool flush_compressed(); 00045 bool flush_uncompressed(); 00046 }; 00047 00048 #endif