diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2020-05-05 06:19:29 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2020-05-05 06:19:29 +0100 |
commit | 9991a14e8105b0b8e6f2baaec3ed50d1fb54f009 (patch) | |
tree | 2af989495acc8645fedf079691c4f83a2157ac1b /cmd-queue.c | |
parent | fc13e9bc2b09815a0b38741672d1c70a33500fac (diff) | |
download | rtmux-9991a14e8105b0b8e6f2baaec3ed50d1fb54f009.tar.gz rtmux-9991a14e8105b0b8e6f2baaec3ed50d1fb54f009.tar.bz2 rtmux-9991a14e8105b0b8e6f2baaec3ed50d1fb54f009.zip |
Add formats for after hook command arguments.
Diffstat (limited to 'cmd-queue.c')
-rw-r--r-- | cmd-queue.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/cmd-queue.c b/cmd-queue.c index 59f86c64..620a3e93 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -341,9 +341,15 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item, struct cmd_find_state *current, const char *fmt, ...) { struct cmdq_state *state = item->state; + struct cmd *cmd = item->cmd; + struct args *args = cmd_get_args(cmd); + struct args_entry *entryp; + struct args_value *valuep; struct options *oo; va_list ap; - char *name; + char *name, tmp[32], flag, *arguments; + int i; + const char *value; struct cmdq_item *new_item; struct cmdq_state *new_state; struct options_entry *o; @@ -375,6 +381,37 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item, new_state = cmdq_new_state(current, &state->event, CMDQ_STATE_NOHOOKS); cmdq_add_format(new_state, "hook", "%s", name); + arguments = args_print(args); + cmdq_add_format(new_state, "hook_arguments", "%s", arguments); + free(arguments); + + for (i = 0; i < args->argc; i++) { + xsnprintf(tmp, sizeof tmp, "hook_argument_%d", i); + cmdq_add_format(new_state, tmp, "%s", args->argv[i]); + } + flag = args_first(args, &entryp); + while (flag != 0) { + value = args_get(args, flag); + if (value == NULL) { + xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag); + cmdq_add_format(new_state, tmp, "1"); + } else { + xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag); + cmdq_add_format(new_state, tmp, "%s", value); + } + + i = 0; + value = args_first_value(args, flag, &valuep); + while (value != NULL) { + xsnprintf(tmp, sizeof tmp, "hook_flag_%c_%d", flag, i); + cmdq_add_format(new_state, tmp, "%s", value); + i++; + value = args_next_value(&valuep); + } + + flag = args_next(&entryp); + } + a = options_array_first(o); while (a != NULL) { cmdlist = options_array_item_value(a)->cmdlist; |