From: Maxim Mamontov Date: Sun, 8 Jun 2014 20:39:27 +0000 (+0300) Subject: Lots of stylistic fixes. X-Git-Tag: 2.409~310 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/d1d9452a687184ac6b992fadc77e89c8a308e388?hp=086e44c60b861d665fe2a3e1cd7d691201e91c8c Lots of stylistic fixes. Conflicts: projects/stargazer/plugins/configuration/sgconfig/parser.h stglibs/srvconf.lib/netunit.cpp stglibs/srvconf.lib/parsers/get_tariff.cpp --- diff --git a/projects/rscriptd/listener.cpp b/projects/rscriptd/listener.cpp index ead5d33b..9fe4c0f0 100644 --- a/projects/rscriptd/listener.cpp +++ b/projects/rscriptd/listener.cpp @@ -49,10 +49,9 @@ LISTENER::LISTENER() receiverStopped(true), processorStopped(true), userTimeout(0), - listenSocket(0) + listenSocket(0), + version("rscriptd listener v.1.2") { -version = "rscriptd listener v.1.2"; - pthread_mutex_init(&mutex, NULL); } //----------------------------------------------------------------------------- diff --git a/projects/sgconf/parser.cpp b/projects/sgconf/parser.cpp index 82b7ca9e..9d340e83 100644 --- a/projects/sgconf/parser.cpp +++ b/projects/sgconf/parser.cpp @@ -86,7 +86,6 @@ parse_depth--; int ParseReply(void * data, list * ans) { int done = 0; -int len; parse_depth = 0; parser = XML_ParserCreate(NULL); @@ -103,7 +102,7 @@ XML_SetElementHandler(parser, StartElement, EndElement); list::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; diff --git a/projects/stargazer/admins_impl.cpp b/projects/stargazer/admins_impl.cpp index 7d73dde1..10d1108e 100644 --- a/projects/stargazer/admins_impl.cpp +++ b/projects/stargazer/admins_impl.cpp @@ -201,17 +201,6 @@ for (unsigned int i = 0; i < adminsList.size(); i++) 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"); diff --git a/projects/stargazer/admins_impl.h b/projects/stargazer/admins_impl.h index 48435b75..7434c445 100644 --- a/projects/stargazer/admins_impl.h +++ b/projects/stargazer/admins_impl.h @@ -53,7 +53,6 @@ public: 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); diff --git a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp index 5a15a10a..7894d491 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp +++ b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp @@ -77,7 +77,8 @@ AUTH_IA_SETTINGS::AUTH_IA_SETTINGS() userTimeout(0), port(0), errorStr(), - freeMbShowType(freeMbCash) + freeMbShowType(freeMbCash), + logProtocolErrors(false) { } //----------------------------------------------------------------------------- @@ -285,15 +286,6 @@ phase = 4; 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; @@ -696,11 +688,10 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); std::map::iterator it; it = ip2user.begin(); -uint32_t sip; while (it != ip2user.end()) { - sip = it->first; + uint32_t sip = it->first; static UTIME currTime; gettimeofday(&currTime, NULL); @@ -1170,7 +1161,7 @@ int AUTH_IA::Process_CONN_SYN_8(CONN_SYN_8 * connSyn, IA_USER * iaUser, uint32_t #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(connSyn), iaUser, sip); enabledDirs = connSyn->dirs; return ret; } diff --git a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h index 87350556..5e454124 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h +++ b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.h @@ -92,7 +92,6 @@ public: void SetPhase2(); void SetPhase3(); void SetPhase4(); - void SetPhase5(); int GetPhase() const; void UpdateTime(); diff --git a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp index 41817d92..400709bd 100644 --- a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp +++ b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.cpp @@ -165,11 +165,11 @@ pthread_sigmask(SIG_BLOCK, &signalSet, NULL); DIVERT_CAP * dc = static_cast(d); dc->isRunning = true; -char buffer[64]; +char buffer[pcktSize + 14]; while (dc->nonstop) { RAW_PACKET rp; - dc->DivertCapRead(buffer, 64, NULL); + dc->DivertCapRead(buffer, sizeof(buffer), NULL); if (buffer[12] != 0x8) continue; diff --git a/projects/stargazer/plugins/capture/ipq_linux/libipq.c b/projects/stargazer/plugins/capture/ipq_linux/libipq.c index a7ed5745..d0eb33b3 100644 --- a/projects/stargazer/plugins/capture/ipq_linux/libipq.c +++ b/projects/stargazer/plugins/capture/ipq_linux/libipq.c @@ -323,13 +323,6 @@ int ipq_message_type(const unsigned char *buf) 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))); @@ -380,12 +373,6 @@ int ipq_set_verdict(const struct ipq_handle *h, 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); diff --git a/projects/stargazer/plugins/capture/ipq_linux/libipq.h b/projects/stargazer/plugins/capture/ipq_linux/libipq.h index 58a71587..17d4c9cb 100644 --- a/projects/stargazer/plugins/capture/ipq_linux/libipq.h +++ b/projects/stargazer/plugins/capture/ipq_linux/libipq.h @@ -71,16 +71,12 @@ ipq_packet_msg_t *ipq_get_packet(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_ctl(const struct ipq_handle *h, int request, ...); - char *ipq_errstr(void); //void ipq_perror(const char *s); diff --git a/projects/stargazer/plugins/capture/nfqueue/nfqueue.cpp b/projects/stargazer/plugins/capture/nfqueue/nfqueue.cpp index 6a339523..68f7270c 100644 --- a/projects/stargazer/plugins/capture/nfqueue/nfqueue.cpp +++ b/projects/stargazer/plugins/capture/nfqueue/nfqueue.cpp @@ -98,6 +98,8 @@ NFQ_CAP::NFQ_CAP() nonstop(false), isRunning(false), queueNumber(0), + nfqHandle(NULL), + queueHandle(NULL), traffCnt(NULL), logger(GetPluginLogger(GetStgLogger(), "cap_nfqueue")) { diff --git a/projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp index ad9c0324..643f6e74 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/admins_methods.cpp @@ -95,7 +95,6 @@ std::string cookie = paramList.getString(0); std::string login = paramList.getString(1); paramList.verifyEnd(2); -std::map structVal; ADMIN_INFO adminInfo; if (config->GetAdminInfo(cookie, &adminInfo)) diff --git a/projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp b/projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp index 895088dc..7d3afaca 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp +++ b/projects/stargazer/plugins/configuration/rpcconfig/info_methods.cpp @@ -77,8 +77,6 @@ void METHOD_LOGOUT::execute(xmlrpc_c::paramList const & paramList, std::string cookie = paramList.getString(0); paramList.verifyEnd(1); -std::map structVal; - if (config->LogoutAdmin(cookie)) { *retvalPtr = xmlrpc_c::value_boolean(false); diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser.cpp index 1ac4828a..5499c382 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser.cpp @@ -921,13 +921,12 @@ else if (strcasecmp(el, "traff") == 0) { int j = 0; - int dir; 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) { diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp index b1285a77..d93b3448 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_admin.cpp @@ -45,17 +45,16 @@ answerList->push_back(""); ADMIN_CONF ac; int h = admins->OpenSearch(); -unsigned int p; 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, "", ac.login.c_str(), p); answerList->push_back(s); } @@ -105,20 +104,6 @@ else } } //----------------------------------------------------------------------------- -int PARSER_DEL_ADMIN::CheckAttr(const char **attr) -{ -/* - * 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) diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp b/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp index 0e001b22..a4531703 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_tariff.cpp @@ -304,7 +304,6 @@ return 0; //----------------------------------------------------------------------------- int PARSER_CHG_TARIFF::ParseStart(void *, const char * el, const char ** attr) { -char st[50]; double price[DIR_NUM]; int t[DIR_NUM]; depth++; @@ -387,6 +386,7 @@ else for (int j = 0; j < DIR_NUM; j++) { + char st[50]; snprintf(st, 50, "Time%d", j); if (strcasecmp(el, st) == 0) { diff --git a/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp b/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp index 9b448f6c..2b50f24c 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/rsconf.cpp @@ -57,7 +57,6 @@ enum //----------------------------------------------------------------------------- int CONFIGPROTO::Prepare() { -std::list ansList; //óÀÄÁ ÂÕÄÅÔ ÐÏÍÅÝÅÎ ÏÔ×ÅÔ ÄÌÑ ÍÅÎÅÄÖÅÒÁ ËÌÉÅÎÔÏ× int res; struct sockaddr_in listenAddr; diff --git a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp index 06381144..f5687699 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp +++ b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.cpp @@ -141,7 +141,7 @@ sigset_t signalSet; sigfillset(&signalSet); pthread_sigmask(SIG_BLOCK, &signalSet, NULL); -STG_CONFIG * stgConf = (STG_CONFIG *)d; +STG_CONFIG * stgConf = static_cast(d); stgConf->isRunning = true; stgConf->config.Run(); diff --git a/projects/stargazer/plugins/other/radius/radius.cpp b/projects/stargazer/plugins/other/radius/radius.cpp index 90ec1891..8e52cdb4 100644 --- a/projects/stargazer/plugins/other/radius/radius.cpp +++ b/projects/stargazer/plugins/other/radius/radius.cpp @@ -261,7 +261,7 @@ sigset_t signalSet; sigfillset(&signalSet); pthread_sigmask(SIG_BLOCK, &signalSet, NULL); -RADIUS * rad = (RADIUS *)d; +RADIUS * rad = static_cast(d); RAD_PACKET packet; rad->isRunning = true; @@ -542,11 +542,6 @@ packet->packetType = RAD_ACCEPT_PACKET; return 0; } //----------------------------------------------------------------------------- -void RADIUS::PrintServices(const std::list & svcs) -{ -for_each(svcs.begin(), svcs.end(), Printer()); -} -//----------------------------------------------------------------------------- bool RADIUS::FindUser(USER_PTR * ui, const std::string & login) const { if (users->FindByName(login, ui)) diff --git a/projects/stargazer/plugins/other/radius/radius.h b/projects/stargazer/plugins/other/radius/radius.h index c424c007..8f5ba2a4 100644 --- a/projects/stargazer/plugins/other/radius/radius.h +++ b/projects/stargazer/plugins/other/radius/radius.h @@ -133,21 +133,12 @@ private: bool CanAcctService(const std::string & svc) const; bool IsAllowedService(const std::string & svc) const; - void PrintServices(const std::list & svcs); - - struct Printer : public std::unary_function - { - void operator()(const std::string & line) - { - printfd("radius.cpp", "'%s'\n", line.c_str()); - } - }; struct SPrinter : public std::unary_function, void> - { + { void operator()(const std::pair & 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()); + } }; BLOWFISH_CTX ctx; diff --git a/projects/stargazer/plugins/other/rscript/rscript.h b/projects/stargazer/plugins/other/rscript/rscript.h index bc6aa92f..e0412fb0 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.h +++ b/projects/stargazer/plugins/other/rscript/rscript.h @@ -140,6 +140,7 @@ struct USER { USER(const std::vector & r, USER_PTR it) : user(it), routers(r), + shortPacketsCount(0), ip(user->GetCurrIP()) {} diff --git a/projects/stargazer/plugins/store/files/file_store.cpp b/projects/stargazer/plugins/store/files/file_store.cpp index 0466b824..bf5d389a 100644 --- a/projects/stargazer/plugins/store/files/file_store.cpp +++ b/projects/stargazer/plugins/store/files/file_store.cpp @@ -577,7 +577,6 @@ int FILES_STORE::RestoreUserConf(USER_CONF * conf, const std::string & login, co { CONFIGFILE cf(fileName); int e = cf.Error(); -std::string str; if (e) { @@ -850,7 +849,6 @@ return 0; //----------------------------------------------------------------------------- int FILES_STORE::SaveUserStat(const USER_STAT & stat, const std::string & login) const { -char s[22]; std::string fileName; fileName = storeSettings.GetUsersDir() + "/" + login + "/stat"; @@ -868,6 +866,7 @@ fileName = storeSettings.GetUsersDir() + "/" + login + "/stat"; for (int i = 0; i < DIR_NUM; i++) { + char s[22]; snprintf(s, 22, "D%d", i); cfstat.WriteInt(s, stat.monthDown[i]); snprintf(s, 22, "U%d", i); @@ -1115,10 +1114,6 @@ return 0; //-----------------------------------------------------------------------------*/ 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()); @@ -1136,7 +1131,10 @@ strprintf(&fileName, "%s/%s.adm", storeSettings.GetAdminsDir().c_str(), ac.login return -1; } + char pass[ADM_PASSWD_LEN + 1]; memset(pass, 0, sizeof(pass)); + + char adminPass[ADM_PASSWD_LEN + 1]; memset(adminPass, 0, sizeof(adminPass)); BLOWFISH_CTX ctx; @@ -1151,6 +1149,7 @@ strprintf(&fileName, "%s/%s.adm", storeSettings.GetAdminsDir().c_str(), ac.login } pass[ADM_PASSWD_LEN - 1] = 0; + char passwordE[2 * ADM_PASSWD_LEN + 2]; Encode12(passwordE, pass, ADM_PASSWD_LEN); cf.WriteString("password", passwordE); @@ -1833,7 +1832,7 @@ if (!msgFile) } bool res = true; -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); diff --git a/projects/stargazer/plugins/store/firebird/firebird_store.cpp b/projects/stargazer/plugins/store/firebird/firebird_store.cpp index 37b5184f..3c4f32ad 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store.cpp @@ -63,6 +63,7 @@ FIREBIRD_STORE::FIREBIRD_STORE() mutex(), til(IBPP::ilConcurrency), tlr(IBPP::lrWait), + schemaVersion(0), logger(GetPluginLogger(GetStgLogger(), "store_firebird")) { pthread_mutex_init(&mutex, NULL); @@ -140,8 +141,6 @@ int FIREBIRD_STORE::CheckVersion() IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr); IBPP::Statement st = IBPP::StatementFactory(db, tr); -std::string name; - try { tr->Start(); diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp index 325e7d7f..d6ff1a3a 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp @@ -128,8 +128,6 @@ IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr); IBPP::Statement st = IBPP::StatementFactory(db, tr); int32_t id, i; -double pda, pdb, pna, pnb; -int threshold; try { @@ -185,11 +183,13 @@ try 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) { @@ -202,6 +202,7 @@ try pnb = td.dirPrice[i].priceNightB; } + int threshold = 0; if (td.dirPrice[i].noDiscount) { threshold = 0xffFFffFF; @@ -211,26 +212,26 @@ try 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(); } tr->Commit(); } @@ -254,11 +255,6 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); 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; @@ -275,6 +271,7 @@ try tr->Rollback(); return -1; } + int32_t id; st->Get(1, id); st->Get(3, td->tariffConf.fee); st->Get(4, td->tariffConf.free); @@ -290,7 +287,7 @@ try st->Prepare("select * from tb_tariffs_params where fk_tariff = ?"); st->Set(1, id); st->Execute(); - i = 0; + int i = 0; while (st->Fetch()) { i++; @@ -301,6 +298,7 @@ try tr->Rollback(); return -1; } + int16_t dir; st->Get(3, dir); st->Get(4, td->dirPrice[dir].priceDayA); td->dirPrice[dir].priceDayA /= 1024*1024; @@ -329,8 +327,11 @@ try td->dirPrice[dir].noDiscount = false; } + IBPP::Time tb; st->Get(9, tb); + IBPP::Time te; st->Get(10, te); + int h, m, s; tb.GetTime(h, m, s); td->dirPrice[dir].hDay = h; td->dirPrice[dir].mDay = m; diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp index 3f00b16b..13162207 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp @@ -131,16 +131,9 @@ int FIREBIRD_STORE::SaveStat(const USER_STAT & stat, int year, int month) const { - 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; - try { tr->Start(); @@ -166,11 +159,15 @@ try printfd(__FILE__, "No stat info for user '%s'\n", login.c_str()); return -1; } + int32_t sid; st->Get(1, sid); st->Close(); + IBPP::Timestamp actTime; time_t2ts(stat.lastActivityTime, &actTime); + IBPP::Timestamp addTime; time_t2ts(stat.lastCashAddTime, &addTime); + IBPP::Date dt; if (year != 0) ym2date(year, month, &dt); else @@ -198,7 +195,7 @@ try 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 = ?, \ @@ -234,11 +231,6 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); 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::const_iterator it; - try { tr->Start(); @@ -252,9 +244,11 @@ try tr->Rollback(); return -1; } + int32_t uid; st->Get(1, uid); st->Close(); + IBPP::Timestamp creditExpire; time_t2ts(conf.creditExpire, &creditExpire); st->Prepare("update tb_users set \ @@ -308,7 +302,7 @@ try 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::const_iterator it = conf.service.begin(); it != conf.service.end(); ++it) { st->Set(1, uid); st->Set(2, *it); @@ -321,9 +315,9 @@ try st->Execute(); st->Close(); - i = 0; + int i = 0; 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::const_iterator it = conf.userdata.begin(); it != conf.userdata.end(); ++it) { st->Set(1, uid); st->Set(2, *it); @@ -346,7 +340,6 @@ try } tr->Commit(); } - catch (IBPP::Exception & ex) { tr->Rollback(); @@ -366,10 +359,6 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); 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; - try { tr->Start(); @@ -382,6 +371,7 @@ try printfd(__FILE__, "User '%s' not found in database\n", login.c_str()); return -1; } + int32_t uid; st->Get(1, uid); st->Close(); @@ -398,12 +388,16 @@ try return -1; } + int32_t sid; 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); + IBPP::Timestamp addTime; st->Get(6, addTime); + int32_t passiveTime; st->Get(7, passiveTime); stat->passiveTime = passiveTime; @@ -416,10 +410,11 @@ try 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++) { if (st->Fetch()) { + int dir; st->Get(3, dir); st->Get(5, (int64_t &)stat->monthUp[dir]); st->Get(4, (int64_t &)stat->monthDown[dir]); @@ -451,13 +446,6 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); 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; - try { tr->Start(); @@ -482,12 +470,15 @@ try tr->Rollback(); return -1; } + int32_t uid; st->Get(1, uid); // Getting base config st->Get(2, conf->address); + bool test; st->Get(3, test); conf->alwaysOnline = test; st->Get(4, conf->credit); + IBPP::Timestamp timestamp; st->Get(5, timestamp); conf->creditExpire = ts2time_t(timestamp); @@ -523,6 +514,7 @@ try st->Execute(); while (st->Fetch()) { + std::string name; st->Get(1, name); conf->service.push_back(name); } @@ -534,6 +526,7 @@ try st->Execute(); while (st->Fetch()) { + int i; st->Get(2, i); st->Get(1, conf->userdata[i]); } @@ -547,6 +540,7 @@ try conf->ips.Erase(); while (st->Fetch()) { + IP_MASK im; st->Get(1, (int32_t &)im.ip); st->Get(2, (int32_t &)im.mask); conf->ips.Add(im); @@ -554,7 +548,6 @@ try tr->Commit(); } - catch (IBPP::Exception & ex) { tr->Rollback(); @@ -678,9 +671,6 @@ IBPP::Statement st = IBPP::StatementFactory(db, tr); IBPP::Timestamp now; now.Now(); -int32_t id; -int i; - try { tr->Start(); @@ -688,12 +678,13 @@ try st->Set(1, login); st->Set(2, now); st->Execute(); + int32_t id; 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); @@ -780,8 +771,6 @@ IBPP::Timestamp now; IBPP::Date nowDate; nowDate.Today(); now.Now(); -int32_t id; -int i; if (SaveStat(stat, login, year, month)) { @@ -799,6 +788,7 @@ try st->Set(4, nowDate); st->Execute(); + int32_t id; st->Get(1, id); st->Close(); @@ -806,7 +796,7 @@ try (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); @@ -815,7 +805,6 @@ try tr->Commit(); } - catch (IBPP::Exception & ex) { tr->Rollback(); diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.cpp b/projects/stargazer/plugins/store/mysql/mysql_store.cpp index 995ed538..8f64acdf 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.cpp +++ b/projects/stargazer/plugins/store/mysql/mysql_store.cpp @@ -73,7 +73,7 @@ int GetTime(const std::string & str, time_t * val, time_t defaultVal) } //----------------------------------------------------------------------------- -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; @@ -116,7 +116,8 @@ MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS() dbUser(), dbPass(), dbName(), - dbHost() + dbHost(), + schemaVersion(0) { } //----------------------------------------------------------------------------- @@ -191,7 +192,6 @@ int MYSQL_STORE::ParseSettings() { int ret = storeSettings.ParseSettings(settings); MYSQL mysql; -MYSQL * sock; mysql_init(&mysql); if (ret) errorStr = storeSettings.GetStrError(); @@ -202,7 +202,7 @@ else errorStr = "Database password must be not empty. Please read Manual."; return -1; } - + MYSQL * sock; if (!(sock = mysql_real_connect(&mysql,storeSettings.GetDBHost().c_str(), storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(), 0,0,NULL,0))) @@ -757,8 +757,6 @@ if (mysql_num_rows(res) != 1) row = mysql_fetch_row(res); -std::string param; - conf->password = row[1]; if (conf->password.empty()) @@ -1306,9 +1304,7 @@ char password[ADM_PASSWD_LEN + 1]; char passwordE[2*ADM_PASSWD_LEN + 2]; BLOWFISH_CTX ctx; -memset(pass, 0, sizeof(pass)); memset(password, 0, sizeof(password)); -memset(passwordE, 0, sizeof(passwordE)); std::string p; MYSQL_RES *res; diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp index bccef5aa..5a55504d 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp @@ -242,7 +242,6 @@ if (PQstatus(connection) != CONNECTION_OK) } } -std::string login; PGresult * result; if (StartTransaction()) diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp index c9cb7ccf..ab78f00f 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp @@ -255,10 +255,6 @@ if (EscapeString(ename)) return -1; } -int32_t id, i; -double pda, pdb, pna, pnb; -int threshold; - { std::ostringstream query; query << "SELECT pk_tariff FROM tb_tariffs WHERE name = '" << ename << "'"; @@ -298,6 +294,7 @@ if (tuples != 1) PQclear(result); + int32_t id; tuple >> id; } @@ -331,11 +328,12 @@ if (PQresultStatus(result) != PGRES_COMMAND_OK) PQclear(result); -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) { @@ -348,6 +346,7 @@ for(i = 0; i < DIR_NUM; i++) pnb = td.dirPrice[i].priceNightB * 1024 * 1024; } + int threshold = 0; if (td.dirPrice[i].noDiscount) { threshold = 0xffFFffFF; diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp index 3331a07d..20d9b908 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp @@ -1369,8 +1369,6 @@ if (PQstatus(connection) != CONNECTION_OK) } } -PGresult * result; - if (StartTransaction()) { printfd(__FILE__, "POSTGRESQL_STORE::WriteDetailedStat(): 'Failed to start transaction'\n"); @@ -1408,7 +1406,7 @@ for (it = statTree.begin(); it != statTree.end(); ++it) << 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) { diff --git a/projects/stargazer/traffcounter_impl.cpp b/projects/stargazer/traffcounter_impl.cpp index fce47595..83c699f8 100644 --- a/projects/stargazer/traffcounter_impl.cpp +++ b/projects/stargazer/traffcounter_impl.cpp @@ -566,7 +566,6 @@ while (ln != rules.end()) foundU = true; *dirU = ln->dir; //printfd(__FILE__, "Up rule ok! %d\n", ln->dir); - //PrintRule(ln->rule); } } //if (!foundU) @@ -613,7 +612,6 @@ while (ln != rules.end()) foundD = true; *dirD = ln->dir; //printfd(__FILE__, "Down rule ok! %d\n", ln->dir); - //PrintRule(ln->rule); } } //if (!foundD) @@ -627,11 +625,6 @@ if (!foundD) *dirD = DIR_NUM; } //----------------------------------------------------------------------------- -void TRAFFCOUNTER_IMPL::SetRulesFile(const std::string & fn) -{ -rulesFileName = fn; -} -//----------------------------------------------------------------------------- bool TRAFFCOUNTER_IMPL::ReadRules(bool test) { //printfd(__FILE__, "TRAFFCOUNTER::ReadRules()\n"); @@ -704,7 +697,6 @@ while (fgets(str, 1023, f)) } if (!test) rules.push_back(rul); - //PrintRule(rul); } fclose(f); @@ -720,8 +712,6 @@ rul.proto = all; if (!test) rules.push_back(rul); -//PrintRule(rul); - return false; } //----------------------------------------------------------------------------- @@ -875,33 +865,6 @@ void TRAFFCOUNTER_IMPL::FreeRules() 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(rule.dir)); -} -//----------------------------------------------------------------------------- void TRAFFCOUNTER_IMPL::SetMonitorDir(const std::string & dir) { monitorDir = dir; diff --git a/projects/stargazer/traffcounter_impl.h b/projects/stargazer/traffcounter_impl.h index 7e552f82..12439313 100644 --- a/projects/stargazer/traffcounter_impl.h +++ b/projects/stargazer/traffcounter_impl.h @@ -186,8 +186,6 @@ public: TRAFFCOUNTER_IMPL(USERS_IMPL * users, const std::string & rulesFileName); ~TRAFFCOUNTER_IMPL(); - void SetRulesFile(const std::string & rulesFileName); - int Reload(); int Start(); int Stop(); @@ -204,7 +202,6 @@ private: 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); diff --git a/stglibs/common.lib/common.cpp b/stglibs/common.lib/common.cpp index db2ff6b3..c7c1bf05 100644 --- a/stglibs/common.lib/common.cpp +++ b/stglibs/common.lib/common.cpp @@ -274,10 +274,9 @@ return str; //--------------------------------------------------------------------------- void KOIToWin(const char * s1, char * s2, int l) { -unsigned char t; for (int j = 0; j < l; j++) { - t = s1[j]; + unsigned char t = s1[j]; s2[j] = koi2win[t]; if (s1[j] == 0) @@ -287,10 +286,9 @@ for (int j = 0; j < l; j++) //--------------------------------------------------------------------------- void WinToKOI(const char * s1, char * s2, int l) { -unsigned char t; for (int j = 0; j < l; j++) { - t = s1[j]; + unsigned char t = s1[j]; s2[j] = win2koi[t]; if (s1[j] == 0) @@ -301,11 +299,10 @@ for (int j = 0; j < l; j++) void KOIToWin(const std::string & s1, std::string * s2) { s2->erase(s2->begin(), s2->end()); -unsigned char t; s2->reserve(s1.length()); for (int j = 0; j < (int)s1.length(); j++) { - t = s1[j]; + unsigned char t = s1[j]; s2->push_back(koi2win[t]); } } @@ -313,11 +310,10 @@ for (int j = 0; j < (int)s1.length(); j++) void WinToKOI(const std::string & s1, std::string * s2) { s2->erase(s2->begin(), s2->end()); -unsigned char t; s2->reserve(s1.length()); for (int j = 0; j < (int)s1.length(); j++) { - t = s1[j]; + unsigned char t = s1[j]; s2->push_back(win2koi[t]); } } @@ -400,11 +396,10 @@ int ParseIPString(const char * str, uint32_t * ips, int maxIP) */ char p[255]; -char * p1, *pp; int n = 0; strncpy(p, str, 254); -pp = p; +char * pp = p; memset(ips, 0xFF, sizeof(unsigned long) * maxIP); @@ -416,7 +411,7 @@ if (str[0] == '*' && strlen(str) == 1) for (int i = 0; i < maxIP; i++) { - p1 = strtok(pp, ",\n "); + char * p1 = strtok(pp, ",\n "); pp = NULL; if (p1 == NULL && n == 0)// ÕËÁÚÁÔÅÌØ ÎÕÌØ É ÐÒÏÞÉÔÁÎÏ ÁÄÒÅÓÏ× ÔÏÖÅ ÎÏÌØ @@ -663,20 +658,18 @@ strcpy(str, stren); //--------------------------------------------------------------------------- void DecodeStr(char * str, unsigned long serial, int useHDD) { -int len = strlen(str); +size_t len = strlen(str); char strdc[100]; -int i, j = 0; -char c1, c2; 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; strdc[i/2] = c1+c2; } -for (i = 0; i < len/2; i++) +for (size_t i = 0; i < len/2; i++) { if (!useHDD) strdc[i] = strdc[i]^49; diff --git a/stglibs/dotconfpp.lib/dotconfpp.cpp b/stglibs/dotconfpp.lib/dotconfpp.cpp index 41775256..caf5a590 100644 --- a/stglibs/dotconfpp.lib/dotconfpp.cpp +++ b/stglibs/dotconfpp.lib/dotconfpp.cpp @@ -71,13 +71,13 @@ DOTCONFDocument::DOTCONFDocument(DOTCONFDocument::CaseSensitive caseSensitivity) DOTCONFDocument::~DOTCONFDocument() { - for(std::list::iterator i = nodeTree.begin(); i != nodeTree.end(); i++){ + for(std::list::iterator i = nodeTree.begin(); i != nodeTree.end(); ++i){ delete(*i); } - for(std::list::iterator i = requiredOptions.begin(); i != requiredOptions.end(); i++){ + for(std::list::iterator i = requiredOptions.begin(); i != requiredOptions.end(); ++i){ free(*i); } - for(std::list::iterator i = processedFiles.begin(); i != processedFiles.end(); i++){ + for(std::list::iterator i = processedFiles.begin(); i != processedFiles.end(); ++i){ free(*i); } free(fileName); @@ -188,7 +188,7 @@ int DOTCONFDocument::parseLine() DOTCONFDocumentNode * tagNode = NULL; bool newNode = false; - for(std::list::iterator i = words.begin(); i != words.end(); i++) { + for(std::list::iterator i = words.begin(); i != words.end(); ++i) { word = *i; if(*word == '<'){ @@ -217,7 +217,7 @@ int DOTCONFDocument::parseLine() } else { //closing tag nodeName+=2; std::list::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; @@ -270,11 +270,10 @@ int DOTCONFDocument::parseFile(DOTCONFDocumentNode * _parent) curParent = _parent; quoted = false; - size_t slen = 0; while(fgets(str, 511, file)){ curLine++; - slen = strlen(str); + size_t slen = strlen(str); if( slen >= 510 ){ error(curLine, fileName, "warning: line too long"); } @@ -304,16 +303,14 @@ int DOTCONFDocument::checkConfig(const std::list::iterator { int ret = 0; - DOTCONFDocumentNode * tagNode = NULL; - int vi = 0; - for(std::list::iterator i = from; i != nodeTree.end(); i++){ - tagNode = *i; + for(std::list::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; } - vi = 0; + int vi = 0; 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], '}') ){ @@ -378,7 +375,7 @@ int DOTCONFDocument::setContent(const char * _fileName) std::list::iterator from; DOTCONFDocumentNode * tagNode = NULL; int vi = 0; - for(std::list::iterator i = nodeTree.begin(); i!=nodeTree.end(); i++){ + for(std::list::iterator i = nodeTree.begin(); i!=nodeTree.end(); ++i){ tagNode = *i; if(!cmp_func("IncludeFile", tagNode->name)){ vi = 0; @@ -426,7 +423,7 @@ int DOTCONFDocument::setContent(const char * _fileName) } bool processed = false; - for(std::list::const_iterator itInode = processedFiles.begin(); itInode != processedFiles.end(); itInode++){ + for(std::list::const_iterator itInode = processedFiles.begin(); itInode != processedFiles.end(); ++itInode){ if(!strcmp(*itInode, realpathBuf)){ processed = true; break; @@ -445,7 +442,7 @@ int DOTCONFDocument::setContent(const char * _fileName) } //free(fileName); fileName = strdup(realpathBuf); - from = nodeTree.end(); from--; + from = nodeTree.end(); --from; if(tagNode->parentNode){ DOTCONFDocumentNode * nd = tagNode->parentNode->childNode; @@ -488,9 +485,9 @@ int DOTCONFDocument::setContent(const char * _fileName) int DOTCONFDocument::checkRequiredOptions() { - for(std::list::const_iterator ci = requiredOptions.begin(); ci != requiredOptions.end(); ci++){ + for(std::list::const_iterator ci = requiredOptions.begin(); ci != requiredOptions.end(); ++ci){ bool matched = false; - for(std::list::iterator i = nodeTree.begin(); i!=nodeTree.end(); i++){ + for(std::list::iterator i = nodeTree.begin(); i!=nodeTree.end(); ++i){ if(!cmp_func((*i)->name, *ci)){ matched = true; break; @@ -565,9 +562,8 @@ char * DOTCONFDocument::getSubstitution(char * macro, int lineNum) buf = mempool->strdup(subs); } else { std::list::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]); @@ -641,12 +637,12 @@ const DOTCONFDocumentNode * DOTCONFDocument::findNode(const char * nodeName, con if(startNode != NULL){ while( i != nodeTree.end() && (*i) != startNode ){ - i++; + ++i; } - 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; diff --git a/stglibs/ia.lib/ia.cpp b/stglibs/ia.lib/ia.cpp index aa12a012..1e4760fc 100644 --- a/stglibs/ia.lib/ia.cpp +++ b/stglibs/ia.lib/ia.cpp @@ -297,7 +297,7 @@ if (res == -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)) { diff --git a/stglibs/scriptexecuter.lib/scriptexecuter.c b/stglibs/scriptexecuter.lib/scriptexecuter.c index 728082ae..bdf60230 100644 --- a/stglibs/scriptexecuter.lib/scriptexecuter.c +++ b/stglibs/scriptexecuter.lib/scriptexecuter.c @@ -46,7 +46,6 @@ void Executer(int msgID, pid_t pid, char * procName) void Executer(int msgID, pid_t pid) #endif { -int ret; struct SCRIPT_DATA sd; struct sigaction newsa, oldsa; sigset_t sigmask; @@ -94,7 +93,7 @@ sigaction(SIGUSR1, &newsa, &oldsa); while (nonstop) { sd.mtype = 1; - ret = msgrcv(msgid, &sd, MAX_SCRIPT_LEN, 0, 0); + int ret = msgrcv(msgid, &sd, MAX_SCRIPT_LEN, 0, 0); if (ret < 0) {