summaryrefslogtreecommitdiffabout
path: root/src/eyetil.cc
Unidiff
Diffstat (limited to 'src/eyetil.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyetil.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/eyetil.cc b/src/eyetil.cc
index 7669cb6..57ae607 100644
--- a/src/eyetil.cc
+++ b/src/eyetil.cc
@@ -67,12 +67,26 @@ binary_t binary_t::md5() const {
67 (const unsigned char*)&(front()),size(), 67 (const unsigned char*)&(front()),size(),
68 (unsigned char*)&(rv.front()) )) 68 (unsigned char*)&(rv.front()) ))
69 throw std::runtime_error("failed to md5()"); 69 throw std::runtime_error("failed to md5()");
70 return rv; 70 return rv;
71} 71}
72 72
73void md5_digester::init() {
74 if(!MD5_Init(&ctx)) throw std::runtime_error("failed to MD5_Init()");
75}
76void md5_digester::update(const void *d,size_t l) {
77 if(!MD5_Update(&ctx,d,l)) throw std::runtime_error("failed to MD5_Update()");
78}
79binary_t md5_digester::final() {
80 binary_t rv(MD5_DIGEST_LENGTH);
81 if(!MD5_Final((unsigned char*)&(rv.front()), &ctx))
82 throw std::runtime_error("failed to MD5_Final()");
83 return rv;
84}
85
86
73static void make_path_for_template(const std::string& p,mode_t m) { 87static void make_path_for_template(const std::string& p,mode_t m) {
74 struct stat st; 88 struct stat st;
75 std::string pp; 89 std::string pp;
76 for(std::string::size_type sl=p.find('/',1); 90 for(std::string::size_type sl=p.find('/',1);
77 sl!=std::string::npos; 91 sl!=std::string::npos;
78 sl=p.find('/',sl+1)) { 92 sl=p.find('/',sl+1)) {