From 37f9bb46d815e8ba6377c3435d72c052267831ed Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 6 May 2012 07:38:17 +0000 Subject: Add a helper function to open the terminal for attach-/new-session. --- server-client.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index b7212379..2cbb5bf3 100644 --- a/server-client.c +++ b/server-client.c @@ -105,6 +105,25 @@ server_client_create(int fd) log_debug("new client %d", fd); } +/* Open client terminal if needed. */ +int +server_client_open(struct client *c, struct session *s, char **cause) +{ + struct options *oo = s != NULL ? &s->options : &global_s_options; + char *overrides; + + if (!(c->flags & CLIENT_TERMINAL)) { + *cause = xstrdup ("not a terminal"); + return (-1); + } + + overrides = options_get_string(oo, "terminal-overrides"); + if (tty_open(&c->tty, overrides, cause) != 0) + return (-1); + + return (0); +} + /* Lost a client. */ void server_client_lost(struct client *c) -- cgit