diff options
author | nicm <nicm> | 2017-04-22 10:22:39 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-04-22 10:22:39 +0000 |
commit | ee45a8a149e1a3c8fe7c232a9e32f3a007e21bee (patch) | |
tree | 21cc9cafd10d55cd7cd92ec616d08ac59adc4a0a /cmd-detach-client.c | |
parent | 2c0f826c360fc5a8f0e125759b596eb28441ba65 (diff) | |
download | rtmux-ee45a8a149e1a3c8fe7c232a9e32f3a007e21bee.tar.gz rtmux-ee45a8a149e1a3c8fe7c232a9e32f3a007e21bee.tar.bz2 rtmux-ee45a8a149e1a3c8fe7c232a9e32f3a007e21bee.zip |
Get rid of the extra layer of flags and cmd_prepare() and just store the
CMD_FIND_* flags in the cmd_entry and call it for the command. Commands
with special requirements call it themselves and update the target for
hooks to use.
Diffstat (limited to 'cmd-detach-client.c')
-rw-r--r-- | cmd-detach-client.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/cmd-detach-client.c b/cmd-detach-client.c index 2e21f795..85b9a4ed 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -37,8 +37,7 @@ const struct cmd_entry cmd_detach_client_entry = { .usage = "[-aP] [-E shell-command] " "[-s target-session] " CMD_TARGET_CLIENT_USAGE, - .sflag = CMD_SESSION, - .tflag = CMD_CLIENT, + .source = { 's', CMD_FIND_SESSION, CMD_FIND_CANFAIL }, .flags = CMD_READONLY, .exec = cmd_detach_client_exec @@ -51,8 +50,6 @@ const struct cmd_entry cmd_suspend_client_entry = { .args = { "t:", 0, 0 }, .usage = CMD_TARGET_CLIENT_USAGE, - .tflag = CMD_CLIENT, - .flags = 0, .exec = cmd_detach_client_exec }; @@ -61,11 +58,14 @@ static enum cmd_retval cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = self->args; - struct client *c = item->state.c, *cloop; + struct client *c, *cloop; struct session *s; enum msgtype msgtype; const char *cmd = args_get(args, 'E'); + if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL) + return (CMD_RETURN_ERROR); + if (self->entry == &cmd_suspend_client_entry) { server_client_suspend(c); return (CMD_RETURN_NORMAL); @@ -77,7 +77,9 @@ cmd_detach_client_exec(struct cmd *self, struct cmdq_item *item) msgtype = MSG_DETACH; if (args_has(args, 's')) { - s = item->state.sflag.s; + s = item->source.s; + if (s == NULL) + return (CMD_RETURN_NORMAL); TAILQ_FOREACH(cloop, &clients, entry) { if (cloop->session == s) { if (cmd != NULL) |