X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/45f7304806cbe47a5235c43e25e54f2a043bc42b..80aca6d78d4ff5d514216fe96c44e2ee75c4e933:/projects/sgauth/settings_impl.cpp diff --git a/projects/sgauth/settings_impl.cpp b/projects/sgauth/settings_impl.cpp index bcb56170..1a7b8dcd 100644 --- a/projects/sgauth/settings_impl.cpp +++ b/projects/sgauth/settings_impl.cpp @@ -21,9 +21,9 @@ #include #include +#include "stg/common.h" +#include "stg/conffiles.h" #include "settings_impl.h" -#include "common.h" -#include "conffiles.h" SETTINGS_IMPL::SETTINGS_IMPL() : port(0), @@ -38,71 +38,6 @@ SETTINGS_IMPL::SETTINGS_IMPL() { } //----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseYesNo(const string & value, bool * val) -{ -if (0 == strcasecmp(value.c_str(), "yes")) - { - *val = true; - return 0; - } -if (0 == strcasecmp(value.c_str(), "no")) - { - *val = false; - return 0; - } - -strError = "Incorrect value \'" + value + "\'."; -return -1; -} -//----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseInt(const string & value, int * val) -{ -if (str2x(value, *val)) - { - strError = "Cannot convert \'" + value + "\' to integer."; - return -1; - } -return 0; -} -//----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseUnsigned(const string & value, unsigned * val) -{ -if (str2x(value, *val)) - { - strError = "Cannot convert \'" + value + "\' to unsigned integer."; - return -1; - } -return 0; -} -//----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseIntInRange(const string & value, int min, int max, int * val) -{ -if (ParseInt(value, val) != 0) - return -1; - -if (*val < min || *val > max) - { - strError = "Value \'" + value + "\' out of range."; - return -1; - } - -return 0; -} -//----------------------------------------------------------------------------- -int SETTINGS_IMPL::ParseUnsignedInRange(const string & value, unsigned min, unsigned max, unsigned * val) -{ -if (ParseUnsigned(value, val) != 0) - return -1; - -if (*val < min || *val > max) - { - strError = "Value \'" + value + "\' out of range."; - return -1; - } - -return 0; -} -//----------------------------------------------------------------------------- int SETTINGS_IMPL::ReadSettings() { CONFIGFILE cf(confFile); @@ -150,6 +85,8 @@ if (ParseIntInRange(temp, 1, 65535, &port)) return -1; } +cf.ReadString("LocalName", &localName, ""); + cf.ReadString("LocalPort", &temp, "0"); if (ParseIntInRange(temp, 0, 65535, &localPort)) {