From d0e48d929c19d39c4a13e57e0f8a8dd6194d6dde Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 11 Nov 2006 14:27:33 +0100 Subject: [PATCH 1/1] I want the pty to be seen. that private struct is a nonsense in its current form. Signed-off-by: Pierre Habouzit --- madtty/madtty.c | 25 ++++++++++--------------- madtty/madtty.h | 10 +--------- madtty/roteprivate.h | 3 --- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/madtty/madtty.c b/madtty/madtty.c index f76e743..8fbc469 100644 --- a/madtty/madtty.c +++ b/madtty/madtty.c @@ -73,7 +73,7 @@ RoteTerm *rote_vt_create(int rows, int cols) /* allocate private data */ rt->pd = (RoteTermPrivate*)calloc(sizeof(RoteTermPrivate), 1); - rt->pd->pty = -1; /* no pty for now */ + rt->pty = -1; /* no pty for now */ /* initial scrolling area is the whole window */ rt->pd->scrolltop = 0; @@ -219,19 +219,19 @@ pid_t rote_vt_forkpty(RoteTerm *rt, const char *path, const char *argv[]) ws.ws_col = rt->cols; ws.ws_xpixel = ws.ws_ypixel = 0; - if (run_process(path, argv, &rt->pd->pty, &rt->childpid)) { + if (run_process(path, argv, &rt->pty, &rt->childpid)) { return -1; } - ioctl(rt->pd->pty, TIOCSWINSZ, &ws); + ioctl(rt->pty, TIOCSWINSZ, &ws); return rt->childpid; } void rote_vt_forsake_child(RoteTerm *rt) { - if (rt->pd->pty >= 0) - close(rt->pd->pty); - rt->pd->pty = -1; + if (rt->pty >= 0) + close(rt->pty); + rt->pty = -1; rt->childpid = 0; } @@ -260,17 +260,17 @@ void rote_vt_update(RoteTerm *rt) int rote_vt_read(RoteTerm *rt, char *buf, int buflen) { - if (rt->pd->pty < 0) { + if (rt->pty < 0) { errno = EINVAL; return -1; } - return read(rt->pd->pty, buf, buflen); + return read(rt->pty, buf, buflen); } void rote_vt_write(RoteTerm *rt, const char *data, int len) { - if (rt->pd->pty < 0) { + if (rt->pty < 0) { /* no pty, so just inject the data plain and simple */ rote_vt_inject(rt, data, len); return; @@ -279,7 +279,7 @@ void rote_vt_write(RoteTerm *rt, const char *data, int len) /* write data to pty. Keep calling write() until we have written * everything. */ while (len > 0) { - int byteswritten = write(rt->pd->pty, data, len); + int byteswritten = write(rt->pty, data, len); if (byteswritten < 0) { /* very ugly way to inform the error. Improvements welcome! */ static char errormsg[] = "\n(ROTE: pty write() error)\n"; @@ -317,11 +317,6 @@ void rote_vt_restore_snapshot(RoteTerm *rt, void *snapbuf) } } -int rote_vt_get_pty_fd(RoteTerm *rt) -{ - return rt->pd->pty; -} - static const char *keytable[KEY_MAX+1]; static void keytable_init() diff --git a/madtty/madtty.h b/madtty/madtty.h index cb34762..69d7288 100644 --- a/madtty/madtty.h +++ b/madtty/madtty.h @@ -118,6 +118,7 @@ typedef struct RoteTerm_ { * that will be used for newly inserted * characters */ + int pty; /* pty of the process */ pid_t childpid; /* pid of the child process running in the * terminal; 0 for none. This is READ-ONLY. */ @@ -242,13 +243,4 @@ void *rote_vt_take_snapshot(RoteTerm *rt); * This function does NOT free() the passed buffer */ void rote_vt_restore_snapshot(RoteTerm *rt, void *snapbuf); -/* Returns the pseudo tty descriptor associated with the given terminal. - * Please don't do weird things with it (like close it for instance), - * or things will break - * - * This function returns -1 if the given terminal does not yet have - * an associated pty. A pty is only associated to a terminal when - * needed, e.g. on a call to rote_vt_forkpty. */ -int rote_vt_get_pty_fd(RoteTerm *rt); - #endif /* MADTTY_MADTTY_H */ diff --git a/madtty/roteprivate.h b/madtty/roteprivate.h index 679ed10..628a993 100644 --- a/madtty/roteprivate.h +++ b/madtty/roteprivate.h @@ -40,9 +40,6 @@ struct RoteTermPrivate_ { * the initial escape (\x1B) character. */ int esbuf_len; /* length of buffer. The following property * is always kept: esbuf[esbuf_len] == '\0' */ - - int pty; /* file descriptor for the pty attached to - * this terminal. -1 if none. */ }; /* Interprets a CSI escape sequence stored in rt->pd->esbuf, -- 2.20.1