Disk ARchive  2.5.13
Full featured and portable backup and archiving tool
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 
34 
35 
44 
45 
53 
54 
58 
59 
60 
61 #ifndef LIBDAR_HPP
62 #define LIBDAR_HPP
63 
64 #include "../my_config.h"
65 
66 extern "C"
67 {
68 #if MUTEX_WORKS
69 #if HAVE_PTHREAD_H
70 #include <pthread.h>
71 #endif
72 #endif
73 }
74 
75 
76 #include <string>
77 #include "compressor.hpp"
78 #include "path.hpp"
79 #include "mask.hpp"
80 #include "integers.hpp"
81 #include "infinint.hpp"
82 #include "statistics.hpp"
83 #include "user_interaction.hpp"
84 #include "deci.hpp"
85 #include "archive.hpp"
86 #include "crypto.hpp"
87 #include "thread_cancellation.hpp"
89 #include "capabilities.hpp"
90 
93 
95 #define LIBDAR_XXXXXXXX
96 
98 #define LIBDAR_NOEXCEPT 0
99 #define LIBDAR_EMEMORY 1
101 #define LIBDAR_EBUG 2
103 #define LIBDAR_EINFININT 3
105 #define LIBDAR_ELIMITINT 4
107 #define LIBDAR_ERANGE 5
109 #define LIBDAR_EDECI 6
111 #define LIBDAR_EFEATURE 7
113 #define LIBDAR_EHARDWARE 8
115 #define LIBDAR_EUSER_ABORT 9
117 #define LIBDAR_EDATA 10
119 #define LIBDAR_ESCRIPT 11
121 #define LIBDAR_ELIBCALL 12
123 #define LIBDAR_UNKNOWN 13
125 #define LIBDAR_ECOMPILATION 14
127 #define LIBDAR_THREAD_CANCEL 15
129 
132 namespace libdar
133 {
136 
137 
144 
146  // LIBDAR INITIALIZATION METHODS //
147  // //
148  // A FUNCTION OF THE get_version*() FAMILY *MUST* BE CALLED //
149  // BEFORE ANY OTHER FUNCTION OF THIS LIBRARY //
150  // //
151  // CLIENT PROGRAM MUST CHECK THAT THE MAJOR NUMBER RETURNED //
152  // BY THIS CALL IS NOT GREATER THAN THE VERSION USED AT COMPILATION //
153  // TIME. IF SO, THE PROGRAM MUST ABORT AND RETURN A WARNING TO THE //
154  // USER TELLING THE DYNAMICALLY LINKED VERSION IS TOO RECENT AND NOT //
155  // COMPATIBLE WITH THIS SOFTWARE. THE MESSAGE MUST INVITE THE USER //
156  // TO UPGRADE HIS SOFTWARE WITH A MORE RECENT VERSION COMPATIBLE WITH //
157  // THIS LIBDAR RELEASE. //
159 
161 
170  extern void get_version(U_I & major, U_I & medium, U_I & minor, bool init_libgcrypt = true);
171 
173 
185  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);
186 
187 
189  // CLOSING/CLEANING LIBDAR //
191 
192  // while libdar has only a single boolean as global variable
193  // that defines whether the library is initialized or not
194  // it must proceed to mutex, and dependent libraries initializations
195  // (liblzo, libgcrypt, etc.), which is done during the get_version() call
196  // Some library also need to clear some data so the following call
197  // is provided in that aim and must be called when libdar will no more
198  // be used by the application.
199 
200  extern void close_and_clean();
201 
202 
204  // WRAPPER FUNCTIONS AROUND archive class methods to trap exceptions and convert them in error code and message
205  // these are intended for C program/programmers not enough confident with C++.
206  //
207  // FOR LIBDAR C++ APPLICATIONS, YOU WOULD RATHER USE THE archive C++ CLASS THAN THESE FOLLOWING WRAPPERS
208  //
210 
211 
213 
218  const path & chem, const std::string & basename,
219  const std::string & extension,
220  const archive_options_read & options,
221  U_16 & exception,
222  std::string & except_msg);
223 
224 
226 
231  const path & fs_root,
232  const path & sauv_path,
233  const std::string & filename,
234  const std::string & extension,
235  const archive_options_create & options,
236  statistics * progressive_report,
237  U_16 & exception,
238  std::string & except_msg);
239 
240 
241 
243 
248  archive *ptr,
249  const path &sauv_path,
250  const std::string & filename,
251  const std::string & extension,
252  const archive_options_isolate & options,
253  U_16 & exception,
254  std::string & except_msg);
255 
257 
262  const path & sauv_path,
263  archive *ref_arch1,
264  const std::string & filename,
265  const std::string & extension,
266  const archive_options_merge & options,
267  statistics * progressive_report,
268  U_16 & exception,
269  std::string & except_msg);
270 
271 
273 
277  extern void close_archive_noexcept(archive *ptr,
278  U_16 & exception,
279  std::string & except_msg);
280 
281 
283 
288  archive *ptr,
289  const path &fs_root,
290  const archive_options_extract & options,
291  statistics * progressive_report,
292  U_16 & exception,
293  std::string & except_msg);
294 
295 
297 
301  extern void op_listing_noexcept(user_interaction & dialog,
302  archive *ptr,
303  const archive_options_listing & options,
304  U_16 & exception,
305  std::string & except_msg);
306 
307 
309 
314  archive *ptr,
315  const path & fs_root,
316  const archive_options_diff & options,
317  statistics * progressive_report,
318  U_16 & exception,
319  std::string & except_msg);
320 
321 
323 
328  archive *ptr,
329  const archive_options_test & options,
330  statistics * progressive_report,
331  U_16 & exception,
332  std::string & except_msg);
333 
334 
336 
340  extern bool get_children_of_noexcept(user_interaction & dialog,
341  archive *ptr,
342  const std::string & dir,
343  U_16 & exception,
344  std::string & except_msg);
345 
346 
347 
349  // TOOLS ROUTINES //
351 
352 
354 
364  extern char *libdar_str2charptr_noexcept(const std::string & x, U_16 & exception, std::string & except_msg);
365 
367  // THREAD CANCELLATION ROUTINES //
369 
370 #if MUTEX_WORKS
371 
378  inline extern void cancel_thread(pthread_t tid, bool immediate = true, U_64 flag = 0) { thread_cancellation::cancel(tid, immediate, flag); }
379 
381 
384  inline extern bool cancel_status(pthread_t tid) { return thread_cancellation::cancel_status(tid); }
385 
387 
391  inline extern bool cancel_clear(pthread_t tid) { return thread_cancellation::clear_pending_request(tid); }
392 #endif
393 
394 
396 
397 } // end of namespace
398 
399 #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 "read" 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:143
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 "isolate" constructor ...
const U_I LIBDAR_COMPILE_TIME_MAJOR
libdar Major version defined at compilation time
Definition: libdar.hpp:139
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 "merging" 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 "create" 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:141
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
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
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) ...