mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +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;
|
const BackendVtable *vt;
|
||||||
};
|
};
|
||||||
struct BackendVtable {
|
struct BackendVtable {
|
||||||
const char *(*init) (Seat *seat, Backend **backend_out,
|
const char *(*init) (const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_out, LogContext *logctx, Conf *conf,
|
||||||
const char *host, int port,
|
const char *host, int port,
|
||||||
char **realhost, bool nodelay, bool keepalive);
|
char **realhost, bool nodelay, bool keepalive);
|
||||||
|
|
||||||
@ -525,7 +525,7 @@ struct BackendVtable {
|
|||||||
static inline const char *backend_init(
|
static inline const char *backend_init(
|
||||||
const BackendVtable *vt, Seat *seat, Backend **out, LogContext *logctx,
|
const BackendVtable *vt, Seat *seat, Backend **out, LogContext *logctx,
|
||||||
Conf *conf, const char *host, int port, char **rhost, bool nd, bool ka)
|
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)
|
static inline void backend_free(Backend *be)
|
||||||
{ be->vt->free(be); }
|
{ be->vt->free(be); }
|
||||||
static inline void backend_reconfig(Backend *be, Conf *conf)
|
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
|
* Also places the canonical host name into `realhost'. It must be
|
||||||
* freed by the caller.
|
* freed by the caller.
|
||||||
*/
|
*/
|
||||||
static const char *raw_init(Seat *seat, Backend **backend_handle,
|
static const char *raw_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port, char **realhost,
|
Conf *conf, const char *host, int port,
|
||||||
bool nodelay, bool keepalive)
|
char **realhost, bool nodelay, bool keepalive)
|
||||||
{
|
{
|
||||||
SockAddr *addr;
|
SockAddr *addr;
|
||||||
const char *err;
|
const char *err;
|
||||||
@ -135,7 +135,7 @@ static const char *raw_init(Seat *seat, Backend **backend_handle,
|
|||||||
|
|
||||||
raw = snew(Raw);
|
raw = snew(Raw);
|
||||||
raw->plug.vt = &Raw_plugvt;
|
raw->plug.vt = &Raw_plugvt;
|
||||||
raw->backend.vt = &raw_backend;
|
raw->backend.vt = vt;
|
||||||
raw->s = NULL;
|
raw->s = NULL;
|
||||||
raw->closed_on_socket_error = false;
|
raw->closed_on_socket_error = false;
|
||||||
*backend_handle = &raw->backend;
|
*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
|
* Also places the canonical host name into `realhost'. It must be
|
||||||
* freed by the caller.
|
* freed by the caller.
|
||||||
*/
|
*/
|
||||||
static const char *rlogin_init(Seat *seat, Backend **backend_handle,
|
static const char *rlogin_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port, char **realhost,
|
Conf *conf, const char *host, int port,
|
||||||
bool nodelay, bool keepalive)
|
char **realhost, bool nodelay, bool keepalive)
|
||||||
{
|
{
|
||||||
SockAddr *addr;
|
SockAddr *addr;
|
||||||
const char *err;
|
const char *err;
|
||||||
@ -167,7 +167,7 @@ static const char *rlogin_init(Seat *seat, Backend **backend_handle,
|
|||||||
|
|
||||||
rlogin = snew(Rlogin);
|
rlogin = snew(Rlogin);
|
||||||
rlogin->plug.vt = &Rlogin_plugvt;
|
rlogin->plug.vt = &Rlogin_plugvt;
|
||||||
rlogin->backend.vt = &rlogin_backend;
|
rlogin->backend.vt = vt;
|
||||||
rlogin->s = NULL;
|
rlogin->s = NULL;
|
||||||
rlogin->closed_on_socket_error = false;
|
rlogin->closed_on_socket_error = false;
|
||||||
rlogin->seat = seat;
|
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.
|
* Returns an error message, or NULL on success.
|
||||||
*/
|
*/
|
||||||
static const char *ssh_init(Seat *seat, Backend **backend_handle,
|
static const char *ssh_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port, char **realhost,
|
Conf *conf, const char *host, int port,
|
||||||
bool nodelay, bool keepalive)
|
char **realhost, bool nodelay, bool keepalive)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
Ssh *ssh;
|
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_width = conf_get_int(ssh->conf, CONF_width);
|
||||||
ssh->term_height = conf_get_int(ssh->conf, CONF_height);
|
ssh->term_height = conf_get_int(ssh->conf, CONF_height);
|
||||||
|
|
||||||
ssh->backend.vt = &ssh_backend;
|
ssh->backend.vt = vt;
|
||||||
*backend_handle = &ssh->backend;
|
*backend_handle = &ssh->backend;
|
||||||
|
|
||||||
ssh->seat = seat;
|
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
|
* Also places the canonical host name into `realhost'. It must be
|
||||||
* freed by the caller.
|
* freed by the caller.
|
||||||
*/
|
*/
|
||||||
static const char *telnet_init(Seat *seat, Backend **backend_handle,
|
static const char *telnet_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port,
|
Conf *conf, const char *host, int port,
|
||||||
char **realhost, bool nodelay, bool keepalive)
|
char **realhost, bool nodelay, bool keepalive)
|
||||||
{
|
{
|
||||||
SockAddr *addr;
|
SockAddr *addr;
|
||||||
@ -694,7 +694,7 @@ static const char *telnet_init(Seat *seat, Backend **backend_handle,
|
|||||||
|
|
||||||
telnet = snew(Telnet);
|
telnet = snew(Telnet);
|
||||||
telnet->plug.vt = &Telnet_plugvt;
|
telnet->plug.vt = &Telnet_plugvt;
|
||||||
telnet->backend.vt = &telnet_backend;
|
telnet->backend.vt = vt;
|
||||||
telnet->conf = conf_copy(conf);
|
telnet->conf = conf_copy(conf);
|
||||||
telnet->s = NULL;
|
telnet->s = NULL;
|
||||||
telnet->closed_on_socket_error = false;
|
telnet->closed_on_socket_error = false;
|
||||||
|
26
testback.c
26
testback.c
@ -32,10 +32,12 @@
|
|||||||
|
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
|
|
||||||
static const char *null_init(Seat *, Backend **, LogContext *, Conf *,
|
static const char *null_init(const BackendVtable *, Seat *, Backend **,
|
||||||
const char *, int, char **, int, int);
|
LogContext *, Conf *, const char *, int, char **,
|
||||||
static const char *loop_init(Seat *, Backend **, LogContext *, Conf *,
|
bool, bool);
|
||||||
const char *, int, char **, int, int);
|
static const char *loop_init(const BackendVtable *, Seat *, Backend **,
|
||||||
|
LogContext *, Conf *, const char *, int, char **,
|
||||||
|
bool, bool);
|
||||||
static void null_free(Backend *);
|
static void null_free(Backend *);
|
||||||
static void loop_free(Backend *);
|
static void loop_free(Backend *);
|
||||||
static void null_reconfig(Backend *, Conf *);
|
static void null_reconfig(Backend *, Conf *);
|
||||||
@ -72,10 +74,10 @@ struct loop_state {
|
|||||||
Backend backend;
|
Backend backend;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *null_init(Seat *seat, Backend **backend_handle,
|
static const char *null_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port, char **realhost,
|
Conf *conf, const char *host, int port,
|
||||||
int nodelay, int keepalive) {
|
char **realhost, bool nodelay, bool keepalive) {
|
||||||
/* No local authentication phase in this protocol */
|
/* No local authentication phase in this protocol */
|
||||||
seat_set_trust_status(seat, false);
|
seat_set_trust_status(seat, false);
|
||||||
|
|
||||||
@ -83,10 +85,10 @@ static const char *null_init(Seat *seat, Backend **backend_handle,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *loop_init(Seat *seat, Backend **backend_handle,
|
static const char *loop_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port, char **realhost,
|
Conf *conf, const char *host, int port,
|
||||||
int nodelay, int keepalive) {
|
char **realhost, bool nodelay, bool keepalive) {
|
||||||
struct loop_state *st = snew(struct loop_state);
|
struct loop_state *st = snew(struct loop_state);
|
||||||
|
|
||||||
/* No local authentication phase in this protocol */
|
/* 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
|
* it gets the argv array from the global variable pty_argv, expecting
|
||||||
* that it will have been invoked by pterm.
|
* that it will have been invoked by pterm.
|
||||||
*/
|
*/
|
||||||
static const char *pty_init(Seat *seat, Backend **backend_handle,
|
static const char *pty_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port,
|
Conf *conf, const char *host, int port,
|
||||||
char **realhost, bool nodelay, bool keepalive)
|
char **realhost, bool nodelay, bool keepalive)
|
||||||
{
|
{
|
||||||
const char *cmd = NULL;
|
const char *cmd = NULL;
|
||||||
@ -1281,6 +1281,7 @@ static const char *pty_init(Seat *seat, Backend **backend_handle,
|
|||||||
if (pty_argv && pty_argv[0] && !pty_argv[1])
|
if (pty_argv && pty_argv[0] && !pty_argv[1])
|
||||||
cmd = pty_argv[0];
|
cmd = pty_argv[0];
|
||||||
|
|
||||||
|
assert(vt == &pty_backend);
|
||||||
*backend_handle = pty_backend_create(
|
*backend_handle = pty_backend_create(
|
||||||
seat, logctx, conf, pty_argv, cmd, modes, false, NULL, NULL);
|
seat, logctx, conf, pty_argv, cmd, modes, false, NULL, NULL);
|
||||||
*realhost = dupstr("");
|
*realhost = dupstr("");
|
||||||
|
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
|
* Also places the canonical host name into `realhost'. It must be
|
||||||
* freed by the caller.
|
* freed by the caller.
|
||||||
*/
|
*/
|
||||||
static const char *serial_init(Seat *seat, Backend **backend_handle,
|
static const char *serial_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port, char **realhost,
|
Conf *conf, const char *host, int port,
|
||||||
bool nodelay, bool keepalive)
|
char **realhost, bool nodelay, bool keepalive)
|
||||||
{
|
{
|
||||||
Serial *serial;
|
Serial *serial;
|
||||||
const char *err;
|
const char *err;
|
||||||
@ -292,7 +292,7 @@ static const char *serial_init(Seat *seat, Backend **backend_handle,
|
|||||||
seat_set_trust_status(seat, false);
|
seat_set_trust_status(seat, false);
|
||||||
|
|
||||||
serial = snew(Serial);
|
serial = snew(Serial);
|
||||||
serial->backend.vt = &serial_backend;
|
serial->backend.vt = vt;
|
||||||
*backend_handle = &serial->backend;
|
*backend_handle = &serial->backend;
|
||||||
|
|
||||||
serial->seat = seat;
|
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
|
* Also places the canonical host name into `realhost'. It must be
|
||||||
* freed by the caller.
|
* freed by the caller.
|
||||||
*/
|
*/
|
||||||
static const char *serial_init(Seat *seat, Backend **backend_handle,
|
static const char *serial_init(const BackendVtable *vt, Seat *seat,
|
||||||
LogContext *logctx, Conf *conf,
|
Backend **backend_handle, LogContext *logctx,
|
||||||
const char *host, int port,
|
Conf *conf, const char *host, int port,
|
||||||
char **realhost, bool nodelay, bool keepalive)
|
char **realhost, bool nodelay, bool keepalive)
|
||||||
{
|
{
|
||||||
Serial *serial;
|
Serial *serial;
|
||||||
@ -209,7 +209,7 @@ static const char *serial_init(Seat *seat, Backend **backend_handle,
|
|||||||
serial->out = serial->in = NULL;
|
serial->out = serial->in = NULL;
|
||||||
serial->bufsize = 0;
|
serial->bufsize = 0;
|
||||||
serial->break_in_progress = false;
|
serial->break_in_progress = false;
|
||||||
serial->backend.vt = &serial_backend;
|
serial->backend.vt = vt;
|
||||||
*backend_handle = &serial->backend;
|
*backend_handle = &serial->backend;
|
||||||
|
|
||||||
serial->seat = seat;
|
serial->seat = seat;
|
||||||
|
Loading…
Reference in New Issue
Block a user