1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 12:02:47 -05:00

Add BinarySink wrappers on existing forms of output.

There's now a stdio_sink, whose write function calls fwrite on the
given FILE *; a bufchain_sink, whose write function appends to the
given bufchain; and on Windows there's a handle_sink whose write
function writes to the given 'struct handle'. (That is, not the raw
Windows HANDLE, but our event-loop-friendly wrapper on it.)

Not yet used for anything, but they're about to be.
This commit is contained in:
Simon Tatham
2019-02-20 06:52:54 +00:00
parent 5dadbdf556
commit bc1aa9c656
5 changed files with 65 additions and 0 deletions

View File

@ -715,3 +715,15 @@ void *handle_get_privdata(struct handle *h)
{
return h->u.g.privdata;
}
static void handle_sink_write(BinarySink *bs, const void *data, size_t len)
{
handle_sink *sink = BinarySink_DOWNCAST(bs, handle_sink);
handle_write(sink->h, data, len);
}
void handle_sink_init(handle_sink *sink, struct handle *h)
{
sink->h = h;
BinarySink_INIT(sink, handle_sink_write);
}

View File

@ -24,6 +24,7 @@
#endif
#include "defs.h"
#include "marshal.h"
#include "tree234.h"
@ -621,6 +622,12 @@ size_t handle_backlog(struct handle *h);
void *handle_get_privdata(struct handle *h);
struct handle *handle_add_foreign_event(HANDLE event,
void (*callback)(void *), void *ctx);
/* Analogue of stdio_sink in marshal.h, for a Windows handle */
struct handle_sink {
struct handle *h;
BinarySink_IMPLEMENTATION;
};
void handle_sink_init(handle_sink *sink, struct handle *h);
/*
* winpgntc.c needs to schedule callbacks for asynchronous agent