]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/cmd_rehash.cpp
OOPS! We try again, since I'm smoking craq. LF is 0x0a NOT CR.
[user/henk/code/inspircd.git] / src / cmd_rehash.cpp
index 16fe3e058f57055f929c2c3d31e819c013944a21..34789b0eaca8f0d6b46a8b4771f122d125830650 100644 (file)
@@ -2,80 +2,55 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
- *                       E-mail:
- *                <brain.net>
- *                <Craig.net>
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
  *
- * Written by Craig Edwards, Craig McLure, and others.
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
  *
  * ---------------------------------------------------
  */
 
-using namespace std;
-
-#include "inspircd_config.h"
 #include "inspircd.h"
-#include "inspircd_io.h"
-#include <time.h>
-#include <string>
-#ifdef GCC3
-#include <ext/hash_map>
-#else
-#include <hash_map>
-#endif
-#include <map>
-#include <sstream>
-#include <vector>
-#include <deque>
+#include "configreader.h"
 #include "users.h"
-#include "ctables.h"
-#include "globals.h"
 #include "modules.h"
-#include "dynamic.h"
-#include "wildcard.h"
-#include "message.h"
-#include "commands.h"
-#include "mode.h"
-#include "xline.h"
-#include "inspstring.h"
-#include "dnsqueue.h"
-#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "socketengine.h"
-#include "typedefs.h"
-#include "command_parse.h"
-#include "cmd_rehash.h"
+#include "commands/cmd_rehash.h"
+
+
 
-extern ServerConfig* Config;
-extern InspIRCd* ServerInstance;
-extern int MODCOUNT;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern time_t TIME;
-extern user_hash clientlist;
-extern chan_hash chanlist;
-extern whowas_hash whowas;
-extern std::vector<userrec*> all_opers;
-extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[65536];
+extern "C" DllExport command_t* init_command(InspIRCd* Instance)
+{
+       return new cmd_rehash(Instance);
+}
 
-void cmd_rehash::Handle (char **parameters, int pcnt, userrec *user)
+CmdResult cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user)
 {
-       WriteServ(user->fd,"382 %s %s :Rehashing",user->nick,CleanFilename(CONFIG_FILE));
-       std::string parameter = "";
+       user->WriteServ("382 %s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
+       std::string parameter;
+       std::string old_disabled = ServerInstance->Config->DisabledCommands;
        if (pcnt)
        {
                parameter = parameters[0];
        }
        else
        {
-               WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
-               Config->Read(false,user);
+               ServerInstance->WriteOpers("*** %s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
+               ServerInstance->CloseLog();
+               ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc);
+               ServerInstance->RehashUsersAndChans();
+               FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
+               ServerInstance->Config->Read(false,user);
+               ServerInstance->Res->Rehash();
+               ServerInstance->ResetMaxBans();
        }
-       FOREACH_MOD(I_OnRehash,OnRehash(parameter));
-}
+       if (old_disabled != ServerInstance->Config->DisabledCommands)
+               InitializeDisabledCommands(ServerInstance->Config->DisabledCommands, ServerInstance);
+
+       FOREACH_MOD(I_OnRehash,OnRehash(user, parameter));
 
+       ServerInstance->BuildISupport();
+
+       return CMD_SUCCESS;
+}