diff --git a/misc.c b/misc.c index fb32da5d..08198004 100644 --- a/misc.c +++ b/misc.c @@ -751,6 +751,22 @@ void bufchain_fetch(bufchain *ch, void *data, int len) } } +void bufchain_fetch_consume(bufchain *ch, void *data, int len) +{ + bufchain_fetch(ch, data, len); + bufchain_consume(ch, len); +} + +int bufchain_try_fetch_consume(bufchain *ch, void *data, int len) +{ + if (ch->buffersize >= len) { + bufchain_fetch_consume(ch, data, len); + return TRUE; + } else { + return FALSE; + } +} + /* ---------------------------------------------------------------------- * My own versions of malloc, realloc and free. Because I want * malloc and realloc to bomb out and exit the program if they run diff --git a/misc.h b/misc.h index 32e7bc32..d2efdca7 100644 --- a/misc.h +++ b/misc.h @@ -82,6 +82,8 @@ void bufchain_add(bufchain *ch, const void *data, int len); void bufchain_prefix(bufchain *ch, void **data, int *len); void bufchain_consume(bufchain *ch, int len); void bufchain_fetch(bufchain *ch, void *data, int len); +void bufchain_fetch_consume(bufchain *ch, void *data, int len); +int bufchain_try_fetch_consume(bufchain *ch, void *data, int len); int validate_manual_hostkey(char *key);