]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_rehash.cpp
Whoops
[user/henk/code/inspircd.git] / src / commands / cmd_rehash.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "xline.h"
16 #include "commands/cmd_rehash.h"
17
18
19
20 extern "C" DllExport Command* init_command(InspIRCd* Instance)
21 {
22         return new CommandRehash(Instance);
23 }
24
25 CmdResult CommandRehash::Handle (const char** parameters, int pcnt, User *user)
26 {
27         user->WriteServ("382 %s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
28         std::string parameter;
29         std::string old_disabled = ServerInstance->Config->DisabledCommands;
30         if (pcnt)
31         {
32                 parameter = parameters[0];
33         }
34         else
35         {
36                 ServerInstance->WriteOpers("*** %s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
37                 ServerInstance->CloseLog();
38                 if (!ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc))
39                         user->WriteServ("*** NOTICE %s :ERROR: Could not open logfile %s: %s", user->nick, ServerInstance->Config->logpath.c_str(), strerror(errno));
40                 ServerInstance->RehashUsersAndChans();
41                 FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
42                 ServerInstance->Config->Read(false,user);
43                 // Get XLine to do it's thing.
44                 ServerInstance->XLines->CheckELines();
45                 ServerInstance->XLines->ApplyLines();
46                 ServerInstance->Res->Rehash();
47                 ServerInstance->ResetMaxBans();
48         }
49         if (old_disabled != ServerInstance->Config->DisabledCommands)
50                 InitializeDisabledCommands(ServerInstance->Config->DisabledCommands, ServerInstance);
51
52         FOREACH_MOD(I_OnRehash,OnRehash(user, parameter));
53
54         ServerInstance->BuildISupport();
55
56         return CMD_SUCCESS;
57 }
58