From 2b73d006c66c0960e80ca4482a72ed27e8298121 Mon Sep 17 00:00:00 2001 From: pk910 Date: Sat, 13 Aug 2011 00:37:29 +0200 Subject: [PATCH] fixed last commit --- modcmd.c | 56 ++++++++++++++++++++++++++++---------------------------- modcmd.h | 8 ++++---- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/modcmd.c b/modcmd.c index 180c968..bd39a47 100644 --- a/modcmd.c +++ b/modcmd.c @@ -163,21 +163,21 @@ int changeChannelTrigger(int botid, struct ChanNode *chan, char *new_trigger) { int bind_cmd_to_function(int botid, char *cmd, struct cmd_function *func) { int bind_index = get_binds_index(cmd[0]); - struct cmd_binding *bind; - for(bind = cmd_binds[bind_index]; bind; bind = bind->next) { - if(bind->botid == botid && strcmp(bind->cmd, cmd) == 0) + struct cmd_binding *cbind; + for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) { + if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) return 0; } - bind = malloc(sizeof(*bind)); - if (!bind) { + cbind = malloc(sizeof(*cbind)); + if (!cbind) { perror("malloc() failed"); return 0; } - bind->botid = botid; - bind->cmd = strdup(cmd); - bind->func = func; - bind->next = cmd_binds[bind_index]; - cmd_binds[bind_index] = bind; + cbind->botid = botid; + cbind->cmd = strdup(cmd); + cbind->func = func; + cbind->next = cmd_binds[bind_index]; + cmd_binds[bind_index] = cbind; return 1; } @@ -189,38 +189,38 @@ int bind_cmd_to_command(int botid, char *cmd, char *func) { } if(!cmdfunc) return 0; int bind_index = get_binds_index(cmd[0]); - struct cmd_binding *bind; - for(bind = cmd_binds[bind_index]; bind; bind = bind->next) { - if(bind->botid == botid && strcmp(bind->cmd, cmd) == 0) + struct cmd_binding *cbind; + for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) { + if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) return 0; } - bind = malloc(sizeof(*bind)); - if (!bind) { + cbind = malloc(sizeof(*cbind)); + if (!cbind) { perror("malloc() failed"); return 0; } - bind->botid = botid; - bind->cmd = strdup(cmd); - bind->func = cmdfunc; - bind->next = cmd_binds[bind_index]; - cmd_binds[bind_index] = bind; + cbind->botid = botid; + cbind->cmd = strdup(cmd); + cbind->func = cmdfunc; + cbind->next = cmd_binds[bind_index]; + cmd_binds[bind_index] = cbind; return 1; } int unbind_cmd(int botid, char *cmd) { int bind_index = get_binds_index(cmd[0]); - struct cmd_binding *bind, *last = NULL; - for(bind = cmd_binds[bind_index]; bind; bind = bind->next) { - if(bind->botid == botid && strcmp(bind->cmd, cmd) == 0) { + struct cmd_binding *cbind, *last = NULL; + for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) { + if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) { if(last) - last->next = bind->next; + last->next = cbind->next; else - cmd_binds[bind_index] = bind->next; - free(bind->cmd); - free(bind); + cmd_binds[bind_index] = cbind->next; + free(cbind->cmd); + free(cbind); return 1; } else - last = bind; + last = cbind; } return 0; } diff --git a/modcmd.h b/modcmd.h index 4bff7d9..673f74c 100644 --- a/modcmd.h +++ b/modcmd.h @@ -14,8 +14,8 @@ struct cmd_function { int botid; cmd_bind_t *func; - struct cmd_binding *next; -} + struct cmd_function *next; +}; struct cmd_binding { char *cmd; @@ -23,14 +23,14 @@ struct cmd_binding { struct cmd_function *func; struct cmd_binding *next; -} +}; struct trigger_cache { int botid; char *trigger; struct trigger_cache *next; -} +}; void init_modcmd(); struct* ClientSocket get_prefered_bot(int botid); -- 2.20.1