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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 #ifndef __MAINPACKET_H__
21 #define __MAINPACKET_H__
22
23 // The main packet ties all other critical packets together.
24 // It specifies the block size to use for both verification of
25 // files and for the Reed Solomon computation.
26 // It also specifies how many of the source files are repairable
27 // and in what order they should be processed.
28
29 class MainPacket : public CriticalPacket
30 {
31 public:
32 // Construct the packet
MainPacket(void)33 MainPacket(void) {};
~MainPacket(void)34 ~MainPacket(void) {};
35
36 public:
37 // Load a main packet from a specified file
38 bool Load(DiskFile *diskfile, u64 offset, PACKET_HEADER &header);
39
40 public:
41 // Get the set id.
42 const MD5Hash& SetId(void) const;
43
44 // Get the block size.
45 u64 BlockSize(void) const;
46
47 // Get the file counts.
48 u32 RecoverableFileCount(void) const;
49 u32 TotalFileCount(void) const;
50
51 // Get the fileid of one file
52 const MD5Hash& FileId(u32 filenumber) const;
53
54 protected:
55 u64 blocksize;
56 u32 totalfilecount;
57 u32 recoverablefilecount;
58 };
59
60 // Get the data block size
BlockSize(void)61 inline u64 MainPacket::BlockSize(void) const
62 {
63 assert(packetdata != 0);
64
65 return blocksize;
66 }
67
68 // Get the number of recoverable files
RecoverableFileCount(void)69 inline u32 MainPacket::RecoverableFileCount(void) const
70 {
71 assert(packetdata != 0);
72
73 return recoverablefilecount;
74 }
75
76 // Get the total number of files
TotalFileCount(void)77 inline u32 MainPacket::TotalFileCount(void) const
78 {
79 assert(packetdata != 0);
80
81 return totalfilecount;
82 }
83
84 // Get the file id hash of one of the files
FileId(u32 filenumber)85 inline const MD5Hash& MainPacket::FileId(u32 filenumber) const
86 {
87 assert(packetdata != 0);
88 assert(filenumber<totalfilecount);
89
90 // return ((const MAINPACKET*)packetdata)->fileid()[filenumber];
91 return ((const MAINPACKET*)packetdata)->fileid[filenumber];
92 }
93
SetId(void)94 inline const MD5Hash& MainPacket::SetId(void) const
95 {
96 return ((const MAINPACKET*)packetdata)->header.setid;
97 }
98
99
100 #endif // __MAINPACKET_H__
101