summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-08-09 18:20:12 +0200
committerattilamolnar <attilamolnar@hush.com>2013-08-09 18:20:12 +0200
commitb4542af6b4c69dff7d2c28d9c435304b7d78dc38 (patch)
tree8a42ca6672184895ab63cf5488fe6c474353e027
parente4b76e65025ce6039e6c07fa7c7b28962abd6e18 (diff)
Accept std::string as parameter in User::ChangeHost(), ChangeIdent() and ChangeName()
Pass the string itself to IsIdent() instead of string.c_str()
-rw-r--r--include/users.h6
-rw-r--r--src/commands/cmd_user.cpp4
-rw-r--r--src/modules/m_chghost.cpp2
-rw-r--r--src/modules/m_chgident.cpp4
-rw-r--r--src/modules/m_chgname.cpp2
-rw-r--r--src/modules/m_dnsbl.cpp4
-rw-r--r--src/modules/m_ident.cpp2
-rw-r--r--src/modules/m_sethost.cpp2
-rw-r--r--src/modules/m_setident.cpp4
-rw-r--r--src/modules/m_setname.cpp2
-rw-r--r--src/modules/m_spanningtree/uid.cpp6
-rw-r--r--src/users.cpp6
12 files changed, 22 insertions, 22 deletions
diff --git a/include/users.h b/include/users.h
index 478476cdd..73f1334d2 100644
--- a/include/users.h
+++ b/include/users.h
@@ -593,7 +593,7 @@ class CoreExport User : public Extensible
* @return True if the change succeeded, false if it didn't
* (a module vetoed the change).
*/
- bool ChangeDisplayedHost(const char* host);
+ bool ChangeDisplayedHost(const std::string& host);
/** Change the ident (username) of a user.
* ALWAYS use this function, rather than writing User::ident directly,
@@ -602,7 +602,7 @@ class CoreExport User : public Extensible
* @param newident The new ident to set
* @return True if the change succeeded, false if it didn't
*/
- bool ChangeIdent(const char* newident);
+ bool ChangeIdent(const std::string& newident);
/** Change a users realname field.
* ALWAYS use this function, rather than writing User::fullname directly,
@@ -611,7 +611,7 @@ class CoreExport User : public Extensible
* @param gecos The user's new realname
* @return True if the change succeeded, false if otherwise
*/
- bool ChangeName(const char* gecos);
+ bool ChangeName(const std::string& gecos);
/** Change a user's nick
* @param newnick The new nick
diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp
index 305d0847f..b4d86f07b 100644
--- a/src/commands/cmd_user.cpp
+++ b/src/commands/cmd_user.cpp
@@ -45,7 +45,7 @@ CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, L
/* A user may only send the USER command once */
if (!(user->registered & REG_USER))
{
- if (!ServerInstance->IsIdent(parameters[0].c_str()))
+ if (!ServerInstance->IsIdent(parameters[0]))
{
/*
* RFC says we must use this numeric, so we do. Let's make it a little more nub friendly though. :)
@@ -61,7 +61,7 @@ CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, L
* ~ character, and +1 for null termination, therefore we can safely use up to
* IDENTMAX here.
*/
- user->ChangeIdent(parameters[0].c_str());
+ user->ChangeIdent(parameters[0]);
user->fullname.assign(parameters[3].empty() ? "No info" : parameters[3], 0, ServerInstance->Config->Limits.MaxGecos);
user->registered = (user->registered | REG_USER);
}
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index 4fcb5ce80..664508301 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -64,7 +64,7 @@ class CommandChghost : public Command
if (IS_LOCAL(dest))
{
- if ((dest->ChangeDisplayedHost(parameters[1].c_str())) && (!ServerInstance->ULine(user->server)))
+ if ((dest->ChangeDisplayedHost(parameters[1])) && (!ServerInstance->ULine(user->server)))
{
// fix by brain - ulines set hosts silently
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost);
diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp
index 1c0cba27e..b9de3e45b 100644
--- a/src/modules/m_chgident.cpp
+++ b/src/modules/m_chgident.cpp
@@ -51,7 +51,7 @@ class CommandChgident : public Command
return CMD_FAILURE;
}
- if (!ServerInstance->IsIdent(parameters[1].c_str()))
+ if (!ServerInstance->IsIdent(parameters[1]))
{
user->WriteNotice("*** CHGIDENT: Invalid characters in ident");
return CMD_FAILURE;
@@ -59,7 +59,7 @@ class CommandChgident : public Command
if (IS_LOCAL(dest))
{
- dest->ChangeIdent(parameters[1].c_str());
+ dest->ChangeIdent(parameters[1]);
if (!ServerInstance->ULine(user->server))
ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGIDENT to change %s's ident to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str());
diff --git a/src/modules/m_chgname.cpp b/src/modules/m_chgname.cpp
index fa25c52a0..efcce1590 100644
--- a/src/modules/m_chgname.cpp
+++ b/src/modules/m_chgname.cpp
@@ -57,7 +57,7 @@ class CommandChgname : public Command
if (IS_LOCAL(dest))
{
- dest->ChangeName(parameters[1].c_str());
+ dest->ChangeName(parameters[1]);
ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGNAME to change %s's GECOS to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->fullname.c_str());
}
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 5519380dc..b457648e6 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -118,13 +118,13 @@ class DNSBLResolver : public DNS::Request
if (!ConfEntry->ident.empty())
{
them->WriteServ("304 " + them->nick + " :Your ident has been set to " + ConfEntry->ident + " because you matched " + reason);
- them->ChangeIdent(ConfEntry->ident.c_str());
+ them->ChangeIdent(ConfEntry->ident);
}
if (!ConfEntry->host.empty())
{
them->WriteServ("304 " + them->nick + " :Your host has been set to " + ConfEntry->host + " because you matched " + reason);
- them->ChangeDisplayedHost(ConfEntry->host.c_str());
+ them->ChangeDisplayedHost(ConfEntry->host);
}
nameExt.set(them, ConfEntry->name);
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 12a71144f..bbd66530e 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -258,7 +258,7 @@ class IdentRequestSocket : public EventHandler
* we're done.
*/
result += *i;
- if (!ServerInstance->IsIdent(result.c_str()))
+ if (!ServerInstance->IsIdent(result))
{
result.erase(result.end()-1);
break;
diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp
index 636f2ff6b..fb9fd7f1f 100644
--- a/src/modules/m_sethost.cpp
+++ b/src/modules/m_sethost.cpp
@@ -52,7 +52,7 @@ class CommandSethost : public Command
return CMD_FAILURE;
}
- if (user->ChangeDisplayedHost(parameters[0].c_str()))
+ if (user->ChangeDisplayedHost(parameters[0]))
{
ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->dhost);
return CMD_SUCCESS;
diff --git a/src/modules/m_setident.cpp b/src/modules/m_setident.cpp
index 93d26f48b..024421347 100644
--- a/src/modules/m_setident.cpp
+++ b/src/modules/m_setident.cpp
@@ -41,13 +41,13 @@ class CommandSetident : public Command
return CMD_FAILURE;
}
- if (!ServerInstance->IsIdent(parameters[0].c_str()))
+ if (!ServerInstance->IsIdent(parameters[0]))
{
user->WriteNotice("*** SETIDENT: Invalid characters in ident");
return CMD_FAILURE;
}
- user->ChangeIdent(parameters[0].c_str());
+ user->ChangeIdent(parameters[0]);
ServerInstance->SNO->WriteGlobalSno('a', "%s used SETIDENT to change their ident to '%s'", user->nick.c_str(), user->ident.c_str());
return CMD_SUCCESS;
diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp
index bb1935775..4c9d6ae53 100644
--- a/src/modules/m_setname.cpp
+++ b/src/modules/m_setname.cpp
@@ -40,7 +40,7 @@ class CommandSetname : public Command
return CMD_FAILURE;
}
- if (user->ChangeName(parameters[0].c_str()))
+ if (user->ChangeName(parameters[0]))
{
ServerInstance->SNO->WriteGlobalSno('a', "%s used SETNAME to change their GECOS to '%s'", user->nick.c_str(), parameters[0].c_str());
}
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index dd4591a9b..cc583bd33 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -157,7 +157,7 @@ CmdResult CommandFHost::Handle(const parameterlist &params, User* src)
{
if (IS_SERVER(src))
return CMD_FAILURE;
- src->ChangeDisplayedHost(params[0].c_str());
+ src->ChangeDisplayedHost(params[0]);
return CMD_SUCCESS;
}
@@ -165,7 +165,7 @@ CmdResult CommandFIdent::Handle(const parameterlist &params, User* src)
{
if (IS_SERVER(src))
return CMD_FAILURE;
- src->ChangeIdent(params[0].c_str());
+ src->ChangeIdent(params[0]);
return CMD_SUCCESS;
}
@@ -173,7 +173,7 @@ CmdResult CommandFName::Handle(const parameterlist &params, User* src)
{
if (IS_SERVER(src))
return CMD_FAILURE;
- src->ChangeName(params[0].c_str());
+ src->ChangeName(params[0]);
return CMD_SUCCESS;
}
diff --git a/src/users.cpp b/src/users.cpp
index bb7588fb2..3bc196321 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1106,7 +1106,7 @@ bool User::SharesChannelWith(User *other)
return false;
}
-bool User::ChangeName(const char* gecos)
+bool User::ChangeName(const std::string& gecos)
{
if (!this->fullname.compare(gecos))
return true;
@@ -1124,7 +1124,7 @@ bool User::ChangeName(const char* gecos)
return true;
}
-bool User::ChangeDisplayedHost(const char* shost)
+bool User::ChangeDisplayedHost(const std::string& shost)
{
if (dhost == shost)
return true;
@@ -1148,7 +1148,7 @@ bool User::ChangeDisplayedHost(const char* shost)
return true;
}
-bool User::ChangeIdent(const char* newident)
+bool User::ChangeIdent(const std::string& newident)
{
if (this->ident == newident)
return true;