diff options
author | Thomas Adam <thomas@xteddy.org> | 2020-04-14 00:01:41 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2020-04-14 00:01:41 +0100 |
commit | 653a159225609f7e5efb45bc78cdf7b480d7ef93 (patch) | |
tree | de075bcb7fdbd8a3fbd9f800c3a04c63cfdfac6b /cmd-queue.c | |
parent | 2159ff3256df4b823dfaed24e64047249cf079c2 (diff) | |
parent | fc83517913c8280c222a6cf78ca7fb8053421b37 (diff) | |
download | rtmux-653a159225609f7e5efb45bc78cdf7b480d7ef93.tar.gz rtmux-653a159225609f7e5efb45bc78cdf7b480d7ef93.tar.bz2 rtmux-653a159225609f7e5efb45bc78cdf7b480d7ef93.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-queue.c')
-rw-r--r-- | cmd-queue.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/cmd-queue.c b/cmd-queue.c index 97d19f81..16c58401 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -42,6 +42,7 @@ struct cmdq_item { struct cmdq_item *next; struct client *client; + struct client *target_client; enum cmdq_type type; u_int group; @@ -145,6 +146,13 @@ cmdq_get_client(struct cmdq_item *item) return (item->client); } +/* Get item target client. */ +struct client * +cmdq_get_target_client(struct cmdq_item *item) +{ + return (item->target_client); +} + /* Get item state. */ struct cmdq_state * cmdq_get_state(struct cmdq_item *item) @@ -483,14 +491,15 @@ cmdq_find_flag(struct cmdq_item *item, struct cmd_find_state *fs, static enum cmd_retval cmdq_fire_command(struct cmdq_item *item) { - struct client *c = item->client; - const char *name = cmdq_name(c); + const char *name = cmdq_name(item->client); struct cmdq_state *state = item->state; struct cmd *cmd = item->cmd; + struct args *args = cmd_get_args(cmd); const struct cmd_entry *entry = cmd_get_entry(cmd); + struct client *tc, *saved = item->client; enum cmd_retval retval; struct cmd_find_state *fsp, fs; - int flags; + int flags, quiet = 0; char *tmp; if (log_get_level() > 1) { @@ -504,6 +513,25 @@ cmdq_fire_command(struct cmdq_item *item) if (item->client == NULL) item->client = cmd_find_client(item, NULL, 1); + + if (entry->flags & CMD_CLIENT_CANFAIL) + quiet = 1; + if (entry->flags & CMD_CLIENT_CFLAG) { + tc = cmd_find_client(item, args_get(args, 'c'), quiet); + if (tc == NULL && !quiet) { + retval = CMD_RETURN_ERROR; + goto out; + } + } else if (entry->flags & CMD_CLIENT_TFLAG) { + tc = cmd_find_client(item, args_get(args, 't'), quiet); + if (tc == NULL && !quiet) { + retval = CMD_RETURN_ERROR; + goto out; + } + } else + tc = cmd_find_client(item, NULL, 1); + item->target_client = tc; + retval = cmdq_find_flag(item, &item->source, &entry->source); if (retval == CMD_RETURN_ERROR) goto out; @@ -511,6 +539,7 @@ cmdq_fire_command(struct cmdq_item *item) if (retval == CMD_RETURN_ERROR) goto out; + retval = entry->exec(cmd, item); if (retval == CMD_RETURN_ERROR) goto out; @@ -528,7 +557,7 @@ cmdq_fire_command(struct cmdq_item *item) } out: - item->client = c; + item->client = saved; if (retval == CMD_RETURN_ERROR) cmdq_guard(item, "error", flags); else |