| 2123 | } |
| 2124 | |
| 2125 | staticfn void |
| 2126 | cmdbind_add(uchar key, const struct ext_func_tab *extcmd, boolean user) |
| 2127 | { |
| 2128 | struct Cmd_bind *bind = cmdbind_get(key); |
| 2129 | |
| 2130 | if (!key) |
| 2131 | return; |
| 2132 | if (!extcmd && bind) { |
| 2133 | cmdbind_remove(key); |
| 2134 | return; |
| 2135 | } |
| 2136 | |
| 2137 | /* binding exists, set it to this command */ |
| 2138 | if (bind) { |
| 2139 | bind->cmd = extcmd; |
| 2140 | bind->userbind = user; |
| 2141 | if (bind->param) { |
| 2142 | free(bind->param); |
| 2143 | bind->param = NULL; |
| 2144 | } |
| 2145 | return; |
| 2146 | } else { |
| 2147 | bind = (struct Cmd_bind *) alloc(sizeof(struct Cmd_bind)); |
| 2148 | bind->key = key; |
| 2149 | bind->userbind = user; |
| 2150 | bind->param = NULL; |
| 2151 | bind->cmd = extcmd; |
| 2152 | bind->next = gc.Cmd.cmdbinds; |
| 2153 | gc.Cmd.cmdbinds = bind; |
| 2154 | } |
| 2155 | } |
| 2156 | |
| 2157 | staticfn void |
| 2158 | cmdbind_remove(uchar key) |
no test coverage detected