-rw-r--r-- | src/eyetil.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/eyetil.h b/src/eyetil.h index 7517ba6..8784cb4 100644 --- a/src/eyetil.h +++ b/src/eyetil.h | |||
@@ -45,61 +45,72 @@ struct md5_digester { | |||
45 | update_iterator(const update_iterator& x) : d(x.d) { } | 45 | update_iterator(const update_iterator& x) : d(x.d) { } |
46 | 46 | ||
47 | update_iterator& operator*() { return *this; } | 47 | update_iterator& operator*() { return *this; } |
48 | update_iterator& operator++() { return *this; } | 48 | update_iterator& operator++() { return *this; } |
49 | update_iterator& operator++(int) { return *this; } | 49 | update_iterator& operator++(int) { return *this; } |
50 | 50 | ||
51 | update_iterator& operator=(const T& x) { | 51 | update_iterator& operator=(const T& x) { |
52 | d->update(x); return *this; | 52 | d->update(x); return *this; |
53 | } | 53 | } |
54 | }; | 54 | }; |
55 | 55 | ||
56 | template<typename T> | 56 | template<typename T> |
57 | update_iterator<T> updater() { | 57 | update_iterator<T> updater() { |
58 | return update_iterator<T>(this); | 58 | return update_iterator<T>(this); |
59 | } | 59 | } |
60 | 60 | ||
61 | }; | 61 | }; |
62 | template<> inline void md5_digester::update<binary_t>(const binary_t& x) { | 62 | template<> inline void md5_digester::update<binary_t>(const binary_t& x) { |
63 | update((const unsigned char*)&(x.front()),x.size()); | 63 | update((const unsigned char*)&(x.front()),x.size()); |
64 | } | 64 | } |
65 | 65 | ||
66 | #pragma pack(1) | 66 | #pragma pack(1) |
67 | struct block512_t { | 67 | struct block512_t { |
68 | enum { words = 512 / sizeof(uint16_t) }; | 68 | enum { words = 512 / sizeof(uint16_t) }; |
69 | uint16_t data[words]; | 69 | uint16_t data[words]; |
70 | 70 | ||
71 | inline uint8_t *dptr(size_t o) { return ((uint8_t*)this)+o; } | 71 | inline uint8_t *dptr(size_t o) { return ((uint8_t*)this)+o; } |
72 | 72 | ||
73 | static uint16_t tcpcksum(block512_t& data); | 73 | static uint16_t tcpcksum(block512_t& data); |
74 | }; | 74 | }; |
75 | #pragma pack() | 75 | #pragma pack() |
76 | 76 | ||
77 | struct integrity_digester { | ||
78 | md5_digester md5; | ||
79 | size_t data_size; | ||
80 | block512_t data; | ||
81 | |||
82 | integrity_digester() : data_size(0) { } | ||
83 | void update(const void *d,size_t s); | ||
84 | binary_t final(const std::string& ukey); | ||
85 | }; | ||
86 | |||
87 | |||
77 | class tmpdir_t { | 88 | class tmpdir_t { |
78 | public: | 89 | public: |
79 | std::string dir; | 90 | std::string dir; |
80 | 91 | ||
81 | tmpdir_t(const std::string& dt); | 92 | tmpdir_t(const std::string& dt); |
82 | ~tmpdir_t(); | 93 | ~tmpdir_t(); |
83 | 94 | ||
84 | std::string get_file(const std::string& f); | 95 | std::string get_file(const std::string& f); |
85 | }; | 96 | }; |
86 | 97 | ||
87 | class tarchive_t { | 98 | class tarchive_t { |
88 | public: | 99 | public: |
89 | struct archive *a; | 100 | struct archive *a; |
90 | struct archive_entry *e; | 101 | struct archive_entry *e; |
91 | 102 | ||
92 | tarchive_t(void *p,size_t s); | 103 | tarchive_t(void *p,size_t s); |
93 | ~tarchive_t(); | 104 | ~tarchive_t(); |
94 | 105 | ||
95 | bool read_next_header(); | 106 | bool read_next_header(); |
96 | 107 | ||
97 | std::string entry_pathname(); | 108 | std::string entry_pathname(); |
98 | 109 | ||
99 | bool read_data_into_fd(int fd); | 110 | bool read_data_into_fd(int fd); |
100 | }; | 111 | }; |
101 | 112 | ||
102 | binary_t integrity_digest(const void *ptr,size_t size, | 113 | binary_t integrity_digest(const void *ptr,size_t size, |
103 | const std::string& ukey); | 114 | const std::string& ukey); |
104 | 115 | ||
105 | #endif /* __EYETIL_H */ | 116 | #endif /* __EYETIL_H */ |