mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-05 21:42: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:
@ -61,16 +61,58 @@ void cleanup_exit(int code)
|
||||
exit(code);
|
||||
}
|
||||
|
||||
void set_busy_status(Frontend *frontend, int status)
|
||||
/*
|
||||
* Various error message and/or fatal exit functions.
|
||||
*/
|
||||
void console_print_error_msg(const char *prefix, const char *msg)
|
||||
{
|
||||
struct termios cf;
|
||||
premsg(&cf);
|
||||
fputs(prefix, stderr);
|
||||
fputs(": ", stderr);
|
||||
fputs(msg, stderr);
|
||||
fputc('\n', stderr);
|
||||
fflush(stderr);
|
||||
postmsg(&cf);
|
||||
}
|
||||
|
||||
void update_specials_menu(Frontend *frontend)
|
||||
void console_print_error_msg_fmt_v(
|
||||
const char *prefix, const char *fmt, va_list ap)
|
||||
{
|
||||
char *msg = dupvprintf(fmt, ap);
|
||||
console_print_error_msg(prefix, msg);
|
||||
sfree(msg);
|
||||
}
|
||||
|
||||
void notify_remote_exit(Frontend *frontend)
|
||||
void console_print_error_msg_fmt(const char *prefix, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
console_print_error_msg_fmt_v(prefix, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void modalfatalbox(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
console_print_error_msg_fmt_v("FATAL ERROR", fmt, ap);
|
||||
va_end(ap);
|
||||
cleanup_exit(1);
|
||||
}
|
||||
|
||||
void nonfatal(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
console_print_error_msg_fmt_v("ERROR", fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void console_connection_fatal(Seat *seat, const char *msg)
|
||||
{
|
||||
console_print_error_msg("FATAL ERROR", msg);
|
||||
cleanup_exit(1);
|
||||
}
|
||||
|
||||
void timer_change_notify(unsigned long next)
|
||||
@ -111,9 +153,10 @@ static int block_and_read(int fd, void *buf, size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int verify_ssh_host_key(Frontend *frontend, char *host, int port,
|
||||
const char *keytype, char *keystr, char *fingerprint,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
int console_verify_ssh_host_key(
|
||||
Seat *seat, const char *host, int port,
|
||||
const char *keytype, char *keystr, char *fingerprint,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -217,12 +260,9 @@ int verify_ssh_host_key(Frontend *frontend, char *host, int port,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Ask whether the selected algorithm is acceptable (since it was
|
||||
* below the configured 'warn' threshold).
|
||||
*/
|
||||
int askalg(Frontend *frontend, const char *algtype, const char *algname,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
int console_confirm_weak_crypto_primitive(
|
||||
Seat *seat, const char *algtype, const char *algname,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
static const char msg[] =
|
||||
"The first %s supported by the server is\n"
|
||||
@ -268,8 +308,9 @@ int askalg(Frontend *frontend, const char *algtype, const char *algname,
|
||||
}
|
||||
}
|
||||
|
||||
int askhk(Frontend *frontend, const char *algname, const char *betteralgs,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
int console_confirm_weak_cached_hostkey(
|
||||
Seat *seat, const char *algname, const char *betteralgs,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
static const char msg[] =
|
||||
"The first host key type we have stored for this server\n"
|
||||
|
Reference in New Issue
Block a user