summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorNaram Qashat <cyberbotx@cyberbotx.com>2010-06-27 23:15:05 -0400
committerNaram Qashat <cyberbotx@cyberbotx.com>2010-06-27 23:15:05 -0400
commit28e12bc24a9c85f4f0d1e37567618ec39cb501f6 (patch)
treecc70ebeef95a9d95174afe3ef038b0d673346f58 /src/modules
parent051ebe3eea0f8529b64c0e443c61103ba2f7dee8 (diff)
The next of a few "CBX OCDing over code style" commits, maybe the last.
NOTES: I have been unable to compile the db_mysql_* functions on my system here, so those are untested. db-convert seems to be badly programmed and needs more work in my opinion.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/cs_appendtopic.cpp30
-rw-r--r--src/modules/cs_enforce.cpp31
-rw-r--r--src/modules/cs_tban.cpp18
-rw-r--r--src/modules/hs_request.cpp81
-rw-r--r--src/modules/mysql/db_mysql.h16
-rw-r--r--src/modules/mysql/db_mysql_execute.cpp4
-rw-r--r--src/modules/mysql/db_mysql_read.cpp130
-rw-r--r--src/modules/mysql/db_mysql_write.cpp131
-rw-r--r--src/modules/ns_maxemail.cpp12
-rw-r--r--src/modules/os_info.cpp33
-rw-r--r--src/modules/ssl/m_ssl.cpp18
11 files changed, 177 insertions, 327 deletions
diff --git a/src/modules/cs_appendtopic.cpp b/src/modules/cs_appendtopic.cpp
index a1c84d0ab..03f20ba6c 100644
--- a/src/modules/cs_appendtopic.cpp
+++ b/src/modules/cs_appendtopic.cpp
@@ -12,8 +12,8 @@
* Send bug reports to the Anope Coder instead of the module
* author, because any changes since the inclusion into anope
* are not supported by the original author.
- *
*/
+
/*************************************************************************/
#include "module.h"
@@ -41,11 +41,13 @@
/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */
/* ---------------------------------------------------------------------- */
-#define LNG_NUM_STRINGS 3
-
-#define LNG_CHAN_HELP 0
-#define LNG_CHAN_HELP_APPENDTOPIC 1
-#define LNG_APPENDTOPIC_SYNTAX 2
+enum
+{
+ LNG_CHAN_HELP,
+ LNG_CHAN_HELP_APPENDTOPIC,
+ LNG_APPENDTOPIC_SYNTAX,
+ LNG_NUM_STRINGS
+};
static Module *me;
@@ -96,20 +98,14 @@ class CommandCSAppendTopic : public Command
if (!check_access(u, ci, CA_TOPIC))
Alog() << Config.s_ChanServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin.";
- if (ircd->join2set)
+ if (ircd->join2set && whosends(ci) == ChanServ)
{
- if (whosends(ci) == ChanServ)
- {
- ChanServ->Join(c);
- ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX
- }
+ ChanServ->Join(c);
+ ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX
}
ircdproto->SendTopic(whosends(ci), c, u->nick.c_str(), topic);
- if (ircd->join2set)
- {
- if (whosends(ci) == ChanServ)
- ChanServ->Part(c);
- }
+ if (ircd->join2set && whosends(ci) == ChanServ)
+ ChanServ->Part(c);
}
return MOD_CONT;
}
diff --git a/src/modules/cs_enforce.cpp b/src/modules/cs_enforce.cpp
index a3be24c7a..c4cfbecc9 100644
--- a/src/modules/cs_enforce.cpp
+++ b/src/modules/cs_enforce.cpp
@@ -17,14 +17,16 @@
#define AUTHOR "Anope"
-#define LNG_NUM_STRINGS 6
-
-#define LNG_CHAN_HELP 0
-#define LNG_ENFORCE_SYNTAX 1
-#define LNG_CHAN_HELP_ENFORCE 2
-#define LNG_CHAN_HELP_ENFORCE_R_ENABLED 3
-#define LNG_CHAN_HELP_ENFORCE_R_DISABLED 4
-#define LNG_CHAN_RESPONSE 5
+enum
+{
+ LNG_CHAN_HELP,
+ LNG_ENFORCE_SYNTAX,
+ LNG_CHAN_HELP_ENFORCE,
+ LNG_CHAN_HELP_ENFORCE_R_ENABLED,
+ LNG_CHAN_HELP_ENFORCE_R_DISABLED,
+ LNG_CHAN_RESPONSE,
+ LNG_NUM_STRINGS
+};
static Module *me;
@@ -71,7 +73,7 @@ class CommandCSEnforce : public Command
hadsecureops = true;
}
- for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
UserContainer *uc = *it;
@@ -79,10 +81,7 @@ class CommandCSEnforce : public Command
}
if (hadsecureops)
- {
ci->UnsetFlag(CI_SECUREOPS);
- }
-
}
void DoRestricted(Channel *c)
@@ -101,7 +100,7 @@ class CommandCSEnforce : public Command
if (ci->levels[CA_NOJOIN] < 0)
ci->levels[CA_NOJOIN] = 0;
- for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
UserContainer *uc = *it++;
@@ -128,18 +127,16 @@ class CommandCSEnforce : public Command
Alog(LOG_DEBUG) << "[cs_enforce] Enforcing mode +R on " << c->name;
- for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
+ for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
UserContainer *uc = *it++;
-
+
if (!uc->user->IsIdentified())
{
get_idealban(ci, uc->user, mask, sizeof(mask));
reason = getstring(uc->user, CHAN_NOT_ALLOWED_TO_JOIN);
if (!c->HasMode(CMODE_REGISTERED))
- {
c->SetMode(NULL, CMODE_BAN, mask);
- }
c->Kick(NULL, uc->user, "%s", reason);
}
}
diff --git a/src/modules/cs_tban.cpp b/src/modules/cs_tban.cpp
index 88e541ac8..844606222 100644
--- a/src/modules/cs_tban.cpp
+++ b/src/modules/cs_tban.cpp
@@ -12,7 +12,6 @@
* Send bug reports to the Anope Coder instead of the module
* author, because any changes since the inclusion into anope
* are not supported by the original author.
- *
*/
/*************************************************************************/
@@ -29,11 +28,14 @@ void mAddLanguages();
static Module *me = NULL;
-#define LANG_NUM_STRINGS 4
-#define TBAN_HELP 0
-#define TBAN_SYNTAX 1
-#define TBAN_HELP_DETAIL 2
-#define TBAN_RESPONSE 3
+enum
+{
+ TBAN_HELP,
+ TBAN_SYNTAX,
+ TBAN_HELP_DETAIL,
+ TBAN_RESPONSE,
+ LANG_NUM_STRINGS
+};
class CommandCSTBan : public Command
{
@@ -57,14 +59,12 @@ class CommandCSTBan : public Command
else if (!(u2 = finduser(nick)))
notice_lang(Config.s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
else
- {
if (canBanUser(c, u, u2))
{
get_idealban(c->ci, u2, mask, sizeof(mask));
addBan(c, dotime(time), mask);
mySendResponse(u, chan, mask, time);
}
- }
return MOD_CONT;
}
@@ -179,9 +179,7 @@ class TempBan : public CallBack
Channel *c;
if ((c = findchan(chan)) && c->ci)
- {
c->RemoveMode(NULL, CMODE_BAN, mask);
- }
}
};
diff --git a/src/modules/hs_request.cpp b/src/modules/hs_request.cpp
index 05e5969f2..5399140bc 100644
--- a/src/modules/hs_request.cpp
+++ b/src/modules/hs_request.cpp
@@ -25,29 +25,31 @@ int HSRequestMemoOper = 0;
int HSRequestMemoSetters = 0;
/* Language defines */
-#define LNG_NUM_STRINGS 21
-
-#define LNG_REQUEST_SYNTAX 0
-#define LNG_REQUESTED 1
-#define LNG_REQUEST_WAIT 2
-#define LNG_REQUEST_MEMO 3
-#define LNG_ACTIVATE_SYNTAX 4
-#define LNG_ACTIVATED 5
-#define LNG_ACTIVATE_MEMO 6
-#define LNG_REJECT_SYNTAX 7
-#define LNG_REJECTED 8
-#define LNG_REJECT_MEMO 9
-#define LNG_REJECT_MEMO_REASON 10
-#define LNG_NO_REQUEST 11
-#define LNG_HELP 12
-#define LNG_HELP_SETTER 13
-#define LNG_HELP_REQUEST 14
-#define LNG_HELP_ACTIVATE 15
-#define LNG_HELP_ACTIVATE_MEMO 16
-#define LNG_HELP_REJECT 17
-#define LNG_HELP_REJECT_MEMO 18
-#define LNG_WAITING_SYNTAX 19
-#define LNG_HELP_WAITING 20
+enum
+{
+ LNG_REQUEST_SYNTAX,
+ LNG_REQUESTED,
+ LNG_REQUEST_WAIT,
+ LNG_REQUEST_MEMO,
+ LNG_ACTIVATE_SYNTAX,
+ LNG_ACTIVATED,
+ LNG_ACTIVATE_MEMO,
+ LNG_REJECT_SYNTAX,
+ LNG_REJECTED,
+ LNG_REJECT_MEMO,
+ LNG_REJECT_MEMO_REASON,
+ LNG_NO_REQUEST,
+ LNG_HELP,
+ LNG_HELP_SETTER,
+ LNG_HELP_REQUEST,
+ LNG_HELP_ACTIVATE,
+ LNG_HELP_ACTIVATE_MEMO,
+ LNG_HELP_REJECT,
+ LNG_HELP_REJECT_MEMO,
+ LNG_WAITING_SYNTAX,
+ LNG_HELP_WAITING,
+ LNG_NUM_STRINGS
+};
void my_add_host_request(char *nick, char *vIdent, char *vhost, char *creator, time_t tmp_time);
int my_isvalidchar(const char c);
@@ -107,9 +109,7 @@ class CommandHSRequest : public Command
return MOD_CONT;
}
else
- {
for (s = vIdent; *s; ++s)
- {
if (!my_isvalidchar(*s))
{
notice_lang(Config.s_HostServ, u, HOST_SET_IDENT_ERROR);
@@ -118,8 +118,6 @@ class CommandHSRequest : public Command
delete [] hostmask;
return MOD_CONT;
}
- }
- }
if (!ircd->vident)
{
notice_lang(Config.s_HostServ, u, HOST_NO_VIDENT);
@@ -157,20 +155,17 @@ class CommandHSRequest : public Command
if ((na = findnick(nick)))
{
- if (HSRequestMemoOper || HSRequestMemoSetters)
+ if ((HSRequestMemoOper || HSRequestMemoSetters) && Config.MSSendDelay > 0 && u && u->lastmemosend + Config.MSSendDelay > now)
{
- if (Config.MSSendDelay > 0 && u && u->lastmemosend + Config.MSSendDelay > now)
+ me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_WAIT, Config.MSSendDelay);
+ u->lastmemosend = now;
+ if (vIdent)
{
- me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_WAIT, Config.MSSendDelay);
- u->lastmemosend = now;
- if (vIdent)
- {
- delete [] vIdent;
- delete [] rawhostmask;
- }
- delete [] hostmask;
- return MOD_CONT;
+ delete [] vIdent;
+ delete [] rawhostmask;
}
+ delete [] hostmask;
+ return MOD_CONT;
}
my_add_host_request(const_cast<char *>(nick), vIdent, hostmask, const_cast<char *>(u->nick.c_str()), now);
@@ -328,7 +323,7 @@ class HSListBase : public Command
unsigned display_counter = 0;
tm *tm;
- for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(); it != Requests.end(); ++it)
+ for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it)
{
HostRequest *hr = it->second;
if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config.NSListMax)
@@ -721,7 +716,7 @@ class HSRequest : public Module
void OnDatabaseWrite(void (*Write)(const std::string &))
{
- for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(); it != Requests.end(); ++it)
+ for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it)
{
HostRequest *hr = it->second;
std::stringstream buf;
@@ -779,7 +774,7 @@ void req_send_memos(User *u, char *vIdent, char *vHost)
{
int z = 2;
char host[BUFSIZE];
- std::list<std::pair<ci::string, ci::string> >::iterator it;
+ std::list<std::pair<ci::string, ci::string> >::iterator it, it_end;
if (vIdent)
snprintf(host, sizeof(host), "%s@%s", vIdent, vHost);
@@ -787,13 +782,11 @@ void req_send_memos(User *u, char *vIdent, char *vHost)
snprintf(host, sizeof(host), "%s", vHost);
if (HSRequestMemoOper == 1)
- {
- for (it = Config.Opers.begin(); it != Config.Opers.end(); ++it)
+ for (it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it)
{
ci::string nick = it->first;
my_memo_lang(u, nick.c_str(), z, LNG_REQUEST_MEMO, host);
}
- }
if (HSRequestMemoSetters == 1)
{
/* Needs to be rethought because of removal of HostSetters in favor of opertype priv -- CyberBotX
diff --git a/src/modules/mysql/db_mysql.h b/src/modules/mysql/db_mysql.h
index f2885408f..34ae50931 100644
--- a/src/modules/mysql/db_mysql.h
+++ b/src/modules/mysql/db_mysql.h
@@ -1,3 +1,6 @@
+#ifndef DB_MYSQL_H
+#define DB_MYSQL_H
+
#include "module.h"
struct NickAliasFlagInfo
@@ -117,15 +120,15 @@ MemoFlagInfo MemoFlags[] = {
#define MYSQLPP_MYSQL_HEADERS_BURIED
#include <mysql++/mysql++.h>
-inline std::string SQLAssign(const mysqlpp::String& s) { return s.c_str(); }
+inline std::string SQLAssign(const mysqlpp::String &s) { return s.c_str(); }
class DBMySQL;
static DBMySQL *me;
-bool ExecuteQuery(mysqlpp::Query& query)
+bool ExecuteQuery(mysqlpp::Query &query)
{
Alog(LOG_DEBUG) << "MySQL: " << query.str();
-
+
if (!query.execute())
{
Alog() << "MySQL: error executing query: " << query.error();
@@ -135,15 +138,13 @@ bool ExecuteQuery(mysqlpp::Query& query)
return true;
}
-mysqlpp::StoreQueryResult StoreQuery(mysqlpp::Query& query)
+mysqlpp::StoreQueryResult StoreQuery(mysqlpp::Query &query)
{
Alog(LOG_DEBUG) << "MySQL: " << query.str();
mysqlpp::StoreQueryResult result = query.store();
if (!result)
- {
Alog() << "MySQL: error executing query: " << query.error();
- }
return result;
}
@@ -195,7 +196,7 @@ class DBMySQL : public Module
delete Con;
throw ModuleException(Error.c_str());
}
-
+
mysqlpp::Query query(Con);
query << "SET NAMES 'utf8'";
ExecuteQuery(query);
@@ -208,3 +209,4 @@ class DBMySQL : public Module
}
};
+#endif // DB_MYSQL_H
diff --git a/src/modules/mysql/db_mysql_execute.cpp b/src/modules/mysql/db_mysql_execute.cpp
index 2313edd37..2cc6ab6df 100644
--- a/src/modules/mysql/db_mysql_execute.cpp
+++ b/src/modules/mysql/db_mysql_execute.cpp
@@ -75,7 +75,7 @@ class SQLTimer : public Timer
if (qres && qres.num_rows())
{
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
User *u;
NickAlias *na = NULL;
@@ -149,7 +149,7 @@ class DBMySQLExecute : public DBMySQL
{
_SQLTimer = new SQLTimer();
}
-
+
~DBMySQLExecute()
{
delete _SQLTimer;
diff --git a/src/modules/mysql/db_mysql_read.cpp b/src/modules/mysql/db_mysql_read.cpp
index 3c5fb359a..3ffc82366 100644
--- a/src/modules/mysql/db_mysql_read.cpp
+++ b/src/modules/mysql/db_mysql_read.cpp
@@ -34,8 +34,7 @@ static void LoadDatabase()
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = new NickCore(SQLAssign(qres[i]["display"]));
nc->pass = SQLAssign(qres[i]["pass"]);
@@ -51,28 +50,20 @@ static void LoadDatabase()
spacesepstream sep(SQLAssign(qres[i]["flags"]));
std::string buf;
while (sep.GetToken(buf))
- {
for (int j = 0; NickCoreFlags[j].Flag != -1; ++j)
- {
if (NickCoreFlags[j].Name == buf)
- {
nc->SetFlag(NickCoreFlags[j].Flag);
- }
- }
- }
nc->language = atoi(qres[i]["language"].c_str());
nc->channelcount = atoi(qres[i]["channelcount"].c_str());
nc->memos.memomax = atoi(qres[i]["memomax"].c_str());
}
- }
query << "SELECT * FROM `anope_ns_access`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = findcore(qres[i]["display"].c_str());
if (!nc)
@@ -83,14 +74,12 @@ static void LoadDatabase()
nc->AddAccess(SQLAssign(qres[i]["access"]));
}
- }
query << "SELECT * FROM `anope_ns_core_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = findcore(qres[i]["display"].c_str());
if (!nc)
@@ -102,14 +91,12 @@ static void LoadDatabase()
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nc, SQLAssign(qres[i]["name"]), Params));
}
- }
query << "SELECT * FROM `anope_ns_alias`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = findcore(qres[i]["display"].c_str());
if (!nc)
@@ -128,24 +115,16 @@ static void LoadDatabase()
spacesepstream sep(SQLAssign(qres[i]["flags"]));
std::string buf;
while (sep.GetToken(buf))
- {
for (int j = 0; NickAliasFlags[j].Flag != -1; ++j)
- {
if (NickAliasFlags[j].Name == buf)
- {
na->SetFlag(NickAliasFlags[j].Flag);
- }
- }
- }
}
- }
query << "SELECT * FROM `anope_ns_alias_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickAlias *na = findnick(SQLAssign(qres[i]["nick"]));
if (!na)
@@ -157,14 +136,12 @@ static void LoadDatabase()
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(na, SQLAssign(qres[i]["name"]), Params));
}
- }
query << "SELECT * FROM `anope_bs_core`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
BotInfo *bi = findbot(SQLAssign(qres[i]["nick"]));
if (!bi)
@@ -178,28 +155,22 @@ static void LoadDatabase()
spacesepstream sep(SQLAssign(qres[i]["flags"]));
std::string buf;
while (sep.GetToken(buf))
- {
for (unsigned j = 0; BotServFlags[j].Flag != -1; ++j)
- {
if (buf == BotServFlags[j].Name)
{
bi->SetFlag(BotServFlags[j].Flag);
break;
}
- }
- }
}
bi->created = atol(qres[i]["created"]);
bi->chancount = atol(qres[i]["chancount"]);
}
- }
query << "SELECT * FROM `anope_bs_info_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
BotInfo *bi = findbot(SQLAssign(qres[i]["botname"]));
if (!bi)
@@ -212,14 +183,12 @@ static void LoadDatabase()
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(bi, SQLAssign(qres[i]["name"]), Params));
}
- }
query << "SELECT * FROM `anope_cs_info`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc;
if (qres[i]["founder"].size())
@@ -254,16 +223,12 @@ static void LoadDatabase()
std::string buf;
spacesepstream sep(SQLAssign(qres[i]["flags"]));
while (sep.GetToken(buf))
- {
for (int j = 0; ChannelFlags[j].Flag != -1; ++j)
- {
if (buf == ChannelFlags[j].Name)
{
ci->SetFlag(ChannelFlags[j].Flag);
break;
}
- }
- }
}
if (qres[i]["forbidby"].size())
ci->forbidby = sstrdup(qres[i]["forbidby"].c_str());
@@ -316,16 +281,12 @@ static void LoadDatabase()
std::string buf;
spacesepstream sep(SQLAssign(qres[i]["botflags"]));
while (sep.GetToken(buf))
- {
for (int j = 0; BotFlags[j].Flag != -1; ++j)
- {
if (buf == BotFlags[j].Name)
{
ci->botflags.SetFlag(BotFlags[j].Flag);
break;
}
- }
- }
}
}
if (qres[i]["capsmin"].size())
@@ -339,14 +300,12 @@ static void LoadDatabase()
if (qres[i]["repeattimes"].size())
ci->repeattimes = atoi(qres[i]["repeattimes"].c_str());
}
- }
query << "SELECT * FROM `anope_cs_ttb";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -357,14 +316,12 @@ static void LoadDatabase()
ci->ttb[atoi(qres[i]["ttb_id"].c_str())] = atoi(qres[i]["value"].c_str());
}
- }
query << "SELECT * FROM `anope_bs_badwords`";
qres = StoreQuery(query);
-
+
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -372,7 +329,7 @@ static void LoadDatabase()
Alog() << "MySQL: Channel badwords entry for nonexistant channel " << qres[i]["channel"];
continue;
}
-
+
BadWordType BWTYPE = BW_ANY;
if (qres[i]["type"] == "SINGLE")
BWTYPE = BW_SINGLE;
@@ -382,14 +339,12 @@ static void LoadDatabase()
BWTYPE = BW_END;
ci->AddBadWord(SQLAssign(qres[i]["word"]), BWTYPE);
}
- }
query << "SELECT * FROM `anope_cs_access`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -406,14 +361,12 @@ static void LoadDatabase()
ci->AddAccess(nc, atoi(qres[i]["level"]), SQLAssign(qres[i]["creator"]), atol(qres[i]["last_seen"]));
}
- }
query << "SELECT * FROM `anope_cs_akick`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -426,12 +379,10 @@ static void LoadDatabase()
std::string flag, mask;
bool stuck = false;
while (sep.GetToken(flag))
- {
if (flag == "ISNICK")
nc = findcore(qres[i]["mask"]);
else if (flag == "STUCK")
stuck = true;
- }
AutoKick *ak;
if (nc)
ak = ci->AddAkick(SQLAssign(qres[i]["creator"]), nc, SQLAssign(qres[i]["reason"]), atol(qres[i]["created"].c_str()), atol(qres[i]["last_used"].c_str()));
@@ -442,14 +393,12 @@ static void LoadDatabase()
if (nc)
ak->SetFlag(AK_ISNICK);
}
- }
query << "SELECT * FROM `anope_cs_levels`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -459,14 +408,12 @@ static void LoadDatabase()
}
ci->levels[atoi(qres[i]["position"])] = atoi(qres[i]["level"]);
}
- }
query << "SELECT * FROM `anope_cs_info_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (!ci)
@@ -474,19 +421,17 @@ static void LoadDatabase()
Alog() << "MySQL: Channel metadata for nonexistant channel " << qres[i]["channel"];
continue;
}
-
+
EventReturn MOD_RESULT;
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(ci, SQLAssign(qres[i]["name"]), Params));
}
- }
query << "SELECT * FROM `anope_ns_request`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickRequest *nr = new NickRequest(qres[i]["nick"].c_str());
nr->passcode = SQLAssign(qres[i]["passcode"]);
@@ -494,27 +439,23 @@ static void LoadDatabase()
nr->email = sstrdup(qres[i]["email"].c_str());
nr->requested = atol(qres[i]["requested"].c_str());
}
- }
EventReturn MOD_RESULT;
query << "SELECT * FROM `anope_extra`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
std::vector<std::string> params = MakeVector(SQLAssign(qres[i]["data"]));
FOREACH_RESULT(I_OnDatabaseRead, OnDatabaseRead(params));
}
- }
query << "SELECT * FROM `anope_ns_core_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickCore *nc = findcore(qres[i]["nick"].c_str());
if (nc)
@@ -523,14 +464,12 @@ static void LoadDatabase()
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nc, SQLAssign(qres[i]["name"]), params));
}
}
- }
query << "SELECT * FROM `anope_ns_alias_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
NickAlias *na = findnick(SQLAssign(qres[i]["nick"]));
if (na)
@@ -539,14 +478,12 @@ static void LoadDatabase()
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(na, SQLAssign(qres[i]["name"]), params));
}
}
- }
query << "SELECT * FROM `anope_cs_info_metadata`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
if (ci)
@@ -555,14 +492,12 @@ static void LoadDatabase()
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(ci, SQLAssign(qres[i]["name"]), params));
}
}
- }
query << "SELECT * FROM `anope_ms_info`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.num_rows(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
MemoInfo *mi = NULL;
if (qres[i]["serv"] == "NICK")
@@ -592,37 +527,27 @@ static void LoadDatabase()
}
}
else
- {
m->number = 1;
- }
m->time = atol(qres[i]["time"].c_str());
m->text = sstrdup(qres[i]["text"].c_str());
-
+
if (qres[i]["flags"].size())
{
spacesepstream sep(SQLAssign(qres[i]["flags"]));
std::string buf;
while (sep.GetToken(buf))
- {
for (unsigned j = 0; MemoFlags[j].Flag != -1; ++j)
- {
if (MemoFlags[j].Name == buf)
- {
m->SetFlag(MemoFlags[j].Flag);
- }
- }
- }
}
}
}
- }
query << "SELECT * FROM `anope_os_akills`";
qres = StoreQuery(query);
if (qres && SGLine)
- {
- for (size_t i = 0; i < qres.size(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ci::string user = qres[i]["user"].c_str();
ci::string host = qres[i]["host"].c_str();
@@ -638,14 +563,12 @@ static void LoadDatabase()
x->Created = seton;
}
}
- }
query << "SELECT * FROM `anope_os_xlines`";
qres = StoreQuery(query);
if (qres)
- {
- for (size_t i = 0; i < qres.size(); ++i)
+ for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
{
ci::string mask = qres[i]["mask"].c_str();
ci::string by = qres[i]["xby"].c_str();
@@ -666,7 +589,6 @@ static void LoadDatabase()
x->Created = seton;
}
}
- }
}
class DBMySQLRead : public DBMySQL
diff --git a/src/modules/mysql/db_mysql_write.cpp b/src/modules/mysql/db_mysql_write.cpp
index b5686fa2f..c5c002a7e 100644
--- a/src/modules/mysql/db_mysql_write.cpp
+++ b/src/modules/mysql/db_mysql_write.cpp
@@ -7,12 +7,8 @@ static std::string BuildFlagsList(ChannelInfo *ci)
std::string ret;
for (int i = 0; ChannelFlags[i].Flag != -1; ++i)
- {
if (ci->HasFlag(ChannelFlags[i].Flag))
- {
ret += " " + ChannelFlags[i].Name;
- }
- }
if (!ret.empty())
ret.erase(ret.begin());
@@ -25,12 +21,8 @@ static std::string BuildFlagsList(NickAlias *na)
std::string ret;
for (int i = 0; NickAliasFlags[i].Flag != -1; ++i)
- {
if (na->HasFlag(NickAliasFlags[i].Flag))
- {
ret += " " + NickAliasFlags[i].Name;
- }
- }
if (!ret.empty())
ret.erase(ret.begin());
@@ -43,12 +35,8 @@ static std::string BuildFlagsList(NickCore *nc)
std::string ret;
for (int i = 0; NickCoreFlags[i].Flag != -1; ++i)
- {
if (nc->HasFlag(NickCoreFlags[i].Flag))
- {
ret += " " + NickCoreFlags[i].Name;
- }
- }
if (!ret.empty())
ret.erase(ret.begin());
@@ -61,16 +49,12 @@ static std::string BuildFlagsList(Memo *m)
std::string ret;
for (int i = 0; MemoFlags[i].Flag != -1; ++i)
- {
if (m->HasFlag(MemoFlags[i].Flag))
- {
ret += " " + MemoFlags[i].Name;
- }
- }
if (!ret.empty())
ret.erase(ret.begin());
-
+
return ret;
}
@@ -78,16 +62,14 @@ static std::string MakeMLock(ChannelInfo *ci, bool status)
{
std::string ret;
- for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
+ for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(), it_end = ModeManager::Modes.end(); it != it_end; ++it)
{
if ((*it)->Class == MC_CHANNEL)
{
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
if (ci->HasMLock(cm->Name, status))
- {
ret += " " + cm->NameAsString;
- }
}
}
@@ -111,17 +93,15 @@ static std::string GetMLockParams(ChannelInfo *ci)
{
std::string ret;
- for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
+ for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(), it_end = ModeManager::Modes.end(); it != it_end; ++it)
{
if ((*it)->Class == MC_CHANNEL)
{
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
-
+
std::string param;
if (ci->GetParam(cm->Name, param))
- {
ret += " " + cm->NameAsString + " " + param;
- }
}
}
@@ -136,12 +116,8 @@ static std::string GetBotFlags(Flags<BotServFlag>& Flags)
std::string buf;
for (int i = 0; BotFlags[i].Flag != -1; ++i)
- {
if (Flags.HasFlag(BotFlags[i].Flag))
- {
buf += " " + BotFlags[i].Name;
- }
- }
if (!buf.empty())
buf.erase(buf.begin());
@@ -154,16 +130,12 @@ static std::string GetBotServFlags(BotInfo *bi)
std::string buf;
for (int i = 0; BotServFlags[i].Flag != -1; ++i)
- {
if (bi->HasFlag(BotServFlags[i].Flag))
- {
buf += " " + BotServFlags[i].Name;
- }
- }
if (!buf.empty())
buf.erase(buf.begin());;
-
+
return buf;
}
@@ -200,7 +172,7 @@ void WriteCoreMetadata(const std::string &key, const std::string &data)
{
if (!CurCore)
throw CoreException("WritCoreMetadata without a core to write");
-
+
mysqlpp::Query query(me->Con);
query << "INSERT DELAYED INTO `anope_ns_core_metadata` (nick, name, value) VALUES(" <