Disk ARchive
2.4.5
|
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 // $Id$ 00022 // 00023 /*********************************************************************/ 00024 // 00025 00026 // NOTE : The following comments are used by doxygen to generate the documentation of reference 00027 00039 00040 00049 00050 00058 00059 00063 00064 00065 00066 #ifndef LIBDAR_HPP 00067 #define LIBDAR_HPP 00068 00069 #include "../my_config.h" 00070 00071 extern "C" 00072 { 00073 #if MUTEX_WORKS 00074 #if HAVE_PTHREAD_H 00075 #include <pthread.h> 00076 #endif 00077 #endif 00078 } 00079 00080 00081 #include <string> 00082 #include "compressor.hpp" 00083 #include "path.hpp" 00084 #include "mask.hpp" 00085 #include "integers.hpp" 00086 #include "infinint.hpp" 00087 #include "statistics.hpp" 00088 #include "user_interaction.hpp" 00089 #include "deci.hpp" 00090 #include "archive.hpp" 00091 #include "crypto.hpp" 00092 #include "thread_cancellation.hpp" 00093 #include "compile_time_features.hpp" 00094 00097 00099 #define LIBDAR_XXXXXXXX 00100 00102 #define LIBDAR_NOEXCEPT 0 00103 00104 #define LIBDAR_EMEMORY 1 00105 00106 #define LIBDAR_EBUG 2 00107 00108 #define LIBDAR_EINFININT 3 00109 00110 #define LIBDAR_ELIMITINT 4 00111 00112 #define LIBDAR_ERANGE 5 00113 00114 #define LIBDAR_EDECI 6 00115 00116 #define LIBDAR_EFEATURE 7 00117 00118 #define LIBDAR_EHARDWARE 8 00119 00120 #define LIBDAR_EUSER_ABORT 9 00121 00122 #define LIBDAR_EDATA 10 00123 00124 #define LIBDAR_ESCRIPT 11 00125 00126 #define LIBDAR_ELIBCALL 12 00127 00128 #define LIBDAR_UNKNOWN 13 00129 00130 #define LIBDAR_ECOMPILATION 14 00131 00132 #define LIBDAR_THREAD_CANCEL 15 00133 00134 00136 namespace libdar 00137 { 00140 00141 00143 const U_I LIBDAR_COMPILE_TIME_MAJOR = 5; 00145 const U_I LIBDAR_COMPILE_TIME_MEDIUM = 2; 00147 const U_I LIBDAR_COMPILE_TIME_MINOR = 2; 00148 00150 // LIBDAR INITIALIZATION METHODS // 00151 // // 00152 // A FUNCTION OF THE get_version*() FAMILY *MUST* BE CALLED // 00153 // BEFORE ANY OTHER FUNCTION OF THIS LIBRARY // 00154 // // 00155 // CLIENT PROGRAM MUST CHECK THAT THE MAJOR NUMBER RETURNED // 00156 // BY THIS CALL IS NOT GREATER THAN THE VERSION USED AT COMPILATION // 00157 // TIME. IF SO, THE PROGRAM MUST ABORT AND RETURN A WARNING TO THE // 00158 // USER TELLING THE DYNAMICALLY LINKED VERSION IS TOO RECENT AND NOT // 00159 // COMPATIBLE WITH THIS SOFTWARE. THE MESSAGE MUST INVITE THE USER // 00160 // TO UPGRADE HIS SOFTWARE WITH A MORE RECENT VERSION COMPATIBLE WITH // 00161 // THIS LIBDAR RELEASE. // 00163 00165 00174 extern void get_version(U_I & major, U_I & medium, U_I & minor, bool init_libgcrypt = true); 00175 00177 00189 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); 00190 00191 00193 // CLOSING/CLEANING LIBDAR // 00195 00196 // while libdar has only a single boolean as global variable 00197 // that defines whether the library is initialized or not 00198 // it must proceed to mutex, and dependent libraries initializations 00199 // (liblzo, libgcrypt, etc.), which is done during the get_version() call 00200 // Some library also need to clear some data so the following call 00201 // is provided in that aim and must be called when libdar will no more 00202 // be used by the application. 00203 00204 extern void close_and_clean(); 00205 00206 00208 // WRAPPER FUNCTIONS AROUND archive class methods to trap exceptions and convert them in error code and message 00209 // these are intended for C program/programmers not enough confident with C++. 00210 // 00211 // FOR LIBDAR C++ APPLICATIONS, YOU WOULD RATHER USE THE archive C++ CLASS THAN THESE FOLLOWING WRAPPERS 00212 // 00214 00215 00217 00221 extern archive* open_archive_noexcept(user_interaction & dialog, 00222 const path & chem, const std::string & basename, 00223 const std::string & extension, 00224 const archive_options_read & options, 00225 U_16 & exception, 00226 std::string & except_msg); 00227 00228 00230 00234 extern archive *create_archive_noexcept(user_interaction & dialog, 00235 const path & fs_root, 00236 const path & sauv_path, 00237 const std::string & filename, 00238 const std::string & extension, 00239 const archive_options_create & options, 00240 statistics * progressive_report, 00241 U_16 & exception, 00242 std::string & except_msg); 00243 00244 00245 00247 00251 extern archive *isolate_archive_noexcept(user_interaction & dialog, 00252 const path &sauv_path, 00253 archive *ref_arch, 00254 const std::string & filename, 00255 const std::string & extension, 00256 const archive_options_isolate & options, 00257 U_16 & exception, 00258 std::string & except_msg); 00259 00261 00265 extern archive *merge_archive_noexcept(user_interaction & dialog, 00266 const path & sauv_path, 00267 archive *ref_arch1, 00268 const std::string & filename, 00269 const std::string & extension, 00270 const archive_options_merge & options, 00271 statistics * progressive_report, 00272 U_16 & exception, 00273 std::string & except_msg); 00274 00275 00277 00281 extern void close_archive_noexcept(archive *ptr, 00282 U_16 & exception, 00283 std::string & except_msg); 00284 00285 00287 00291 extern statistics op_extract_noexcept(user_interaction & dialog, 00292 archive *ptr, 00293 const path &fs_root, 00294 const archive_options_extract & options, 00295 statistics * progressive_report, 00296 U_16 & exception, 00297 std::string & except_msg); 00298 00299 00301 00305 extern void op_listing_noexcept(user_interaction & dialog, 00306 archive *ptr, 00307 const archive_options_listing & options, 00308 U_16 & exception, 00309 std::string & except_msg); 00310 00311 00313 00317 extern statistics op_diff_noexcept(user_interaction & dialog, 00318 archive *ptr, 00319 const path & fs_root, 00320 const archive_options_diff & options, 00321 statistics * progressive_report, 00322 U_16 & exception, 00323 std::string & except_msg); 00324 00325 00327 00331 extern statistics op_test_noexcept(user_interaction & dialog, 00332 archive *ptr, 00333 const archive_options_test & options, 00334 statistics * progressive_report, 00335 U_16 & exception, 00336 std::string & except_msg); 00337 00338 00340 00344 extern bool get_children_of_noexcept(user_interaction & dialog, 00345 archive *ptr, 00346 const std::string & dir, 00347 U_16 & exception, 00348 std::string & except_msg); 00349 00350 00351 00353 // TOOLS ROUTINES // 00355 00356 00358 00368 extern char *libdar_str2charptr_noexcept(const std::string & x, U_16 & exception, std::string & except_msg); 00369 00371 // THREAD CANCELLATION ROUTINES // 00373 00374 #if MUTEX_WORKS 00375 00376 00382 inline extern void cancel_thread(pthread_t tid, bool immediate = true, U_64 flag = 0) { thread_cancellation::cancel(tid, immediate, flag); } 00383 00385 00388 inline extern bool cancel_status(pthread_t tid) { return thread_cancellation::cancel_status(tid); } 00389 00391 00395 inline extern bool cancel_clear(pthread_t tid) { return thread_cancellation::clear_pending_request(tid); } 00396 #endif 00397 00398 00400 00401 } // end of namespace 00402 00403 #endif