#include "../lib/base64.h"
#include "../core/modules.h"
#include "../lib/version.h"
+#include "../lib/irc_string.h"
#include "control.h"
#include <stdio.h>
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 _init() {
controlcmds=newcommandtree();
registercontrolhelpcmd("die",NO_DEVELOPER,1,&die,"Usage: die <reason>\nTerminates the service.");
registercontrolhelpcmd("insmod",NO_DEVELOPER,1,&controlinsmod,"Usage: insmod <module>\nAdds a module to the running instance.");
registercontrolhelpcmd("rmmod",NO_DEVELOPER,1,&controlrmmod,"Usage: rmmod <module>\nRemoves a module from the running instance.");
- registercontrolhelpcmd("lsmod",NO_DEVELOPER,0,&controllsmod,"Usage: lsmod\nLists currently running modules.");
+ registercontrolhelpcmd("lsmod",NO_OPER,0,&controllsmod,"Usage: lsmod\nLists currently running modules.");
registercontrolhelpcmd("rehash",NO_DEVELOPER,1,&controlrehash,"Usage: rehash\nReloads configuration file.");
registercontrolhelpcmd("showcommands",NO_ACCOUNT,0,&controlshowcommands,"Usage: showcommands\nShows all registered commands.");
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);
scheduleoneshot(time(NULL)+1,&controlconnect,NULL);
}
deregistercontrolcmd("help",&controlhelpcmd);
destroycommandtree(controlcmds);
+
+ deregisterhook(HOOK_CORE_REHASH, &handlerehash);
}
void registercontrolhelpcmd(const char *name, int level, int maxparams, CommandHandler handler, char *help) {
if (target->umodes) {
controlreply((nick *)sender,"Umode(s) : %s",printflags(target->umodes,umodeflags));
}
+ if (IsOper(target) && target->opername)
+ controlreply((nick *)sender,"Opered as : %s",target->opername->content);
if (IsAccount(target)) {
controlreply((nick *)sender,"Account : %s",target->authname);
if (target->accountts)
controlreply((nick *)sender,"AccountTS : %ld",target->accountts);
- if (target->auth)
+ if (target->auth) {
controlreply((nick *)sender,"UserID : %ld",target->auth->userid);
- if (target->accountflags)
- controlreply((nick *)sender,"AccFlags : %s",printflags(target->accountflags,accountflags));
+ if (target->auth->flags)
+ controlreply((nick *)sender,"AccFlags : %s",printflags(target->auth->flags,accountflags));
+ }
}
hooknick=(nick *)sender;
char *ptr;
if (cargc < 1) { /* list all loaded modules */
- ptr = lsmod(i);
- controlreply((nick *)sender,"Module");
+ const char *ver, *buildid;
+ time_t t, t2 = time(NULL);
+ ptr = lsmod(i, &ver, &buildid, &t);
+
+ /* 9999d 24h 59m 59s fbf2a4a69ee1-tip */
+ controlreply((nick *)sender,"Module Loaded for Version Build id");
while (ptr != NULL) {
- const char *ver = lsmodver(i);
- controlreply((nick *)sender,"%s%s%s%s", ptr, ver?" (":"", ver?ver:"", ver?")":"");
- ptr = lsmod(++i);
+ controlreply((nick *)sender," %-40s %-17s %-20s %s", ptr, longtoduration(t2-t, 2), ver?ver:"", buildid?buildid:"");
+ ptr = lsmod(++i, &ver, &buildid, &t);
}
} else {
- ptr = lsmod(getindex(cargv[0]));
+ ptr = lsmod(getindex(cargv[0]), NULL, NULL, NULL);
controlreply((nick *)sender,"Module \"%s\" %s", cargv[0], (ptr ? "is loaded." : "is NOT loaded."));
}
return CMD_OK;
}
int die(void *sender, int cargc, char **cargv) {
- if (cargc<1) {
+ if (cargc<1 || (strlen(cargv[0]) < 10)) {
controlreply((nick *)sender,"You must give a reason.");
return CMD_USAGE;
}
void controlspecialrmmod(void *arg) {
struct specialsched *a = (struct specialsched *)arg;
+ sstring *froo = a->modulename;
a->schedule = NULL;
- sstring *froo = a->modulename;
rmmod(froo->content);
freesstring(froo);
void controlspecialreloadmod(void *arg) {
struct specialsched *a = (struct specialsched *)arg;
+ sstring *froo = a->modulename;
a->schedule = NULL;
- sstring *froo = a->modulename;
safereload(froo->content);
freesstring(froo);
}
void controlhelp(nick *np, Command *cmd) {
- char *cp = cmd->help, *sp = cp;
- if(!cp || !*cp) {
+ sstring *scp = cmd->help;
+ if(!scp) {
controlreply(np, "Sorry, no help for this command.");
} else {
+ char *cp = scp->content, *sp = cp;
int finished = 0;
for(;;cp++) {
if(*cp == '\0' || *cp == '\n') {
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...");
+}
+