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;
return res;
}
+template <typename T>
+bool str2res(const std::string& source, RESETABLE<T>& dest, T divisor)
+{
+ T value = 0;
+ if (str2x(source, value))
+ return false;
+ dest = value / divisor;
+ return true;
+}
+
template <typename A, typename C, typename F>
bool String2AOS(const std::string & source, A & array, size_t size, RESETABLE<F> C::* field, F divisor)
{
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;
}
#include "firebird_store.h"
#include "stg/ibpp.h"
+namespace
+{
+
+const int pt_mega = 1024 * 1024;
+
+}
+
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::GetTariffsList(std::vector<std::string> * tariffsList) const
{
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;
}
#include "postgresql_store.h"
#include "stg/locker.h"
+namespace
+{
+
+const int pt_mega = 1024 * 1024;
+
+}
+
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::GetTariffsList(std::vector<std::string> * tariffsList) const
{
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;
}
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;
}
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);