author | Michael Krelin <hacker@klever.net> | 2009-04-05 13:32:09 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2009-04-05 13:32:09 (UTC) |
commit | 878315238f71307b5b62ed314096f4a7c465bf3e (patch) (unidiff) | |
tree | dad1579d95b1f7189dc6be5cbd66c36cf340cb94 /src/eyetil.h | |
parent | 01eedb36de69f92fc896c525047df78b34f87324 (diff) | |
download | iii-878315238f71307b5b62ed314096f4a7c465bf3e.zip iii-878315238f71307b5b62ed314096f4a7c465bf3e.tar.gz iii-878315238f71307b5b62ed314096f4a7c465bf3e.tar.bz2 |
integrity digest calculation
implemented integrity digest calculation for uploaded files,
thanks to cdavies of eye-fi forums.
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | src/eyetil.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/eyetil.h b/src/eyetil.h index 195d24f..378f703 100644 --- a/src/eyetil.h +++ b/src/eyetil.h | |||
@@ -1,48 +1,51 @@ | |||
1 | #ifndef __EYETIL_H | 1 | #ifndef __EYETIL_H |
2 | #define __EYETIL_H | 2 | #define __EYETIL_H |
3 | 3 | ||
4 | #include <vector> | 4 | #include <vector> |
5 | #include <string> | 5 | #include <string> |
6 | #include <archive.h> | 6 | #include <archive.h> |
7 | #include <archive_entry.h> | 7 | #include <archive_entry.h> |
8 | 8 | ||
9 | class binary_t : public std::vector<unsigned char> { | 9 | class binary_t : public std::vector<unsigned char> { |
10 | public: | 10 | public: |
11 | binary_t() { } | 11 | binary_t() { } |
12 | binary_t(size_type n) : std::vector<unsigned char>(n) { } | 12 | binary_t(size_type n) : std::vector<unsigned char>(n) { } |
13 | binary_t(const std::string& h) { from_hex(h); } | 13 | binary_t(const std::string& h) { from_hex(h); } |
14 | binary_t(const void *d,size_t s) { from_data(d,s); } | 14 | binary_t(const void *d,size_t s) { from_data(d,s); } |
15 | 15 | ||
16 | binary_t& from_hex(const std::string& h); | 16 | binary_t& from_hex(const std::string& h); |
17 | binary_t& from_data(const void *d,size_t s); | 17 | binary_t& from_data(const void *d,size_t s); |
18 | 18 | ||
19 | std::string hex() const; | 19 | std::string hex() const; |
20 | binary_t md5() const; | 20 | binary_t md5() const; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | class tmpdir_t { | 23 | class tmpdir_t { |
24 | public: | 24 | public: |
25 | std::string dir; | 25 | std::string dir; |
26 | 26 | ||
27 | tmpdir_t(const std::string& dt); | 27 | tmpdir_t(const std::string& dt); |
28 | ~tmpdir_t(); | 28 | ~tmpdir_t(); |
29 | 29 | ||
30 | std::string get_file(const std::string& f); | 30 | std::string get_file(const std::string& f); |
31 | }; | 31 | }; |
32 | 32 | ||
33 | class tarchive_t { | 33 | class tarchive_t { |
34 | public: | 34 | public: |
35 | struct archive *a; | 35 | struct archive *a; |
36 | struct archive_entry *e; | 36 | struct archive_entry *e; |
37 | 37 | ||
38 | tarchive_t(void *p,size_t s); | 38 | tarchive_t(void *p,size_t s); |
39 | ~tarchive_t(); | 39 | ~tarchive_t(); |
40 | 40 | ||
41 | bool read_next_header(); | 41 | bool read_next_header(); |
42 | 42 | ||
43 | std::string entry_pathname(); | 43 | std::string entry_pathname(); |
44 | 44 | ||
45 | bool read_data_into_fd(int fd); | 45 | bool read_data_into_fd(int fd); |
46 | }; | 46 | }; |
47 | 47 | ||
48 | binary_t integrity_digest(const void *ptr,size_t size, | ||
49 | const std::string& ukey); | ||
50 | |||
48 | #endif /* __EYETIL_H */ | 51 | #endif /* __EYETIL_H */ |