mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 04:22:47 -05:00
New abstraction 'Seat', to pass to backends.
This is a new vtable-based abstraction which is passed to a backend in place of Frontend, and it implements only the subset of the Frontend functions needed by a backend. (Many other Frontend functions still exist, notably the wide range of things called by terminal.c providing platform-independent operations on the GUI terminal window.) The purpose of making it a vtable is that this opens up the possibility of creating a backend as an internal implementation detail of some other activity, by providing just that one backend with a custom Seat that implements the methods differently. For example, this refactoring should make it feasible to directly implement an SSH proxy type, aka the 'jump host' feature supported by OpenSSH, aka 'open a secondary SSH session in MAINCHAN_DIRECT_TCP mode, and then expose the main channel of that as the Socket for the primary connection'. (Which of course you can already do by spawning 'plink -nc' as a separate proxy process, but this would permit it in the _same_ process without anything getting confused.) I've centralised a full set of stub methods in misc.c for the new abstraction, which allows me to get rid of several annoying stubs in the previous code. Also, while I'm here, I've moved a lot of duplicated modalfatalbox() type functions from application main program files into wincons.c / uxcons.c, which I think saves duplication overall. (A minor visible effect is that the prefixes on those console-based fatal error messages will now be more consistent between applications.)
This commit is contained in:
12
unix/uxser.c
12
unix/uxser.c
@ -19,7 +19,7 @@
|
||||
|
||||
typedef struct Serial Serial;
|
||||
struct Serial {
|
||||
Frontend *frontend;
|
||||
Seat *seat;
|
||||
LogContext *logctx;
|
||||
int fd;
|
||||
int finished;
|
||||
@ -279,7 +279,7 @@ static const char *serial_configure(Serial *serial, Conf *conf)
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *serial_init(Frontend *frontend, Backend **backend_handle,
|
||||
static const char *serial_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port, char **realhost,
|
||||
int nodelay, int keepalive)
|
||||
@ -292,7 +292,7 @@ static const char *serial_init(Frontend *frontend, Backend **backend_handle,
|
||||
serial->backend.vt = &serial_backend;
|
||||
*backend_handle = &serial->backend;
|
||||
|
||||
serial->frontend = frontend;
|
||||
serial->seat = seat;
|
||||
serial->logctx = logctx;
|
||||
serial->finished = FALSE;
|
||||
serial->inbufsize = 0;
|
||||
@ -322,7 +322,7 @@ static const char *serial_init(Frontend *frontend, Backend **backend_handle,
|
||||
/*
|
||||
* Specials are always available.
|
||||
*/
|
||||
update_specials_menu(serial->frontend);
|
||||
seat_update_specials_menu(serial->seat);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -390,7 +390,7 @@ static void serial_select_result(int fd, int event)
|
||||
perror("read serial port");
|
||||
exit(1);
|
||||
} else if (ret > 0) {
|
||||
serial->inbufsize = from_backend(serial->frontend, 0, buf, ret);
|
||||
serial->inbufsize = seat_stdout(serial->seat, buf, ret);
|
||||
serial_uxsel_setup(serial); /* might acquire backlog and freeze */
|
||||
}
|
||||
} else if (event == 2) {
|
||||
@ -405,7 +405,7 @@ static void serial_select_result(int fd, int event)
|
||||
|
||||
serial->finished = TRUE;
|
||||
|
||||
notify_remote_exit(serial->frontend);
|
||||
seat_notify_remote_exit(serial->seat);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user