RZ

01: // RZMagic.hh # common utilities for rz analysis and synthesis
02:
03: #ifndef _RZMagic_HH
04: #define _RZMagic_HH 1
05:
06: #include <vector>
07: #include <functional>
08:
09: #include "AlgoBytewiseGF.hh"
10:
11: /****** rz file format wrapper ******
12:
13: These definitions provide internal representation only.
14: Actual serialization occurs in the relevant code.  I wrote wrapper functions
15: for these operations but this resulted in more code than actually doing the
16: serialization only as needed
17:
18: rz file byte ranges (words are 4 byte bigendian unsigned integers)
19:
20: [0,16) RZMagic (16 bytes)
21: [16,32) RZSums (4 words)
22: [32,64) RZStreamStructure (8 words)
23: [64,64 + n_blks * 16) RZSignatureTable (n_blks of SignatureEntry entries)
24:
25: ******/
26:
27: namespace RZ {
28:     struct RZMagic {
29:         static char const file_magic[];
30:     };
31:
32:     struct RZModuli {
33:         unsigned int modulus_a, modulus_b, modulus_c, blocks_of;
34:         RZModuli();
35:         RZModuli(unsigned int, unsigned int, unsigned int, unsigned int);
36:     };
37:
38:     struct RZStreamStructure {
39:         unsigned int n_blks, rz_crc, sc_end, rz_end;
40:         unsigned int n_cont, rz_czr, sc_off, rz_off;
41:     };
42:
43:     namespace RZSignatureTable {
44:         struct SignatureEntry { unsigned int sig_a, sig_b, sig_c, rz_to; };
45:         struct EntryTo: std::unary_function< SignatureEntry, unsigned int > {
46:             unsigned int operator()(SignatureEntry e) { return e.rz_to; }
47:         };
48:         typedef std::vector< SignatureEntry > Signature;
49:     };
50:
51:     struct RZWrapper: RZMagic, RZModuli, RZStreamStructure {
52:         RZSignatureTable::Signature signature_table;
53:         unsigned int wrapper_size, block_size, file_size;
54:     };
55:
56:     struct Sums {
57:         Bytewise::Checksum32 const a;
58:         Bytewise::Checksum32 const b;
59:         Bytewise::Rollingsum const c;
60:         Sums(RZModuli m);
61:     };
62: }
63:
64: // RZMagic.hh # common utilities for rz analysis and synthesis
65:
66: #endif