Disk ARchive  2.5.0
Full featured and portable backup and archiving tool
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
libdar.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 
22  // NOTE : The following comments are used by doxygen to generate the documentation of reference
23 
35 
36 
45 
46 
54 
55 
59 
60 
61 
62 #ifndef LIBDAR_HPP
63 #define LIBDAR_HPP
64 
65 #include "../my_config.h"
66 
67 extern "C"
68 {
69 #if MUTEX_WORKS
70 #if HAVE_PTHREAD_H
71 #include <pthread.h>
72 #endif
73 #endif
74 }
75 
76 
77 #include <string>
78 #include "compressor.hpp"
79 #include "path.hpp"
80 #include "mask.hpp"
81 #include "integers.hpp"
82 #include "infinint.hpp"
83 #include "statistics.hpp"
84 #include "user_interaction.hpp"
85 #include "deci.hpp"
86 #include "archive.hpp"
87 #include "crypto.hpp"
88 #include "thread_cancellation.hpp"
90 #include "capabilities.hpp"
91 
94 
96 #define LIBDAR_XXXXXXXX
97 
99 #define LIBDAR_NOEXCEPT 0
100 #define LIBDAR_EMEMORY 1
102 #define LIBDAR_EBUG 2
104 #define LIBDAR_EINFININT 3
106 #define LIBDAR_ELIMITINT 4
108 #define LIBDAR_ERANGE 5
110 #define LIBDAR_EDECI 6
112 #define LIBDAR_EFEATURE 7
114 #define LIBDAR_EHARDWARE 8
116 #define LIBDAR_EUSER_ABORT 9
118 #define LIBDAR_EDATA 10
120 #define LIBDAR_ESCRIPT 11
122 #define LIBDAR_ELIBCALL 12
124 #define LIBDAR_UNKNOWN 13
126 #define LIBDAR_ECOMPILATION 14
128 #define LIBDAR_THREAD_CANCEL 15
130 
133 namespace libdar
134 {
137 
138 
145 
147  // LIBDAR INITIALIZATION METHODS //
148  // //
149  // A FUNCTION OF THE get_version*() FAMILY *MUST* BE CALLED //
150  // BEFORE ANY OTHER FUNCTION OF THIS LIBRARY //
151  // //
152  // CLIENT PROGRAM MUST CHECK THAT THE MAJOR NUMBER RETURNED //
153  // BY THIS CALL IS NOT GREATER THAN THE VERSION USED AT COMPILATION //
154  // TIME. IF SO, THE PROGRAM MUST ABORT AND RETURN A WARNING TO THE //
155  // USER TELLING THE DYNAMICALLY LINKED VERSION IS TOO RECENT AND NOT //
156  // COMPATIBLE WITH THIS SOFTWARE. THE MESSAGE MUST INVITE THE USER //
157  // TO UPGRADE HIS SOFTWARE WITH A MORE RECENT VERSION COMPATIBLE WITH //
158  // THIS LIBDAR RELEASE. //
160 
162 
171  extern void get_version(U_I & major, U_I & medium, U_I & minor, bool init_libgcrypt = true);
172 
174 
186  extern void get_version_noexcept(U_I & major, U_I & medium, U_I & minor, U_16 & exception, std::string & except_msg, bool init_libgcrypt = true);
187 
188 
190  // CLOSING/CLEANING LIBDAR //
192 
193  // while libdar has only a single boolean as global variable
194  // that defines whether the library is initialized or not
195  // it must proceed to mutex, and dependent libraries initializations
196  // (liblzo, libgcrypt, etc.), which is done during the get_version() call
197  // Some library also need to clear some data so the following call
198  // is provided in that aim and must be called when libdar will no more
199  // be used by the application.
200 
201  extern void close_and_clean();
202 
203 
205  // WRAPPER FUNCTIONS AROUND archive class methods to trap exceptions and convert them in error code and message
206  // these are intended for C program/programmers not enough confident with C++.
207  //
208  // FOR LIBDAR C++ APPLICATIONS, YOU WOULD RATHER USE THE archive C++ CLASS THAN THESE FOLLOWING WRAPPERS
209  //
211 
212 
214 
219  const path & chem, const std::string & basename,
220  const std::string & extension,
221  const archive_options_read & options,
222  U_16 & exception,
223  std::string & except_msg);
224 
225 
227 
232  const path & fs_root,
233  const path & sauv_path,
234  const std::string & filename,
235  const std::string & extension,
236  const archive_options_create & options,
237  statistics * progressive_report,
238  U_16 & exception,
239  std::string & except_msg);
240 
241 
242 
244 
249  archive *ptr,
250  const path &sauv_path,
251  const std::string & filename,
252  const std::string & extension,
253  const archive_options_isolate & options,
254  U_16 & exception,
255  std::string & except_msg);
256 
258 
263  const path & sauv_path,
264  archive *ref_arch1,
265  const std::string & filename,
266  const std::string & extension,
267  const archive_options_merge & options,
268  statistics * progressive_report,
269  U_16 & exception,
270  std::string & except_msg);
271 
272 
274 
278  extern void close_archive_noexcept(archive *ptr,
279  U_16 & exception,
280  std::string & except_msg);
281 
282 
284 
289  archive *ptr,
290  const path &fs_root,
291  const archive_options_extract & options,
292  statistics * progressive_report,
293  U_16 & exception,
294  std::string & except_msg);
295 
296 
298 
302  extern void op_listing_noexcept(user_interaction & dialog,
303  archive *ptr,
304  const archive_options_listing & options,
305  U_16 & exception,
306  std::string & except_msg);
307 
308 
310 
315  archive *ptr,
316  const path & fs_root,
317  const archive_options_diff & options,
318  statistics * progressive_report,
319  U_16 & exception,
320  std::string & except_msg);
321 
322 
324 
329  archive *ptr,
330  const archive_options_test & options,
331  statistics * progressive_report,
332  U_16 & exception,
333  std::string & except_msg);
334 
335 
337 
341  extern bool get_children_of_noexcept(user_interaction & dialog,
342  archive *ptr,
343  const std::string & dir,
344  U_16 & exception,
345  std::string & except_msg);
346 
347 
348 
350  // TOOLS ROUTINES //
352 
353 
355 
365  extern char *libdar_str2charptr_noexcept(const std::string & x, U_16 & exception, std::string & except_msg);
366 
368  // THREAD CANCELLATION ROUTINES //
370 
371 #if MUTEX_WORKS
372 
379  inline extern void cancel_thread(pthread_t tid, bool immediate = true, U_64 flag = 0) { thread_cancellation::cancel(tid, immediate, flag); }
380 
382 
385  inline extern bool cancel_status(pthread_t tid) { return thread_cancellation::cancel_status(tid); }
386 
388 
392  inline extern bool cancel_clear(pthread_t tid) { return thread_cancellation::clear_pending_request(tid); }
393 #endif
394 
395 
397 
398 } // end of namespace
399 
400 #endif
archive * open_archive_noexcept(user_interaction &dialog, const path &chem, const std::string &basename, const std::string &extension, const archive_options_read &options, U_16 &exception, std::string &except_msg)
this is a wrapper around the archive constructor known as the &quot;read&quot; constructor
void get_version(U_I &major, U_I &medium, U_I &minor, bool init_libgcrypt=true)
return the libdar version, and make libdar initialization (may throw Exceptions)
are defined here basic integer types that tend to be portable
the archive class is defined in this module
const U_I LIBDAR_COMPILE_TIME_MINOR
libdar Minor version defined at compilation time
Definition: libdar.hpp:144
class holding optional parameters used to test the structure coherence of an existing archive ...
This is a pure virtual class that is used by libdar when interaction with the user is required...
nested namespace containing routines that give features activated at compile time ...
the crypto algoritm definition
archive * isolate_archive_noexcept(user_interaction &dialog, archive *ptr, const path &sauv_path, const std::string &filename, const std::string &extension, const archive_options_isolate &options, U_16 &exception, std::string &except_msg)
this is a wrapper around the archive constructor known as the &quot;isolate&quot; constructor ...
const U_I LIBDAR_COMPILE_TIME_MAJOR
libdar Major version defined at compilation time
Definition: libdar.hpp:140
void close_archive_noexcept(archive *ptr, U_16 &exception, std::string &except_msg)
this is wrapper around the archive destructor
the archive class realizes the most general operations on archives
Definition: archive.hpp:56
void op_listing_noexcept(user_interaction &dialog, archive *ptr, const archive_options_listing &options, U_16 &exception, std::string &except_msg)
this is wrapper around the op_listing method
defines the interaction between libdar and the user.Three classes are defined
statistics op_extract_noexcept(user_interaction &dialog, archive *ptr, const path &fs_root, const archive_options_extract &options, statistics *progressive_report, U_16 &exception, std::string &except_msg)
this is wrapper around the op_extract method
here is the definition of the path classthe path class handle path and provide several operation on t...
archive * merge_archive_noexcept(user_interaction &dialog, const path &sauv_path, archive *ref_arch1, const std::string &filename, const std::string &extension, const archive_options_merge &options, statistics *progressive_report, U_16 &exception, std::string &except_msg)
this is a wrapper around the archive constructor known as the &quot;merging&quot; constructor ...
handle the statistic structure that gives a summary of treated files after each operatio ...
archive * create_archive_noexcept(user_interaction &dialog, const path &fs_root, const path &sauv_path, const std::string &filename, const std::string &extension, const archive_options_create &options, statistics *progressive_report, U_16 &exception, std::string &except_msg)
this is a wrapper around the archive constructor known as the &quot;create&quot; constructor ...
to be able to cancel libdar operation while running in a given thread.the class thread_cancellation i...
char * libdar_str2charptr_noexcept(const std::string &x, U_16 &exception, std::string &except_msg)
routine provided to convert std::string to char *
class holding optional parameters used to extract files from an existing archive
switch module to limitint (32 ou 64 bits integers) or infinint
here lies a collection of mask classes
manages the decimal representation of infinint
statistics op_test_noexcept(user_interaction &dialog, archive *ptr, const archive_options_test &options, statistics *progressive_report, U_16 &exception, std::string &except_msg)
this is wrapper around the op_test method
compression engine implementation
class holding optional parameters used to list the contents of an existing archive ...
statistics op_diff_noexcept(user_interaction &dialog, archive *ptr, const path &fs_root, const archive_options_diff &options, statistics *progressive_report, U_16 &exception, std::string &except_msg)
this is wrapper around the op_diff method
provide information about current thread (underlying using the widthdrawn POSIX.1e API) ...
const U_I LIBDAR_COMPILE_TIME_MEDIUM
libdar Medium version defined at compilation time
Definition: libdar.hpp:142
bool get_children_of_noexcept(user_interaction &dialog, archive *ptr, const std::string &dir, U_16 &exception, std::string &except_msg)
this is wrapper around the get_children_of method
class holding optional parameters used to read an existing archive
class holding optional parameters used to proceed to the merge operation
class holding optional parameters used to create an archive
class holding optional parameters used to isolate an existing archive
structure returned by libdar call to give a summary of the operation done in term of file treated ...
Definition: statistics.hpp:68
the class path is here to manipulate paths in the Unix notation: using&#39;/&#39;
Definition: path.hpp:50
void get_version_noexcept(U_I &major, U_I &medium, U_I &minor, U_16 &exception, std::string &except_msg, bool init_libgcrypt=true)
return the libdar version, and make libdar initialization (does not throw exceptions) ...