diff options
Diffstat (limited to 'src/core/ms_set.c')
-rw-r--r-- | src/core/ms_set.c | 93 |
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> ¶ms, MemoInfo *mi) + CommandReturn DoNotify(User *u, std::vector<ci::string> ¶ms, 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> ¶ms, MemoInfo *mi) + CommandReturn DoLimit(User *u, std::vector<ci::string> ¶ms, 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> ¶ms) + CommandReturn Execute(User *u, std::vector<ci::string> ¶ms) { - 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; |