diff options
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r-- | cmd-new-session.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c index 2e0df33d..8477d9b2 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -30,8 +30,8 @@ * Create a new session and attach to the current terminal unless -d is given. */ -int cmd_new_session_check(struct args *); -int cmd_new_session_exec(struct cmd *, struct cmd_ctx *); +enum cmd_retval cmd_new_session_check(struct args *); +enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_new_session_entry = { "new-session", "new", @@ -44,15 +44,15 @@ const struct cmd_entry cmd_new_session_entry = { cmd_new_session_exec }; -int +enum cmd_retval cmd_new_session_check(struct args *args) { if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n'))) - return (-1); - return (0); + return (CMD_RETURN_ERROR); + return (CMD_RETURN_NORMAL); } -int +enum cmd_retval cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; @@ -71,11 +71,11 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (newname != NULL) { if (!session_check_name(newname)) { ctx->error(ctx, "bad session name: %s", newname); - return (-1); + return (CMD_RETURN_ERROR); } if (session_find(newname) != NULL) { ctx->error(ctx, "duplicate session: %s", newname); - return (-1); + return (CMD_RETURN_ERROR); } } @@ -83,7 +83,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (target != NULL) { groupwith = cmd_find_session(ctx, target, 0); if (groupwith == NULL) - return (-1); + return (CMD_RETURN_ERROR); } else groupwith = NULL; @@ -131,7 +131,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) { ctx->error(ctx, "open terminal failed: %s", cause); free(cause); - return (-1); + return (CMD_RETURN_ERROR); } } @@ -163,7 +163,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) args_get(args, 'x'), 1, USHRT_MAX, &errstr); if (errstr != NULL) { ctx->error(ctx, "width %s", errstr); - return (-1); + return (CMD_RETURN_ERROR); } } if (args_has(args, 'y')) { @@ -171,7 +171,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) args_get(args, 'y'), 1, USHRT_MAX, &errstr); if (errstr != NULL) { ctx->error(ctx, "height %s", errstr); - return (-1); + return (CMD_RETURN_ERROR); } } } @@ -202,7 +202,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (s == NULL) { ctx->error(ctx, "create session failed: %s", cause); free(cause); - return (-1); + return (CMD_RETURN_ERROR); } environ_free(&env); @@ -269,5 +269,5 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) ARRAY_FREE(&cfg_causes); } - return (!detached); /* 1 means don't tell command client to exit */ + return (detached ? CMD_RETURN_NORMAL : CMD_RETURN_ATTACH); } |