# header_version.hpp

Go to the documentation of this file.

    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_version.hpp,v 1.12 2005/05/08 12:12:01 edrusb Rel $
    00022 //
    00023 /*********************************************************************/
    00024
    00028
    00029 #ifndef HEADER_VERSION_HPP
    00030 #define HEADER_VERSION_HPP
    00031
    00032 #include "../my_config.h"
    00033 #include "infinint.hpp"
    00034 #include "generic_file.hpp"
    00035 #include "tools.hpp"
    00036
    00037 namespace libdar
    00038 {
    00039     const int VERSION_FLAG_SAVED_EA_ROOT = 0x80;      // no more used since version "05"
    00040     const int VERSION_FLAG_SAVED_EA_USER = 0x40;      // no more used since version "05"
    00041     const int VERSION_FLAG_SCRAMBLED     = 0x20;      // scrambled or strong encryption used
    00042     const int VERSION_SIZE = 3;
    00043     typedef char dar_version[VERSION_SIZE];
    00044     extern void version_copy(dar_version & dst, const dar_version & src);
    00045     extern bool version_greater(const dar_version & left, const dar_version & right);
    00046         // operation left > right
    00047
    00048     struct header_version
    00049     {
    00050         dar_version edition;
    00051         char algo_zip;
    00052         std::string cmd_line;
    00053         unsigned char flag; // added at edition 02
    00054
    00055         void read(generic_file &f)
    00056             {
    00057                 f.read(edition, sizeof(edition));
    00058                 f.read(&algo_zip, sizeof(algo_zip));
    00059                 tools_read_string(f, cmd_line);
    00060                 if(version_greater(edition, "01"))
    00061                     f.read((char *)&flag, (size_t)1);
    00062                 else
    00063                     flag = 0;
    00064             };
    00065         void write(generic_file &f)
    00066             {
    00067                 f.write(edition, sizeof(edition));
    00068                 f.write(&algo_zip, sizeof(algo_zip));
    00069                 tools_write_string(f, cmd_line);
    00070                 f.write((char *)&flag, (size_t)1);
    00071             };
    00072     };
    00073
    00074 } // end of namespace
    00075
    00076 #endif