os_shutdown.c

Go to the documentation of this file.
00001 /* OperServ core functions
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  *
00012  */
00013 /*************************************************************************/
00014 
00015 #include "module.h"
00016 
00017 static int do_shutdown(User * u);
00018 static void myOperServHelp(User * u);
00019 
00026 int AnopeInit(int argc, char **argv)
00027 {
00028     Command *c;
00029 
00030     moduleAddAuthor("Anope");
00031     moduleAddVersion(VERSION_STRING);
00032     moduleSetType(CORE);
00033 
00034     c = createCommand("SHUTDOWN", do_shutdown, is_services_root,
00035                       OPER_HELP_SHUTDOWN, -1, -1, -1, -1);
00036     moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
00037 
00038     moduleSetOperHelp(myOperServHelp);
00039 
00040     return MOD_CONT;
00041 }
00042 
00046 void AnopeFini(void)
00047 {
00048 
00049 }
00050 
00051 
00056 static void myOperServHelp(User * u)
00057 {
00058     if (is_services_root(u)) {
00059         notice_lang(s_OperServ, u, OPER_HELP_CMD_SHUTDOWN);
00060     }
00061 }
00062 
00068 static int do_shutdown(User * u)
00069 {
00070     quitmsg = calloc(32 + strlen(u->nick), 1);
00071     if (!quitmsg)
00072         quitmsg = "SHUTDOWN command received, but out of memory!";
00073     else
00074         sprintf(quitmsg, "SHUTDOWN command received from %s", u->nick);
00075 
00076     if (GlobalOnCycle) {
00077         oper_global(NULL, "%s", GlobalOnCycleMessage);
00078     }
00079     save_data = 1;
00080     delayed_quit = 1;
00081     return MOD_CONT;
00082 }