blob: 5635aed73a64c5e7463c99d2009c3536f624588b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/* ISC license. */
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/siovec.h>
#include <skalibs/buffer.h>
int buffer_putvall (buffer *b, struct iovec const *v, unsigned int n, size_t *written)
{
size_t len = siovec_len(v, n) ;
size_t w = n ;
struct iovec vv[n ? n : 1] ;
if (*written > len) return (errno = EINVAL, 0) ;
while (w--) vv[w] = v[w] ;
w = *written ;
for (;;)
{
siovec_seek(vv, n, w) ;
w = buffer_putvnoflush(b, vv, n) ;
*written += w ;
if (*written >= len) return 1 ;
buffer_flush(b) ;
if (buffer_isfull(b)) return 0 ;
}
}
|