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 2006/01/08 16:33:42 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 00047 const U_32 SAUV_MAGIC_NUMBER = 123; 00048 00049 typedef U_32 magic_number; 00050 typedef char label[LABEL_SIZE]; 00051 00052 extern void label_copy(label & left, const label & right); 00053 extern bool header_label_is_equal(const label &a, const label &b); 00054 extern void header_generate_internal_filename(label & ret); 00055 00056 struct header 00057 { 00058 magic_number magic; 00059 label internal_name; 00060 char flag; 00061 char extension; // extension rules the use of the following fields 00062 infinint size_ext; // if EXTENSION_SIZE 00063 00064 header(); 00065 header(const header & ref) { copy_from(ref); }; 00066 struct header & operator = (const header & ref) { copy_from(ref); return *this; }; 00067 00068 void read(generic_file & f); 00069 void write(generic_file & f); 00070 void read(user_interaction & dialog, S_I fd); 00071 void write(user_interaction & dialog, S_I fd); 00072 00073 static U_I size() { return sizeof(magic_number) + sizeof(label) + 2*sizeof(char); }; 00074 void copy_from(const header & ref); 00075 }; 00076 00077 } // end of namespace 00078 00079 #endif