Disk ARchive
2.3.11
|
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 : dar.linux@free.fr 00020 /*********************************************************************/ 00021 // $Id: header.hpp,v 1.9.2.1 2009/01/24 16:01:16 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00028 00029 00030 #ifndef HEADER_HPP 00031 #define HEADER_HPP 00032 00033 #include "../my_config.h" 00034 #include "infinint.hpp" 00035 #include "generic_file.hpp" 00036 #include "user_interaction.hpp" 00037 00038 namespace libdar 00039 { 00040 const unsigned int LABEL_SIZE = 10; 00041 00042 const char FLAG_NON_TERMINAL = 'N'; 00043 const char FLAG_TERMINAL = 'T'; 00044 const char EXTENSION_NO = 'N'; 00045 const char EXTENSION_SIZE = 'S'; 00046 const char EXTENSION_TLV = 'T'; 00047 00048 const U_32 SAUV_MAGIC_NUMBER = 123; 00049 00050 typedef U_32 magic_number; 00051 typedef char label[LABEL_SIZE]; 00052 00053 extern void label_copy(label & left, const label & right); 00054 extern bool header_label_is_equal(const label &a, const label &b); 00055 extern void header_generate_internal_filename(label & ret); 00056 00057 struct header 00058 { 00059 magic_number magic; 00060 label internal_name; 00061 char flag; 00062 char extension; // extension rules the use of the following fields 00063 infinint size_ext; // if EXTENSION_SIZE 00064 00065 header(); 00066 header(const header & ref) { copy_from(ref); }; 00067 struct header & operator = (const header & ref) { copy_from(ref); return *this; }; 00068 00069 void read(generic_file & f); 00070 void write(generic_file & f); 00071 void read(user_interaction & dialog, S_I fd); 00072 void write(user_interaction & dialog, S_I fd); 00073 00074 static U_I size() { return sizeof(magic_number) + sizeof(label) + 2*sizeof(char); }; 00075 void copy_from(const header & ref); 00076 }; 00077 00078 } // end of namespace 00079 00080 #endif