summaryrefslogtreecommitdiff
path: root/src/modules/m_customtitle.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2013-05-06 11:49:50 +0100
committerPeter Powell <petpow@saberuk.com>2013-05-15 03:32:56 +0100
commitaccccc212cd4f08a3c5532b1ae7a17e76bac8718 (patch)
tree18f4370778cc79d2f21a4308dafbb29a77cfa213 /src/modules/m_customtitle.cpp
parent23e8bba13c55d33ce89d505780da36c9589e300a (diff)
Replace some C-isms with C++-isms.
* 'const char*' to 'const std::string&'. * snprintf to std::string concatenation. * Replace duplicated OneOfMatches with InspIRCd::MatchMask.
Diffstat (limited to 'src/modules/m_customtitle.cpp')
-rw-r--r--src/modules/m_customtitle.cpp24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp
index 1fc49190b..6b100605e 100644
--- a/src/modules/m_customtitle.cpp
+++ b/src/modules/m_customtitle.cpp
@@ -35,27 +35,10 @@ class CommandTitle : public Command
syntax = "<user> <password>";
}
- bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
- {
- std::stringstream hl(hostlist);
- std::string xhost;
- while (hl >> xhost)
- {
- if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map))
- {
- return true;
- }
- }
- return false;
- }
-
CmdResult Handle(const std::vector<std::string> &parameters, User* user)
{
- char TheHost[MAXBUF];
- char TheIP[MAXBUF];
-
- snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(), user->host.c_str());
- snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(), user->GetIPString().c_str());
+ const std::string userHost = user->ident + "@" + user->host;
+ const std::string userIP = user->ident + "@" + user->GetIPString();
ConfigTagList tags = ServerInstance->Config->ConfTags("title");
for (ConfigIter i = tags.first; i != tags.second; ++i)
@@ -67,7 +50,8 @@ class CommandTitle : public Command
std::string title = i->second->getString("title");
std::string vhost = i->second->getString("vhost");
- if (Name == parameters[0] && !ServerInstance->PassCompare(user, pass, parameters[1], hash) && OneOfMatches(TheHost,TheIP,host.c_str()) && !title.empty())
+ if (Name == parameters[0] && !ServerInstance->PassCompare(user, pass, parameters[1], hash) &&
+ InspIRCd::MatchMask(host, userHost, userIP) && !title.empty())
{
ctitle.set(user, title);