Anope IRC Services  Version 1.8
os_restart.c
Go to the documentation of this file.
1 /* OperServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 #ifdef _WIN32
18 /* OperServ restart needs access to this if were gonna avoid sending ourself a signal */
19 extern MDE void do_restart_services(void);
20 #endif
21 
22 static int do_restart(User * u);
23 static void myOperServHelp(User * u);
24 
31 int AnopeInit(int argc, char **argv)
32 {
33  Command *c;
34 
35  moduleAddAuthor("Anope");
36  moduleAddVersion(VERSION_STRING);
39  OPER_HELP_RESTART, -1, -1, -1, -1);
41 
43 
44  return MOD_CONT;
45 }
46 
50 void AnopeFini(void)
51 {
52 
53 }
54 
55 
60 static void myOperServHelp(User * u)
61 {
62  if (is_services_root(u)) {
63  notice_lang(s_OperServ, u, OPER_HELP_CMD_RESTART);
64  }
65 }
66 
72 static int do_restart(User * u)
73 {
74 #ifdef SERVICES_BIN
75  quitmsg = calloc(31 + strlen(u->nick), 1);
76  if (!quitmsg)
77  quitmsg = "RESTART command received, but out of memory!";
78  else
79  sprintf(quitmsg, "RESTART command received from %s", u->nick);
80 
81  if (GlobalOnCycle) {
82  oper_global(NULL, "%s", GlobalOnCycleMessage);
83  }
84  /* raise(SIGHUP); */
86 #else
87  notice_lang(s_OperServ, u, OPER_CANNOT_RESTART);
88 #endif
89  return MOD_CONT;
90 }
E char * quitmsg
Definition: extern.h:792
char nick[NICKMAX]
Definition: services.h:875
void AnopeFini(void)
Definition: os_restart.c:50
E int GlobalOnCycle
Definition: extern.h:430
E void oper_global(char *nick, char *fmt,...)
Definition: operserv.c:691
#define MDE
Definition: modules.h:89
E void do_restart_services(void)
Definition: main.c:279
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
E int is_services_root(User *u)
Definition: operserv.c:577
#define OPERSERV
Definition: modules.h:62
E char * s_OperServ
Definition: extern.h:289
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
MDE void moduleSetOperHelp(void(*func)(User *u))
Definition: modules.c:2126
#define MOD_CONT
Definition: modules.h:54
E char * GlobalOnCycleMessage
Definition: extern.h:432
int AnopeInit(int argc, char **argv)
Definition: os_restart.c:31
static int do_restart(User *u)
Definition: os_restart.c:72
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
static void myOperServHelp(User *u)
Definition: os_restart.c:60
#define MOD_UNIQUE
Definition: module.h:11