diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-05-20 11:46:07 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-05-20 11:46:07 +0000 |
commit | 6f099b77282e917b685cce147d969dce4f3a90e7 (patch) | |
tree | e8f5dd7ad3239007e0b1ad78a807def5cd425578 /usr.bin/tmux/cmd-queue.c | |
parent | 1eb0e5705cde3a330f37bb66a31081a06c01af6d (diff) |
Replace the various identical error callbacks with a single one in cmd-queue.c.
Diffstat (limited to 'usr.bin/tmux/cmd-queue.c')
-rw-r--r-- | usr.bin/tmux/cmd-queue.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c index 68b5f1b2916..84976d3c74f 100644 --- a/usr.bin/tmux/cmd-queue.c +++ b/usr.bin/tmux/cmd-queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-queue.c,v 1.66 2019/05/18 21:14:10 nicm Exp $ */ +/* $OpenBSD: cmd-queue.c,v 1.67 2019/05/20 11:46:06 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -329,6 +329,25 @@ cmdq_get_callback1(const char *name, cmdq_cb cb, void *data) return (item); } +/* Generic error callback. */ +static enum cmd_retval +cmdq_error_callback(struct cmdq_item *item, void *data) +{ + char *error = data; + + cmdq_error(item, "%s", error); + free(error); + + return (CMD_RETURN_NORMAL); +} + +/* Get an error callback for the command queue. */ +struct cmdq_item * +cmdq_get_error(const char *error) +{ + return (cmdq_get_callback(cmdq_error_callback, xstrdup(error))); +} + /* Fire callback on callback queue. */ static enum cmd_retval cmdq_fire_callback(struct cmdq_item *item) |