diff options
Diffstat (limited to 'server/server/config.cpp')
-rw-r--r-- | server/server/config.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/server/server/config.cpp b/server/server/config.cpp index cb5581a..22e0a8c 100644 --- a/server/server/config.cpp +++ b/server/server/config.cpp @@ -26,6 +26,8 @@ config::config(const char *pth) load_proxy_list(); load_static_proxy_list(); load_firewall_list(); + load_deleted_list(); + load_upload_list(); } const int config::get_int(const std::string& data, const char* var, int default_) { @@ -56,6 +58,45 @@ const std::string config::get_string(const std::string& data, const char* var, c return default_; } +void config::load_upload_list(char *pth) +{ + std::ifstream config; + if(!pth) + { + std::string cfg_path = boost::filesystem::initial_path().string(); + cfg_path += "/upload_list.cfg"; + config.open(cfg_path.c_str(), std::fstream::in); + } + else + config.open(pth, std::fstream::in); + std::string cfg_str((std::istreambuf_iterator<char>(config)), std::istreambuf_iterator<char>()); + config.close(); + if(!cfg_str.empty()) + { + std::string::size_type p1 = 0, p2 = 0, l = 1; + if(cfg_str.find("\r\n") != std::string::npos) + l = 2; + p2 = cfg_str.find(';'); + while(p2 != std::string::npos) + { + std::string line = cfg_str.substr(p1, p2-p1); + p1 = p2+l; + std::string::size_type lp1 = 0, lp2 = 0; + std::string source, destination, hash; + byte *hash_buf = NULL; + lp2 = line.find('\x20', lp1); + source = line.substr(lp1, lp2-lp1); + lp1 = lp2+1; + lp2 = line.find(l, lp1); + destination = line.substr(lp1, lp2-lp1); + //TODO calc hash + upload_list.push_back(upload_entry(source, destination, hash)); + p2 = cfg_str.find(';', p1); + } + } +} + + void config::load_proxy_list(char *pth) { std::ifstream config; @@ -304,6 +345,11 @@ std::list<std::string> *config::get_deleted_list() return &deleted_list; } +std::list<upload_entry> *config::get_upload_list() +{ + return &upload_list; +} + bool config::ignore_ssl_errors() { return vars.ignore_ssl_errors; |