serviceChg(0),
corpChg(0)
{}
- PRIV(uint32_t p)
+ explicit PRIV(uint32_t p)
: userStat((p & 0x00000003) >> 0x00),
userConf((p & 0x0000000C) >> 0x02),
userCash((p & 0x00000030) >> 0x04),
login(),
password("* NO PASSWORD *")
{}
- ADMIN_CONF(const ADMIN_CONF & rvalue)
- : priv(rvalue.priv),
- login(rvalue.login),
- password(rvalue.password)
- {}
ADMIN_CONF(const PRIV & pr, const std::string & l, const std::string & p)
: priv(pr),
login(l),
struct CORP_CONF
{
CORP_CONF() : name(), cash(0) {}
-CORP_CONF(const std::string & n) : name(n), cash(0) {}
+explicit CORP_CONF(const std::string & n) : name(n), cash(0) {}
CORP_CONF(const std::string & n, double c) : name(n), cash(c) {}
std::string name;
class STG_LOCKER
{
public:
- STG_LOCKER(pthread_mutex_t * m)
+ explicit STG_LOCKER(pthread_mutex_t * m)
: mutex(m)
{
pthread_mutex_lock(mutex);
#ifndef __PLUGIN_CREATOR_H__
#define __PLUGIN_CREATOR_H__
+#include "noncopyable.h"
+
template <class T>
-class PLUGIN_CREATOR
+class PLUGIN_CREATOR : private NONCOPYABLE
{
public:
PLUGIN_CREATOR() : plugin(new T()) {}
- ~PLUGIN_CREATOR() { delete plugin; }
+ //~PLUGIN_CREATOR() { delete plugin; }
T * GetPlugin() { return plugin; }
private:
T * plugin;
-
- PLUGIN_CREATOR(const PLUGIN_CREATOR<T> & rvalue);
- PLUGIN_CREATOR<T> & operator=(const PLUGIN_CREATOR<T> & rvalue);
};
#endif
typedef T value_type;
RESETABLE() : value(), is_set(false) {}
- RESETABLE(const T & v) : value(v), is_set(true) {}
-
- RESETABLE(const RESETABLE<T> & rvalue)
- : value(rvalue.value),
- is_set(rvalue.is_set)
- {}
-
- RESETABLE<T> & operator=(const RESETABLE<T> & rhs)
- {
- value = rhs.value;
- is_set = rhs.is_set;
- return *this;
- }
+ explicit RESETABLE(const T & v) : value(v), is_set(true) {}
RESETABLE<T> & operator=(const T & rhs)
{
SERVICE_CONF()
: name(), comment(), cost(0), payDay(0)
{}
-SERVICE_CONF(const std::string & n)
+explicit SERVICE_CONF(const std::string & n)
: name(n), comment(), cost(0), payDay(0)
{}
SERVICE_CONF(const std::string & n, double c)
cost(), payDay()
{}
-SERVICE_CONF_RES(const SERVICE_CONF & rhs)
+explicit SERVICE_CONF_RES(const SERVICE_CONF & rhs)
: name(rhs.name), comment(rhs.comment),
cost(rhs.cost), payDay(rhs.payDay)
{}
changePolicyTimeout(0)
{}
- TARIFF_CONF(const std::string & n)
+ explicit TARIFF_CONF(const std::string & n)
: fee(0),
free(0),
traffType(TARIFF::TRAFF_UP_DOWN),
dirPrice(DIR_NUM)
{}
- TARIFF_DATA(const std::string & name)
+ explicit TARIFF_DATA(const std::string & name)
: tariffConf(name),
dirPrice(DIR_NUM)
{}
-
- TARIFF_DATA(const TARIFF_DATA & td)
- : tariffConf(td.tariffConf),
- dirPrice(td.dirPrice)
- {}
-
- TARIFF_DATA & operator=(const TARIFF_DATA & td)
- {
- tariffConf = td.tariffConf;
- dirPrice = td.dirPrice;
- return *this;
- }
};
//-----------------------------------------------------------------------------
struct TARIFF_DATA_RES
template<typename varT>
class USER_PROPERTY : public USER_PROPERTY_BASE {
public:
- USER_PROPERTY(varT & val);
+ explicit USER_PROPERTY(varT & val);
virtual ~USER_PROPERTY();
void Set(const varT & rvalue);
REGISTRY properties;
public:
- USER_PROPERTIES(const SETTINGS& s);
+ explicit USER_PROPERTIES(const SETTINGS& s);
USER_STAT & Stat() { return stat; }
USER_CONF & Conf() { return conf; }
typedef ContainerType::size_type IndexType;
DIR_TRAFF() : traff(DIR_NUM) {}
- DIR_TRAFF(const DIR_TRAFF & ts) : traff(ts.traff) {}
- DIR_TRAFF & operator=(const DIR_TRAFF & ts) { traff = ts.traff; return *this; }
const uint64_t & operator[](IndexType idx) const { return traff[idx]; }
uint64_t & operator[](IndexType idx) { return traff[idx]; }
IndexType size() const { return traff.size(); }
typedef ContainerType::size_type IndexType;
DIR_TRAFF_RES() : traff(DIR_NUM) {}
- DIR_TRAFF_RES(const DIR_TRAFF & ts)
+ explicit DIR_TRAFF_RES(const DIR_TRAFF & ts)
: traff(ts.size())
{
for (IndexType i = 0; i < ts.size(); ++i)
traff[i] = ts[i];
}
+ DIR_TRAFF_RES & operator=(const DIR_TRAFF & ts)
+ {
+ for (IndexType i = 0; i < ts.size(); ++i)
+ traff[i] = ts[i];
+ return *this;
+ }
const ValueType & operator[](IndexType idx) const { return traff[idx]; }
ValueType & operator[](IndexType idx) { return traff[idx]; }
IndexType size() const { return traff.size(); }
tv_usec = 0;
}
- UTIME(time_t t)
+ explicit UTIME(time_t t)
{
tv_sec = t;
tv_usec = 0;
class IsNotTimedOut : public std::unary_function<const AliveData &, bool> {
public:
- IsNotTimedOut(double to) : timeout(to), now(time(NULL)) {}
+ explicit IsNotTimedOut(double to) : timeout(to), now(time(NULL)) {}
bool operator()(const AliveData & data) const
{
return difftime(now, data.lastAlive) < timeout;
class DisconnectUser : public std::unary_function<const UserData &, void> {
public:
- DisconnectUser(LISTENER & l) : listener(l) {};
+ explicit DisconnectUser(LISTENER & l) : listener(l) {};
void operator()(const UserData & data)
{
listener.Disconnect(data);
class PIDFile {
public:
- PIDFile(const std::string & fn);
+ explicit PIDFile(const std::string & fn);
~PIDFile();
private:
std::string fileName;
sprintf(str," <TD id=\"TraffTableDSCellC\">%s</TD>\n", gettext("Session Download"));
res = send(outerSocket, str, strlen(str), 0);
-rowNum = 0;
for (j = 0; j < DIR_NUM; j++)
{
if (dirName[j][0] == 0)
class SETTINGS_IMPL {
public:
SETTINGS_IMPL() : confFile("./sgconv.conf") {}
- SETTINGS_IMPL(const std::string & cf) : confFile(cf) {}
+ explicit SETTINGS_IMPL(const std::string & cf) : confFile(cf) {}
~SETTINGS_IMPL() {}
int ReadSettings();
*/
#include "admin_impl.h"
+
#include "stg/common.h"
//-----------------------------------------------------------------------------
ADMIN_IMPL::ADMIN_IMPL()
: ADMIN(),
conf(),
- ip(0),
- WriteServLog(GetStgLogger())
+ ip(0)
{
}
//-----------------------------------------------------------------------------
ADMIN_IMPL::ADMIN_IMPL(const ADMIN_CONF & ac)
: ADMIN(),
conf(ac),
- ip(0),
- WriteServLog(GetStgLogger())
+ ip(0)
{
}
//-----------------------------------------------------------------------------
const std::string & password)
: ADMIN(),
conf(priv, login, password),
- ip(0),
- WriteServLog(GetStgLogger())
+ ip(0)
{
}
//-----------------------------------------------------------------------------
#ifndef ADMIN_IMPL_H
#define ADMIN_IMPL_H
-#include <string>
-
#include "stg/admin.h"
#include "stg/os_int.h"
#include "stg/admin_conf.h"
-#include "stg/logger.h"
+
+#include <string>
class ADMIN_IMPL : public ADMIN {
public:
ADMIN_IMPL();
- ADMIN_IMPL(const ADMIN_CONF & ac);
+ explicit ADMIN_IMPL(const ADMIN_CONF & ac);
ADMIN_IMPL(const PRIV & priv,
const std::string & login,
const std::string & password);
private:
ADMIN_CONF conf;
uint32_t ip;
- STG_LOGGER & WriteServLog;
};
#endif
$Author: faust $
*/
-#include <cerrno>
-#include <cassert>
-#include <algorithm>
-
#include "stg/common.h"
#include "admins_impl.h"
#include "admin_impl.h"
+#include <cerrno>
+#include <cassert>
+#include <algorithm>
+
//-----------------------------------------------------------------------------
ADMINS_IMPL::ADMINS_IMPL(STORE * st)
: ADMINS(),
- stg(0xFFFF, "@stargazer", ""),
- noAdmin(0xFFFF, "NO-ADMIN", ""),
+ stg(PRIV(0xFFFF), "@stargazer", ""),
+ noAdmin(PRIV(0xFFFF), "NO-ADMIN", ""),
data(),
store(st),
WriteServLog(GetStgLogger()),
return -1;
}
-ADMIN_IMPL adm(0, login, "");
+ADMIN_IMPL adm(PRIV(0), login, "");
admin_iter ai(find(data.begin(), data.end(), adm));
if (ai != data.end())
int ADMINS_IMPL::Del(const std::string & login, const ADMIN * admin)
{
STG_LOCKER lock(&mutex);
-ADMIN_IMPL adm(0, login, "");
const PRIV * priv = admin->GetPriv();
if (!priv->adminChg)
return -1;
}
-admin_iter ai(find(data.begin(), data.end(), adm));
+admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, "")));
if (ai == data.end())
{
{
if (si->second == ai)
(si->second)++;
- si++;
+ ++si;
}
data.remove(*ai);
return -1;
}
-ADMIN_IMPL adm(0, ac.login, "");
-admin_iter ai(find(data.begin(), data.end(), adm));
+admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), ac.login, "")));
if (ai == data.end())
{
for (unsigned int i = 0; i < adminsList.size(); i++)
{
- ADMIN_CONF ac(0, adminsList[i], "");
+ ADMIN_CONF ac(PRIV(0), adminsList[i], "");
if (store->RestoreAdmin(&ac, adminsList[i]))
{
return false;
}
-ADMIN_IMPL adm(0, l, "");
-admin_iter ai(find(data.begin(), data.end(), adm));
+admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), l, "")));
if (ai != data.end())
{
return true;
}
-ADMIN_IMPL adm(0, login, "");
-const_admin_iter ai(find(data.begin(), data.end(), adm));
+const_admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, "")));
if (ai != data.end())
return true;
return true;
}
-ADMIN_IMPL adm(0, login, "");
-admin_iter ai(find(data.begin(), data.end(), adm));
+admin_iter ai(find(data.begin(), data.end(), ADMIN_IMPL(PRIV(0), login, "")));
if (ai == data.end())
{
#ifndef ADMINS_IMPL_H
#define ADMINS_IMPL_H
-#include <pthread.h>
-
-#include <list>
-#include <map>
-#include <string>
+#include "admin_impl.h"
#include "stg/admins.h"
#include "stg/admin.h"
#include "stg/store.h"
#include "stg/noncopyable.h"
#include "stg/logger.h"
-#include "admin_impl.h"
+
+#include <list>
+#include <map>
+#include <string>
+
+#include <pthread.h>
class ADMINS_IMPL : private NONCOPYABLE, public ADMINS {
public:
- ADMINS_IMPL(STORE * st);
+ explicit ADMINS_IMPL(STORE * st);
virtual ~ADMINS_IMPL() {}
int Add(const std::string & login, const ADMIN * admin);
* Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
-#include <cerrno>
-#include <cassert>
-#include <algorithm>
+#include "corps_impl.h"
#include "stg/admin.h"
#include "stg/common.h"
-#include "corps_impl.h"
+
+#include <cerrno>
+#include <cassert>
+#include <algorithm>
//-----------------------------------------------------------------------------
CORPORATIONS_IMPL::CORPORATIONS_IMPL(STORE * st)
{
if (csi->second == si)
(csi->second)++;
- csi++;
+ ++csi;
}
data.remove(*si);
#ifndef CORPORATIONS_IMPL_H
#define CORPORATIONS_IMPL_H
-#include <pthread.h>
-
-#include <list>
-#include <map>
-#include <string>
-
#include "stg/corporations.h"
#include "stg/corp_conf.h"
#include "stg/locker.h"
#include "stg/noncopyable.h"
#include "stg/logger.h"
+#include <list>
+#include <map>
+#include <string>
+
+#include <pthread.h>
+
class ADMIN;
class CORPORATIONS_IMPL : private NONCOPYABLE, public CORPORATIONS {
public:
- CORPORATIONS_IMPL(STORE * st);
+ explicit CORPORATIONS_IMPL(STORE * st);
virtual ~CORPORATIONS_IMPL() {}
int Add(const CORP_CONF & corp, const ADMIN * admin);
class PIDFile {
public:
- PIDFile(const std::string & fn);
+ explicit PIDFile(const std::string & fn);
~PIDFile();
private:
std::string fileName;
//-----------------------------------------------------------------------------
PLUGIN_RUNNER::~PLUGIN_RUNNER()
{
+delete &m_plugin;
if (dlclose(libHandle))
{
errorStr = "Failed to unload plugin '" + pluginFileName + "': " + dlerror();
class PLUGIN_RUNNER {
public:
struct Error : public std::runtime_error {
- Error(const std::string & msg) : runtime_error(msg) {}
+ explicit Error(const std::string & msg) : runtime_error(msg) {}
};
PLUGIN_RUNNER(const std::string & pluginFileName,
class IS_CONTAINS_USER: public std::binary_function<varType, USER_PTR, bool>
{
public:
- bool operator()(varType notifier, USER_PTR user) const
+ bool operator()(const varType& notifier, USER_PTR user) const
{
return notifier.GetUser() == user;
}
class ADD_USER_NONIFIER: public NOTIFIER_BASE<USER_PTR> {
public:
- ADD_USER_NONIFIER(AUTH_AO & a) : auth(a) {}
+ explicit ADD_USER_NONIFIER(AUTH_AO & a) : auth(a) {}
virtual ~ADD_USER_NONIFIER() {}
void Notify(const USER_PTR & user) { auth.AddUser(user); }
class DEL_USER_NONIFIER: public NOTIFIER_BASE<USER_PTR> {
public:
- DEL_USER_NONIFIER(AUTH_AO & a) : auth(a) {}
+ explicit DEL_USER_NONIFIER(AUTH_AO & a) : auth(a) {}
virtual ~DEL_USER_NONIFIER() {}
void Notify(const USER_PTR & user) { auth.DelUser(user); }
{
touchTime = stgTime;
std::string monFile = ia->stgSettings->GetMonitorDir() + "/inetaccess_r";
- TouchFile(monFile.c_str());
+ TouchFile(monFile);
}
}
// TODO change counter to timer and MONITOR_TIME_DELAY_SEC
if (++a % (50 * 60) == 0 && ia->stgSettings->GetMonitoring())
{
- TouchFile(monFile.c_str());
+ TouchFile(monFile);
}
}
&& (currTime - it->second.phase.GetTime()) > iaSettings.GetUserDelay())
{
if (iaSettings.LogProtocolErrors())
- logger("User '%s'. Protocol version: %d. Phase 2: connect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay());
+ logger("User '%s'. Protocol version: %d. Phase 2: connect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay().GetSec());
it->second.phase.SetPhase1();
printfd(__FILE__, "Phase changed from 2 to 1. Reason: timeout\n");
ip2user.erase(it++);
if ((currTime - it->second.phase.GetTime()) > iaSettings.GetUserTimeout())
{
if (iaSettings.LogProtocolErrors())
- logger("User '%s'. Protocol version: %d. Phase 3: alive timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserTimeout());
+ logger("User '%s'. Protocol version: %d. Phase 3: alive timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserTimeout().GetSec());
users->Unauthorize(it->second.user->GetLogin(), this);
ip2user.erase(it++);
continue;
&& ((currTime - it->second.phase.GetTime()) > iaSettings.GetUserDelay()))
{
if (iaSettings.LogProtocolErrors())
- logger("User '%s'. Protocol version: %d. Phase 4: disconnect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay());
+ logger("User '%s'. Protocol version: %d. Phase 4: disconnect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay().GetSec());
it->second.phase.SetPhase3();
printfd(__FILE__, "Phase changed from 4 to 3. Reason: timeout\n");
}
iaUser->rnd = static_cast<uint32_t>(random());
connSynAck6.rnd = iaUser->rnd;
-connSynAck6.userTimeOut = iaSettings.GetUserTimeout();
-connSynAck6.aliveDelay = iaSettings.GetUserDelay();
+connSynAck6.userTimeOut = iaSettings.GetUserTimeout().GetSec();
+connSynAck6.aliveDelay = iaSettings.GetUserDelay().GetSec();
#ifdef ARCH_BE
SwapBytes(connSynAck6.len);
iaUser->rnd = static_cast<uint32_t>(random());
connSynAck8.rnd = iaUser->rnd;
-connSynAck8.userTimeOut = iaSettings.GetUserTimeout();
-connSynAck8.aliveDelay = iaSettings.GetUserDelay();
+connSynAck8.userTimeOut = iaSettings.GetUserTimeout().GetSec();
+connSynAck8.aliveDelay = iaSettings.GetUserDelay().GetSec();
#ifdef ARCH_BE
SwapBytes(connSynAck8.len);
#ifndef INETACCESS_H
#define INETACCESS_H
-#include <sys/time.h>
-#include <pthread.h>
-
-#include <cstring>
-#include <ctime>
-#include <string>
-#include <map>
-#include <list>
-#include <functional>
-#include <utility>
-
#include "stg/os_int.h"
#include "stg/auth.h"
#include "stg/store.h"
#include "stg/utime.h"
#include "stg/logger.h"
+#include <cstring>
+#include <ctime>
+#include <string>
+#include <map>
+#include <list>
+#include <functional>
+#include <utility>
+
+#include <sys/time.h>
+#include <pthread.h>
+
#define IA_PROTO_VER (6)
//#define IA_DEBUG (1)
virtual ~AUTH_IA_SETTINGS() {}
const std::string & GetStrError() const { return errorStr; }
int ParseSettings(const MODULE_SETTINGS & s);
- int GetUserDelay() const { return userDelay; }
- int GetUserTimeout() const { return userTimeout; }
+ UTIME GetUserDelay() const { return UTIME(userDelay); }
+ UTIME GetUserTimeout() const { return UTIME(userTimeout); }
uint16_t GetUserPort() const { return port; }
FREEMB GetFreeMbShowType() const { return freeMbShowType; }
bool LogProtocolErrors() const { return logProtocolErrors; }
//-----------------------------------------------------------------------------
class DEL_USER_NOTIFIER: public NOTIFIER_BASE<USER_PTR> {
public:
- DEL_USER_NOTIFIER(AUTH_IA & a) : auth(a) {}
+ explicit DEL_USER_NOTIFIER(AUTH_IA & a) : auth(a) {}
virtual ~DEL_USER_NOTIFIER() {}
void Notify(const USER_PTR & user);
//-----------------------------------------------------------------------------
class UnauthorizeUser : std::unary_function<const std::pair<uint32_t, IA_USER> &, void> {
public:
- UnauthorizeUser(AUTH_IA * a) : auth(a) {}
+ explicit UnauthorizeUser(AUTH_IA * a) : auth(a) {}
UnauthorizeUser(const UnauthorizeUser & rvalue) : auth(rvalue.auth) {}
void operator()(const std::pair<uint32_t, IA_USER> & p)
{
class METHOD_LOGIN : public xmlrpc_c::method
{
public:
- METHOD_LOGIN(RPC_CONFIG * c)
+ explicit METHOD_LOGIN(RPC_CONFIG * c)
: config(c)
{
}
class METHOD_LOGOUT : public xmlrpc_c::method
{
public:
- METHOD_LOGOUT(RPC_CONFIG * c)
+ explicit METHOD_LOGOUT(RPC_CONFIG * c)
: config(c)
{
}
class TARIFF_HELPER
{
public:
- TARIFF_HELPER(TARIFF_DATA & td)
+ explicit TARIFF_HELPER(TARIFF_DATA & td)
: data(td)
{}
CONFIGPROTO::~CONFIGPROTO()
{
+ {
std::deque<STG::Conn *>::iterator it;
for (it = m_conns.begin(); it != m_conns.end(); ++it)
delete *it;
+ }
+ {
+ BASE_PARSER::REGISTRY::iterator it;
+ for (it = m_registry.begin(); it != m_registry.end(); ++it)
+ delete it->second;
+ }
}
int CONFIGPROTO::Prepare()
class CONFIGPROTO {
public:
- CONFIGPROTO(PLUGIN_LOGGER & l);
+ explicit CONFIGPROTO(PLUGIN_LOGGER & l);
~CONFIGPROTO();
void SetPort(uint16_t port) { m_port = port; }
close(m_sock);
XML_ParserFree(m_xmlParser);
+
+ delete m_stream;
+ delete m_parser;
}
bool Conn::Read()
answer = m_parser->GetAnswer();
else
answer = "<Error result=\"Unknown command.\"/>";
+ delete m_parser;
+ m_parser = NULL;
printfd(__FILE__, "Writing %d bytes of answer.\n", answer.length());
stream.Put(answer.c_str(), answer.length() + 1 /* including \0 */, true /* final */);
return stream.IsOk();
public:
struct Error : public std::runtime_error
{
- Error(const std::string& message) : runtime_error(message.c_str()) {}
+ explicit Error(const std::string& message) : runtime_error(message.c_str()) {}
};
Conn(const BASE_PARSER::REGISTRY & registry,
public:
struct FACTORY
{
+ virtual ~FACTORY() {}
virtual BASE_PARSER * create(const ADMIN & admin) = 0;
};
typedef std::map<std::string, FACTORY *> REGISTRY;
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMINS & admins) : m_admins(admins) {}
+ explicit FACTORY(const ADMINS & admins) : m_admins(admins) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_ADMINS(admin, m_admins); }
static void Register(REGISTRY & registry, const ADMINS & admins)
{ registry[ToLower(tag)] = new FACTORY(admins); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(ADMINS & admins) : m_admins(admins) {}
+ explicit FACTORY(ADMINS & admins) : m_admins(admins) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_ADMIN(admin, m_admins); }
static void Register(REGISTRY & registry, ADMINS & admins)
{ registry[ToLower(tag)] = new FACTORY(admins); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(ADMINS & admins) : m_admins(admins) {}
+ explicit FACTORY(ADMINS & admins) : m_admins(admins) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_ADMIN(admin, m_admins); }
static void Register(REGISTRY & registry, ADMINS & admins)
{ registry[ToLower(tag)] = new FACTORY(admins); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(ADMINS & admins) : m_admins(admins) {}
+ explicit FACTORY(ADMINS & admins) : m_admins(admins) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_ADMIN(admin, m_admins); }
static void Register(REGISTRY & registry, ADMINS & admins)
{ registry[ToLower(tag)] = new FACTORY(admins); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const USERS & users) : m_users(users) {}
+ explicit FACTORY(const USERS & users) : m_users(users) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new AUTH_BY(admin, m_users); }
static void Register(REGISTRY & registry, const USERS & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(USERS & users) : m_users(users) {}
+ explicit FACTORY(USERS & users) : m_users(users) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new SEND_MESSAGE(admin, m_users); }
static void Register(REGISTRY & registry, USERS & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const TARIFFS & tariffs) : m_tariffs(tariffs) {}
+ explicit FACTORY(const TARIFFS & tariffs) : m_tariffs(tariffs) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_TARIFFS(admin, m_tariffs); }
static void Register(REGISTRY & registry, const TARIFFS & tariffs)
{ registry[ToLower(tag)] = new FACTORY(tariffs); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {}
+ explicit FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_TARIFF(admin, m_tariffs); }
static void Register(REGISTRY & registry, TARIFFS & tariffs)
{ registry[ToLower(tag)] = new FACTORY(tariffs); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {}
+ explicit FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_TARIFF(admin, m_tariffs); }
static void Register(REGISTRY & registry, TARIFFS & tariffs)
{ registry[ToLower(tag)] = new FACTORY(tariffs); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(USERS & users) : m_users(users) {}
+ explicit FACTORY(USERS & users) : m_users(users) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USERS(admin, m_users); }
static void Register(REGISTRY & registry, USERS & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const USERS & users) : m_users(users) {}
+ explicit FACTORY(const USERS & users) : m_users(users) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USER(admin, m_users); }
static void Register(REGISTRY & registry, const USERS & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(USERS & users) : m_users(users) {}
+ explicit FACTORY(USERS & users) : m_users(users) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_USER(admin, m_users); }
static void Register(REGISTRY & registry, USERS & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(USERS & users) : m_users(users) {}
+ explicit FACTORY(USERS & users) : m_users(users) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_USER(admin, m_users); }
static void Register(REGISTRY & registry, USERS & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const USERS & users) : m_users(users) {}
+ explicit FACTORY(const USERS & users) : m_users(users) {}
virtual BASE_PARSER * create(const ADMIN & admin) { return new CHECK_USER(admin, m_users); }
static void Register(REGISTRY & registry, const USERS & users)
{ registry[ToLower(tag)] = new FACTORY(users); }
#ifndef PING_H
#define PING_H
-#include <pthread.h>
-
-#include <string>
-#include <list>
-
#include "stg/os_int.h"
#include "stg/plugin.h"
#include "stg/module_settings.h"
#include "stg/users.h"
#include "stg/logger.h"
+#include <string>
+#include <list>
+
+#include <pthread.h>
+
extern "C" PLUGIN * GetPlugin();
class PING;
//-----------------------------------------------------------------------------
class ADD_USER_NONIFIER_PING: public NOTIFIER_BASE<USER_PTR> {
public:
- ADD_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE<USER_PTR>(), ping(p) {}
+ explicit ADD_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE<USER_PTR>(), ping(p) {}
virtual ~ADD_USER_NONIFIER_PING() {}
void Notify(const USER_PTR & user);
//-----------------------------------------------------------------------------
class DEL_USER_NONIFIER_PING: public NOTIFIER_BASE<USER_PTR> {
public:
- DEL_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE<USER_PTR>(), ping(p) {}
+ explicit DEL_USER_NONIFIER_PING(PING & p) : NOTIFIER_BASE<USER_PTR>(), ping(p) {}
virtual ~DEL_USER_NONIFIER_PING() {}
void Notify(const USER_PTR & user);
void DelUser(USER_PTR u);
private:
- PING(const PING & rvalue);
+ explicit PING(const PING & rvalue);
PING & operator=(const PING & rvalue);
void GetUsers();
* Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
-#include <sys/time.h>
+#include "rscript.h"
-#include <csignal>
-#include <cassert>
-#include <cstdlib>
-#include <cerrno>
-#include <cstring>
-#include <algorithm>
+#include "ur_functor.h"
+#include "send_functor.h"
#include "stg/common.h"
#include "stg/locker.h"
#include "stg/user_property.h"
#include "stg/plugin_creator.h"
#include "stg/logger.h"
-#include "rscript.h"
-#include "ur_functor.h"
-#include "send_functor.h"
+
+#include <algorithm>
+
+#include <csignal>
+#include <cassert>
+#include <cstdlib>
+#include <cerrno>
+#include <cstring>
+
+#include <sys/time.h>
+#include <netinet/ip.h>
extern volatile time_t stgTime;
template<typename T>
struct USER_IS
{
- USER_IS(USER_PTR u) : user(u) {}
+ explicit USER_IS(USER_PTR u) : user(u) {}
bool operator()(const T & notifier) { return notifier.GetUser() == user; }
USER_PTR user;
#ifndef RSCRIPT_H
#define RSCRIPT_H
-#include <pthread.h>
-
-#include <string>
-#include <list>
-#include <map>
-#include <functional>
-#include <utility>
-
#include "stg/plugin.h"
#include "stg/module_settings.h"
#include "stg/os_int.h"
#include "nrmap_parser.h"
+#include <string>
+#include <list>
+#include <map>
+#include <functional>
+#include <utility>
+
+#include <pthread.h>
+
extern "C" PLUGIN * GetPlugin();
#define RS_DEBUG (1)
//-----------------------------------------------------------------------------
class ADD_USER_NONIFIER: public NOTIFIER_BASE<USER_PTR> {
public:
- ADD_USER_NONIFIER(REMOTE_SCRIPT & r)
+ explicit ADD_USER_NONIFIER(REMOTE_SCRIPT & r)
: NOTIFIER_BASE<USER_PTR>(), rs(r) {}
virtual ~ADD_USER_NONIFIER() {}
void Notify(const USER_PTR & user);
//-----------------------------------------------------------------------------
class DEL_USER_NONIFIER: public NOTIFIER_BASE<USER_PTR> {
public:
- DEL_USER_NONIFIER(REMOTE_SCRIPT & r)
+ explicit DEL_USER_NONIFIER(REMOTE_SCRIPT & r)
: NOTIFIER_BASE<USER_PTR>(), rs(r) {}
virtual ~DEL_USER_NONIFIER() {}
void Notify(const USER_PTR & user);
//-----------------------------------------------------------------------------
struct USER {
USER(const std::vector<uint32_t> & r, USER_PTR it)
- : user(it),
+ : lastSentTime(0),
+ user(it),
routers(r),
shortPacketsCount(0),
ip(user->GetCurrIP())
//-----------------------------------------------------------------------------
class DisconnectUser : public std::unary_function<std::pair<const uint32_t, USER> &, void> {
public:
- DisconnectUser(REMOTE_SCRIPT & rs) : rscript(rs) {}
+ explicit DisconnectUser(REMOTE_SCRIPT & rs) : rscript(rs) {}
void operator()(std::pair<const uint32_t, USER> & p)
{
rscript.Send(p.second, true);
#ifndef __SEND_FUNCTOR_H__
#define __SEND_FUNCTOR_H__
-#include <sys/types.h>
-#include <sys/socket.h>
+#include "stg/os_int.h"
#include <functional>
-#include "stg/os_int.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/ip.h>
class PacketSender : public std::unary_function<uint32_t, ssize_t> {
public:
#ifndef __UR_FUNCTOR_H__
#define __UR_FUNCTOR_H__
-#include <functional>
-#include <algorithm>
-#include <utility>
+#include "rscript.h"
#include "stg/os_int.h"
#include "stg/common.h"
-#include "rscript.h"
+#include <functional>
+#include <algorithm>
+#include <utility>
namespace RS
{
class UpdateRouter : public std::unary_function<std::pair<const uint32_t, RS::USER>, void>
{
public:
- UpdateRouter(REMOTE_SCRIPT & t)
+ explicit UpdateRouter(REMOTE_SCRIPT & t)
: obj(t) {}
void operator() (std::pair<const uint32_t, USER> & val)
{
obj.SendDirect(val.second, *oldIt, true); // Disconnect on old router
++oldIt;
- }
+ }
else if (*oldIt < *newIt)
{
obj.SendDirect(val.second, *oldIt, true); // Disconnect on old router
}
else
{
- if (oldIt != val.second.routers.end())
- ++oldIt;
+ ++oldIt;
if (newIt != newRouters.end())
++newIt;
}
class TotalUsersSensor : public Sensor {
public:
- TotalUsersSensor(const USERS & u) : users(u) {}
+ explicit TotalUsersSensor(const USERS & u) : users(u) {}
virtual ~TotalUsersSensor() {}
bool GetValue(ObjectSyntax_t * objectSyntax) const
class UsersSensor : public Sensor {
public:
- UsersSensor(USERS & u) : users(u) {}
+ explicit UsersSensor(USERS & u) : users(u) {}
virtual ~UsersSensor() {}
bool GetValue(ObjectSyntax_t * objectSyntax) const;
class ConnectedUsersSensor : public UsersSensor {
public:
- ConnectedUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit ConnectedUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~ConnectedUsersSensor() {}
private:
class AuthorizedUsersSensor : public UsersSensor {
public:
- AuthorizedUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit AuthorizedUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~AuthorizedUsersSensor() {}
private:
class AlwaysOnlineUsersSensor : public UsersSensor {
public:
- AlwaysOnlineUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit AlwaysOnlineUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~AlwaysOnlineUsersSensor() {}
private:
class NoCashUsersSensor : public UsersSensor {
public:
- NoCashUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit NoCashUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~NoCashUsersSensor() {}
private:
class DisabledDetailStatsUsersSensor : public UsersSensor {
public:
- DisabledDetailStatsUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit DisabledDetailStatsUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~DisabledDetailStatsUsersSensor() {}
private:
class DisabledUsersSensor : public UsersSensor {
public:
- DisabledUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit DisabledUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~DisabledUsersSensor() {}
private:
class PassiveUsersSensor : public UsersSensor {
public:
- PassiveUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit PassiveUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~PassiveUsersSensor() {}
private:
class CreditUsersSensor : public UsersSensor {
public:
- CreditUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit CreditUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~CreditUsersSensor() {}
private:
class FreeMbUsersSensor : public UsersSensor {
public:
- FreeMbUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit FreeMbUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~FreeMbUsersSensor() {}
private:
class TariffChangeUsersSensor : public UsersSensor {
public:
- TariffChangeUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit TariffChangeUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~TariffChangeUsersSensor() {}
private:
class ActiveUsersSensor : public UsersSensor {
public:
- ActiveUsersSensor(USERS & u) : UsersSensor(u) {}
+ explicit ActiveUsersSensor(USERS & u) : UsersSensor(u) {}
virtual ~ActiveUsersSensor() {}
private:
class TotalTariffsSensor : public Sensor {
public:
- TotalTariffsSensor(const TARIFFS & t) : tariffs(t) {}
+ explicit TotalTariffsSensor(const TARIFFS & t) : tariffs(t) {}
virtual ~TotalTariffsSensor() {}
bool GetValue(ObjectSyntax_t * objectSyntax) const
class TotalAdminsSensor : public Sensor {
public:
- TotalAdminsSensor(const ADMINS & a) : admins(a) {}
+ explicit TotalAdminsSensor(const ADMINS & a) : admins(a) {}
virtual ~TotalAdminsSensor() {}
bool GetValue(ObjectSyntax_t * objectSyntax) const
class TotalServicesSensor : public Sensor {
public:
- TotalServicesSensor(const SERVICES & s) : services(s) {}
+ explicit TotalServicesSensor(const SERVICES & s) : services(s) {}
virtual ~TotalServicesSensor() {}
bool GetValue(ObjectSyntax_t * objectSyntax) const
class TotalCorporationsSensor : public Sensor {
public:
- TotalCorporationsSensor(const CORPORATIONS & c) : corporations(c) {}
+ explicit TotalCorporationsSensor(const CORPORATIONS & c) : corporations(c) {}
virtual ~TotalCorporationsSensor() {}
bool GetValue(ObjectSyntax_t * objectSyntax) const
class TotalRulesSensor : public Sensor {
public:
- TotalRulesSensor(const TRAFFCOUNTER & t) : traffcounter(t) {}
+ explicit TotalRulesSensor(const TRAFFCOUNTER & t) : traffcounter(t) {}
virtual ~TotalRulesSensor() {}
bool GetValue(ObjectSyntax_t * objectSyntax) const
template <typename T>
class ConstSensor : public Sensor {
public:
- ConstSensor(const T & v) : value(v) {}
+ explicit ConstSensor(const T & v) : value(v) {}
virtual ~ConstSensor() {}
bool GetValue(ObjectSyntax * objectSyntax) const
//-----------------------------------------------------------------------------
class ADD_DEL_TARIFF_NOTIFIER : public NOTIFIER_BASE<TARIFF_DATA>, private NONCOPYABLE {
public:
- ADD_DEL_TARIFF_NOTIFIER(SMUX & s)
+ explicit ADD_DEL_TARIFF_NOTIFIER(SMUX & s)
: NOTIFIER_BASE<TARIFF_DATA>(), smux(s) {}
void Notify(const TARIFF_DATA &);
//-----------------------------------------------------------------------------
class ADD_USER_NOTIFIER : public NOTIFIER_BASE<USER_PTR>, private NONCOPYABLE {
public:
- ADD_USER_NOTIFIER(SMUX & s) : NOTIFIER_BASE<USER_PTR>(), smux(s) {}
+ explicit ADD_USER_NOTIFIER(SMUX & s) : NOTIFIER_BASE<USER_PTR>(), smux(s) {}
void Notify(const USER_PTR &);
private:
//-----------------------------------------------------------------------------
class DEL_USER_NOTIFIER : public NOTIFIER_BASE<USER_PTR>, private NONCOPYABLE {
public:
- DEL_USER_NOTIFIER(SMUX & s) : NOTIFIER_BASE<USER_PTR>(), smux(s) {}
+ explicit DEL_USER_NOTIFIER(SMUX & s) : NOTIFIER_BASE<USER_PTR>(), smux(s) {}
void Notify(const USER_PTR &);
private:
class TableSensor {
public:
- TableSensor(const std::string & p) : prefix(p) {}
+ explicit TableSensor(const std::string & p) : prefix(p) {}
virtual ~TableSensor() {}
const std::string & GetPrefix() const { return prefix; }
class OID {
public:
- OID(const std::string & str);
+ explicit OID(const std::string & str);
OID(const char * str, size_t length);
- OID(const std::vector<unsigned> & arcs);
+ explicit OID(const std::vector<unsigned> & arcs);
OID(const unsigned * arcs, size_t length);
- OID(OBJECT_IDENTIFIER_t * oid);
+ explicit OID(OBJECT_IDENTIFIER_t * oid);
OID(const OID & rvalue);
~OID();
else
td->tariffConf.changePolicy = TARIFF::StringToChangePolicy(str);
-if (conf.ReadString("ChangePolicyTimeout", &str, "1970-01-01 00:00:00") < 0)
- td->tariffConf.changePolicyTimeout = 0;
-else
- td->tariffConf.changePolicyTimeout = readTime(str);
+conf.ReadTime("ChangePolicyTimeout", &td->tariffConf.changePolicyTimeout, 0);
return 0;
}
//-----------------------------------------------------------------------------
{
if(mysql_select_db(sock, storeSettings.GetDBName().c_str()))
{
- errorStr = "Couldn't select database! With error:\n";
- errorStr += mysql_error(sock);
- mysql_close(sock);
- ret = -1;
+ errorStr = "Couldn't select database! With error:\n";
+ errorStr += mysql_error(sock);
+ mysql_close(sock);
+ ret = -1;
}
- ret = CheckAllTables(sock);
+ else
+ ret = CheckAllTables(sock);
}
}
else
{
if (csi->second == si)
(csi->second)++;
- csi++;
+ ++csi;
}
data.remove(*si);
#ifndef SERVICES_IMPL_H
#define SERVICES_IMPL_H
-#include <pthread.h>
-
-#include <list>
-#include <map>
-#include <string>
-
#include "stg/services.h"
#include "stg/service_conf.h"
#include "stg/locker.h"
#include "stg/noncopyable.h"
#include "stg/logger.h"
+#include <list>
+#include <map>
+#include <string>
+
+#include <pthread.h>
+
class ADMIN;
class SERVICES_IMPL : private NONCOPYABLE, public SERVICES {
public:
- SERVICES_IMPL(STORE * st);
+ explicit SERVICES_IMPL(STORE * st);
virtual ~SERVICES_IMPL() {}
int Add(const SERVICE_CONF & service, const ADMIN * admin);
#ifndef SETTINGS_IMPL_H
#define SETTINGS_IMPL_H
-#include <string>
-#include <vector>
-
#include "stg/settings.h"
#include "stg/common.h"
#include "stg/module_settings.h"
+#include <string>
+#include <vector>
+
//-----------------------------------------------------------------------------
enum DETAIL_STAT_PERIOD {
dsPeriod_1,
//-----------------------------------------------------------------------------
class SETTINGS_IMPL : public SETTINGS {
public:
- SETTINGS_IMPL(const std::string &);
+ explicit SETTINGS_IMPL(const std::string &);
SETTINGS_IMPL(const SETTINGS_IMPL &);
virtual ~SETTINGS_IMPL() {}
SETTINGS_IMPL & operator=(const SETTINGS_IMPL &);
return true;
}
+delete plugin;
+
if (dlclose(handle))
{
errorStr = "Failed to unload plugin '";
#ifndef __STORE_LOADER_H__
#define __STORE_LOADER_H__
-#include <string>
-
#include "stg/module_settings.h"
#include "stg/noncopyable.h"
+#include <string>
+
class STORE;
class SETTINGS_IMPL;
class STORE_LOADER : private NONCOPYABLE {
public:
- STORE_LOADER(const SETTINGS_IMPL & settings);
+ explicit STORE_LOADER(const SETTINGS_IMPL & settings);
~STORE_LOADER();
bool Load();
#ifndef TARIFF_IMPL_H
#define TARIFF_IMPL_H
-#include <ctime>
+#include "stg/tariff.h"
+#include "stg/os_int.h"
+#include "stg/tariff_conf.h"
#include <string>
#include <list>
-#include "stg/tariff.h"
-#include "stg/os_int.h"
-#include "stg/tariff_conf.h"
+#include <ctime>
#define TARIFF_DAY 0
#define TARIFF_NIGHT 1
: TARIFF(),
tariffData()
{}
- TARIFF_IMPL(const std::string & name)
+ explicit TARIFF_IMPL(const std::string & name)
: TARIFF(),
tariffData(name)
{}
- TARIFF_IMPL(const TARIFF_DATA & td)
+ explicit TARIFF_IMPL(const TARIFF_DATA & td)
: TARIFF(),
tariffData(td)
{}
- TARIFF_IMPL(const TARIFF_IMPL & t)
- : TARIFF(),
- tariffData(t.tariffData)
- {}
virtual ~TARIFF_IMPL() {}
double GetPriceWithTraffType(uint64_t up,
#ifndef TARIFFS_IMPL_H
#define TARIFFS_IMPL_H
-#include <pthread.h>
+#include "stg/tariff.h"
+#include "stg/tariffs.h"
+#include "stg/tariff_conf.h"
+#include "tariff_impl.h"
#include <string>
#include <list>
#include <set>
-#include "stg/tariff.h"
-#include "stg/tariffs.h"
-#include "stg/tariff_conf.h"
-#include "tariff_impl.h"
+#include <pthread.h>
#define TARIFF_DAY 0
#define TARIFF_NIGHT 1
public:
typedef std::list<TARIFF_IMPL> Tariffs;
- TARIFFS_IMPL(STORE * store);
+ explicit TARIFFS_IMPL(STORE * store);
virtual ~TARIFFS_IMPL();
int ReadTariffs ();
const TARIFF * FindByName(const std::string & name) const;
std::string monFile(tc->monitorDir + "/traffcounter_r");
printfd(__FILE__, "Monitor=%d file TRAFFCOUNTER %s\n", tc->monitoring, monFile.c_str());
touchTime = stgTime;
- TouchFile(monFile.c_str());
+ TouchFile(monFile);
}
if (++c % FLUSH_TIME == 0)
std::string monFile = monitorDir + "/traffcounter_p";
printfd(__FILE__, "Monitor=%d file TRAFFCOUNTER %s\n", monitoring, monFile.c_str());
touchTimeP = stgTime;
- TouchFile(monFile.c_str());
+ TouchFile(monFile);
}
STG_LOCKER lock(&mutex);
int * dirU, // Direction for incoming packet
int * dirD) const // Direction for outgoing packet
{
-bool addrMatchU;
-bool portMatchU;
-bool addrMatchD;
-bool portMatchD;
+bool addrMatchU = false;
+bool portMatchU = false;
+bool addrMatchD = false;
+bool portMatchD = false;
bool foundU = false; // Was rule for U found ?
bool foundD = false; // Was rule for D found ?
//printfd(__FILE__, "foundU=%d, foundD=%d\n", foundU, foundD);
{
if (!foundU)
{
- addrMatchU = false;
portMatchU = false;
switch (ln->proto)
if (!foundD)
{
- addrMatchD = false;
portMatchD = false;
switch (ln->proto)
continue;
}
- r = sscanf(str,"%100s %100s %100s", tp, ta, td);
+ r = sscanf(str,"%99s %99s %99s", tp, ta, td);
if (r != 3)
{
printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d. There must be 3 parameters.\n", rulesFileName.c_str(), lineNumber);
#ifndef TRAFFCOUNTER_IMPL_H
#define TRAFFCOUNTER_IMPL_H
-#include <pthread.h>
-
-#include <ctime>
-#include <list>
-#include <map>
-#include <string>
-
#include "stg/traffcounter.h"
#include "stg/os_int.h"
#include "stg/logger.h"
#include "eventloop.h"
#include "user_impl.h"
+#include <ctime>
+#include <list>
+#include <map>
+#include <string>
+
+#include <pthread.h>
+
#define PROTOMAX (5)
class USERS_IMPL;
//-----------------------------------------------------------------------------
class ADD_USER_NONIFIER: public NOTIFIER_BASE<USER_IMPL_PTR> {
public:
- ADD_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) :
+ explicit ADD_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) :
NOTIFIER_BASE<USER_IMPL_PTR>(),
traffCnt(t)
{}
//-----------------------------------------------------------------------------
class DEL_USER_NONIFIER: public NOTIFIER_BASE<USER_IMPL_PTR> {
public:
- DEL_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) :
+ explicit DEL_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) :
NOTIFIER_BASE<USER_IMPL_PTR>(),
traffCnt(t)
{}
userdata7(property.userdata7),
userdata8(property.userdata8),
userdata9(property.userdata9),
+ sessionUploadModTime(stgTime),
+ sessionDownloadModTime(stgTime),
passiveNotifier(this),
disabledNotifier(this),
tariffNotifier(this),
userdata7(property.userdata7),
userdata8(property.userdata8),
userdata9(property.userdata9),
+ sessionUploadModTime(stgTime),
+ sessionDownloadModTime(stgTime),
passiveNotifier(this),
disabledNotifier(this),
tariffNotifier(this),
userdata9(property.userdata9),
sessionUpload(),
sessionDownload(),
+ sessionUploadModTime(stgTime),
+ sessionDownloadModTime(stgTime),
passiveNotifier(this),
disabledNotifier(this),
tariffNotifier(this),
class CHG_PASSIVE_NOTIFIER : public PROPERTY_NOTIFIER_BASE<int>,
private NONCOPYABLE {
public:
- CHG_PASSIVE_NOTIFIER(USER_IMPL * u) : user(u) {}
+ explicit CHG_PASSIVE_NOTIFIER(USER_IMPL * u) : user(u) {}
void Notify(const int & oldPassive, const int & newPassive);
private:
class CHG_DISABLED_NOTIFIER : public PROPERTY_NOTIFIER_BASE<int>,
private NONCOPYABLE {
public:
- CHG_DISABLED_NOTIFIER(USER_IMPL * u) : user(u) {}
+ explicit CHG_DISABLED_NOTIFIER(USER_IMPL * u) : user(u) {}
void Notify(const int & oldValue, const int & newValue);
private:
class CHG_TARIFF_NOTIFIER : public PROPERTY_NOTIFIER_BASE<std::string>,
private NONCOPYABLE {
public:
- CHG_TARIFF_NOTIFIER(USER_IMPL * u) : user(u) {}
+ explicit CHG_TARIFF_NOTIFIER(USER_IMPL * u) : user(u) {}
void Notify(const std::string & oldTariff, const std::string & newTariff);
private:
class CHG_CASH_NOTIFIER : public PROPERTY_NOTIFIER_BASE<double>,
private NONCOPYABLE {
public:
- CHG_CASH_NOTIFIER(USER_IMPL * u) : user(u) {}
+ explicit CHG_CASH_NOTIFIER(USER_IMPL * u) : user(u) {}
void Notify(const double & oldCash, const double & newCash);
private:
class CHG_IPS_NOTIFIER : public PROPERTY_NOTIFIER_BASE<USER_IPS>,
private NONCOPYABLE {
public:
- CHG_IPS_NOTIFIER(USER_IMPL * u) : user(u) {}
+ explicit CHG_IPS_NOTIFIER(USER_IMPL * u) : user(u) {}
void Notify(const USER_IPS & oldIPs, const USER_IPS & newIPs);
private:
{
//printfd(__FILE__, "Monitor=%d file TRAFFCOUNTER %s\n", tc->monitoring, monFile.c_str());
touchTime = stgTime;
- TouchFile(monFile.c_str());
+ TouchFile(monFile);
}
stgUsleep(100000);
return val;
}
//---------------------------------------------------------------------------
-std::string Trim(std::string val)
+std::string Trim(const std::string& val)
{
return TrimR(TrimL(val));
}
virtual void error(int lineNum, const char * fileName, const char * fmt, ...);
public:
- DOTCONFDocument(CaseSensitive caseSensitivity = CASESENSITIVE);
+ explicit DOTCONFDocument(CaseSensitive caseSensitivity = CASESENSITIVE);
virtual ~DOTCONFDocument();
void setErrorCallback(DOTCONFCallback _callback, void * _data) { errorCallback = _callback; errorCallbackData = _data; }
#ifndef STG_LOGGER_H
#define STG_LOGGER_H
-#include <pthread.h>
-
#include <string>
+#include <pthread.h>
+
class STG_LOGGER;
STG_LOGGER & GetStgLogger();
//-----------------------------------------------------------------------------
class STG_LOGGER_LOCKER
{
public:
- STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); }
+ explicit STG_LOGGER_LOCKER(pthread_mutex_t * m) : mutex(m) { pthread_mutex_lock(mutex); }
~STG_LOGGER_LOCKER() { pthread_mutex_unlock(mutex); }
private:
typedef std::multimap<uint32_t, time_t> PingIPs;
typedef PingIPs::size_type SizeType;
- STG_PINGER(time_t delay = 15);
+ explicit STG_PINGER(time_t delay = 15);
~STG_PINGER();
int Start();