summaryrefslogtreecommitdiff
path: root/src/libstddjb/buffer_get.c
blob: fbc0de31ad6db7cdc68b25de2aa80b713b834a0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
/* ISC license. */

#include <errno.h>
#include <skalibs/buffer.h>

ssize_t buffer_get (buffer *b, char *s, size_t len)
{
  size_t w = 0 ;
  int r = buffer_getall(b, s, len, &w) ;
  return r == -1 ? errno == EPIPE ? (errno = 0, w) : -1 :
         !r ? (errno = EWOULDBLOCK, -1) : w ;
}