mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 01:18:00 +00:00
Add some more bufchain_try_* functions.
We already had bufchain_try_fetch_consume; now we also have bufchain_try_fetch (for when you want to wait until that much data is available but then not commit to removing it), and bufchain_try_consume (so you can conveniently ignore a certain amount of incoming data).
This commit is contained in:
parent
4e93a2c1b8
commit
efee4e0eae
2
misc.h
2
misc.h
@ -123,6 +123,8 @@ ptrlen bufchain_prefix(bufchain *ch);
|
||||
void bufchain_consume(bufchain *ch, size_t len);
|
||||
void bufchain_fetch(bufchain *ch, void *data, size_t len);
|
||||
void bufchain_fetch_consume(bufchain *ch, void *data, size_t len);
|
||||
bool bufchain_try_consume(bufchain *ch, size_t len);
|
||||
bool bufchain_try_fetch(bufchain *ch, void *data, size_t len);
|
||||
bool bufchain_try_fetch_consume(bufchain *ch, void *data, size_t len);
|
||||
size_t bufchain_fetch_consume_up_to(bufchain *ch, void *data, size_t len);
|
||||
void bufchain_set_callback_inner(
|
||||
|
@ -153,6 +153,26 @@ void bufchain_fetch_consume(bufchain *ch, void *data, size_t len)
|
||||
bufchain_consume(ch, len);
|
||||
}
|
||||
|
||||
bool bufchain_try_fetch(bufchain *ch, void *data, size_t len)
|
||||
{
|
||||
if (ch->buffersize >= len) {
|
||||
bufchain_fetch(ch, data, len);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool bufchain_try_consume(bufchain *ch, size_t len)
|
||||
{
|
||||
if (ch->buffersize >= len) {
|
||||
bufchain_consume(ch, len);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool bufchain_try_fetch_consume(bufchain *ch, void *data, size_t len)
|
||||
{
|
||||
if (ch->buffersize >= len) {
|
||||
|
Loading…
Reference in New Issue
Block a user