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

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

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