summaryrefslogtreecommitdiff
path: root/server/server/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server/server/config.cpp')
-rwxr-xr-xserver/server/config.cpp66
1 files changed, 25 insertions, 41 deletions
diff --git a/server/server/config.cpp b/server/server/config.cpp
index ac0f95e..ad5e3e0 100755
--- a/server/server/config.cpp
+++ b/server/server/config.cpp
@@ -75,18 +75,31 @@ void config::load_cvars()
{
std::ifstream config;
config.open(cli_config_path.c_str(), std::fstream::in);
- if(config.is_open())
+ if(!config.is_open())
+ return;
+ if(!cvars.empty())
+ cvars.clear();
+ std::string cfg_str((std::istreambuf_iterator<char>(config)), std::istreambuf_iterator<char>());
+ config.close();
+ if(!cfg_str.empty())
{
- std::string cfg_str((std::istreambuf_iterator<char>(config)), std::istreambuf_iterator<char>());
- config.close();
- cvars.config_update_interval = get_int(cfg_str, "config_update_interval=", 300);
- cvars.client_update_interval = get_int(cfg_str, "client_update_interval=", 60000);
- cvars.welcome_msg = get_string(cfg_str, "welcome_msg=", "");
- cvars.cfg_downloaded_msg = get_string(cfg_str, "config_downloaded_msg=", "");
- cvars.top_text = get_string(cfg_str, "top_panel_text=", "");
- cvars.bottom_text = get_string(cfg_str, "bottom_panel_text=", "");
- cvars.speed_visibility = get_int(cfg_str, "speed_visibility=", 1);
+ 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)
+ {
+ cvars.push_back(cfg_str.substr(p1, p2-p1));
+ p1 = p2+l+1;
+ p2 = cfg_str.find(';', p1);
+ }
}
+/* cvars.config_update_interval = get_int(cfg_str, "config_update_interval=", 300);
+ cvars.client_update_interval = get_int(cfg_str, "client_update_interval=", 60000);
+ cvars.welcome_msg = get_string(cfg_str, "welcome_msg=", "");
+ cvars.top_text = get_string(cfg_str, "top_panel_text=", "");
+ cvars.bottom_text = get_string(cfg_str, "bottom_panel_text=", "");
+ cvars.speed_visibility = get_int(cfg_str, "speed_visibility=", 1); */
}
config::config(const char *pth): cfg_reload_thr(NULL), speed_test_thr(NULL)
@@ -551,40 +564,11 @@ bool config::ignore_ssl_errors()
return vars.ignore_ssl_errors;
}
-const int config::c_cfg_upd_int()
+std::list<std::string>* config::cli_cfg()
{
- return cvars.config_update_interval;
+ return &cvars;
}
-const int config::c_cli_upd_int()
-{
- return cvars.client_update_interval;
-}
-
-bool config::c_speed_visibility()
-{
- return cvars.speed_visibility;
-}
-
-const std::string& config::c_welcome_msg()
-{
- return cvars.welcome_msg;
-}
-
-const std::string& config::c_cfg_download_msg()
-{
- return cvars.cfg_downloaded_msg;
-}
-
-const std::string& config::c_top_text()
-{
- return cvars.top_text;
-}
-
-const std::string& config::c_bottom_text()
-{
- return cvars.bottom_text;
-}
const std::string& config::speed_test_file_url()
{
return vars.speed_test_file_url;