mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 03:52:49 -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:
10
pinger.c
10
pinger.c
@ -9,8 +9,7 @@ struct pinger_tag {
|
||||
int interval;
|
||||
int pending;
|
||||
unsigned long when_set, next;
|
||||
Backend *back;
|
||||
void *backhandle;
|
||||
Backend *backend;
|
||||
};
|
||||
|
||||
static void pinger_schedule(Pinger pinger);
|
||||
@ -20,7 +19,7 @@ static void pinger_timer(void *ctx, unsigned long now)
|
||||
Pinger pinger = (Pinger)ctx;
|
||||
|
||||
if (pinger->pending && now == pinger->next) {
|
||||
pinger->back->special(pinger->backhandle, TS_PING);
|
||||
backend_special(pinger->backend, TS_PING);
|
||||
pinger->pending = FALSE;
|
||||
pinger_schedule(pinger);
|
||||
}
|
||||
@ -45,14 +44,13 @@ static void pinger_schedule(Pinger pinger)
|
||||
}
|
||||
}
|
||||
|
||||
Pinger pinger_new(Conf *conf, Backend *back, void *backhandle)
|
||||
Pinger pinger_new(Conf *conf, Backend *backend)
|
||||
{
|
||||
Pinger pinger = snew(struct pinger_tag);
|
||||
|
||||
pinger->interval = conf_get_int(conf, CONF_ping_interval);
|
||||
pinger->pending = FALSE;
|
||||
pinger->back = back;
|
||||
pinger->backhandle = backhandle;
|
||||
pinger->backend = backend;
|
||||
pinger_schedule(pinger);
|
||||
|
||||
return pinger;
|
||||
|
Reference in New Issue
Block a user