diff options
author | Christian Pointner <equinox@helsinki.at> | 2009-11-04 04:37:05 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2009-11-04 04:37:05 (GMT) |
commit | 7882d05127816e6885268182a3769bc7a091de94 (patch) | |
tree | 436160f1e3f2980edc092759e56c617492dae1ba /switchctl.c | |
parent | 14e460a9bcaadaa2dd206a5c701814cd5e1d4648 (diff) |
alias table for switch commands
Diffstat (limited to 'switchctl.c')
-rw-r--r-- | switchctl.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/switchctl.c b/switchctl.c index b3150d5..f961f31 100644 --- a/switchctl.c +++ b/switchctl.c @@ -76,7 +76,7 @@ int send_response(int fd, const char* response) return ret; } -int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst) +int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst, options_t* opt) { log_printf(DEBUG, "processing command from %d", fd); @@ -123,7 +123,8 @@ int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst) switch(cmd_id) { case SWITCH: case STATUS: { - int ret = cmd_push(cmd_q, fd, cmd_id, param); + char* tmp = key_value_storage_find(&opt->alias_table_, param); + int ret = cmd_push(cmd_q, fd, cmd_id, tmp != NULL ? tmp : param); if(ret) return ret; @@ -199,7 +200,7 @@ int process_switch(int switch_fd) return ret; } -int main_loop(int switch_fd, int cmd_listen_fd) +int main_loop(int switch_fd, int cmd_listen_fd, options_t* opt) { log_printf(NOTICE, "entering main loop"); @@ -271,7 +272,7 @@ int main_loop(int switch_fd, int cmd_listen_fd) client_t* lst = client_lst; while(lst) { if(FD_ISSET(lst->fd, &tmpfds)) { - return_value = nonblock_recvline(&(lst->buffer), lst->fd, &cmd_q, client_lst); + return_value = nonblock_recvline(&(lst->buffer), lst->fd, &cmd_q, client_lst, opt); if(return_value == 2) { log_printf(DEBUG, "removing closed command connection (fd=%d)", lst->fd); client_t* deletee = lst; @@ -406,7 +407,7 @@ int main(int argc, char* argv[]) if(ret) ret = 2; else - ret = main_loop(switch_fd, cmd_listen_fd); + ret = main_loop(switch_fd, cmd_listen_fd, &opt); } if(ret == 2) { |