+
+void unregister_module_commands(int module_id) {
+ struct cmd_function *cmdfunct, *nextfunct, *prevfunct = NULL;
+ int i;
+ for(cmdfunct = cmd_functions; cmdfunct; cmdfunct = nextfunct) {
+ nextfunct = cmdfunct->next;
+ if(cmdfunct->module_id == module_id) {
+ for(i = 0; i < 27; i++) {
+ struct cmd_binding *cbind, *next, *last = NULL;
+ for(cbind = cmd_binds[i]; cbind; cbind = next) {
+ next = cbind->next;
+ if(cmdfunct == cbind->func) {
+ if(last)
+ last->next = cbind->next;
+ else
+ cmd_binds[i] = cbind->next;
+ free(cbind->cmd);
+ if(cbind->paramcount) {
+ int j;
+ for(j = 0; j < cbind->paramcount; j++)
+ free(cbind->parameters[j]);
+ }
+ if(cbind->channel_access)
+ free(cbind->channel_access);
+ free(cbind);
+ } else
+ last = cbind;
+ }
+ }
+ if(prevfunct)
+ prevfunct->next = nextfunct;
+ else
+ cmd_functions = nextfunct;
+ free(cmdfunct->name);
+ free(cmdfunct);
+ } else
+ prevfunct = cmdfunct;
+ }
+ struct trigger_callback *cb, *prevcb = NULL, *nextcb;
+ for(cb = trigger_callbacks; cb; cb = nextcb) {
+ nextcb = cb->next;
+ if(cb->module_id == module_id) {
+ if(prevcb)
+ prevcb->next = nextcb;
+ else
+ trigger_callbacks = nextcb;
+ free(cb);
+ } else
+ prevcb = cb;
+ }
+}