Conflicts:
projects/stargazer/plugins/configuration/sgconfig/parser.h
stglibs/srvconf.lib/netunit.cpp
stglibs/srvconf.lib/parsers/get_tariff.cpp
34 files changed:
receiverStopped(true),
processorStopped(true),
userTimeout(0),
receiverStopped(true),
processorStopped(true),
userTimeout(0),
+ listenSocket(0),
+ version("rscriptd listener v.1.2")
-version = "rscriptd listener v.1.2";
-
pthread_mutex_init(&mutex, NULL);
}
//-----------------------------------------------------------------------------
pthread_mutex_init(&mutex, NULL);
}
//-----------------------------------------------------------------------------
int ParseReply(void * data, list<string> * ans)
{
int done = 0;
int ParseReply(void * data, list<string> * ans)
{
int done = 0;
parse_depth = 0;
parser = XML_ParserCreate(NULL);
parse_depth = 0;
parser = XML_ParserCreate(NULL);
list<string>::iterator n = ans->begin();
while (n != ans->end())
{
list<string>::iterator n = ans->begin();
while (n != ans->end())
{
- len = strlen(n->c_str());
+ size_t len = strlen(n->c_str());
if (++n == ans->end())
done = 1;
if (++n == ans->end())
done = 1;
return 0;
}
//-----------------------------------------------------------------------------
return 0;
}
//-----------------------------------------------------------------------------
-void ADMINS_IMPL::PrintAdmins() const
-{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-const_admin_iter ai(data.begin());
-while (ai != data.end())
- {
- ai->Print();
- ai++;
- }
-}
-//-----------------------------------------------------------------------------
bool ADMINS_IMPL::Find(const string & l, ADMIN ** admin)
{
assert(admin != NULL && "Pointer to admin is not null");
bool ADMINS_IMPL::Find(const string & l, ADMIN ** admin)
{
assert(admin != NULL && "Pointer to admin is not null");
int Add(const std::string & login, const ADMIN * admin);
int Del(const std::string & login, const ADMIN * admin);
int Change(const ADMIN_CONF & ac, const ADMIN * admin);
int Add(const std::string & login, const ADMIN * admin);
int Del(const std::string & login, const ADMIN * admin);
int Change(const ADMIN_CONF & ac, const ADMIN * admin);
- void PrintAdmins() const;
const ADMIN * GetSysAdmin() const { return &stg; }
const ADMIN * GetNoAdmin() const { return &noAdmin; }
bool Find(const std::string & l, ADMIN ** admin);
const ADMIN * GetSysAdmin() const { return &stg; }
const ADMIN * GetNoAdmin() const { return &noAdmin; }
bool Find(const std::string & l, ADMIN ** admin);
userTimeout(0),
port(0),
errorStr(),
userTimeout(0),
port(0),
errorStr(),
- freeMbShowType(freeMbCash)
+ freeMbShowType(freeMbCash),
+ logProtocolErrors(false)
{
}
//-----------------------------------------------------------------------------
{
}
//-----------------------------------------------------------------------------
gettimeofday(&phaseTime, NULL);
}
//-----------------------------------------------------------------------------
gettimeofday(&phaseTime, NULL);
}
//-----------------------------------------------------------------------------
-void IA_PHASE::SetPhase5()
-{
-#ifdef IA_PHASE_DEBUG
-WritePhaseChange(5);
-#endif
-phase = 5;
-gettimeofday(&phaseTime, NULL);
-}
-//-----------------------------------------------------------------------------
int IA_PHASE::GetPhase() const
{
return phase;
int IA_PHASE::GetPhase() const
{
return phase;
std::map<uint32_t, IA_USER>::iterator it;
it = ip2user.begin();
std::map<uint32_t, IA_USER>::iterator it;
it = ip2user.begin();
while (it != ip2user.end())
{
while (it != ip2user.end())
{
+ uint32_t sip = it->first;
static UTIME currTime;
gettimeofday(&currTime, NULL);
static UTIME currTime;
gettimeofday(&currTime, NULL);
#ifdef ARCH_BE
SwapBytes(connSyn->dirs);
#endif
#ifdef ARCH_BE
SwapBytes(connSyn->dirs);
#endif
-int ret = Process_CONN_SYN_6((CONN_SYN_6*)connSyn, iaUser, sip);
+int ret = Process_CONN_SYN_6(reinterpret_cast<CONN_SYN_6 *>(connSyn), iaUser, sip);
enabledDirs = connSyn->dirs;
return ret;
}
enabledDirs = connSyn->dirs;
return ret;
}
void SetPhase2();
void SetPhase3();
void SetPhase4();
void SetPhase2();
void SetPhase3();
void SetPhase4();
int GetPhase() const;
void UpdateTime();
int GetPhase() const;
void UpdateTime();
DIVERT_CAP * dc = static_cast<DIVERT_CAP *>(d);
dc->isRunning = true;
DIVERT_CAP * dc = static_cast<DIVERT_CAP *>(d);
dc->isRunning = true;
+char buffer[pcktSize + 14];
while (dc->nonstop)
{
RAW_PACKET rp;
while (dc->nonstop)
{
RAW_PACKET rp;
- dc->DivertCapRead(buffer, 64, NULL);
+ dc->DivertCapRead(buffer, sizeof(buffer), NULL);
if (buffer[12] != 0x8)
continue;
if (buffer[12] != 0x8)
continue;
return((struct nlmsghdr*)buf)->nlmsg_type;
}
//-----------------------------------------------------------------------------
return((struct nlmsghdr*)buf)->nlmsg_type;
}
//-----------------------------------------------------------------------------
-int ipq_get_msgerr(const unsigned char *buf)
-{
- struct nlmsghdr *h = (struct nlmsghdr *)buf;
- struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
- return -err->error;
-}
-//-----------------------------------------------------------------------------
ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf)
{
return(ipq_packet_msg_t *)(NLMSG_DATA((struct nlmsghdr *)(buf)));
ipq_packet_msg_t *ipq_get_packet(const unsigned char *buf)
{
return(ipq_packet_msg_t *)(NLMSG_DATA((struct nlmsghdr *)(buf)));
return ipq_netlink_sendmsg(h, &msg, 0);
}
//-----------------------------------------------------------------------------
return ipq_netlink_sendmsg(h, &msg, 0);
}
//-----------------------------------------------------------------------------
-/* Not implemented yet */
-int ipq_ctl(const struct ipq_handle __attribute__((unused)) * handle, int __attribute__((unused)) request, ...)
-{
- return 1;
-}
-//-----------------------------------------------------------------------------
char *ipq_errstr(void)
{
return ipq_strerror(ipq_errno);
char *ipq_errstr(void)
{
return ipq_strerror(ipq_errno);
int ipq_message_type(const unsigned char *buf);
int ipq_message_type(const unsigned char *buf);
-int ipq_get_msgerr(const unsigned char *buf);
-
int ipq_set_verdict(const struct ipq_handle *h,
ipq_id_t id,
unsigned int verdict,
size_t data_len,
unsigned char *buf);
int ipq_set_verdict(const struct ipq_handle *h,
ipq_id_t id,
unsigned int verdict,
size_t data_len,
unsigned char *buf);
-int ipq_ctl(const struct ipq_handle *h, int request, ...);
-
char *ipq_errstr(void);
//void ipq_perror(const char *s);
char *ipq_errstr(void);
//void ipq_perror(const char *s);
nonstop(false),
isRunning(false),
queueNumber(0),
nonstop(false),
isRunning(false),
queueNumber(0),
+ nfqHandle(NULL),
+ queueHandle(NULL),
traffCnt(NULL),
logger(GetPluginLogger(GetStgLogger(), "cap_nfqueue"))
{
traffCnt(NULL),
logger(GetPluginLogger(GetStgLogger(), "cap_nfqueue"))
{
std::string login = paramList.getString(1);
paramList.verifyEnd(2);
std::string login = paramList.getString(1);
paramList.verifyEnd(2);
-std::map<std::string, xmlrpc_c::value> structVal;
ADMIN_INFO adminInfo;
if (config->GetAdminInfo(cookie, &adminInfo))
ADMIN_INFO adminInfo;
if (config->GetAdminInfo(cookie, &adminInfo))
std::string cookie = paramList.getString(0);
paramList.verifyEnd(1);
std::string cookie = paramList.getString(0);
paramList.verifyEnd(1);
-std::map<std::string, xmlrpc_c::value> structVal;
-
if (config->LogoutAdmin(cookie))
{
*retvalPtr = xmlrpc_c::value_boolean(false);
if (config->LogoutAdmin(cookie))
{
*retvalPtr = xmlrpc_c::value_boolean(false);
if (strcasecmp(el, "traff") == 0)
{
int j = 0;
if (strcasecmp(el, "traff") == 0)
{
int j = 0;
DIR_TRAFF dtu;
DIR_TRAFF dtd;
uint64_t t = 0;
while (attr[j])
{
DIR_TRAFF dtu;
DIR_TRAFF dtd;
uint64_t t = 0;
while (attr[j])
{
- dir = attr[j][2] - '0';
+ int dir = attr[j][2] - '0';
if (strncasecmp(attr[j], "md", 2) == 0)
{
if (strncasecmp(attr[j], "md", 2) == 0)
{
ADMIN_CONF ac;
int h = admins->OpenSearch();
ADMIN_CONF ac;
int h = admins->OpenSearch();
while (admins->SearchNext(h, &ac) == 0)
{
//memcpy(&p, &ac.priv, sizeof(unsigned int));
while (admins->SearchNext(h, &ac) == 0)
{
//memcpy(&p, &ac.priv, sizeof(unsigned int));
- p = (ac.priv.userStat << 0) +
- (ac.priv.userConf << 2) +
- (ac.priv.userCash << 4) +
- (ac.priv.userPasswd << 6) +
- (ac.priv.userAddDel << 8) +
- (ac.priv.adminChg << 10) +
- (ac.priv.tariffChg << 12);
+ unsigned int p = (ac.priv.userStat << 0) +
+ (ac.priv.userConf << 2) +
+ (ac.priv.userCash << 4) +
+ (ac.priv.userPasswd << 6) +
+ (ac.priv.userAddDel << 8) +
+ (ac.priv.adminChg << 10) +
+ (ac.priv.tariffChg << 12);
strprintf(&s, "<admin login=\"%s\" priv=\"%d\"/>", ac.login.c_str(), p);
answerList->push_back(s);
}
strprintf(&s, "<admin login=\"%s\" priv=\"%d\"/>", ac.login.c_str(), p);
answerList->push_back(s);
}
}
}
//-----------------------------------------------------------------------------
}
}
//-----------------------------------------------------------------------------
-int PARSER_DEL_ADMIN::CheckAttr(const char **attr)
-{
-/* <DelAdmin login=\"admin\">
- * attr[0] = "login" (word login)
- * attr[1] = login, value of login
- * attr[2] = NULL */
-
-if (strcasecmp(attr[0], "login") == 0 && attr[1] && !attr[2])
- {
- return 0;
- }
-return -1;
-}
-//-----------------------------------------------------------------------------
// ADD ADMIN
//-----------------------------------------------------------------------------
int PARSER_ADD_ADMIN::ParseStart(void *, const char *el, const char **attr)
// ADD ADMIN
//-----------------------------------------------------------------------------
int PARSER_ADD_ADMIN::ParseStart(void *, const char *el, const char **attr)
//-----------------------------------------------------------------------------
int PARSER_CHG_TARIFF::ParseStart(void *, const char * el, const char ** attr)
{
//-----------------------------------------------------------------------------
int PARSER_CHG_TARIFF::ParseStart(void *, const char * el, const char ** attr)
{
double price[DIR_NUM];
int t[DIR_NUM];
depth++;
double price[DIR_NUM];
int t[DIR_NUM];
depth++;
for (int j = 0; j < DIR_NUM; j++)
{
for (int j = 0; j < DIR_NUM; j++)
{
snprintf(st, 50, "Time%d", j);
if (strcasecmp(el, st) == 0)
{
snprintf(st, 50, "Time%d", j);
if (strcasecmp(el, st) == 0)
{
//-----------------------------------------------------------------------------
int CONFIGPROTO::Prepare()
{
//-----------------------------------------------------------------------------
int CONFIGPROTO::Prepare()
{
-std::list<std::string> ansList; //óÀÄÁ ÂÕÄÅÔ ÐÏÍÅÝÅÎ ÏÔ×ÅÔ ÄÌÑ ÍÅÎÅÄÖÅÒÁ ËÌÉÅÎÔÏ×
int res;
struct sockaddr_in listenAddr;
int res;
struct sockaddr_in listenAddr;
sigfillset(&signalSet);
pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
sigfillset(&signalSet);
pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
-STG_CONFIG * stgConf = (STG_CONFIG *)d;
+STG_CONFIG * stgConf = static_cast<STG_CONFIG *>(d);
stgConf->isRunning = true;
stgConf->config.Run();
stgConf->isRunning = true;
stgConf->config.Run();
sigfillset(&signalSet);
pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
sigfillset(&signalSet);
pthread_sigmask(SIG_BLOCK, &signalSet, NULL);
-RADIUS * rad = (RADIUS *)d;
+RADIUS * rad = static_cast<RADIUS *>(d);
RAD_PACKET packet;
rad->isRunning = true;
RAD_PACKET packet;
rad->isRunning = true;
return 0;
}
//-----------------------------------------------------------------------------
return 0;
}
//-----------------------------------------------------------------------------
-void RADIUS::PrintServices(const std::list<std::string> & svcs)
-{
-for_each(svcs.begin(), svcs.end(), Printer());
-}
-//-----------------------------------------------------------------------------
bool RADIUS::FindUser(USER_PTR * ui, const std::string & login) const
{
if (users->FindByName(login, ui))
bool RADIUS::FindUser(USER_PTR * ui, const std::string & login) const
{
if (users->FindByName(login, ui))
bool CanAcctService(const std::string & svc) const;
bool IsAllowedService(const std::string & svc) const;
bool CanAcctService(const std::string & svc) const;
bool IsAllowedService(const std::string & svc) const;
- void PrintServices(const std::list<std::string> & svcs);
-
- struct Printer : public std::unary_function<std::string, void>
- {
- void operator()(const std::string & line)
- {
- printfd("radius.cpp", "'%s'\n", line.c_str());
- }
- };
struct SPrinter : public std::unary_function<std::pair<std::string, RAD_SESSION>, void>
struct SPrinter : public std::unary_function<std::pair<std::string, RAD_SESSION>, void>
void operator()(const std::pair<std::string, RAD_SESSION> & it)
void operator()(const std::pair<std::string, RAD_SESSION> & it)
- {
- printfd("radius.cpp", "%s - ('%s', '%s')\n", it.first.c_str(), it.second.userName.c_str(), it.second.serviceType.c_str());
- }
+ {
+ printfd("radius.cpp", "%s - ('%s', '%s')\n", it.first.c_str(), it.second.userName.c_str(), it.second.serviceType.c_str());
+ }
USER(const std::vector<uint32_t> & r, USER_PTR it)
: user(it),
routers(r),
USER(const std::vector<uint32_t> & r, USER_PTR it)
: user(it),
routers(r),
{
CONFIGFILE cf(fileName);
int e = cf.Error();
{
CONFIGFILE cf(fileName);
int e = cf.Error();
//-----------------------------------------------------------------------------
int FILES_STORE::SaveUserStat(const USER_STAT & stat, const std::string & login) const
{
//-----------------------------------------------------------------------------
int FILES_STORE::SaveUserStat(const USER_STAT & stat, const std::string & login) const
{
std::string fileName;
fileName = storeSettings.GetUsersDir() + "/" + login + "/stat";
std::string fileName;
fileName = storeSettings.GetUsersDir() + "/" + login + "/stat";
for (int i = 0; i < DIR_NUM; i++)
{
for (int i = 0; i < DIR_NUM; i++)
{
snprintf(s, 22, "D%d", i);
cfstat.WriteInt(s, stat.monthDown[i]);
snprintf(s, 22, "U%d", i);
snprintf(s, 22, "D%d", i);
cfstat.WriteInt(s, stat.monthDown[i]);
snprintf(s, 22, "U%d", i);
//-----------------------------------------------------------------------------*/
int FILES_STORE::SaveAdmin(const ADMIN_CONF & ac) const
{
//-----------------------------------------------------------------------------*/
int FILES_STORE::SaveAdmin(const ADMIN_CONF & ac) const
{
-char passwordE[2 * ADM_PASSWD_LEN + 2];
-char pass[ADM_PASSWD_LEN + 1];
-char adminPass[ADM_PASSWD_LEN + 1];
-
std::string fileName;
strprintf(&fileName, "%s/%s.adm", storeSettings.GetAdminsDir().c_str(), ac.login.c_str());
std::string fileName;
strprintf(&fileName, "%s/%s.adm", storeSettings.GetAdminsDir().c_str(), ac.login.c_str());
+ char pass[ADM_PASSWD_LEN + 1];
memset(pass, 0, sizeof(pass));
memset(pass, 0, sizeof(pass));
+
+ char adminPass[ADM_PASSWD_LEN + 1];
memset(adminPass, 0, sizeof(adminPass));
BLOWFISH_CTX ctx;
memset(adminPass, 0, sizeof(adminPass));
BLOWFISH_CTX ctx;
}
pass[ADM_PASSWD_LEN - 1] = 0;
}
pass[ADM_PASSWD_LEN - 1] = 0;
+ char passwordE[2 * ADM_PASSWD_LEN + 2];
Encode12(passwordE, pass, ADM_PASSWD_LEN);
cf.WriteString("password", passwordE);
Encode12(passwordE, pass, ADM_PASSWD_LEN);
cf.WriteString("password", passwordE);
-res &= (fprintf(msgFile, "%d\n", msg.header.type) >= 0);
+res &= (fprintf(msgFile, "%u\n", msg.header.type) >= 0);
res &= (fprintf(msgFile, "%u\n", msg.header.lastSendTime) >= 0);
res &= (fprintf(msgFile, "%u\n", msg.header.creationTime) >= 0);
res &= (fprintf(msgFile, "%u\n", msg.header.showTime) >= 0);
res &= (fprintf(msgFile, "%u\n", msg.header.lastSendTime) >= 0);
res &= (fprintf(msgFile, "%u\n", msg.header.creationTime) >= 0);
res &= (fprintf(msgFile, "%u\n", msg.header.showTime) >= 0);
mutex(),
til(IBPP::ilConcurrency),
tlr(IBPP::lrWait),
mutex(),
til(IBPP::ilConcurrency),
tlr(IBPP::lrWait),
logger(GetPluginLogger(GetStgLogger(), "store_firebird"))
{
pthread_mutex_init(&mutex, NULL);
logger(GetPluginLogger(GetStgLogger(), "store_firebird"))
{
pthread_mutex_init(&mutex, NULL);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int32_t id, i;
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int32_t id, i;
-double pda, pdb, pna, pnb;
-int threshold;
for(i = 0; i < DIR_NUM; i++)
{
for(i = 0; i < DIR_NUM; i++)
{
- tb.SetTime(td.dirPrice[i].hDay, td.dirPrice[i].mDay, 0);
- te.SetTime(td.dirPrice[i].hNight, td.dirPrice[i].mNight, 0);
+ tb.SetTime(td.dirPrice[i].hDay, td.dirPrice[i].mDay, 0);
+ te.SetTime(td.dirPrice[i].hNight, td.dirPrice[i].mNight, 0);
- pda = td.dirPrice[i].priceDayA * 1024 * 1024;
- pdb = td.dirPrice[i].priceDayB * 1024 * 1024;
+ double pda = td.dirPrice[i].priceDayA * 1024 * 1024;
+ double pdb = td.dirPrice[i].priceDayB * 1024 * 1024;
+ double pna = 0;
+ double pnb = 0;
if (td.dirPrice[i].singlePrice)
{
if (td.dirPrice[i].singlePrice)
{
pnb = td.dirPrice[i].priceNightB;
}
pnb = td.dirPrice[i].priceNightB;
}
if (td.dirPrice[i].noDiscount)
{
threshold = 0xffFFffFF;
if (td.dirPrice[i].noDiscount)
{
threshold = 0xffFFffFF;
threshold = td.dirPrice[i].threshold;
}
threshold = td.dirPrice[i].threshold;
}
- st->Prepare("update tb_tariffs_params set \
- price_day_a = ?, \
- price_day_b = ?, \
- price_night_a = ?, \
- price_night_b = ?, \
- threshold = ?, \
- time_day_begins = ?, \
- time_day_ends = ? \
- where fk_tariff = ? and dir_num = ?");
- st->Set(1, pda);
- st->Set(2, pdb);
- st->Set(3, pna);
- st->Set(4, pnb);
- st->Set(5, threshold);
- st->Set(6, tb);
- st->Set(7, te);
- st->Set(8, id);
- st->Set(9, i);
- st->Execute();
- st->Close();
+ st->Prepare("update tb_tariffs_params set \
+ price_day_a = ?, \
+ price_day_b = ?, \
+ price_night_a = ?, \
+ price_night_b = ?, \
+ threshold = ?, \
+ time_day_begins = ?, \
+ time_day_ends = ? \
+ where fk_tariff = ? and dir_num = ?");
+ st->Set(1, pda);
+ st->Set(2, pdb);
+ st->Set(3, pna);
+ st->Set(4, pnb);
+ st->Set(5, threshold);
+ st->Set(6, tb);
+ st->Set(7, te);
+ st->Set(8, id);
+ st->Set(9, i);
+ st->Execute();
+ st->Close();
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
-int32_t id;
-int16_t dir;
-int i;
-IBPP::Time tb, te;
-int h, m, s;
td->tariffConf.name = tariffName;
td->tariffConf.name = tariffName;
tr->Rollback();
return -1;
}
tr->Rollback();
return -1;
}
st->Get(1, id);
st->Get(3, td->tariffConf.fee);
st->Get(4, td->tariffConf.free);
st->Get(1, id);
st->Get(3, td->tariffConf.fee);
st->Get(4, td->tariffConf.free);
st->Prepare("select * from tb_tariffs_params where fk_tariff = ?");
st->Set(1, id);
st->Execute();
st->Prepare("select * from tb_tariffs_params where fk_tariff = ?");
st->Set(1, id);
st->Execute();
while (st->Fetch())
{
i++;
while (st->Fetch())
{
i++;
tr->Rollback();
return -1;
}
tr->Rollback();
return -1;
}
st->Get(3, dir);
st->Get(4, td->dirPrice[dir].priceDayA);
td->dirPrice[dir].priceDayA /= 1024*1024;
st->Get(3, dir);
st->Get(4, td->dirPrice[dir].priceDayA);
td->dirPrice[dir].priceDayA /= 1024*1024;
td->dirPrice[dir].noDiscount = false;
}
td->dirPrice[dir].noDiscount = false;
}
tb.GetTime(h, m, s);
td->dirPrice[dir].hDay = h;
td->dirPrice[dir].mDay = m;
tb.GetTime(h, m, s);
td->dirPrice[dir].hDay = h;
td->dirPrice[dir].mDay = m;
int year,
int month) const
{
int year,
int month) const
{
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
-IBPP::Timestamp actTime;
-IBPP::Timestamp addTime;
-IBPP::Date dt;
-int i;
-int32_t sid, uid;
-
printfd(__FILE__, "No stat info for user '%s'\n", login.c_str());
return -1;
}
printfd(__FILE__, "No stat info for user '%s'\n", login.c_str());
return -1;
}
st->Get(1, sid);
st->Close();
st->Get(1, sid);
st->Close();
+ IBPP::Timestamp actTime;
time_t2ts(stat.lastActivityTime, &actTime);
time_t2ts(stat.lastActivityTime, &actTime);
+ IBPP::Timestamp addTime;
time_t2ts(stat.lastCashAddTime, &addTime);
time_t2ts(stat.lastCashAddTime, &addTime);
if (year != 0)
ym2date(year, month, &dt);
else
if (year != 0)
ym2date(year, month, &dt);
else
st->Execute();
st->Close();
st->Execute();
st->Close();
- for(i = 0; i < DIR_NUM; i++)
+ for(int i = 0; i < DIR_NUM; i++)
{
st->Prepare("update tb_stats_traffic set \
upload = ?, \
{
st->Prepare("update tb_stats_traffic set \
upload = ?, \
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
-int i;
-int32_t uid;
-IBPP::Timestamp creditExpire;
-std::vector<std::string>::const_iterator it;
-
tr->Rollback();
return -1;
}
tr->Rollback();
return -1;
}
st->Get(1, uid);
st->Close();
st->Get(1, uid);
st->Close();
+ IBPP::Timestamp creditExpire;
time_t2ts(conf.creditExpire, &creditExpire);
st->Prepare("update tb_users set \
time_t2ts(conf.creditExpire, &creditExpire);
st->Prepare("update tb_users set \
st->Prepare("insert into tb_users_services (fk_user, fk_service) \
values (?, (select pk_service from tb_services \
where name = ?))");
st->Prepare("insert into tb_users_services (fk_user, fk_service) \
values (?, (select pk_service from tb_services \
where name = ?))");
- for(it = conf.service.begin(); it != conf.service.end(); ++it)
+ for(std::vector<std::string>::const_iterator it = conf.service.begin(); it != conf.service.end(); ++it)
{
st->Set(1, uid);
st->Set(2, *it);
{
st->Set(1, uid);
st->Set(2, *it);
st->Execute();
st->Close();
st->Execute();
st->Close();
st->Prepare("insert into tb_users_data (fk_user, data, num) values (?, ?, ?)");
st->Prepare("insert into tb_users_data (fk_user, data, num) values (?, ?, ?)");
- for (it = conf.userdata.begin(); it != conf.userdata.end(); ++it)
+ for (std::vector<std::string>::const_iterator it = conf.userdata.begin(); it != conf.userdata.end(); ++it)
{
st->Set(1, uid);
st->Set(2, *it);
{
st->Set(1, uid);
st->Set(2, *it);
catch (IBPP::Exception & ex)
{
tr->Rollback();
catch (IBPP::Exception & ex)
{
tr->Rollback();
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
-IBPP::Timestamp actTime, addTime;
-int i, dir;
-int32_t uid, sid, passiveTime;
-
printfd(__FILE__, "User '%s' not found in database\n", login.c_str());
return -1;
}
printfd(__FILE__, "User '%s' not found in database\n", login.c_str());
return -1;
}
st->Get(1, uid);
st->Close();
st->Get(1, uid);
st->Close();
st->Get(1, sid);
st->Get(2, stat->cash);
st->Get(3, stat->freeMb);
st->Get(1, sid);
st->Get(2, stat->cash);
st->Get(3, stat->freeMb);
+ IBPP::Timestamp actTime;
st->Get(4, actTime);
st->Get(5, stat->lastCashAdd);
st->Get(4, actTime);
st->Get(5, stat->lastCashAdd);
+ IBPP::Timestamp addTime;
st->Get(7, passiveTime);
stat->passiveTime = passiveTime;
st->Get(7, passiveTime);
stat->passiveTime = passiveTime;
st->Prepare("select * from tb_stats_traffic where fk_stat = ?");
st->Set(1, sid);
st->Execute();
st->Prepare("select * from tb_stats_traffic where fk_stat = ?");
st->Set(1, sid);
st->Execute();
- for(i = 0; i < DIR_NUM; i++)
+ for(int i = 0; i < DIR_NUM; i++)
st->Get(3, dir);
st->Get(5, (int64_t &)stat->monthUp[dir]);
st->Get(4, (int64_t &)stat->monthDown[dir]);
st->Get(3, dir);
st->Get(5, (int64_t &)stat->monthUp[dir]);
st->Get(4, (int64_t &)stat->monthDown[dir]);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
-int32_t uid;
-int i;
-IBPP::Timestamp timestamp;
-IP_MASK im;
-std::string name;
-bool test;
-
tr->Rollback();
return -1;
}
tr->Rollback();
return -1;
}
st->Get(1, uid);
// Getting base config
st->Get(2, conf->address);
st->Get(1, uid);
// Getting base config
st->Get(2, conf->address);
st->Get(3, test);
conf->alwaysOnline = test;
st->Get(4, conf->credit);
st->Get(3, test);
conf->alwaysOnline = test;
st->Get(4, conf->credit);
+ IBPP::Timestamp timestamp;
st->Get(5, timestamp);
conf->creditExpire = ts2time_t(timestamp);
st->Get(5, timestamp);
conf->creditExpire = ts2time_t(timestamp);
st->Execute();
while (st->Fetch())
{
st->Execute();
while (st->Fetch())
{
st->Get(1, name);
conf->service.push_back(name);
}
st->Get(1, name);
conf->service.push_back(name);
}
st->Execute();
while (st->Fetch())
{
st->Execute();
while (st->Fetch())
{
st->Get(2, i);
st->Get(1, conf->userdata[i]);
}
st->Get(2, i);
st->Get(1, conf->userdata[i]);
}
conf->ips.Erase();
while (st->Fetch())
{
conf->ips.Erase();
while (st->Fetch())
{
st->Get(1, (int32_t &)im.ip);
st->Get(2, (int32_t &)im.mask);
conf->ips.Add(im);
st->Get(1, (int32_t &)im.ip);
st->Get(2, (int32_t &)im.mask);
conf->ips.Add(im);
catch (IBPP::Exception & ex)
{
tr->Rollback();
catch (IBPP::Exception & ex)
{
tr->Rollback();
IBPP::Timestamp now;
now.Now();
IBPP::Timestamp now;
now.Now();
st->Set(1, login);
st->Set(2, now);
st->Execute();
st->Set(1, login);
st->Set(2, now);
st->Execute();
st->Get(1, id);
st->Prepare("insert into tb_sessions_data \
(fk_session_log, dir_num, session_upload, \
session_download, month_upload, month_download) \
values (?, ?, ?, ?, ?, ?)");
st->Get(1, id);
st->Prepare("insert into tb_sessions_data \
(fk_session_log, dir_num, session_upload, \
session_download, month_upload, month_download) \
values (?, ?, ?, ?, ?, ?)");
- for(i = 0; i < DIR_NUM; i++)
+ for(int i = 0; i < DIR_NUM; i++)
{
st->Set(1, id);
st->Set(2, i);
{
st->Set(1, id);
st->Set(2, i);
IBPP::Date nowDate;
nowDate.Today();
now.Now();
IBPP::Date nowDate;
nowDate.Today();
now.Now();
if (SaveStat(stat, login, year, month))
{
if (SaveStat(stat, login, year, month))
{
st->Set(4, nowDate);
st->Execute();
st->Set(4, nowDate);
st->Execute();
st->Get(1, id);
st->Close();
st->Get(1, id);
st->Close();
(fk_stat, dir_num, upload, download) \
values (?, ?, 0, 0)");
(fk_stat, dir_num, upload, download) \
values (?, ?, 0, 0)");
- for(i = 0; i < DIR_NUM; i++)
+ for(int i = 0; i < DIR_NUM; i++)
{
st->Set(1, id);
st->Set(2, i);
{
st->Set(1, id);
st->Set(2, i);
catch (IBPP::Exception & ex)
{
tr->Rollback();
catch (IBPP::Exception & ex)
{
tr->Rollback();
}
//-----------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------
-std::string ReplaceStr(std::string source, const std::string symlist, const char chgsym)
+std::string ReplaceStr(std::string source, const std::string & symlist, const char chgsym)
{
std::string::size_type pos=0;
{
std::string::size_type pos=0;
dbUser(),
dbPass(),
dbName(),
dbUser(),
dbPass(),
dbName(),
+ dbHost(),
+ schemaVersion(0)
{
}
//-----------------------------------------------------------------------------
{
}
//-----------------------------------------------------------------------------
{
int ret = storeSettings.ParseSettings(settings);
MYSQL mysql;
{
int ret = storeSettings.ParseSettings(settings);
MYSQL mysql;
mysql_init(&mysql);
if (ret)
errorStr = storeSettings.GetStrError();
mysql_init(&mysql);
if (ret)
errorStr = storeSettings.GetStrError();
errorStr = "Database password must be not empty. Please read Manual.";
return -1;
}
errorStr = "Database password must be not empty. Please read Manual.";
return -1;
}
if (!(sock = mysql_real_connect(&mysql,storeSettings.GetDBHost().c_str(),
storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(),
0,0,NULL,0)))
if (!(sock = mysql_real_connect(&mysql,storeSettings.GetDBHost().c_str(),
storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(),
0,0,NULL,0)))
row = mysql_fetch_row(res);
row = mysql_fetch_row(res);
conf->password = row[1];
if (conf->password.empty())
conf->password = row[1];
if (conf->password.empty())
char passwordE[2*ADM_PASSWD_LEN + 2];
BLOWFISH_CTX ctx;
char passwordE[2*ADM_PASSWD_LEN + 2];
BLOWFISH_CTX ctx;
-memset(pass, 0, sizeof(pass));
memset(password, 0, sizeof(password));
memset(password, 0, sizeof(password));
-memset(passwordE, 0, sizeof(passwordE));
std::string p;
MYSQL_RES *res;
std::string p;
MYSQL_RES *res;
PGresult * result;
if (StartTransaction())
PGresult * result;
if (StartTransaction())
-int32_t id, i;
-double pda, pdb, pna, pnb;
-int threshold;
-
{
std::ostringstream query;
query << "SELECT pk_tariff FROM tb_tariffs WHERE name = '" << ename << "'";
{
std::ostringstream query;
query << "SELECT pk_tariff FROM tb_tariffs WHERE name = '" << ename << "'";
-for(i = 0; i < DIR_NUM; i++)
+for(int i = 0; i < DIR_NUM; i++)
-
- pda = td.dirPrice[i].priceDayA * 1024 * 1024;
- pdb = td.dirPrice[i].priceDayB * 1024 * 1024;
+ double pda = td.dirPrice[i].priceDayA * 1024 * 1024;
+ double pdb = td.dirPrice[i].priceDayB * 1024 * 1024;
+ double pna = 0;
+ double pnb = 0;
if (td.dirPrice[i].singlePrice)
{
if (td.dirPrice[i].singlePrice)
{
pnb = td.dirPrice[i].priceNightB * 1024 * 1024;
}
pnb = td.dirPrice[i].priceNightB * 1024 * 1024;
}
if (td.dirPrice[i].noDiscount)
{
threshold = 0xffFFffFF;
if (td.dirPrice[i].noDiscount)
{
threshold = 0xffFFffFF;
if (StartTransaction())
{
printfd(__FILE__, "POSTGRESQL_STORE::WriteDetailedStat(): 'Failed to start transaction'\n");
if (StartTransaction())
{
printfd(__FILE__, "POSTGRESQL_STORE::WriteDetailedStat(): 'Failed to start transaction'\n");
<< it->second.up << ", "
<< it->second.cash << ")";
<< it->second.up << ", "
<< it->second.cash << ")";
- result = PQexec(connection, query.str().c_str());
+ PGresult * result = PQexec(connection, query.str().c_str());
if (PQresultStatus(result) != PGRES_COMMAND_OK)
{
if (PQresultStatus(result) != PGRES_COMMAND_OK)
{
foundU = true;
*dirU = ln->dir;
//printfd(__FILE__, "Up rule ok! %d\n", ln->dir);
foundU = true;
*dirU = ln->dir;
//printfd(__FILE__, "Up rule ok! %d\n", ln->dir);
foundD = true;
*dirD = ln->dir;
//printfd(__FILE__, "Down rule ok! %d\n", ln->dir);
foundD = true;
*dirD = ln->dir;
//printfd(__FILE__, "Down rule ok! %d\n", ln->dir);
*dirD = DIR_NUM;
}
//-----------------------------------------------------------------------------
*dirD = DIR_NUM;
}
//-----------------------------------------------------------------------------
-void TRAFFCOUNTER_IMPL::SetRulesFile(const std::string & fn)
-{
-rulesFileName = fn;
-}
-//-----------------------------------------------------------------------------
bool TRAFFCOUNTER_IMPL::ReadRules(bool test)
{
//printfd(__FILE__, "TRAFFCOUNTER::ReadRules()\n");
bool TRAFFCOUNTER_IMPL::ReadRules(bool test)
{
//printfd(__FILE__, "TRAFFCOUNTER::ReadRules()\n");
}
if (!test)
rules.push_back(rul);
}
if (!test)
rules.push_back(rul);
if (!test)
rules.push_back(rul);
if (!test)
rules.push_back(rul);
return false;
}
//-----------------------------------------------------------------------------
return false;
}
//-----------------------------------------------------------------------------
rules.clear();
}
//-----------------------------------------------------------------------------
rules.clear();
}
//-----------------------------------------------------------------------------
-void TRAFFCOUNTER_IMPL::PrintRule(RULE rule) const
-{
-printf("%15s ", inet_ntostring(rule.ip).c_str());
-printf("mask=%08X ", rule.mask);
-printf("port1=%5d ", rule.port1);
-printf("port2=%5d ", rule.port2);
-switch (rule.proto)
- {
- case 0:
- printf("TCP ");
- break;
- case 1:
- printf("UDP ");
- break;
- case 2:
- printf("ICMP ");
- break;
- case 3:
- printf("TCP_UDP ");
- break;
- case 4:
- printf("ALL ");
- break;
- }
-printf("dir=%u \n", static_cast<unsigned>(rule.dir));
-}
-//-----------------------------------------------------------------------------
void TRAFFCOUNTER_IMPL::SetMonitorDir(const std::string & dir)
{
monitorDir = dir;
void TRAFFCOUNTER_IMPL::SetMonitorDir(const std::string & dir)
{
monitorDir = dir;
TRAFFCOUNTER_IMPL(USERS_IMPL * users, const std::string & rulesFileName);
~TRAFFCOUNTER_IMPL();
TRAFFCOUNTER_IMPL(USERS_IMPL * users, const std::string & rulesFileName);
~TRAFFCOUNTER_IMPL();
- void SetRulesFile(const std::string & rulesFileName);
-
int Reload();
int Start();
int Stop();
int Reload();
int Start();
int Stop();
bool ParseAddress(const char * ta, RULE * rule) const;
uint32_t CalcMask(uint32_t msk) const;
void FreeRules();
bool ParseAddress(const char * ta, RULE * rule) const;
uint32_t CalcMask(uint32_t msk) const;
void FreeRules();
- void PrintRule(RULE rule) const;
bool ReadRules(bool test = false);
static void * Run(void * data);
bool ReadRules(bool test = false);
static void * Run(void * data);
//---------------------------------------------------------------------------
void KOIToWin(const char * s1, char * s2, int l)
{
//---------------------------------------------------------------------------
void KOIToWin(const char * s1, char * s2, int l)
{
for (int j = 0; j < l; j++)
{
for (int j = 0; j < l; j++)
{
+ unsigned char t = s1[j];
s2[j] = koi2win[t];
if (s1[j] == 0)
s2[j] = koi2win[t];
if (s1[j] == 0)
//---------------------------------------------------------------------------
void WinToKOI(const char * s1, char * s2, int l)
{
//---------------------------------------------------------------------------
void WinToKOI(const char * s1, char * s2, int l)
{
for (int j = 0; j < l; j++)
{
for (int j = 0; j < l; j++)
{
+ unsigned char t = s1[j];
s2[j] = win2koi[t];
if (s1[j] == 0)
s2[j] = win2koi[t];
if (s1[j] == 0)
void KOIToWin(const std::string & s1, std::string * s2)
{
s2->erase(s2->begin(), s2->end());
void KOIToWin(const std::string & s1, std::string * s2)
{
s2->erase(s2->begin(), s2->end());
s2->reserve(s1.length());
for (int j = 0; j < (int)s1.length(); j++)
{
s2->reserve(s1.length());
for (int j = 0; j < (int)s1.length(); j++)
{
+ unsigned char t = s1[j];
s2->push_back(koi2win[t]);
}
}
s2->push_back(koi2win[t]);
}
}
void WinToKOI(const std::string & s1, std::string * s2)
{
s2->erase(s2->begin(), s2->end());
void WinToKOI(const std::string & s1, std::string * s2)
{
s2->erase(s2->begin(), s2->end());
s2->reserve(s1.length());
for (int j = 0; j < (int)s1.length(); j++)
{
s2->reserve(s1.length());
for (int j = 0; j < (int)s1.length(); j++)
{
+ unsigned char t = s1[j];
s2->push_back(win2koi[t]);
}
}
s2->push_back(win2koi[t]);
}
}
int n = 0;
strncpy(p, str, 254);
int n = 0;
strncpy(p, str, 254);
memset(ips, 0xFF, sizeof(unsigned long) * maxIP);
memset(ips, 0xFF, sizeof(unsigned long) * maxIP);
for (int i = 0; i < maxIP; i++)
{
for (int i = 0; i < maxIP; i++)
{
- p1 = strtok(pp, ",\n ");
+ char * p1 = strtok(pp, ",\n ");
pp = NULL;
if (p1 == NULL && n == 0)// ÕËÁÚÁÔÅÌØ ÎÕÌØ É ÐÒÏÞÉÔÁÎÏ ÁÄÒÅÓÏ× ÔÏÖÅ ÎÏÌØ
pp = NULL;
if (p1 == NULL && n == 0)// ÕËÁÚÁÔÅÌØ ÎÕÌØ É ÐÒÏÞÉÔÁÎÏ ÁÄÒÅÓÏ× ÔÏÖÅ ÎÏÌØ
//---------------------------------------------------------------------------
void DecodeStr(char * str, unsigned long serial, int useHDD)
{
//---------------------------------------------------------------------------
void DecodeStr(char * str, unsigned long serial, int useHDD)
{
+size_t len = strlen(str);
-int i, j = 0;
-char c1, c2;
char serial_c[sizeof(serial)];
memcpy(serial_c, &serial, sizeof(serial));
char serial_c[sizeof(serial)];
memcpy(serial_c, &serial, sizeof(serial));
-for (i = 0; i < len; i += 2)
+for (size_t i = 0; i < len; i += 2)
- c1 = (str[i] - 50);
- c2 = (str[i+1] - 50)<<4;
+ char c1 = (str[i] - 50);
+ char c2 = (str[i+1] - 50)<<4;
-for (i = 0; i < len/2; i++)
+for (size_t i = 0; i < len/2; i++)
{
if (!useHDD)
strdc[i] = strdc[i]^49;
{
if (!useHDD)
strdc[i] = strdc[i]^49;
DOTCONFDocument::~DOTCONFDocument()
{
DOTCONFDocument::~DOTCONFDocument()
{
- for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i != nodeTree.end(); i++){
+ for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i != nodeTree.end(); ++i){
- for(std::list<char*>::iterator i = requiredOptions.begin(); i != requiredOptions.end(); i++){
+ for(std::list<char*>::iterator i = requiredOptions.begin(); i != requiredOptions.end(); ++i){
- for(std::list<char*>::iterator i = processedFiles.begin(); i != processedFiles.end(); i++){
+ for(std::list<char*>::iterator i = processedFiles.begin(); i != processedFiles.end(); ++i){
free(*i);
}
free(fileName);
free(*i);
}
free(fileName);
DOTCONFDocumentNode * tagNode = NULL;
bool newNode = false;
DOTCONFDocumentNode * tagNode = NULL;
bool newNode = false;
- for(std::list<char*>::iterator i = words.begin(); i != words.end(); i++) {
+ for(std::list<char*>::iterator i = words.begin(); i != words.end(); ++i) {
word = *i;
if(*word == '<'){
word = *i;
if(*word == '<'){
} else { //closing tag
nodeName+=2;
std::list<DOTCONFDocumentNode*>::reverse_iterator i=nodeTree.rbegin();
} else { //closing tag
nodeName+=2;
std::list<DOTCONFDocumentNode*>::reverse_iterator i=nodeTree.rbegin();
- for(; i!=nodeTree.rend(); i++){
+ for(; i!=nodeTree.rend(); ++i){
if(!cmp_func(nodeName, (*i)->name) && !(*i)->closed){
(*i)->closed = true;
curParent = (*i)->parentNode;
if(!cmp_func(nodeName, (*i)->name) && !(*i)->closed){
(*i)->closed = true;
curParent = (*i)->parentNode;
curParent = _parent;
quoted = false;
curParent = _parent;
quoted = false;
while(fgets(str, 511, file)){
curLine++;
while(fgets(str, 511, file)){
curLine++;
+ size_t slen = strlen(str);
if( slen >= 510 ){
error(curLine, fileName, "warning: line too long");
}
if( slen >= 510 ){
error(curLine, fileName, "warning: line too long");
}
- DOTCONFDocumentNode * tagNode = NULL;
- int vi = 0;
- for(std::list<DOTCONFDocumentNode*>::iterator i = from; i != nodeTree.end(); i++){
- tagNode = *i;
+ for(std::list<DOTCONFDocumentNode*>::iterator i = from; i != nodeTree.end(); ++i){
+ DOTCONFDocumentNode * tagNode = *i;
if(!tagNode->closed){
error(tagNode->lineNum, tagNode->fileName, "unclosed tag %s", tagNode->name);
ret = -1;
break;
}
if(!tagNode->closed){
error(tagNode->lineNum, tagNode->fileName, "unclosed tag %s", tagNode->name);
ret = -1;
break;
}
while( vi < tagNode->valuesCount ){
//if((tagNode->values[vi])[0] == '$' && (tagNode->values[vi])[1] == '{' && strchr(tagNode->values[vi], '}') ){
if(strstr(tagNode->values[vi], "${") && strchr(tagNode->values[vi], '}') ){
while( vi < tagNode->valuesCount ){
//if((tagNode->values[vi])[0] == '$' && (tagNode->values[vi])[1] == '{' && strchr(tagNode->values[vi], '}') ){
if(strstr(tagNode->values[vi], "${") && strchr(tagNode->values[vi], '}') ){
std::list<DOTCONFDocumentNode*>::iterator from;
DOTCONFDocumentNode * tagNode = NULL;
int vi = 0;
std::list<DOTCONFDocumentNode*>::iterator from;
DOTCONFDocumentNode * tagNode = NULL;
int vi = 0;
- for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); i++){
+ for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); ++i){
tagNode = *i;
if(!cmp_func("IncludeFile", tagNode->name)){
vi = 0;
tagNode = *i;
if(!cmp_func("IncludeFile", tagNode->name)){
vi = 0;
}
bool processed = false;
}
bool processed = false;
- for(std::list<char*>::const_iterator itInode = processedFiles.begin(); itInode != processedFiles.end(); itInode++){
+ for(std::list<char*>::const_iterator itInode = processedFiles.begin(); itInode != processedFiles.end(); ++itInode){
if(!strcmp(*itInode, realpathBuf)){
processed = true;
break;
if(!strcmp(*itInode, realpathBuf)){
processed = true;
break;
}
//free(fileName);
fileName = strdup(realpathBuf);
}
//free(fileName);
fileName = strdup(realpathBuf);
- from = nodeTree.end(); from--;
+ from = nodeTree.end(); --from;
if(tagNode->parentNode){
DOTCONFDocumentNode * nd = tagNode->parentNode->childNode;
if(tagNode->parentNode){
DOTCONFDocumentNode * nd = tagNode->parentNode->childNode;
int DOTCONFDocument::checkRequiredOptions()
{
int DOTCONFDocument::checkRequiredOptions()
{
- for(std::list<char*>::const_iterator ci = requiredOptions.begin(); ci != requiredOptions.end(); ci++){
+ for(std::list<char*>::const_iterator ci = requiredOptions.begin(); ci != requiredOptions.end(); ++ci){
- for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); i++){
+ for(std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin(); i!=nodeTree.end(); ++i){
if(!cmp_func((*i)->name, *ci)){
matched = true;
break;
if(!cmp_func((*i)->name, *ci)){
matched = true;
break;
buf = mempool->strdup(subs);
} else {
std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin();
buf = mempool->strdup(subs);
} else {
std::list<DOTCONFDocumentNode*>::iterator i = nodeTree.begin();
- DOTCONFDocumentNode * tagNode = NULL;
- for(; i!=nodeTree.end(); i++){
- tagNode = *i;
+ for(; i!=nodeTree.end(); ++i){
+ DOTCONFDocumentNode * tagNode = *i;
if(!cmp_func(tagNode->name, variable)){
if(tagNode->valuesCount != 0){
buf = mempool->strdup(tagNode->values[0]);
if(!cmp_func(tagNode->name, variable)){
if(tagNode->valuesCount != 0){
buf = mempool->strdup(tagNode->values[0]);
if(startNode != NULL){
while( i != nodeTree.end() && (*i) != startNode ){
if(startNode != NULL){
while( i != nodeTree.end() && (*i) != startNode ){
- if( i != nodeTree.end() ) i++;
+ if( i != nodeTree.end() ) ++i;
- for(; i!=nodeTree.end(); i++){
+ for(; i!=nodeTree.end(); ++i){
//if(parentNode != NULL && (*i)->parentNode != parentNode){
if((*i)->parentNode != parentNode){
continue;
//if(parentNode != NULL && (*i)->parentNode != parentNode){
if((*i)->parentNode != parentNode){
continue;
#ifdef WIN32
unsigned long arg = 1;
#ifdef WIN32
unsigned long arg = 1;
-res = ioctlsocket(sockr, FIONBIO, &arg);
+ioctlsocket(sockr, FIONBIO, &arg);
#else
if (0 != fcntl(sockr, F_SETFL, O_NONBLOCK))
{
#else
if (0 != fcntl(sockr, F_SETFL, O_NONBLOCK))
{
void Executer(int msgID, pid_t pid)
#endif
{
void Executer(int msgID, pid_t pid)
#endif
{
struct SCRIPT_DATA sd;
struct sigaction newsa, oldsa;
sigset_t sigmask;
struct SCRIPT_DATA sd;
struct sigaction newsa, oldsa;
sigset_t sigmask;
while (nonstop)
{
sd.mtype = 1;
while (nonstop)
{
sd.mtype = 1;
- ret = msgrcv(msgid, &sd, MAX_SCRIPT_LEN, 0, 0);
+ int ret = msgrcv(msgid, &sd, MAX_SCRIPT_LEN, 0, 0);