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 commitb6cbad89fc
, removed again in98538caa39
when the named-pipe revamp made it unnecessary). This is the same idea but centralised for reusability.
This commit is contained in:
@ -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 */
|
||||
|
Reference in New Issue
Block a user