Disk ARchive  2.4.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
.pc/delete2/header.hpp
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$
00022 //
00023 /*********************************************************************/
00024 
00025 #ifndef HEADER_H
00026 #define HEADER_H
00027 
00028 #pragma interface
00029 
00030 #include "infinint.hpp"
00031 #include "generic_file.hpp"
00032 
00033 #define LABEL_SIZE 10
00034 
00035 #define FLAG_NON_TERMINAL 'N'
00036 #define FLAG_TERMINAL 'T'
00037 #define EXTENSION_NO 'N'
00038 #define EXTENSION_SIZE 'S'
00039 
00040 #define SAUV_MAGIC_NUMBER 123
00041 
00042 typedef U_32 magic_number;
00043 typedef char label[LABEL_SIZE];
00044 
00045 extern void label_copy(label & left, const label & right);
00046 extern bool header_label_is_equal(const label &a, const label &b);
00047 extern void header_generate_internal_filename(label & ret);
00048 
00049 struct header
00050 {
00051     magic_number magic;
00052     label internal_name;
00053     char flag;
00054     char extension; // extension rules the use of the following fields
00055     infinint size_ext; // if EXTENSION_SIZE
00056 
00057     header();
00058     header(const header & ref) { copy_from(ref); };
00059     struct header & operator = (const header & ref) { copy_from(ref); return *this; };
00060 
00061     void read(generic_file & f);
00062     void write(generic_file & f);
00063     void read(S_I fd);
00064     void write(S_I fd);
00065 
00066     static U_I size() { return sizeof(magic_number) + sizeof(label) + 2*sizeof(char); };
00067     void copy_from(const header & ref);
00068 };
00069         
00070 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines