summaryrefslogtreecommitdiff
path: root/server/server/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server/server/config.cpp')
-rw-r--r--server/server/config.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/server/server/config.cpp b/server/server/config.cpp
index 60b7946..5fcdfc4 100644
--- a/server/server/config.cpp
+++ b/server/server/config.cpp
@@ -83,14 +83,25 @@ void config::load_upload_list(char *pth)
p1 = p2+l;
std::string::size_type lp1 = 0, lp2 = 0;
std::string source, destination, hash;
- byte *hash_buf = NULL;
lp1++;
lp2 = line.find('"', lp1);
source = line.substr(lp1, lp2-lp1);
lp1 = lp2+3;
lp2 = line.find('"', lp1);
destination = line.substr(lp1, lp2-lp1);
- //TODO calc hash
+ std::ifstream file;
+ MD5_CTX c = {0};
+ MD5_Init(&c);
+ file.open(source.c_str());
+ if(file.is_open())
+ {
+ char hash_buf[1024];
+ while(!file.eof())
+ MD5_Update(&c, hash_buf, file.readsome(hash_buf, 1024));
+ unsigned char result[MD5_DIGEST_LENGTH];
+ MD5_Final(result, &c);
+ hash = (char*)result;
+ }
upload_list.push_back(upload_entry(source, destination, hash));
p2 = cfg_str.find(';', p1);
}