summaryrefslogtreecommitdiff
path: root/src/libstddjb/buffer_get.c
blob: ff67a066a45cfea80f11258cbcc7f216be34ddb2 (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, (int)w) : -1 :
         !r ? (errno = EWOULDBLOCK, -1) : (int)w ;
}