diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2012-07-11 07:10:15 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2012-07-11 07:10:15 +0000 |
commit | ede8312d59c5d08990f83f38682c26434823525b (patch) | |
tree | bdf66e80ca1d71548a554804f4ab6656a828a821 /cmd-list.c | |
parent | df912e3540968a2a0b266e523ecc08bb2dc0ca20 (diff) | |
download | rtmux-ede8312d59c5d08990f83f38682c26434823525b.tar.gz rtmux-ede8312d59c5d08990f83f38682c26434823525b.tar.bz2 rtmux-ede8312d59c5d08990f83f38682c26434823525b.zip |
Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix
problems with using some commands in a command sequence. Most of the
work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
Diffstat (limited to 'cmd-list.c')
-rw-r--r-- | cmd-list.c | 34 |
1 files changed, 19 insertions, 15 deletions
@@ -79,12 +79,13 @@ bad: return (NULL); } -int +enum cmd_retval cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) { struct client *c = ctx->curclient; struct cmd *cmd; - int n, retval, guards; + enum cmd_retval retval; + int guards, n; guards = 0; if (c != NULL && c->session != NULL) @@ -98,21 +99,17 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) if (guards) ctx->print(ctx, "%%end"); - /* Return of -1 is an error. */ - if (n == -1) - return (-1); - - /* - * A 1 return value means the command client is being attached - * (sent MSG_READY). - */ - if (n == 1) { - retval = 1; + switch (n) + { + case CMD_RETURN_ERROR: + return (CMD_RETURN_ERROR); + case CMD_RETURN_ATTACH: + /* Client is being attached (send MSG_READY). */ + retval = CMD_RETURN_ATTACH; /* - * The command client has been attached, so mangle the - * context to treat any following commands as if they - * were called from inside. + * Mangle the context to treat any following commands + * as if they were called from inside. */ if (ctx->curclient == NULL) { ctx->curclient = ctx->cmdclient; @@ -122,6 +119,13 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) ctx->print = key_bindings_print; ctx->info = key_bindings_info; } + break; + case CMD_RETURN_YIELD: + if (retval == CMD_RETURN_NORMAL) + retval = CMD_RETURN_YIELD; + break; + case CMD_RETURN_NORMAL: + break; } } return (retval); |