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:
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user