struct storedhook {
CommandHandler old;
sstring *name;
- sstring *oldhelp;
- sstring *newhelp;
+ cmdhelp *oldhelp;
+ cmdhelp *newhelp;
struct storedhook *next;
} storedhook;
UserMessageHandler oldhandler;
ControlMsg oldreply;
ControlWall oldwall;
+ControlPermitted oldpermitted;
void noperserv_trap_registration(int hooknum, void *arg);
int noperserv_showcommands(void *sender, int cargc, char **cargv);
void noperserv_whois_handler(int hooknum, void *arg);
void noperserv_whois_account_handler(int hooknum, void *arg);
void noperserv_handle_messages(nick *target, int messagetype, void **args);
-void noperserv_reply(nick *np, char *format, ...);
+void noperserv_reply(nick *np, char *format, ...) __attribute__ ((format (printf, 2, 3)));
void noperserv_wall(flag_t permissionlevel, flag_t noticelevel, char *format, ...);
struct specialsched special;
oldwall = controlwall;
controlwall = &noperserv_wall;
+ oldpermitted = controlpermitted;
+ controlpermitted = &noperserv_policy_command_permitted;
+
memset(&special, 0, sizeof(struct specialsched));
if(!mynick) {
newhook->old = fetchcommand->handler;
if(newhelp) {
- newhook->newhelp = getsstring(newhelp, 512);
+ newhook->newhelp = (cmdhelp *)malloc(sizeof(cmdhelp));
+ memset(newhook->newhelp,0,sizeof(cmdhelp));
if(!newhook->newhelp) {
freesstring(newhook->name);
free(newhook);
- return 1;
+ } else {
+ int len = strlen(newhelp) + 1;
+ newhook->newhelp->helpstr = (char *)malloc(len);
+ if (newhook->newhelp->helpstr) {
+ strlcpy(newhook->newhelp->helpstr, newhelp, len);
+ }
+ newhook->oldhelp = fetchcommand->ext;
+ fetchcommand->ext = newhook->newhelp;
}
- newhook->oldhelp = fetchcommand->help;
- fetchcommand->help = newhook->newhelp;
} else {
newhook->newhelp = NULL;
}
if(ch->old && (fetchcommand = findcommandintree(controlcmds, ch->name->content, 1))) {
fetchcommand->handler = ch->old;
if(ch->newhelp) {
- fetchcommand->help = ch->oldhelp;
- freesstring(ch->newhelp);
+ fetchcommand->ext = ch->oldhelp;
+ if ( ((cmdhelp *)ch->newhelp)->helpstr)
+ free( ((cmdhelp *)ch->newhelp)->helpstr);
+ free(ch->newhelp);
}
}
nh = ch->next;
controlwall = oldwall;
controlreply = oldreply;
+ controlpermitted = oldpermitted;
}
void noperserv_trap_registration(int hooknum, void *arg) {
for(i=0;i<n;i++)
if(noperserv_policy_command_permitted(cmdlist[i]->level, np))
- controlreply(np, "%s (%s)", cmdlist[i]->command->content, printflags(cmdlist[i]->level, no_commandflags));
+ controlreply(np, " %-25s %s", cmdlist[i]->command->content, printflags(cmdlist[i]->level, no_commandflags));
controlreply(np, "End of list.");
return CMD_OK;
cmd = findcommandintree(controlcmds,cargv[0],1);
if(!cmd) {
- controlreply(sender, "Unknown command.");
+ controlreply(sender, "Unknown command or access denied.");
return;
}
/* If we were doing "authed user tracking" here we'd put a check in for authlevel */
/* Here it is! */
if (!noperserv_policy_command_permitted(cmd->level, sender)) {
- controlreply(sender, "Access denied.");
+ controlreply(sender, "Unknown command or access denied.");
return;
}