Commit d63de9a1 authored by Niels Möller's avatar Niels Möller
Browse files

* src/client_pty.c (make_pty_request): New function.

Rev: src/client_pty.c:1.5
Rev: src/client_pty.h:1.2
parent 856165c8
......@@ -23,80 +23,110 @@
#include "client_pty.h"
#include "channel_commands.h"
#include "format.h"
#include "tty.h"
#include "werror.h"
#include "xalloc.h"
#include "client_pty.c.x"
/* GABA:
(class
(name pty_request)
(super channel_request_command)
(vars
(tty . int)
(term string)
(ios . "struct termios")
(width . UINT32)
(height . UINT32)
(width_p . UINT32)
(height_p . UINT32)
(modes string)))
(height_p . UINT32)))
*/
/* GABA:
(class
(name pty_request_continuation)
(super command_frame)
(vars
(req object pty_request)))
*/
static int do_pty_continuation(struct command_continuation *s,
struct lsh_object *x)
{
CAST(pty_request_continuation, self, s);
verbose("lsh: pty request %z.\n", x ? "successful" : "failed");
if (x)
{
if (!tty_setattr(self->req->tty, &self->req->ios))
{
werror("do_pty_continuation: "
"Setting the attributes of the local terminal failed.\n");
}
COMMAND_RETURN(self->super.up, x);
}
return LSH_OK | LSH_GOON;
}
static struct command_continuation *
make_pty_continuation(struct pty_request *req,
struct command_continuation *c)
{
NEW(pty_request_continuation, self);
self->req = req;
self->super.up = c;
self->super.super.c = do_pty_continuation;
return &self->super.super;
}
static struct lsh_string *
do_format_pty_request(struct channel_request_command *s,
struct ssh_channel *channel,
int want_reply)
struct command_continuation **c)
{
CAST(pty_request, req, s);
CAST(pty_request, self, s);
verbose("lsh: Requesting a remote pty.\n");
return format_channel_request(ATOM_PTY_REQ, channel, req->super.want_reply,
*c = make_pty_continuation(self, *c);
return format_channel_request(ATOM_PTY_REQ, channel, 1,
"%S%i%i%i%i%S",
req->term,
req->width, req->height,
req->width_p, req->height_p,
req->modes);
self->term,
self->width, self->height,
self->width_p, self->height_p,
tty_encode_term_mode(&self->ios));
}
struct command *make_pty_request(int tty)
{
NEW(pty_request, req);
struct termios ios;
char *term = getenv("TERM");
if (!tty_getwinsize(fd, &req->width, &req->height,
&req->width_p, &req->height_p))
req->width = req->height = req->width_p = req->height_p = 0;
if (tty_getattr(fd, &ios))
req->modes = tty_encode_term_mode(&req->ios);
else
if (!tty_getattr(tty, &req->ios))
{
KILL(req);
return NULL;
}
req->super.format = do_format_pty_request;
if (!tty_getwinsize(tty, &req->width, &req->height,
&req->width_p, &req->height_p))
req->width = req->height = req->width_p = req->height_p = 0;
req->super.format_request = do_format_pty_request;
req->super.super.call = do_channel_request_command;
req->tty = fd;
req->tty = tty;
req->term = term ? format_cstring(term) : ssh_format("");
return &req->super;
return &req->super.super;
}
/* GABA:
(class
(name raw_mode_command)
(super command)
(vars
(fd . int)))
*/
static int do_raw_mode(struct command *s,
struct lsh_object *x,
struct command_continuation *c)
{
CAST(raw_mode_command, self, s);
verbose("lsh: pty request %z.\n", x ? "successful" : "failed");
if (x)
{
#if 0
struct lsh_string *
......
......@@ -25,11 +25,16 @@
#define LSH_CLIENT_PTY_H_INCLUDED
#include "lsh.h"
#include "command.h"
struct command *make_pty_request(int tty);
#if 0
struct lsh_string *
format_pty_req(struct ssh_channel *channel, int want_reply,
UINT8 *term, UINT32 width, UINT32 height, UINT32 width_p,
UINT32 height_p, struct lsh_string *term_modes);
#endif
#endif /* LSH_CLIENT_PTY_H_INCLUDED */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment