aboutsummaryrefslogtreecommitdiff
path: root/cmd-load-buffer.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2012-07-11 19:37:32 +0000
committerTiago Cunha <tcunha@gmx.com>2012-07-11 19:37:32 +0000
commit1f5e6e35d5046693f0ef5ec76535f517757b7122 (patch)
treee53808c90f3a53279554f8580d2b96df606baec3 /cmd-load-buffer.c
parenta432fcd30617610b46d65f49b7513bf5da5694de (diff)
downloadrtmux-1f5e6e35d5046693f0ef5ec76535f517757b7122.tar.gz
rtmux-1f5e6e35d5046693f0ef5ec76535f517757b7122.tar.bz2
rtmux-1f5e6e35d5046693f0ef5ec76535f517757b7122.zip
Sync OpenBSD patchset 1151:
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-load-buffer.c')
-rw-r--r--cmd-load-buffer.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c
index 4b877404..aaf23d99 100644
--- a/cmd-load-buffer.c
+++ b/cmd-load-buffer.c
@@ -30,8 +30,8 @@
* Loads a paste buffer from a file.
*/
-int cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
-void cmd_load_buffer_callback(struct client *, int, void *);
+enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
+void cmd_load_buffer_callback(struct client *, int, void *);
const struct cmd_entry cmd_load_buffer_entry = {
"load-buffer", "loadb",
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_load_buffer_entry = {
cmd_load_buffer_exec
};
-int
+enum cmd_retval
cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct args *args = self->args;
@@ -63,7 +63,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
if (cause != NULL) {
ctx->error(ctx, "buffer %s", cause);
free(cause);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
}
@@ -77,9 +77,9 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
if (error != 0) {
ctx->error(ctx, "%s: %s", path, cause);
free(cause);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
- return (1);
+ return (CMD_RETURN_YIELD);
}
if (c != NULL)
@@ -97,7 +97,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
}
if ((f = fopen(path, "rb")) == NULL) {
ctx->error(ctx, "%s: %s", path, strerror(errno));
- return (-1);
+ return (CMD_RETURN_ERROR);
}
pdata = NULL;
@@ -123,21 +123,21 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
limit = options_get_number(&global_options, "buffer-limit");
if (buffer == -1) {
paste_add(&global_buffers, pdata, psize, limit);
- return (0);
+ return (CMD_RETURN_NORMAL);
}
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
ctx->error(ctx, "no buffer %d", buffer);
free(pdata);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
- return (0);
+ return (CMD_RETURN_NORMAL);
error:
free(pdata);
if (f != NULL)
fclose(f);
- return (-1);
+ return (CMD_RETURN_ERROR);
}
void