1 //  This file is part of par2cmdline (a PAR 2.0 compatible file verification and
2 //  repair tool). See http://parchive.sourceforge.net for details of PAR 2.0.
3 //
4 //  Copyright (c) 2003 Peter Brian Clements
5 //
6 //  par2cmdline is free software; you can redistribute it and/or modify
7 //  it under the terms of the GNU General Public License as published by
8 //  the Free Software Foundation; either version 2 of the License, or
9 //  (at your option) any later version.
10 //
11 //  par2cmdline is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
19 
20 #ifndef __PAR1FILEFORMAT_H__
21 #define __PAR1FILEFORMAT_H__
22 
23 #ifdef WIN32
24 #pragma pack(push, 1)
25 #define PACKED
26 #else
27 #define PACKED __attribute__ ((packed))
28 #endif
29 
30 #ifdef _MSC_VER
31 #pragma warning(disable:4200)
32 #endif
33 
34 struct PAR1MAGIC {u8 magic[8];}PACKED;
35 
36 struct PAR1FILEHEADER
37 {
38   PAR1MAGIC   magic;
39   leu32       fileversion;
40   leu32       programversion;
41   MD5Hash     controlhash;
42   MD5Hash     sethash;
43   leu64       volumenumber;
44   leu64       numberoffiles;
45   leu64       filelistoffset;
46   leu64       filelistsize;
47   leu64       dataoffset;
48   leu64       datasize;
49 }PACKED;
50 
51 struct PAR1FILEENTRY
52 {
53   leu64       entrysize;
54   leu64       status;
55   leu64       filesize;
56   MD5Hash     hashfull;
57   MD5Hash     hash16k;
58   leu16       name[];
59 }PACKED;
60 
61 enum FILEENTRYSTATUS
62 {
63   INPARITYVOLUME = 1,
64   CHECKED = 2,
65 };
66 
67 #ifdef _MSC_VER
68 #pragma warning(default:4200)
69 #endif
70 
71 #ifdef WIN32
72 #pragma pack(pop)
73 #endif
74 #undef PACKED
75 
76 // Operators for comparing the MAGIC values
77 
78 inline bool operator == (const PAR1MAGIC &left, const PAR1MAGIC &right)
79 {
80   return (0==memcmp(&left, &right, sizeof(left)));
81 }
82 
83 inline bool operator != (const PAR1MAGIC &left, const PAR1MAGIC &right)
84 {
85   return !operator==(left, right);
86 }
87 
88 extern PAR1MAGIC par1_magic;
89 
90 #endif //__PAR1FILEFORMAT_H__
91