1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 19:41:01 -05:00

Implement a BinarySink writing to a fixed-size buffer.

This is one of marshal.c's small collection of handy BinarySink
adapters to existing kinds of thing, alongside stdio_sink and
bufchain_sink. It writes into a fixed-size buffer, discarding all
writes after the buffer fills up, and sets a flag to let you know if
it overflowed.

There was one of these in Windows Pageant a while back, under the name
'struct PageantReply' (introduced in commit b6cbad89fc, removed
again in 98538caa39 when the named-pipe revamp made it
unnecessary). This is the same idea but centralised for reusability.
This commit is contained in:
Simon Tatham
2022-11-09 18:53:34 +00:00
parent c8ba48be43
commit 991e22c9bb
3 changed files with 28 additions and 0 deletions

View File

@ -353,7 +353,14 @@ struct bufchain_sink {
bufchain *ch;
BinarySink_IMPLEMENTATION;
};
struct buffer_sink {
char *out;
size_t space;
bool overflowed;
BinarySink_IMPLEMENTATION;
};
void stdio_sink_init(stdio_sink *sink, FILE *fp);
void bufchain_sink_init(bufchain_sink *sink, bufchain *ch);
void buffer_sink_init(buffer_sink *sink, void *buffer, size_t len);
#endif /* PUTTY_MARSHAL_H */