summaryrefslogtreecommitdiffabout
path: root/src/eyetil.h
Unidiff
Diffstat (limited to 'src/eyetil.h') (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyetil.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/eyetil.h b/src/eyetil.h
index 03b9ba8..7517ba6 100644
--- a/src/eyetil.h
+++ b/src/eyetil.h
@@ -42,48 +42,59 @@ struct md5_digester {
42 struct update_iterator : public std::iterator<std::output_iterator_tag,T,void,T*,T&> { 42 struct update_iterator : public std::iterator<std::output_iterator_tag,T,void,T*,T&> {
43 md5_digester *d; 43 md5_digester *d;
44 update_iterator(md5_digester *d_) : d(d_) { } 44 update_iterator(md5_digester *d_) : d(d_) { }
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};
62template<> inline void md5_digester::update<binary_t>(const binary_t& x) { 62template<> 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)
67struct block512_t {
68 enum { words = 512 / sizeof(uint16_t) };
69 uint16_t data[words];
70
71 inline uint8_t *dptr(size_t o) { return ((uint8_t*)this)+o; }
72
73 static uint16_t tcpcksum(block512_t& data);
74};
75#pragma pack()
76
66class tmpdir_t { 77class tmpdir_t {
67 public: 78 public:
68 std::string dir; 79 std::string dir;
69 80
70 tmpdir_t(const std::string& dt); 81 tmpdir_t(const std::string& dt);
71 ~tmpdir_t(); 82 ~tmpdir_t();
72 83
73 std::string get_file(const std::string& f); 84 std::string get_file(const std::string& f);
74}; 85};
75 86
76class tarchive_t { 87class tarchive_t {
77 public: 88 public:
78 struct archive *a; 89 struct archive *a;
79 struct archive_entry *e; 90 struct archive_entry *e;
80 91
81 tarchive_t(void *p,size_t s); 92 tarchive_t(void *p,size_t s);
82 ~tarchive_t(); 93 ~tarchive_t();
83 94
84 bool read_next_header(); 95 bool read_next_header();
85 96
86 std::string entry_pathname(); 97 std::string entry_pathname();
87 98
88 bool read_data_into_fd(int fd); 99 bool read_data_into_fd(int fd);
89}; 100};