diff options
author | nicm <nicm> | 2016-10-16 19:36:37 +0000 |
---|---|---|
committer | nicm <nicm> | 2016-10-16 19:36:37 +0000 |
commit | 3f35b5299fb2c08637aa12757185e5b82eeb3fc1 (patch) | |
tree | 5323b2851735c5b1052a4c2bae303f532bee191c /cmd-queue.c | |
parent | 026ad08b56b4577beab6bad06b8a7a21602bca11 (diff) | |
download | rtmux-3f35b5299fb2c08637aa12757185e5b82eeb3fc1.tar.gz rtmux-3f35b5299fb2c08637aa12757185e5b82eeb3fc1.tar.bz2 rtmux-3f35b5299fb2c08637aa12757185e5b82eeb3fc1.zip |
Provide a way for hooks to tag formats onto the commands they fire so
that the user can get at additional information - now used for the
"hook" format, more to come.
Diffstat (limited to 'cmd-queue.c')
-rw-r--r-- | cmd-queue.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/cmd-queue.c b/cmd-queue.c index 61cf0188..5056fffc 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -102,7 +102,8 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item) static void cmdq_remove(struct cmdq_item *item) { - free((void *)item->hook); + if (item->formats != NULL) + format_free(item->formats); if (item->client != NULL) server_client_unref(item->client); @@ -241,6 +242,28 @@ cmdq_fire_callback(struct cmdq_item *item) return (item->cb(item, item->data)); } +/* Add a format to command queue. */ +void +cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...) +{ + va_list ap; + struct cmdq_item *loop; + char *value; + + va_start(ap, fmt); + xvasprintf(&value, fmt, ap); + va_end(ap); + + for (loop = item; loop != NULL; loop = item->next) { + if (loop->formats == NULL) + loop->formats = format_create(NULL, 0); + format_add(loop->formats, key, "%s", value); + } + + free(value); +} + + /* Process next item on command queue. */ u_int cmdq_next(struct client *c) |