]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_oper/cmd_rehash.cpp
Remove a long obsolete comment from the example conf.
[user/henk/code/inspircd.git] / src / coremods / core_oper / cmd_rehash.cpp
index f71219f7561729f5cdbead9efed86dcd59798c98..31eb4bdc1ce579de1e62adfffdce22eea4d3d1be 100644 (file)
@@ -1,9 +1,15 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2013 Adam <Adam@anope.org>
+ *   Copyright (C) 2012-2015 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009 Matt Smith <dz@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
- *   Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007-2008, 2010 Craig Edwards <brain@inspircd.org>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
 
 
 #include "inspircd.h"
+#include "core_oper.h"
 
-/** Handle /REHASH.
- */
-class CommandRehash : public Command
+CommandRehash::CommandRehash(Module* parent)
+       : Command(parent, "REHASH", 0)
 {
- public:
-       /** Constructor for rehash.
-        */
-       CommandRehash ( Module* parent) : Command(parent,"REHASH",0) { flags_needed = 'o'; Penalty = 2; syntax = "[<servermask>]"; }
-       /** Handle command.
-        * @param parameters The parameters to the command
-        * @param user The user issuing the command
-        * @return A value from CmdResult to indicate command success or failure.
-        */
-       CmdResult Handle(const std::vector<std::string>& parameters, User *user);
-};
+       flags_needed = 'o';
+       Penalty = 2;
+       syntax = "[<servermask>]";
+}
 
-CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, User *user)
+CmdResult CommandRehash::Handle(User* user, const Params& parameters)
 {
        std::string param = parameters.size() ? parameters[0] : "";
 
@@ -62,7 +61,7 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
 
                // the leading "-" is optional; remove it if present.
                if (param[0] == '-')
-                       param = param.substr(1);
+                       param.erase(param.begin());
 
                FOREACH_MOD(OnModuleRehash, (user, param));
                return CMD_SUCCESS;
@@ -71,13 +70,10 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
        // Rehash for me. Try to start the rehash thread
        if (!ServerInstance->ConfigThread)
        {
-               std::string m = user->nick + " is rehashing config file " + FileSystem::GetFileName(ServerInstance->ConfigFileName) + " on " + ServerInstance->Config->ServerName;
-               ServerInstance->SNO->WriteGlobalSno('a', m);
-
-               if (IS_LOCAL(user))
-                       user->WriteNumeric(RPL_REHASHING, "%s :Rehashing", FileSystem::GetFileName(ServerInstance->ConfigFileName).c_str());
-               else
-                       ServerInstance->PI->SendUserNotice(user, "*** Rehashing server " + FileSystem::GetFileName(ServerInstance->ConfigFileName));
+               const std::string configfile = FileSystem::GetFileName(ServerInstance->ConfigFileName);
+               user->WriteRemoteNumeric(RPL_REHASHING, configfile, "Rehashing " + ServerInstance->Config->ServerName);
+               ServerInstance->SNO->WriteGlobalSno('a', "%s is rehashing %s on %s", user->nick.c_str(),
+                       configfile.c_str(), ServerInstance->Config->ServerName.c_str());
 
                /* Don't do anything with the logs here -- logs are restarted
                 * after the config thread has completed.
@@ -90,15 +86,9 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
                 * A rehash is already in progress! ahh shit.
                 * XXX, todo: we should find some way to kill runaway rehashes that are blocking, this is a major problem for unrealircd users
                 */
-               if (IS_LOCAL(user))
-                       user->WriteNotice("*** Could not rehash: A rehash is already in progress.");
-               else
-                       ServerInstance->PI->SendUserNotice(user, "*** Could not rehash: A rehash is already in progress.");
+               user->WriteRemoteNotice("*** Could not rehash: A rehash is already in progress.");
        }
 
        // Always return success so spanningtree forwards an incoming REHASH even if we failed
        return CMD_SUCCESS;
 }
-
-
-COMMAND_INIT(CommandRehash)