buffer_fill.c (330B)
1 /* ISC license. */ 2 3 #include <sys/uio.h> 4 #include <errno.h> 5 #include <skalibs/buffer.h> 6 7 ssize_t buffer_fill (buffer *b) 8 { 9 struct iovec v[2] ; 10 ssize_t r ; 11 if (buffer_isfull(b)) return (errno = ENOBUFS, -1) ; 12 buffer_wpeek(b, v) ; 13 r = (*b->op)(b->fd, v, 2) ; 14 if (r <= 0) return r ; 15 buffer_wseek(b, r) ; 16 return r ; 17 }