+void bind_botwise_unbound_required_functions(int botid, int clientid) {
+ struct cmd_function *cmdfunc;
+ int i, found;
+ struct cmd_binding *cbind;
+ for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
+ if((cmdfunc->flags & CMDFLAG_REQUIRED)) {
+ found = 0;
+ for(i = 0; i < 27; i++) {
+ for(cbind = cmd_binds[i]; cbind; cbind = cbind->next) {
+ if(cbind->botid == botid && (botid || clientid == cbind->clientid) && cbind->func == cmdfunc) {
+ found = 1;
+ break;
+ }
+ }
+ if(found)
+ break;
+ }
+ if(!found && bind_botwise_cmd_to_function(botid, clientid, cmdfunc->name, cmdfunc)) {
+ cbind = find_botwise_cmd_binding(botid, clientid, cmdfunc->name);
+ cbind->flags |= CMDFLAG_TEMPONARY_BIND;
+ }
+ }
+ }
+}
+
+void register_command_alias(int botid, char *alias) {
+ struct cmd_bot_alias *botalias;
+ for(botalias = bot_aliases; botalias; botalias = botalias->next) {
+ if(!stricmp(botalias->alias, alias))
+ return;
+ }
+ botalias = malloc(sizeof(*botalias));
+ if (!botalias) {
+ perror("malloc() failed");
+ return;
+ }
+ botalias->botid = botid;
+ botalias->alias = strdup(alias);
+ botalias->next = bot_aliases;
+ bot_aliases = botalias;
+}
+
+struct cmd_binding *getAllBinds(struct cmd_binding *last) {
+ int bind_index;
+ if(last) {
+ if(last->next)
+ return last->next;
+ bind_index = get_binds_index(last->cmd[0]) + 1;
+ if(bind_index > 26)
+ return NULL;
+ } else
+ bind_index = 0;
+ do {
+ if(cmd_binds[bind_index])
+ return cmd_binds[bind_index];
+ bind_index++;
+ } while(bind_index < 27);
+ return NULL;
+}
+
+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;
+ }
+}