summaryrefslogtreecommitdiff
path: root/src/configparser.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2013-07-10 14:28:05 +0100
committerPeter Powell <petpow@saberuk.com>2013-08-10 14:04:09 +0100
commit86f650e6b8c969b31fae65ea1143644723279b82 (patch)
treeca746c6fb3f5aa59215639ee5a8ab798b1f47862 /src/configparser.cpp
parenta2720d169743cda1b7812b28f79a34fd33802e72 (diff)
Replace range() with min and max arguments on getInt().
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r--src/configparser.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 3289cf396..f3e79e2fd 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -420,7 +420,7 @@ std::string ConfigTag::getString(const std::string& key, const std::string& def)
return res;
}
-long ConfigTag::getInt(const std::string &key, long def)
+long ConfigTag::getInt(const std::string &key, long def, long min, long max)
{
std::string result;
if(!readString(key, result))
@@ -434,15 +434,21 @@ long ConfigTag::getInt(const std::string &key, long def)
switch (toupper(*res_tail))
{
case 'K':
- res= res* 1024;
+ res = res * 1024;
break;
case 'M':
- res= res* 1024 * 1024;
+ res = res * 1024 * 1024;
break;
case 'G':
- res= res* 1024 * 1024 * 1024;
+ res = res * 1024 * 1024 * 1024;
break;
}
+ if (res < min || res > max)
+ {
+ ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "WARNING: <%s:%s> value of %ld is not between %ld and %ld; set to %ld.",
+ tag.c_str(), key.c_str(), res, min, max, def);
+ res = def;
+ }
return res;
}