From: Maxim Mamontov Date: Sun, 20 Dec 2015 17:26:36 +0000 (+0200) Subject: Merge branch 'stg-2.409' into stg-2.409-radius X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/a637d472ffa2023dd0748557f9ef343d7138c2f0?hp=5171f194c7366bc64d7b4f6a7e2a9ca098bdafaf Merge branch 'stg-2.409' into stg-2.409-radius --- diff --git a/include/stg/user_ips.h b/include/stg/user_ips.h index e55f99fa..52e5df77 100644 --- a/include/stg/user_ips.h +++ b/include/stg/user_ips.h @@ -166,7 +166,7 @@ return false; inline bool USER_IPS::OnlyOneIP() const { -if (ips.size() == 1 && ips.front().mask == 32) +if (ips.size() == 1 && ips.front().mask == 32 && ips.front().ip != 0) return true; return false; diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.cpp index cc32b6fc..0607db6f 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_tariffs.cpp @@ -56,6 +56,16 @@ std::string AOS2String(const A & array, size_t size, const F C::* field, F multi return res; } +template +bool str2res(const std::string& source, RESETABLE& dest, T divisor) +{ + T value = 0; + if (str2x(source, value)) + return false; + dest = value / divisor; + return true; +} + template bool String2AOS(const std::string & source, A & array, size_t size, RESETABLE C::* field, F divisor) { @@ -64,15 +74,13 @@ bool String2AOS(const std::string & source, A & array, size_t size, RESETABLE std::string::size_type pos = 0; while (index < size && (pos = source.find('/', from)) != std::string::npos) { - if (str2x(source.substr(from, pos - from), (array[index].*field).data())) + if (!str2res(source.substr(from, pos - from), array[index].*field, divisor)) return false; - (array[index].*field).data() /= divisor; from = pos + 1; ++index; } - if (str2x(source.substr(from), (array[index].*field).data())) + if (str2res(source.substr(from), array[index].*field, divisor)) return false; - (array[index].*field).data() /= divisor; return true; } diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp index f7aef966..a7b719ed 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp @@ -31,6 +31,13 @@ #include "firebird_store.h" #include "stg/ibpp.h" +namespace +{ + +const int pt_mega = 1024 * 1024; + +} + //----------------------------------------------------------------------------- int FIREBIRD_STORE::GetTariffsList(std::vector * tariffsList) const { @@ -305,8 +312,8 @@ try st->Get(7, td->dirPrice[dir].priceNightB); td->dirPrice[dir].priceNightB /= 1024*1024; st->Get(8, td->dirPrice[dir].threshold); - if (std::fabs(td->dirPrice[dir].priceDayA - td->dirPrice[dir].priceNightA) < 1.0e-3 && - std::fabs(td->dirPrice[dir].priceDayB - td->dirPrice[dir].priceNightB) < 1.0e-3) + if (std::fabs(td->dirPrice[dir].priceDayA - td->dirPrice[dir].priceNightA) < 1.0e-3 / pt_mega && + std::fabs(td->dirPrice[dir].priceDayB - td->dirPrice[dir].priceNightB) < 1.0e-3 / pt_mega) { td->dirPrice[dir].singlePrice = true; } diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp index dabc06db..045411b1 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp @@ -36,6 +36,13 @@ #include "postgresql_store.h" #include "stg/locker.h" +namespace +{ + +const int pt_mega = 1024 * 1024; + +} + //----------------------------------------------------------------------------- int POSTGRESQL_STORE::GetTariffsList(std::vector * tariffsList) const { @@ -568,8 +575,8 @@ for (int i = 0; i < std::min(tuples, DIR_NUM); ++i) tuple >> td->dirPrice[dir].mNight; } - if (std::fabs(td->dirPrice[dir].priceDayA - td->dirPrice[dir].priceNightA) > 1.0e-3 && - std::fabs(td->dirPrice[dir].priceDayB - td->dirPrice[dir].priceNightB) > 1.0e-3) + if (std::fabs(td->dirPrice[dir].priceDayA - td->dirPrice[dir].priceNightA) < 1.0e-3 / pt_mega && + std::fabs(td->dirPrice[dir].priceDayB - td->dirPrice[dir].priceNightB) < 1.0e-3 / pt_mega) { td->dirPrice[dir].singlePrice = true; } diff --git a/stglibs/dotconfpp.lib/dotconfpp.cpp b/stglibs/dotconfpp.lib/dotconfpp.cpp index caf5a590..8f766f01 100644 --- a/stglibs/dotconfpp.lib/dotconfpp.cpp +++ b/stglibs/dotconfpp.lib/dotconfpp.cpp @@ -336,7 +336,7 @@ int DOTCONFDocument::setContent(const char * _fileName) char realpathBuf[PATH_MAX]; if(realpath(_fileName, realpathBuf) == NULL){ - error(0, _fileName, "realpath('%s') failed: %s", _fileName, strerror(errno)); + error(0, _fileName, "%s", strerror(errno)); return -1; } @@ -514,9 +514,9 @@ void DOTCONFDocument::error(int lineNum, const char * fileName, const char * fmt char * buf = (char*)mempool->alloc(len); if(lineNum) - (void) snprintf(buf, len, "DOTCONF++: file '%s', line %d: %s\n", fileName, lineNum, msg); + (void) snprintf(buf, len, "File '%s', line %d: %s\n", fileName, lineNum, msg); else - (void) snprintf(buf, len, "DOTCONF++: file '%s': %s\n", fileName, msg); + (void) snprintf(buf, len, "File '%s': %s\n", fileName, msg); if (errorCallback) { errorCallback(errorCallbackData, buf);