| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

wrapperlib.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
29
30 #ifndef WRAPPERLIB_HPP
31 #define WRAPPERLIB_HPP
32
33 #include "../my_config.h"
34
35 extern "C"
36 {
37 #if HAVE_ZLIB_H && LIBZ_AVAILABLE
38 #include <zlib.h>
39 #endif
40
41 #if HAVE_BZLIB_H && LIBBZ2_AVAILABLE
42 #include <bzlib.h>
43 #endif
44
45 #if HAVE_LZMA_H && LIBLZMA_AVAILABLE
46 #include <lzma.h>
47 #endif
48 } // end extern "C"
49
50 #include "integers.hpp"
51 #include "on_pool.hpp"
52
53 namespace libdar
54 {
55
58
59 const int WR_OK = 0;
60 const int WR_MEM_ERROR = 1;
61 const int WR_VERSION_ERROR = 2;
62 const int WR_STREAM_ERROR = 3;
63 const int WR_DATA_ERROR = 4;
64 const int WR_NO_FLUSH = 5;
65 const int WR_BUF_ERROR = 6;
66 const int WR_STREAM_END = 7;
67 const int WR_FINISH = 8;
68
69 enum wrapperlib_mode { zlib_mode, bzlib_mode, xz_mode };
70
72
76
77 class wrapperlib : public on_pool
78 {
79 public:
80 wrapperlib(wrapperlib_mode mode);
81 wrapperlib(const wrapperlib & ref);
82 const wrapperlib & operator = (const wrapperlib & ref);
83 ~wrapperlib();
84
85 void set_next_in(const char *x) { return (this->*x_set_next_in)(x); };
86 void set_avail_in(U_I x) { return (this->*x_set_avail_in)(x); };
87 U_I get_avail_in() const { return (this->*x_get_avail_in)(); };
88 U_64 get_total_in() const { return (this->*x_get_total_in)(); };
89
90 void set_next_out(char *x) { return (this->*x_set_next_out)(x); };
91 char *get_next_out() const { return (this->*x_get_next_out)(); };
92 void set_avail_out(U_I x) { return (this->*x_set_avail_out)(x); };
93 U_I get_avail_out() const { return (this->*x_get_avail_out)(); };
94 U_64 get_total_out() const { return (this->*x_get_total_out)(); };
95
96 S_I compressInit(U_I compression_level) { level = compression_level; return (this->*x_compressInit)(compression_level); };
97 S_I decompressInit() { return (this->*x_decompressInit)(); };
98 S_I compressEnd() { return (this->*x_compressEnd)(); };
99 S_I decompressEnd() { return (this->*x_decompressEnd)(); };
100 S_I compress(S_I flag) { return (this->*x_compress)(flag); };
101 S_I decompress(S_I flag) { return (this->*x_decompress)(flag);};
102 S_I compressReset();
103 S_I decompressReset();
104
105 private:
106 #if LIBZ_AVAILABLE
107 z_stream *z_ptr;
108 #endif
109 #if LIBBZ2_AVAILABLE
110 bz_stream *bz_ptr;
111 #endif
112 #if LIBLZMA_AVAILABLE
113 lzma_stream *lzma_ptr;
114 #endif
115
116 S_I level;
117
118 void (wrapperlib::*x_set_next_in)(const char *x);
119 void (wrapperlib::*x_set_avail_in)(U_I x);
120 U_I (wrapperlib::*x_get_avail_in)() const;
121 U_64 (wrapperlib::*x_get_total_in)() const;
122
123 void (wrapperlib::*x_set_next_out)(char *x);
124 char *(wrapperlib::*x_get_next_out)() const;
125 void (wrapperlib::*x_set_avail_out)(U_I x);
126 U_I (wrapperlib::*x_get_avail_out)() const;
127 U_64 (wrapperlib::*x_get_total_out)() const;
128
129 S_I (wrapperlib::*x_compressInit)(U_I compression_level);
130 S_I (wrapperlib::*x_decompressInit)();
131 S_I (wrapperlib::*x_compressEnd)();
132 S_I (wrapperlib::*x_decompressEnd)();
133 S_I (wrapperlib::*x_compress)(S_I flag);
134 S_I (wrapperlib::*x_decompress)(S_I flag);
135
136
137 // set of routines for zlib
138 #if LIBZ_AVAILABLE
139 S_I z_compressInit(U_I compression_level);
140 S_I z_decompressInit();
141 S_I z_compressEnd();
142 S_I z_decompressEnd();
143 S_I z_compress(S_I flag);
144 S_I z_decompress(S_I flag);
145 void z_set_next_in(const char *x);
146 void z_set_avail_in(U_I x);
147 U_I z_get_avail_in() const;
148 U_64 z_get_total_in() const;
149 void z_set_next_out(char *x);
150 char *z_get_next_out() const;
151 void z_set_avail_out(U_I x);
152 U_I z_get_avail_out() const;
153 U_64 z_get_total_out() const;
154 #endif
155
156 // set of routines for bzlib
157 #if LIBBZ2_AVAILABLE
158 S_I bz_compressInit(U_I compression_level);
159 S_I bz_decompressInit();
160 S_I bz_compressEnd();
161 S_I bz_decompressEnd();
162 S_I bz_compress(S_I flag);
163 S_I bz_decompress(S_I flag);
164 void bz_set_next_in(const char *x);
165 void bz_set_avail_in(U_I x);
166 U_I bz_get_avail_in() const;
167 U_64 bz_get_total_in() const;
168 void bz_set_next_out(char *x);
169 char *bz_get_next_out() const;
170 void bz_set_avail_out(U_I x);
171 U_I bz_get_avail_out() const;
172 U_64 bz_get_total_out() const;
173 #endif
174
175 // set of routines for liblzma
176 #if LIBLZMA_AVAILABLE
177 S_I lzma_compressInit(U_I compression_level);
178 S_I lzma_decompressInit();
179 S_I lzma_end();
180 S_I lzma_encode(S_I flag);
181 void lzma_set_next_in(const char *x);
182 void lzma_set_avail_in(U_I x);
183 U_I lzma_get_avail_in() const;
184 U_64 lzma_get_total_in() const;
185 void lzma_set_next_out(char *x);
186 char *lzma_get_next_out() const;
187 void lzma_set_avail_out(U_I x);
188 U_I lzma_get_avail_out() const;
189 U_64 lzma_get_total_out() const;
190 #endif
191
192 };
193
195
196 } // end of namespace
197
198 #endif
libdar::on_pool
Definition: on_pool.hpp:52
integers.hpp
are defined here basic integer types that tend to be portable
libdar::wrapperlib
this class encapsulates calls to libz or libbz2
Definition: wrapperlib.hpp:77
on_pool.hpp
this is the base class of object that can be allocated on a memory pool
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47