Disk ARchive  2.4.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
wrapperlib.hpp
Go to the documentation of this file.
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 } // end extern "C"
00045 
00046 #include "integers.hpp"
00047 
00048 namespace libdar
00049 {
00050 
00053 
00054     const int WR_OK            = 0;
00055     const int WR_MEM_ERROR     = 1;
00056     const int WR_VERSION_ERROR = 2;
00057     const int WR_STREAM_ERROR  = 3;
00058     const int WR_DATA_ERROR    = 4;
00059     const int WR_NO_FLUSH      = 5;
00060     const int WR_BUF_ERROR     = 6;
00061     const int WR_STREAM_END    = 7;
00062     const int WR_FINISH        = 8;
00063 
00064     enum wrapperlib_mode { zlib_mode, bzlib_mode };
00065 
00067 
00071 
00072     class wrapperlib
00073     {
00074     public:
00075         wrapperlib(wrapperlib_mode mode);
00076         wrapperlib(const wrapperlib & ref);
00077         const wrapperlib & operator = (const wrapperlib & ref);
00078         ~wrapperlib();
00079 
00080         void set_next_in(const char *x) { return (this->*x_set_next_in)(x); };
00081         void set_avail_in(U_I x) { return (this->*x_set_avail_in)(x); };
00082         U_I get_avail_in() const { return (this->*x_get_avail_in)(); };
00083         U_64 get_total_in() const { return (this->*x_get_total_in)(); };
00084 
00085         void set_next_out(char *x) { return (this->*x_set_next_out)(x); };
00086         char *get_next_out() const { return (this->*x_get_next_out)(); };
00087         void set_avail_out(U_I x) { return (this->*x_set_avail_out)(x); };
00088         U_I get_avail_out() const { return (this->*x_get_avail_out)(); };
00089         U_64 get_total_out() const { return (this->*x_get_total_out)(); };
00090 
00091         S_I compressInit(U_I compression_level) { level = compression_level; return (this->*x_compressInit)(compression_level); };
00092         S_I decompressInit() { return (this->*x_decompressInit)(); };
00093         S_I compressEnd() { return (this->*x_compressEnd)(); };
00094         S_I decompressEnd() { return (this->*x_decompressEnd)(); };
00095         S_I compress(S_I flag) { return (this->*x_compress)(flag); };
00096         S_I decompress(S_I flag) { return (this->*x_decompress)(flag);};
00097         S_I compressReset();
00098         S_I decompressReset();
00099 
00100     private:
00101 #if LIBZ_AVAILABLE
00102         z_stream *z_ptr;
00103 #endif
00104 #if LIBBZ2_AVAILABLE
00105         bz_stream *bz_ptr;
00106 #endif
00107         S_I level;
00108 
00109         void (wrapperlib::*x_set_next_in)(const char *x);
00110         void (wrapperlib::*x_set_avail_in)(U_I x);
00111         U_I (wrapperlib::*x_get_avail_in)() const;
00112         U_64 (wrapperlib::*x_get_total_in)() const;
00113 
00114         void (wrapperlib::*x_set_next_out)(char *x);
00115         char *(wrapperlib::*x_get_next_out)() const;
00116         void (wrapperlib::*x_set_avail_out)(U_I x);
00117         U_I (wrapperlib::*x_get_avail_out)() const;
00118         U_64 (wrapperlib::*x_get_total_out)() const;
00119 
00120         S_I (wrapperlib::*x_compressInit)(U_I compression_level);
00121         S_I (wrapperlib::*x_decompressInit)();
00122         S_I (wrapperlib::*x_compressEnd)();
00123         S_I (wrapperlib::*x_decompressEnd)();
00124         S_I (wrapperlib::*x_compress)(S_I flag);
00125         S_I (wrapperlib::*x_decompress)(S_I flag);
00126 
00127 
00128             // set of routines for zlib
00129 #if LIBZ_AVAILABLE
00130         S_I z_compressInit(U_I compression_level);
00131         S_I z_decompressInit();
00132         S_I z_compressEnd();
00133         S_I z_decompressEnd();
00134         S_I z_compress(S_I flag);
00135         S_I z_decompress(S_I flag);
00136         void z_set_next_in(const char *x);
00137         void z_set_avail_in(U_I x);
00138         U_I z_get_avail_in() const;
00139         U_64 z_get_total_in() const;
00140         void z_set_next_out(char *x);
00141         char *z_get_next_out() const;
00142         void z_set_avail_out(U_I x);
00143         U_I z_get_avail_out() const;
00144         U_64 z_get_total_out() const;
00145 #endif
00146 
00147             // set of routines for bzlib
00148 #if LIBBZ2_AVAILABLE
00149         S_I bz_compressInit(U_I compression_level);
00150         S_I bz_decompressInit();
00151         S_I bz_compressEnd();
00152         S_I bz_decompressEnd();
00153         S_I bz_compress(S_I flag);
00154         S_I bz_decompress(S_I flag);
00155         void bz_set_next_in(const char *x);
00156         void bz_set_avail_in(U_I x);
00157         U_I bz_get_avail_in() const;
00158         U_64 bz_get_total_in() const;
00159         void bz_set_next_out(char *x);
00160         char *bz_get_next_out() const;
00161         void bz_set_avail_out(U_I x);
00162         U_I bz_get_avail_out() const;
00163         U_64 bz_get_total_out() const;
00164 #endif
00165     };
00166 
00168 
00169 } // end of namespace
00170 
00171 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines