Disk ARchive
2.4.5
|
00001 /*********************************************************************/ 00002 // dar - disk archive - a backup/restoration program 00003 // Copyright (C) 2002-2052 Denis Corbin 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // to contact the author : dar.linux@free.fr 00020 /*********************************************************************/ 00021 // $Id$ 00022 // 00023 /*********************************************************************/ 00024 00025 #ifndef WRAPPERLIB_HPP 00026 #define WRAPPERLIB_HPP 00027 00028 #include <zlib.h> 00029 #include <bzlib.h> 00030 00031 #define WR_OK 0 00032 #define WR_MEM_ERROR 1 00033 #define WR_VERSION_ERROR 2 00034 #define WR_STREAM_ERROR 3 00035 #define WR_DATA_ERROR 4 00036 #define WR_NO_FLUSH 5 00037 #define WR_BUF_ERROR 6 00038 #define WR_STREAM_END 7 00039 #define WR_FINISH 8 00040 00041 enum wrapperlib_mode { zlib_mode, bzlib_mode }; 00042 00043 class wrapperlib 00044 { 00045 public: 00046 wrapperlib(wrapperlib_mode mode); 00047 wrapperlib(const wrapperlib & ref); 00048 wrapperlib & operator = (const wrapperlib & ref); 00049 ~wrapperlib(); 00050 00051 void set_next_in(char *x) { return (this->*x_set_next_in)(x); }; 00052 void set_avail_in(U_I x) { return (this->*x_set_avail_in)(x); }; 00053 U_I get_avail_in() const { return (this->*x_get_avail_in)(); }; 00054 U_64 get_total_in() const { return (this->*x_get_total_in)(); }; 00055 00056 void set_next_out(char *x) { return (this->*x_set_next_out)(x); }; 00057 char *get_next_out() const { return (this->*x_get_next_out)(); }; 00058 void set_avail_out(U_I x) { return (this->*x_set_avail_out)(x); }; 00059 U_I get_avail_out() const { return (this->*x_get_avail_out)(); }; 00060 U_64 get_total_out() const { return (this->*x_get_total_out)(); }; 00061 00062 S_I compressInit(U_I compression_level) { level = compression_level; return (this->*x_compressInit)(compression_level); }; 00063 S_I decompressInit() { return (this->*x_decompressInit)(); }; 00064 S_I compressEnd() { return (this->*x_compressEnd)(); }; 00065 S_I decompressEnd() { return (this->*x_decompressEnd)(); }; 00066 S_I compress(S_I flag) { return (this->*x_compress)(flag); }; 00067 S_I decompress(S_I flag) { return (this->*x_decompress)(flag);}; 00068 S_I compressReset(); 00069 S_I decompressReset(); 00070 00071 private: 00072 z_stream *z_ptr; 00073 bz_stream *bz_ptr; 00074 S_I level; 00075 00076 void (wrapperlib::*x_set_next_in)(char *x); 00077 void (wrapperlib::*x_set_avail_in)(U_I x); 00078 U_I (wrapperlib::*x_get_avail_in)() const; 00079 U_64 (wrapperlib::*x_get_total_in)() const; 00080 00081 void (wrapperlib::*x_set_next_out)(char *x); 00082 char *(wrapperlib::*x_get_next_out)() const; 00083 void (wrapperlib::*x_set_avail_out)(U_I x); 00084 U_I (wrapperlib::*x_get_avail_out)() const; 00085 U_64 (wrapperlib::*x_get_total_out)() const; 00086 00087 S_I (wrapperlib::*x_compressInit)(U_I compression_level); 00088 S_I (wrapperlib::*x_decompressInit)(); 00089 S_I (wrapperlib::*x_compressEnd)(); 00090 S_I (wrapperlib::*x_decompressEnd)(); 00091 S_I (wrapperlib::*x_compress)(S_I flag); 00092 S_I (wrapperlib::*x_decompress)(S_I flag); 00093 00094 00095 // set of routines for zlib 00096 00097 S_I z_compressInit(U_I compression_level); 00098 S_I z_decompressInit(); 00099 S_I z_compressEnd(); 00100 S_I z_decompressEnd(); 00101 S_I z_compress(S_I flag); 00102 S_I z_decompress(S_I flag); 00103 void z_set_next_in(char *x); 00104 void z_set_avail_in(U_I x); 00105 U_I z_get_avail_in() const; 00106 U_64 z_get_total_in() const; 00107 void z_set_next_out(char *x); 00108 char *z_get_next_out() const; 00109 void z_set_avail_out(U_I x); 00110 U_I z_get_avail_out() const; 00111 U_64 z_get_total_out() const; 00112 00113 // set of routines for bzlib 00114 00115 S_I bz_compressInit(U_I compression_level); 00116 S_I bz_decompressInit(); 00117 S_I bz_compressEnd(); 00118 S_I bz_decompressEnd(); 00119 S_I bz_compress(S_I flag); 00120 S_I bz_decompress(S_I flag); 00121 void bz_set_next_in(char *x); 00122 void bz_set_avail_in(U_I x); 00123 U_I bz_get_avail_in() const; 00124 U_64 bz_get_total_in() const; 00125 void bz_set_next_out(char *x); 00126 char *bz_get_next_out() const; 00127 void bz_set_avail_out(U_I x); 00128 U_I bz_get_avail_out() const; 00129 U_64 bz_get_total_out() const; 00130 }; 00131 00132 #endif