mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
Pass the BackendVtable pointer to backend_init.
Now I can have multiple BackendVtable structures sharing all their function pointers, and still tell which is which when init is setting things up.
This commit is contained in:
parent
91c2e6b4d5
commit
0a09c12edc
6
putty.h
6
putty.h
@ -482,8 +482,8 @@ struct Backend {
|
||||
const BackendVtable *vt;
|
||||
};
|
||||
struct BackendVtable {
|
||||
const char *(*init) (Seat *seat, Backend **backend_out,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *(*init) (const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_out, LogContext *logctx, Conf *conf,
|
||||
const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive);
|
||||
|
||||
@ -525,7 +525,7 @@ struct BackendVtable {
|
||||
static inline const char *backend_init(
|
||||
const BackendVtable *vt, Seat *seat, Backend **out, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port, char **rhost, bool nd, bool ka)
|
||||
{ return vt->init(seat, out, logctx, conf, host, port, rhost, nd, ka); }
|
||||
{ return vt->init(vt, seat, out, logctx, conf, host, port, rhost, nd, ka); }
|
||||
static inline void backend_free(Backend *be)
|
||||
{ be->vt->free(be); }
|
||||
static inline void backend_reconfig(Backend *be, Conf *conf)
|
||||
|
10
raw.c
10
raw.c
@ -119,10 +119,10 @@ static const PlugVtable Raw_plugvt = {
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *raw_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port, char **realhost,
|
||||
bool nodelay, bool keepalive)
|
||||
static const char *raw_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive)
|
||||
{
|
||||
SockAddr *addr;
|
||||
const char *err;
|
||||
@ -135,7 +135,7 @@ static const char *raw_init(Seat *seat, Backend **backend_handle,
|
||||
|
||||
raw = snew(Raw);
|
||||
raw->plug.vt = &Raw_plugvt;
|
||||
raw->backend.vt = &raw_backend;
|
||||
raw->backend.vt = vt;
|
||||
raw->s = NULL;
|
||||
raw->closed_on_socket_error = false;
|
||||
*backend_handle = &raw->backend;
|
||||
|
10
rlogin.c
10
rlogin.c
@ -153,10 +153,10 @@ static const PlugVtable Rlogin_plugvt = {
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *rlogin_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port, char **realhost,
|
||||
bool nodelay, bool keepalive)
|
||||
static const char *rlogin_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive)
|
||||
{
|
||||
SockAddr *addr;
|
||||
const char *err;
|
||||
@ -167,7 +167,7 @@ static const char *rlogin_init(Seat *seat, Backend **backend_handle,
|
||||
|
||||
rlogin = snew(Rlogin);
|
||||
rlogin->plug.vt = &Rlogin_plugvt;
|
||||
rlogin->backend.vt = &rlogin_backend;
|
||||
rlogin->backend.vt = vt;
|
||||
rlogin->s = NULL;
|
||||
rlogin->closed_on_socket_error = false;
|
||||
rlogin->seat = seat;
|
||||
|
10
ssh.c
10
ssh.c
@ -866,10 +866,10 @@ static void ssh_cache_conf_values(Ssh *ssh)
|
||||
*
|
||||
* Returns an error message, or NULL on success.
|
||||
*/
|
||||
static const char *ssh_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port, char **realhost,
|
||||
bool nodelay, bool keepalive)
|
||||
static const char *ssh_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive)
|
||||
{
|
||||
const char *p;
|
||||
Ssh *ssh;
|
||||
@ -891,7 +891,7 @@ static const char *ssh_init(Seat *seat, Backend **backend_handle,
|
||||
ssh->term_width = conf_get_int(ssh->conf, CONF_width);
|
||||
ssh->term_height = conf_get_int(ssh->conf, CONF_height);
|
||||
|
||||
ssh->backend.vt = &ssh_backend;
|
||||
ssh->backend.vt = vt;
|
||||
*backend_handle = &ssh->backend;
|
||||
|
||||
ssh->seat = seat;
|
||||
|
8
telnet.c
8
telnet.c
@ -678,9 +678,9 @@ static const PlugVtable Telnet_plugvt = {
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *telnet_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port,
|
||||
static const char *telnet_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive)
|
||||
{
|
||||
SockAddr *addr;
|
||||
@ -694,7 +694,7 @@ static const char *telnet_init(Seat *seat, Backend **backend_handle,
|
||||
|
||||
telnet = snew(Telnet);
|
||||
telnet->plug.vt = &Telnet_plugvt;
|
||||
telnet->backend.vt = &telnet_backend;
|
||||
telnet->backend.vt = vt;
|
||||
telnet->conf = conf_copy(conf);
|
||||
telnet->s = NULL;
|
||||
telnet->closed_on_socket_error = false;
|
||||
|
26
testback.c
26
testback.c
@ -32,10 +32,12 @@
|
||||
|
||||
#include "putty.h"
|
||||
|
||||
static const char *null_init(Seat *, Backend **, LogContext *, Conf *,
|
||||
const char *, int, char **, int, int);
|
||||
static const char *loop_init(Seat *, Backend **, LogContext *, Conf *,
|
||||
const char *, int, char **, int, int);
|
||||
static const char *null_init(const BackendVtable *, Seat *, Backend **,
|
||||
LogContext *, Conf *, const char *, int, char **,
|
||||
bool, bool);
|
||||
static const char *loop_init(const BackendVtable *, Seat *, Backend **,
|
||||
LogContext *, Conf *, const char *, int, char **,
|
||||
bool, bool);
|
||||
static void null_free(Backend *);
|
||||
static void loop_free(Backend *);
|
||||
static void null_reconfig(Backend *, Conf *);
|
||||
@ -72,10 +74,10 @@ struct loop_state {
|
||||
Backend backend;
|
||||
};
|
||||
|
||||
static const char *null_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port, char **realhost,
|
||||
int nodelay, int keepalive) {
|
||||
static const char *null_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive) {
|
||||
/* No local authentication phase in this protocol */
|
||||
seat_set_trust_status(seat, false);
|
||||
|
||||
@ -83,10 +85,10 @@ static const char *null_init(Seat *seat, Backend **backend_handle,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *loop_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port, char **realhost,
|
||||
int nodelay, int keepalive) {
|
||||
static const char *loop_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive) {
|
||||
struct loop_state *st = snew(struct loop_state);
|
||||
|
||||
/* No local authentication phase in this protocol */
|
||||
|
@ -1268,9 +1268,9 @@ Backend *pty_backend_create(
|
||||
* it gets the argv array from the global variable pty_argv, expecting
|
||||
* that it will have been invoked by pterm.
|
||||
*/
|
||||
static const char *pty_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port,
|
||||
static const char *pty_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive)
|
||||
{
|
||||
const char *cmd = NULL;
|
||||
@ -1281,7 +1281,8 @@ static const char *pty_init(Seat *seat, Backend **backend_handle,
|
||||
if (pty_argv && pty_argv[0] && !pty_argv[1])
|
||||
cmd = pty_argv[0];
|
||||
|
||||
*backend_handle= pty_backend_create(
|
||||
assert(vt == &pty_backend);
|
||||
*backend_handle = pty_backend_create(
|
||||
seat, logctx, conf, pty_argv, cmd, modes, false, NULL, NULL);
|
||||
*realhost = dupstr("");
|
||||
return NULL;
|
||||
|
10
unix/uxser.c
10
unix/uxser.c
@ -279,10 +279,10 @@ 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(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port, char **realhost,
|
||||
bool nodelay, bool keepalive)
|
||||
static const char *serial_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive)
|
||||
{
|
||||
Serial *serial;
|
||||
const char *err;
|
||||
@ -292,7 +292,7 @@ static const char *serial_init(Seat *seat, Backend **backend_handle,
|
||||
seat_set_trust_status(seat, false);
|
||||
|
||||
serial = snew(Serial);
|
||||
serial->backend.vt = &serial_backend;
|
||||
serial->backend.vt = vt;
|
||||
*backend_handle = &serial->backend;
|
||||
|
||||
serial->seat = seat;
|
||||
|
@ -191,9 +191,9 @@ static const char *serial_configure(Serial *serial, HANDLE serport, Conf *conf)
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *serial_init(Seat *seat, Backend **backend_handle,
|
||||
LogContext *logctx, Conf *conf,
|
||||
const char *host, int port,
|
||||
static const char *serial_init(const BackendVtable *vt, Seat *seat,
|
||||
Backend **backend_handle, LogContext *logctx,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, bool nodelay, bool keepalive)
|
||||
{
|
||||
Serial *serial;
|
||||
@ -209,7 +209,7 @@ static const char *serial_init(Seat *seat, Backend **backend_handle,
|
||||
serial->out = serial->in = NULL;
|
||||
serial->bufsize = 0;
|
||||
serial->break_in_progress = false;
|
||||
serial->backend.vt = &serial_backend;
|
||||
serial->backend.vt = vt;
|
||||
*backend_handle = &serial->backend;
|
||||
|
||||
serial->seat = seat;
|
||||
|
Loading…
Reference in New Issue
Block a user