summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--src/eyetil.cc18
-rw-r--r--src/eyetil.h11
2 files changed, 16 insertions, 13 deletions
diff --git a/src/eyetil.cc b/src/eyetil.cc
index 11e2fb7..cd22eea 100644
--- a/src/eyetil.cc
+++ b/src/eyetil.cc
@@ -83,6 +83,11 @@ binary_t md5_digester::final() {
return rv;
}
+uint16_t block512_t::tcpcksum(block512_t& data) {
+ uint32_t sum = std::accumulate(data.data,data.data+words,0);
+ while(uint32_t hw = sum>>16) sum = (sum&0xffff)+hw;
+ return 0xffff&~sum;
+}
static void make_path_for_template(const std::string& p,mode_t m) {
struct stat st;
@@ -150,19 +155,6 @@ bool tarchive_t::read_data_into_fd(int fd) {
return archive_read_data_into_fd(a,fd)==ARCHIVE_OK;
}
-#pragma pack(1)
-struct block512_t {
- enum { words = 512 / sizeof(uint16_t) };
- uint16_t data[words];
-
- static uint16_t tcpcksum(block512_t& data) {
- uint32_t sum = std::accumulate(data.data,data.data+words,0);
- while(uint32_t hw = sum>>16) sum = (sum&0xffff)+hw;
- return 0xffff&~sum;
- }
-
-};
-#pragma pack()
binary_t integrity_digest(const void *ptr,size_t size,const std::string& ukey) {
md5_digester rv;
diff --git a/src/eyetil.h b/src/eyetil.h
index 03b9ba8..7517ba6 100644
--- a/src/eyetil.h
+++ b/src/eyetil.h
@@ -63,6 +63,17 @@ template<> inline void md5_digester::update<binary_t>(const binary_t& x) {
update((const unsigned char*)&(x.front()),x.size());
}
+#pragma pack(1)
+struct block512_t {
+ enum { words = 512 / sizeof(uint16_t) };
+ uint16_t data[words];
+
+ inline uint8_t *dptr(size_t o) { return ((uint8_t*)this)+o; }
+
+ static uint16_t tcpcksum(block512_t& data);
+};
+#pragma pack()
+
class tmpdir_t {
public:
std::string dir;