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') {
struct storedhook {
CommandHandler old;
sstring *name;
- char *oldhelp;
- char *newhelp;
+ sstring *oldhelp;
+ sstring *newhelp;
struct storedhook *next;
} storedhook;
newhook->old = fetchcommand->handler;
if(newhelp) {
- int len = strlen(newhelp) + 1;
- newhook->newhelp = (char *)malloc(len);
+ newhook->newhelp = getsstring(newhelp, 512);
if(!newhook->newhelp) {
freesstring(newhook->name);
free(newhook);
+ return 1;
}
- strlcpy(newhook->newhelp, newhelp, len);
newhook->oldhelp = fetchcommand->help;
fetchcommand->help = newhook->newhelp;
} else {
fetchcommand->handler = ch->old;
if(ch->newhelp) {
fetchcommand->help = ch->oldhelp;
- free(ch->newhelp);
+ freesstring(ch->newhelp);
}
}
nh = ch->next;
nc->ext=NULL;
nc->next=NULL;
if (help) {
- int len=strlen(help);
- nc->help=(char *)malloc(len+1);
- if(nc->help) {
- strncpy(nc->help, help, len);
- nc->help[len] = '\0';
- }
+ nc->help=getsstring(help, 512);
} else {
nc->help=NULL;
}
} else if (insertcommand(nc,ct,0)) {
/* Erk, that didn't work.. */
freesstring(nc->command);
- if(nc->help)
- free(nc->help);
+ freesstring(nc->help);
free(nc);
return NULL;
}
c=*ch;
(*ch)=(Command *)((*ch)->next);
freesstring(c->command);
- if(c->help)
- free(c->help);
+ freesstring(c->help);
free(c);
return 0;
}
c=*ch;
(*ch)=(Command *)((*ch)->next);
freesstring(c->command);
- if(c->help)
- free(c->help);
+ freesstring(c->help);
free(c);
/* We need to regenerate the final pointer if needed;
typedef struct Command {
sstring *command; /* Name of the command/token/thing */
- char *help; /* Help information, sorry splidge! */
+ sstring *help; /* Help information, sorry splidge! */
int level; /* "level" required to use the command/token/thing */
int maxparams; /* Maximum number of parameters for the command/token/thing */
CommandHandler handler; /* Function to deal with the message */