mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 03:52:49 -05:00
Merge duplicate implementations of the trivial Plug.
In the course of reworking the socket vtable system, I noticed that both sshshare.c and x11fwd.c independently invented the idea of a Plug none of whose methods do anything. We don't need more than one of those, so let's centralise the idea to somewhere it can be easily reused.
This commit is contained in:
24
sshshare.c
24
sshshare.c
@ -2031,39 +2031,17 @@ char *ssh_share_sockname(const char *host, int port, Conf *conf)
|
||||
return sockname;
|
||||
}
|
||||
|
||||
static void nullplug_socket_log(Plug plug, int type, SockAddr addr, int port,
|
||||
const char *error_msg, int error_code) {}
|
||||
static void nullplug_closing(Plug plug, const char *error_msg, int error_code,
|
||||
int calling_back) {}
|
||||
static void nullplug_receive(Plug plug, int urgent, char *data, int len) {}
|
||||
static void nullplug_sent(Plug plug, int bufsize) {}
|
||||
|
||||
static const Plug_vtable nullplug_plugvt = {
|
||||
nullplug_socket_log,
|
||||
nullplug_closing,
|
||||
nullplug_receive,
|
||||
nullplug_sent,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct nullplug {
|
||||
const Plug_vtable *plugvt;
|
||||
};
|
||||
|
||||
int ssh_share_test_for_upstream(const char *host, int port, Conf *conf)
|
||||
{
|
||||
char *sockname, *logtext, *ds_err, *us_err;
|
||||
int result;
|
||||
Socket sock;
|
||||
struct nullplug np;
|
||||
|
||||
np.plugvt = &nullplug_plugvt;
|
||||
|
||||
sockname = ssh_share_sockname(host, port, conf);
|
||||
|
||||
sock = NULL;
|
||||
logtext = ds_err = us_err = NULL;
|
||||
result = platform_ssh_share(sockname, conf, &np.plugvt, (Plug)NULL, &sock,
|
||||
result = platform_ssh_share(sockname, conf, nullplug, (Plug)NULL, &sock,
|
||||
&logtext, &ds_err, &us_err, FALSE, TRUE);
|
||||
|
||||
sfree(logtext);
|
||||
|
Reference in New Issue
Block a user