![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 : http://dar.linux.free.fr/email.html 00020 /*********************************************************************/ 00021 00029 00030 #ifndef WRAPPERLIB_HPP 00031 #define WRAPPERLIB_HPP 00032 00033 #include "../my_config.h" 00034 00035 extern "C" 00036 { 00037 #if HAVE_ZLIB_H && LIBZ_AVAILABLE 00038 #include <zlib.h> 00039 #endif 00040 00041 #if HAVE_BZLIB_H && LIBBZ2_AVAILABLE 00042 #include <bzlib.h> 00043 #endif 00044 00045 #if HAVE_LZMA_H && LIBLZMA_AVAILABLE 00046 #include <lzma.h> 00047 #endif 00048 } // end extern "C" 00049 00050 #include "integers.hpp" 00051 #include "on_pool.hpp" 00052 00053 namespace libdar 00054 { 00055 00058 00059 const int WR_OK = 0; 00060 const int WR_MEM_ERROR = 1; 00061 const int WR_VERSION_ERROR = 2; 00062 const int WR_STREAM_ERROR = 3; 00063 const int WR_DATA_ERROR = 4; 00064 const int WR_NO_FLUSH = 5; 00065 const int WR_BUF_ERROR = 6; 00066 const int WR_STREAM_END = 7; 00067 const int WR_FINISH = 8; 00068 00069 enum wrapperlib_mode { zlib_mode, bzlib_mode, xz_mode }; 00070 00072 00076 00077 class wrapperlib : public on_pool 00078 { 00079 public: 00080 wrapperlib(wrapperlib_mode mode); 00081 wrapperlib(const wrapperlib & ref); 00082 const wrapperlib & operator = (const wrapperlib & ref); 00083 ~wrapperlib(); 00084 00085 void set_next_in(const char *x) { return (this->*x_set_next_in)(x); }; 00086 void set_avail_in(U_I x) { return (this->*x_set_avail_in)(x); }; 00087 U_I get_avail_in() const { return (this->*x_get_avail_in)(); }; 00088 U_64 get_total_in() const { return (this->*x_get_total_in)(); }; 00089 00090 void set_next_out(char *x) { return (this->*x_set_next_out)(x); }; 00091 char *get_next_out() const { return (this->*x_get_next_out)(); }; 00092 void set_avail_out(U_I x) { return (this->*x_set_avail_out)(x); }; 00093 U_I get_avail_out() const { return (this->*x_get_avail_out)(); }; 00094 U_64 get_total_out() const { return (this->*x_get_total_out)(); }; 00095 00096 S_I compressInit(U_I compression_level) { level = compression_level; return (this->*x_compressInit)(compression_level); }; 00097 S_I decompressInit() { return (this->*x_decompressInit)(); }; 00098 S_I compressEnd() { return (this->*x_compressEnd)(); }; 00099 S_I decompressEnd() { return (this->*x_decompressEnd)(); }; 00100 S_I compress(S_I flag) { return (this->*x_compress)(flag); }; 00101 S_I decompress(S_I flag) { return (this->*x_decompress)(flag);}; 00102 S_I compressReset(); 00103 S_I decompressReset(); 00104 00105 private: 00106 #if LIBZ_AVAILABLE 00107 z_stream *z_ptr; 00108 #endif 00109 #if LIBBZ2_AVAILABLE 00110 bz_stream *bz_ptr; 00111 #endif 00112 #if LIBLZMA_AVAILABLE 00113 lzma_stream *lzma_ptr; 00114 #endif 00115 00116 S_I level; 00117 00118 void (wrapperlib::*x_set_next_in)(const char *x); 00119 void (wrapperlib::*x_set_avail_in)(U_I x); 00120 U_I (wrapperlib::*x_get_avail_in)() const; 00121 U_64 (wrapperlib::*x_get_total_in)() const; 00122 00123 void (wrapperlib::*x_set_next_out)(char *x); 00124 char *(wrapperlib::*x_get_next_out)() const; 00125 void (wrapperlib::*x_set_avail_out)(U_I x); 00126 U_I (wrapperlib::*x_get_avail_out)() const; 00127 U_64 (wrapperlib::*x_get_total_out)() const; 00128 00129 S_I (wrapperlib::*x_compressInit)(U_I compression_level); 00130 S_I (wrapperlib::*x_decompressInit)(); 00131 S_I (wrapperlib::*x_compressEnd)(); 00132 S_I (wrapperlib::*x_decompressEnd)(); 00133 S_I (wrapperlib::*x_compress)(S_I flag); 00134 S_I (wrapperlib::*x_decompress)(S_I flag); 00135 00136 00137 // set of routines for zlib 00138 #if LIBZ_AVAILABLE 00139 S_I z_compressInit(U_I compression_level); 00140 S_I z_decompressInit(); 00141 S_I z_compressEnd(); 00142 S_I z_decompressEnd(); 00143 S_I z_compress(S_I flag); 00144 S_I z_decompress(S_I flag); 00145 void z_set_next_in(const char *x); 00146 void z_set_avail_in(U_I x); 00147 U_I z_get_avail_in() const; 00148 U_64 z_get_total_in() const; 00149 void z_set_next_out(char *x); 00150 char *z_get_next_out() const; 00151 void z_set_avail_out(U_I x); 00152 U_I z_get_avail_out() const; 00153 U_64 z_get_total_out() const; 00154 #endif 00155 00156 // set of routines for bzlib 00157 #if LIBBZ2_AVAILABLE 00158 S_I bz_compressInit(U_I compression_level); 00159 S_I bz_decompressInit(); 00160 S_I bz_compressEnd(); 00161 S_I bz_decompressEnd(); 00162 S_I bz_compress(S_I flag); 00163 S_I bz_decompress(S_I flag); 00164 void bz_set_next_in(const char *x); 00165 void bz_set_avail_in(U_I x); 00166 U_I bz_get_avail_in() const; 00167 U_64 bz_get_total_in() const; 00168 void bz_set_next_out(char *x); 00169 char *bz_get_next_out() const; 00170 void bz_set_avail_out(U_I x); 00171 U_I bz_get_avail_out() const; 00172 U_64 bz_get_total_out() const; 00173 #endif 00174 00175 // set of routines for liblzma 00176 #if LIBLZMA_AVAILABLE 00177 S_I lzma_compressInit(U_I compression_level); 00178 S_I lzma_decompressInit(); 00179 S_I lzma_end(); 00180 S_I lzma_encode(S_I flag); 00181 void lzma_set_next_in(const char *x); 00182 void lzma_set_avail_in(U_I x); 00183 U_I lzma_get_avail_in() const; 00184 U_64 lzma_get_total_in() const; 00185 void lzma_set_next_out(char *x); 00186 char *lzma_get_next_out() const; 00187 void lzma_set_avail_out(U_I x); 00188 U_I lzma_get_avail_out() const; 00189 U_64 lzma_get_total_out() const; 00190 #endif 00191 00192 }; 00193 00195 00196 } // end of namespace 00197 00198 #endif