Disk ARchive  2.4.5
 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 // $Id: libdar.hpp,v 1.70.2.5 2012/04/15 10:36:44 edrusb Exp $
22 //
23 /*********************************************************************/
24 //
25 
26  // NOTE : The following comments are used by doxygen to generate the documentation of reference
27 
39 
40 
49 
50 
58 
59 
63 
64 
65 
66 #ifndef LIBDAR_HPP
67 #define LIBDAR_HPP
68 
69 #include "../my_config.h"
70 
71 extern "C"
72 {
73 #if MUTEX_WORKS
74 #if HAVE_PTHREAD_H
75 #include <pthread.h>
76 #endif
77 #endif
78 }
79 
80 
81 #include <string>
82 #include "compressor.hpp"
83 #include "path.hpp"
84 #include "mask.hpp"
85 #include "integers.hpp"
86 #include "infinint.hpp"
87 #include "statistics.hpp"
88 #include "user_interaction.hpp"
89 #include "deci.hpp"
90 #include "archive.hpp"
91 #include "crypto.hpp"
92 #include "thread_cancellation.hpp"
94 
97 
99 #define LIBDAR_XXXXXXXX
100 
102 #define LIBDAR_NOEXCEPT 0
103 
104 #define LIBDAR_EMEMORY 1
105 
106 #define LIBDAR_EBUG 2
107 
108 #define LIBDAR_EINFININT 3
109 
110 #define LIBDAR_ELIMITINT 4
111 
112 #define LIBDAR_ERANGE 5
113 
114 #define LIBDAR_EDECI 6
115 
116 #define LIBDAR_EFEATURE 7
117 
118 #define LIBDAR_EHARDWARE 8
119 
120 #define LIBDAR_EUSER_ABORT 9
121 
122 #define LIBDAR_EDATA 10
123 
124 #define LIBDAR_ESCRIPT 11
125 
126 #define LIBDAR_ELIBCALL 12
127 
128 #define LIBDAR_UNKNOWN 13
129 
130 #define LIBDAR_ECOMPILATION 14
131 
132 #define LIBDAR_THREAD_CANCEL 15
133 
134 
136 namespace libdar
137 {
140 
141 
148 
150  // LIBDAR INITIALIZATION METHODS //
151  // //
152  // A FUNCTION OF THE get_version*() FAMILY *MUST* BE CALLED //
153  // BEFORE ANY OTHER FUNCTION OF THIS LIBRARY //
154  // //
155  // CLIENT PROGRAM MUST CHECK THAT THE MAJOR NUMBER RETURNED //
156  // BY THIS CALL IS NOT GREATER THAN THE VERSION USED AT COMPILATION //
157  // TIME. IF SO, THE PROGRAM MUST ABORT AND RETURN A WARNING TO THE //
158  // USER TELLING THE DYNAMICALLY LINKED VERSION IS TOO RECENT AND NOT //
159  // COMPATIBLE WITH THIS SOFTWARE. THE MESSAGE MUST INVITE THE USER //
160  // TO UPGRADE HIS SOFTWARE WITH A MORE RECENT VERSION COMPATIBLE WITH //
161  // THIS LIBDAR RELEASE. //
163 
165 
174  extern void get_version(U_I & major, U_I & medium, U_I & minor, bool init_libgcrypt = true);
175 
177 
189  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);
190 
191 
193  // CLOSING/CLEANING LIBDAR //
195 
196  // while libdar has only a single boolean as global variable
197  // that defines whether the library is initialized or not
198  // it must proceed to mutex, and dependent libraries initializations
199  // (liblzo, libgcrypt, etc.), which is done during the get_version() call
200  // Some library also need to clear some data so the following call
201  // is provided in that aim and must be called when libdar will no more
202  // be used by the application.
203 
204  extern void close_and_clean();
205 
206 
208  // WRAPPER FUNCTIONS AROUND archive class methods to trap exceptions and convert them in error code and message
209  // these are intended for C program/programmers not enough confident with C++.
210  //
211  // FOR LIBDAR C++ APPLICATIONS, YOU WOULD RATHER USE THE archive C++ CLASS THAN THESE FOLLOWING WRAPPERS
212  //
214 
215 
217 
222  const path & chem, const std::string & basename,
223  const std::string & extension,
224  const archive_options_read & options,
225  U_16 & exception,
226  std::string & except_msg);
227 
228 
230 
235  const path & fs_root,
236  const path & sauv_path,
237  const std::string & filename,
238  const std::string & extension,
239  const archive_options_create & options,
240  statistics * progressive_report,
241  U_16 & exception,
242  std::string & except_msg);
243 
244 
245 
247 
252  const path &sauv_path,
253  archive *ref_arch,
254  const std::string & filename,
255  const std::string & extension,
256  const archive_options_isolate & options,
257  U_16 & exception,
258  std::string & except_msg);
259 
261 
266  const path & sauv_path,
267  archive *ref_arch1,
268  const std::string & filename,
269  const std::string & extension,
270  const archive_options_merge & options,
271  statistics * progressive_report,
272  U_16 & exception,
273  std::string & except_msg);
274 
275 
277 
281  extern void close_archive_noexcept(archive *ptr,
282  U_16 & exception,
283  std::string & except_msg);
284 
285 
287 
292  archive *ptr,
293  const path &fs_root,
294  const archive_options_extract & options,
295  statistics * progressive_report,
296  U_16 & exception,
297  std::string & except_msg);
298 
299 
301 
305  extern void op_listing_noexcept(user_interaction & dialog,
306  archive *ptr,
307  const archive_options_listing & options,
308  U_16 & exception,
309  std::string & except_msg);
310 
311 
313 
318  archive *ptr,
319  const path & fs_root,
320  const archive_options_diff & options,
321  statistics * progressive_report,
322  U_16 & exception,
323  std::string & except_msg);
324 
325 
327 
332  archive *ptr,
333  const archive_options_test & options,
334  statistics * progressive_report,
335  U_16 & exception,
336  std::string & except_msg);
337 
338 
340 
344  extern bool get_children_of_noexcept(user_interaction & dialog,
345  archive *ptr,
346  const std::string & dir,
347  U_16 & exception,
348  std::string & except_msg);
349 
350 
351 
353  // TOOLS ROUTINES //
355 
356 
358 
368  extern char *libdar_str2charptr_noexcept(const std::string & x, U_16 & exception, std::string & except_msg);
369 
371  // THREAD CANCELLATION ROUTINES //
373 
374 #if MUTEX_WORKS
375 
376 
382  inline extern void cancel_thread(pthread_t tid, bool immediate = true, U_64 flag = 0) { thread_cancellation::cancel(tid, immediate, flag); }
383 
385 
388  inline extern bool cancel_status(pthread_t tid) { return thread_cancellation::cancel_status(tid); }
389 
391 
395  inline extern bool cancel_clear(pthread_t tid) { return thread_cancellation::clear_pending_request(tid); }
396 #endif
397 
398 
400 
401 } // end of namespace
402 
403 #endif