summaryrefslogtreecommitdiff
path: root/src/core/ms_set.c
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-07-25 00:37:43 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-07-25 00:37:43 +0000
commitb2a57b09742da6c2f2011ad41eb470139d88e14f (patch)
tree054e41a724108706c5ea5f659d2065fe5fae2504 /src/core/ms_set.c
parent443654f15bf036bb18f9847332e2bd03ec823b3d (diff)
Changed params parameter of Command's Execute() from std::vector<std::string> to std::vector<ci::string>, seems to have no ill effects but may require some testing to be sure.
Also a few minor cleanups here and there. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2392 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core/ms_set.c')
-rw-r--r--src/core/ms_set.c93
1 files changed, 46 insertions, 47 deletions
diff --git a/src/core/ms_set.c b/src/core/ms_set.c
index 48d871ed3..a149bb26a 100644
--- a/src/core/ms_set.c
+++ b/src/core/ms_set.c
@@ -18,28 +18,28 @@
class CommandMSSet : public Command
{
private:
- CommandReturn DoNotify(User *u, std::vector<std::string> &params, MemoInfo *mi)
+ CommandReturn DoNotify(User *u, std::vector<ci::string> &params, MemoInfo *mi)
{
- const char *param = params[1].c_str();
+ ci::string param = params[1];
- if (!stricmp(param, "ON"))
+ if (param == "ON")
{
u->nc->flags |= NI_MEMO_SIGNON | NI_MEMO_RECEIVE;
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_ON, s_MemoServ);
}
- else if (!stricmp(param, "LOGON"))
+ else if (param == "LOGON")
{
u->nc->flags |= NI_MEMO_SIGNON;
u->nc->flags &= ~NI_MEMO_RECEIVE;
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_LOGON, s_MemoServ);
}
- else if (!stricmp(param, "NEW"))
+ else if (param == "NEW")
{
u->nc->flags &= ~NI_MEMO_SIGNON;
u->nc->flags |= NI_MEMO_RECEIVE;
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NEW, s_MemoServ);
}
- else if (!stricmp(param, "MAIL"))
+ else if (param == "MAIL")
{
if (u->nc->email)
{
@@ -49,12 +49,12 @@ class CommandMSSet : public Command
else
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_INVALIDMAIL);
}
- else if (!stricmp(param, "NOMAIL"))
+ else if (param == "NOMAIL")
{
u->nc->flags &= ~NI_MEMO_MAIL;
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NOMAIL);
}
- else if (!stricmp(param, "OFF"))
+ else if (param == "OFF")
{
u->nc->flags &= ~(NI_MEMO_SIGNON | NI_MEMO_RECEIVE | NI_MEMO_MAIL);
notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_OFF, s_MemoServ);
@@ -64,26 +64,26 @@ class CommandMSSet : public Command
return MOD_CONT;
}
- CommandReturn DoLimit(User *u, std::vector<std::string> &params, MemoInfo *mi)
+ CommandReturn DoLimit(User *u, std::vector<ci::string> &params, MemoInfo *mi)
{
- const char *p1 = params[1].c_str();
- const char *p2 = params.size() > 2 ? params[2].c_str() : NULL;
- const char *p3 = params.size() > 3 ? params[3].c_str() : NULL;
- const char *user = NULL, *chan = NULL;
+ ci::string p1 = params[1];
+ ci::string p2 = params.size() > 2 ? params[2] : "";
+ ci::string p3 = params.size() > 3 ? params[3] : "";
+ ci::string user, chan;
int32 limit;
NickCore *nc = u->nc;
ChannelInfo *ci = NULL;
bool is_servadmin = u->nc->HasPriv("memoserv/set-limit");
- if (*p1 == '#')
+ if (p1[0] == '#')
{
chan = p1;
p1 = p2;
p2 = p3;
- p3 = params.size() > 4 ? params[4].c_str() : NULL;
- if (!(ci = cs_findchan(chan)))
+ p3 = params.size() > 4 ? params[4] : "";
+ if (!(ci = cs_findchan(chan.c_str())))
{
- notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan);
+ notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan.c_str());
return MOD_CONT;
}
else if (!is_servadmin && !check_access(u, ci, CA_MEMO))
@@ -95,12 +95,12 @@ class CommandMSSet : public Command
}
if (is_servadmin)
{
- if (p2 && stricmp(p2, "HARD") && !chan)
+ if (!p2.empty() && p2 != "HARD" && chan.empty())
{
NickAlias *na;
- if (!(na = findnick(p1)))
+ if (!(na = findnick(p1.c_str())))
{
- notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, p1);
+ notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, p1.c_str());
return MOD_CONT;
}
user = p1;
@@ -109,61 +109,62 @@ class CommandMSSet : public Command
p1 = p2;
p2 = p3;
}
- else if (!p1)
+ else if (p1.empty())
{
syntax_error(s_MemoServ, u, "SET LIMIT", MEMO_SET_LIMIT_SERVADMIN_SYNTAX);
return MOD_CONT;
}
- if ((!isdigit(*p1) && stricmp(p1, "NONE")) || (p2 && stricmp(p2, "HARD")))
+ if ((!isdigit(p1[0]) && p1 != "NONE") || (!p2.empty() && p2 != "HARD"))
{
syntax_error(s_MemoServ, u, "SET LIMIT", MEMO_SET_LIMIT_SERVADMIN_SYNTAX);
return MOD_CONT;
}
- if (chan)
+ if (!chan.empty())
{
- if (p2)
+ if (!p2.empty())
ci->flags |= CI_MEMO_HARDMAX;
else
ci->flags &= ~CI_MEMO_HARDMAX;
}
else
{
- if (p2)
+ if (!p2.empty())
nc->flags |= NI_MEMO_HARDMAX;
else
nc->flags &= ~NI_MEMO_HARDMAX;
}
- limit = atoi(p1);
+ limit = atoi(p1.c_str());
if (limit < 0 || limit > 32767)
{
notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767);
limit = 32767;
}
- if (stricmp(p1, "NONE") == 0)
+ if (p1 == "NONE")
limit = -1;
}
else
{
- if (!p1 || p2 || !isdigit(*p1)) {
+ if (p1.empty() || !p2.empty() || !isdigit(p1[0])) {
syntax_error(s_MemoServ, u, "SET LIMIT", MEMO_SET_LIMIT_SYNTAX);
return MOD_CONT;
}
- if (chan && (ci->flags & CI_MEMO_HARDMAX))
+ if (!chan.empty() && (ci->flags & CI_MEMO_HARDMAX))
{
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_FORBIDDEN, chan);
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_FORBIDDEN, chan.c_str());
return MOD_CONT;
}
- else if (!chan && (nc->flags & NI_MEMO_HARDMAX)) {
+ else if (chan.empty() && (nc->flags & NI_MEMO_HARDMAX))
+ {
notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_FORBIDDEN);
return MOD_CONT;
}
- limit = atoi(p1);
+ limit = atoi(p1.c_str());
/* The first character is a digit, but we could still go negative
* from overflow... watch out! */
if (limit < 0 || (MSMaxMemos > 0 && limit > MSMaxMemos))
{
- if (chan)
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_TOO_HIGH, chan, MSMaxMemos);
+ if (!chan.empty())
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_TOO_HIGH, chan.c_str(), MSMaxMemos);
else
notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_TOO_HIGH, MSMaxMemos);
return MOD_CONT;
@@ -177,25 +178,24 @@ class CommandMSSet : public Command
mi->memomax = limit;
if (limit > 0)
{
- if (!chan && nc == u->nc)
+ if (chan.empty() && nc == u->nc)
notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT, limit);
else
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT, chan ? chan : user, limit);
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT, !chan.empty() ? chan.c_str() : user.c_str(), limit);
}
else if (!limit)
{
- if (!chan && nc == u->nc)
+ if (chan.empty() && nc == u->nc)
notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_ZERO);
else
- notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_ZERO, chan ? chan : user);
+ notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_ZERO, !chan.empty() ? chan.c_str() : user.c_str());
}
else
{
- if (!chan && nc == u->nc)
+ if (chan.empty() && nc == u->nc)
notice_lang(s_MemoServ, u, MEMO_UNSET_YOUR_LIMIT);
else
- notice_lang(s_MemoServ, u, MEMO_UNSET_LIMIT,
- chan ? chan : user);
+ notice_lang(s_MemoServ, u, MEMO_UNSET_LIMIT, !chan.empty() ? chan.c_str() : user.c_str());
}
return MOD_CONT;
}
@@ -204,9 +204,9 @@ class CommandMSSet : public Command
{
}
- CommandReturn Execute(User *u, std::vector<std::string> &params)
+ CommandReturn Execute(User *u, std::vector<ci::string> &params)
{
- const char *cmd = params[0].c_str();
+ ci::string cmd = params[0];
MemoInfo *mi = &u->nc->memos;
if (readonly)
@@ -214,14 +214,13 @@ class CommandMSSet : public Command
notice_lang(s_MemoServ, u, MEMO_SET_DISABLED);
return MOD_CONT;
}
- else if (!stricmp(cmd, "NOTIFY"))
+ else if (cmd == "NOTIFY")
return this->DoNotify(u, params, mi);
- else if (!stricmp(cmd, "LIMIT")) {
+ else if (cmd == "LIMIT")
return this->DoLimit(u, params, mi);
- }
else
{
- notice_lang(s_MemoServ, u, MEMO_SET_UNKNOWN_OPTION, cmd);
+ notice_lang(s_MemoServ, u, MEMO_SET_UNKNOWN_OPTION, cmd.c_str());
notice_lang(s_MemoServ, u, MORE_INFO, s_MemoServ, "SET");
}
return MOD_CONT;