![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 00022 // NOTE : The following comments are used by doxygen to generate the documentation of reference 00023 00034 00035 00044 00045 00053 00054 00058 00059 00060 00061 #ifndef LIBDAR_HPP 00062 #define LIBDAR_HPP 00063 00064 #include "../my_config.h" 00065 00066 extern "C" 00067 { 00068 #if MUTEX_WORKS 00069 #if HAVE_PTHREAD_H 00070 #include <pthread.h> 00071 #endif 00072 #endif 00073 } 00074 00075 00076 #include <string> 00077 #include "compressor.hpp" 00078 #include "path.hpp" 00079 #include "mask.hpp" 00080 #include "integers.hpp" 00081 #include "infinint.hpp" 00082 #include "statistics.hpp" 00083 #include "user_interaction.hpp" 00084 #include "deci.hpp" 00085 #include "archive.hpp" 00086 #include "crypto.hpp" 00087 #include "thread_cancellation.hpp" 00088 #include "compile_time_features.hpp" 00089 #include "capabilities.hpp" 00090 00093 00095 #define LIBDAR_XXXXXXXX 00096 00098 #define LIBDAR_NOEXCEPT 0 00099 00100 #define LIBDAR_EMEMORY 1 00101 00102 #define LIBDAR_EBUG 2 00103 00104 #define LIBDAR_EINFININT 3 00105 00106 #define LIBDAR_ELIMITINT 4 00107 00108 #define LIBDAR_ERANGE 5 00109 00110 #define LIBDAR_EDECI 6 00111 00112 #define LIBDAR_EFEATURE 7 00113 00114 #define LIBDAR_EHARDWARE 8 00115 00116 #define LIBDAR_EUSER_ABORT 9 00117 00118 #define LIBDAR_EDATA 10 00119 00120 #define LIBDAR_ESCRIPT 11 00121 00122 #define LIBDAR_ELIBCALL 12 00123 00124 #define LIBDAR_UNKNOWN 13 00125 00126 #define LIBDAR_ECOMPILATION 14 00127 00128 #define LIBDAR_THREAD_CANCEL 15 00129 00130 00132 namespace libdar 00133 { 00136 00137 00139 const U_I LIBDAR_COMPILE_TIME_MAJOR = 5; 00141 const U_I LIBDAR_COMPILE_TIME_MEDIUM = 7; 00143 const U_I LIBDAR_COMPILE_TIME_MINOR = 2; 00144 00146 // LIBDAR INITIALIZATION METHODS // 00147 // // 00148 // A FUNCTION OF THE get_version*() FAMILY *MUST* BE CALLED // 00149 // BEFORE ANY OTHER FUNCTION OF THIS LIBRARY // 00150 // // 00151 // CLIENT PROGRAM MUST CHECK THAT THE MAJOR NUMBER RETURNED // 00152 // BY THIS CALL IS NOT GREATER THAN THE VERSION USED AT COMPILATION // 00153 // TIME. IF SO, THE PROGRAM MUST ABORT AND RETURN A WARNING TO THE // 00154 // USER TELLING THE DYNAMICALLY LINKED VERSION IS TOO RECENT AND NOT // 00155 // COMPATIBLE WITH THIS SOFTWARE. THE MESSAGE MUST INVITE THE USER // 00156 // TO UPGRADE HIS SOFTWARE WITH A MORE RECENT VERSION COMPATIBLE WITH // 00157 // THIS LIBDAR RELEASE. // 00159 00161 00170 extern void get_version(U_I & major, U_I & medium, U_I & minor, bool init_libgcrypt = true); 00171 00173 00185 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); 00186 00187 00189 // CLOSING/CLEANING LIBDAR // 00191 00192 // while libdar has only a single boolean as global variable 00193 // that defines whether the library is initialized or not 00194 // it must proceed to mutex, and dependent libraries initializations 00195 // (liblzo, libgcrypt, etc.), which is done during the get_version() call 00196 // Some library also need to clear some data so the following call 00197 // is provided in that aim and must be called when libdar will no more 00198 // be used by the application. 00199 00200 extern void close_and_clean(); 00201 00202 00204 // WRAPPER FUNCTIONS AROUND archive class methods to trap exceptions and convert them in error code and message 00205 // these are intended for C program/programmers not enough confident with C++. 00206 // 00207 // FOR LIBDAR C++ APPLICATIONS, YOU WOULD RATHER USE THE archive C++ CLASS THAN THESE FOLLOWING WRAPPERS 00208 // 00210 00211 00213 00217 extern archive* open_archive_noexcept(user_interaction & dialog, 00218 const path & chem, const std::string & basename, 00219 const std::string & extension, 00220 const archive_options_read & options, 00221 U_16 & exception, 00222 std::string & except_msg); 00223 00224 00226 00230 extern archive *create_archive_noexcept(user_interaction & dialog, 00231 const path & fs_root, 00232 const path & sauv_path, 00233 const std::string & filename, 00234 const std::string & extension, 00235 const archive_options_create & options, 00236 statistics * progressive_report, 00237 U_16 & exception, 00238 std::string & except_msg); 00239 00240 00241 00243 00247 extern archive *isolate_archive_noexcept(user_interaction & dialog, 00248 archive *ptr, 00249 const path &sauv_path, 00250 const std::string & filename, 00251 const std::string & extension, 00252 const archive_options_isolate & options, 00253 U_16 & exception, 00254 std::string & except_msg); 00255 00257 00261 extern archive *merge_archive_noexcept(user_interaction & dialog, 00262 const path & sauv_path, 00263 archive *ref_arch1, 00264 const std::string & filename, 00265 const std::string & extension, 00266 const archive_options_merge & options, 00267 statistics * progressive_report, 00268 U_16 & exception, 00269 std::string & except_msg); 00270 00271 00273 00277 extern void close_archive_noexcept(archive *ptr, 00278 U_16 & exception, 00279 std::string & except_msg); 00280 00281 00283 00287 extern statistics op_extract_noexcept(user_interaction & dialog, 00288 archive *ptr, 00289 const path &fs_root, 00290 const archive_options_extract & options, 00291 statistics * progressive_report, 00292 U_16 & exception, 00293 std::string & except_msg); 00294 00295 00297 00301 extern void op_listing_noexcept(user_interaction & dialog, 00302 archive *ptr, 00303 const archive_options_listing & options, 00304 U_16 & exception, 00305 std::string & except_msg); 00306 00307 00309 00313 extern statistics op_diff_noexcept(user_interaction & dialog, 00314 archive *ptr, 00315 const path & fs_root, 00316 const archive_options_diff & options, 00317 statistics * progressive_report, 00318 U_16 & exception, 00319 std::string & except_msg); 00320 00321 00323 00327 extern statistics op_test_noexcept(user_interaction & dialog, 00328 archive *ptr, 00329 const archive_options_test & options, 00330 statistics * progressive_report, 00331 U_16 & exception, 00332 std::string & except_msg); 00333 00334 00336 00340 extern bool get_children_of_noexcept(user_interaction & dialog, 00341 archive *ptr, 00342 const std::string & dir, 00343 U_16 & exception, 00344 std::string & except_msg); 00345 00346 00347 00349 // TOOLS ROUTINES // 00351 00352 00354 00364 extern char *libdar_str2charptr_noexcept(const std::string & x, U_16 & exception, std::string & except_msg); 00365 00367 // THREAD CANCELLATION ROUTINES // 00369 00370 #if MUTEX_WORKS 00371 00372 00378 inline extern void cancel_thread(pthread_t tid, bool immediate = true, U_64 flag = 0) { thread_cancellation::cancel(tid, immediate, flag); } 00379 00381 00384 inline extern bool cancel_status(pthread_t tid) { return thread_cancellation::cancel_status(tid); } 00385 00387 00391 inline extern bool cancel_clear(pthread_t tid) { return thread_cancellation::clear_pending_request(tid); } 00392 #endif 00393 00394 00396 00397 } // end of namespace 00398 00399 #endif