The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

cmd_restart.cpp

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #include "inspircd.h"
00015 #include "configreader.h"
00016 #include "users.h"
00017 #include "commands/cmd_restart.h"
00018 
00019 extern "C" DllExport command_t* init_command(InspIRCd* Instance)
00020 {
00021         return new cmd_restart(Instance);
00022 }
00023 
00024 CmdResult cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
00025 {
00026         ServerInstance->Log(DEFAULT,"Restart: %s",user->nick);
00027         if (!strcmp(parameters[0],ServerInstance->Config->restartpass))
00028         {
00029                 ServerInstance->WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
00030 
00031                 try
00032                 {
00033                         ServerInstance->Restart("Server restarting.");
00034                 }
00035                 catch (...)
00036                 {
00037                         /* We dont actually get here unless theres some fatal and unrecoverable error. */
00038                         exit(0);
00039                 }
00040         }
00041         else
00042         {
00043                 ServerInstance->WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
00044                 return CMD_FAILURE;
00045         }
00046 
00047         return CMD_SUCCESS;
00048 }
00049