]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Accept std::string as parameter in User::ChangeHost(), ChangeIdent() and ChangeName()
authorattilamolnar <attilamolnar@hush.com>
Fri, 9 Aug 2013 16:20:12 +0000 (18:20 +0200)
committerattilamolnar <attilamolnar@hush.com>
Fri, 9 Aug 2013 16:20:12 +0000 (18:20 +0200)
Pass the string itself to IsIdent() instead of string.c_str()

12 files changed:
include/users.h
src/commands/cmd_user.cpp
src/modules/m_chghost.cpp
src/modules/m_chgident.cpp
src/modules/m_chgname.cpp
src/modules/m_dnsbl.cpp
src/modules/m_ident.cpp
src/modules/m_sethost.cpp
src/modules/m_setident.cpp
src/modules/m_setname.cpp
src/modules/m_spanningtree/uid.cpp
src/users.cpp

index 478476cdde38a944a5d87381b6efd80e1a13f960..73f1334d2b54cf25db3853fcf7ce8fd75802d36f 100644 (file)
@@ -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
index 305d0847f2e598bf0ab696f2fb5e7b43687bfdea..b4d86f07bb9de33036b0ab788bbda0c78fbc07fe 100644 (file)
@@ -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);
                }
index 4fcb5ce80c46567637a3e082e788a79983e21d36..664508301d5f3695e762bc8fc49759b4c78bb59f 100644 (file)
@@ -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);
index 1c0cba27ea96a265b4c50311397ab68d813ffee8..b9de3e45bbf97e0d2472522313908cd2dffd1264 100644 (file)
@@ -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());
index fa25c52a00bbe5f337d83553f4e9062d0dbc71c4..efcce15902c1e6f45706a306945e6a126bf4860f 100644 (file)
@@ -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());
                }
 
index 5519380dc1eff8bdfae7874f533a22941860a47e..b457648e672e7e60e147f1b62dd9b2e10614703a 100644 (file)
@@ -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);
index 12a71144f8fd968d444a3ef7241d52ef1bba4480..bbd66530eff64b6d0e6558b24463e7b323f90c5f 100644 (file)
@@ -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;
index 636f2ff6b31ebf2a5702c932ba3f191da829d7e5..fb9fd7f1fad84e051625abce7922a513d28a03dc 100644 (file)
@@ -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;
index 93d26f48bb7d7c97ce353ed4359194b0a52cf9e6..024421347e94370decd8a65a9effd8fec26e314f 100644 (file)
@@ -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;
index bb193577515af707567fd4dfc0d3bad2b469ef2d..4c9d6ae537f93010c655c60267237fd470dabdcc 100644 (file)
@@ -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());
                }
index dd4591a9ba71185f8473e662767a08e90fdac3af..cc583bd3385dee777a7e72a22375172c97f8a04a 100644 (file)
@@ -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;
 }
 
index bb7588fb2069dfd0997e533ed7772bd2820e77e5..3bc19632153840dd9aebdd2b703c2eeefe843cdd 100644 (file)
@@ -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;