1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -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:
Simon Tatham
2018-05-27 15:41:12 +01:00
parent f6d04ef1c4
commit b851d748be
5 changed files with 51 additions and 43 deletions

42
nullplug.c Normal file
View File

@ -0,0 +1,42 @@
/*
* nullplug.c: provide a null implementation of the Plug vtable which
* ignores all calls. Occasionally useful in cases where we want to
* make a network connection just to see if it works, but not do
* anything with it afterwards except close it again.
*/
#include "putty.h"
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
};
static const Plug_vtable *nullplug_plugvt_ptr = &nullplug_plugvt;
/*
* There's a singleton instance of nullplug, because it's not
* interesting enough to worry about making more than one of them.
*/
Plug nullplug = &nullplug_plugvt_ptr;