blob: dca9e3bb3865d5c77a6f7bdd99360322bbeee5af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/* ISC license. */
#include <sys/types.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/buffer.h>
int buffer_getall (buffer *b, char *buf, size_t len, size_t *w)
{
if (*w > len) return (errno = EINVAL, -1) ;
for (;;)
{
ssize_t r ;
*w += buffer_getnofill(b, buf + *w, len - *w) ;
if (*w >= len) break ;
r = sanitize_read(buffer_fill(b)) ;
if (r <= 0) return r ;
}
return 1 ;
}
|