X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fconfigparser.cpp;h=8a3042ebadba5393f4281eeb244fc2fd11181f76;hb=48a400f2e068527b338ceecf8ed1dde2da971ca9;hp=624f3aea64689cf14c9f4529ec85925bf2b64132;hpb=2d36fcb16ef3209fffbe9f4b600971a1edd2ae4b;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configparser.cpp b/src/configparser.cpp index 624f3aea6..8a3042eba 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -496,6 +496,23 @@ long ConfigTag::getInt(const std::string &key, long def, long min, long max) return res; } +unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsigned long min, unsigned long max) +{ + std::string result; + if (!readString(key, result)) + return def; + + const char* res_cstr = result.c_str(); + char* res_tail = NULL; + unsigned long res = strtoul(res_cstr, &res_tail, 0); + if (res_tail == res_cstr) + return def; + + CheckMagnitude(tag, key, result, res, def, res_tail); + CheckRange(tag, key, res, def, min, max); + return res; +} + unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, unsigned long min, unsigned long max) { std::string duration; @@ -507,12 +524,15 @@ unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, return ret; } -double ConfigTag::getFloat(const std::string &key, double def) +double ConfigTag::getFloat(const std::string& key, double def, double min, double max) { std::string result; if (!readString(key, result)) return def; - return strtod(result.c_str(), NULL); + + double res = strtod(result.c_str(), NULL); + CheckRange(tag, key, res, def, min, max); + return res; } bool ConfigTag::getBool(const std::string &key, bool def)