mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-09 07:13:43 -05:00
Turn Backend into a sensible classoid.
Nearly every part of the code that ever handles a full backend structure has historically done it using a pair of pointer variables, one pointing at a constant struct full of function pointers, and the other pointing to a 'void *' state object that's passed to each of those. While I'm modernising the rest of the code, this seems like a good time to turn that into the same more or less type-safe and less cumbersome system as I'm using for other parts of the code, such as Socket, Plug, BinaryPacketProtocol and so forth: the Backend structure contains a vtable pointer, and a system of macro wrappers handles dispatching through that vtable.
This commit is contained in:
@ -37,11 +37,12 @@ void cleanup_exit(int code)
|
||||
exit(code);
|
||||
}
|
||||
|
||||
Backend *select_backend(Conf *conf)
|
||||
const struct Backend_vtable *select_backend(Conf *conf)
|
||||
{
|
||||
Backend *back = backend_from_proto(conf_get_int(conf, CONF_protocol));
|
||||
assert(back != NULL);
|
||||
return back;
|
||||
const struct Backend_vtable *vt =
|
||||
backend_vt_from_proto(conf_get_int(conf, CONF_protocol));
|
||||
assert(vt != NULL);
|
||||
return vt;
|
||||
}
|
||||
|
||||
void initial_config_box(Conf *conf, post_dialog_fn_t after, void *afterctx)
|
||||
@ -83,9 +84,10 @@ void setup(int single)
|
||||
default_protocol = be_default_protocol;
|
||||
/* Find the appropriate default port. */
|
||||
{
|
||||
Backend *b = backend_from_proto(default_protocol);
|
||||
const struct Backend_vtable *vt =
|
||||
backend_vt_from_proto(default_protocol);
|
||||
default_port = 0; /* illegal */
|
||||
if (b)
|
||||
default_port = b->default_port;
|
||||
if (vt)
|
||||
default_port = vt->default_port;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user