int controlreload(void *sender, int cargc, char **cargv);
int controlhelpcmd(void *sender, int cargc, char **cargv);
void controlnoticeopers(flag_t permissionlevel, flag_t noticelevel, char *format, ...);
-void handlerehash(int hooknum, void *arg);
+void handlesignal(int hooknum, void *arg);
void _init() {
controlcmds=newcommandtree();
registercontrolhelpcmd("reload",NO_DEVELOPER,1,&controlreload,"Usage: reload <module>\nReloads specified module.");
registercontrolhelpcmd("help",NO_ANYONE,1,&controlhelpcmd,"Usage: help <command>\nShows help for specified command.");
- registerhook(HOOK_CORE_REHASH, &handlerehash);
+ registerhook(HOOK_CORE_REHASH, &handlesignal);
+ registerhook(HOOK_CORE_SIGINT, &handlesignal);
scheduleoneshot(time(NULL)+1,&controlconnect,NULL);
}
destroycommandtree(controlcmds);
- deregisterhook(HOOK_CORE_REHASH, &handlerehash);
+ deregisterhook(HOOK_CORE_REHASH, &handlesignal);
+ deregisterhook(HOOK_CORE_SIGINT, &handlesignal);
}
void registercontrolhelpcmd(const char *name, int level, int maxparams, CommandHandler handler, char *help) {
/* someone killed me? Bastards */
scheduleoneshot(time(NULL)+1,&controlconnect,NULL);
mynick=NULL;
+ triggerhook(HOOK_CONTROL_REGISTERED, NULL);
break;
default:
controlwall(NO_OPER, noticelevel, "%s", broadcast);
}
-void handlerehash(int hooknum, void *arg) {
- long hupped = (long)arg;
- if(hupped)
- controlwall(NO_OPER, NL_OPERATIONS, "SIGHUP received, rehashing...");
-}
+void handlesignal(int hooknum, void *arg) {
+ char *signal, *action;
+
+ if(hooknum == HOOK_CORE_SIGINT) {
+ signal = "INT";
+ action = "terminating";
+ } else {
+ long hupped = (long)arg;
+ if(!hupped)
+ return;
+ signal = "HUP";
+ action = "rehashing";
+ }
+
+ controlwall(NO_OPER, NL_OPERATIONS, "SIG%s received, %s...", signal, action);
+}