summaryrefslogtreecommitdiff
path: root/src/libstddjb/iobuffer_ufromk.c
blob: 778ddf21d209fb489164dc763f48c9dfe440e8da (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* ISC license. */

#include <skalibs/sysdeps.h>

#ifdef SKALIBS_HASSPLICE

#include <skalibs/iobuffer.h>

int iobuffer_ufromk (iobufferu *u, iobufferk *k)
{
  int in = u->b[0].fd ;
  u->b[0].fd = k->p[0] ;
  while (k->n)
  {
    register int r = iobufferu_fill(u) ;
    if (r <= 0) goto err ;
    k->n -= r ;
  }
  u->b[0].fd = in ;
  return 1 ;

 err:
  u->b[0].fd = in ;
  return 0 ;
}

#else

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

int iobuffer_ufromk (iobufferu *u, iobufferk *k)
{
  (void)u ;
  (void)k ;
  return (errno = ENOSYS, 0) ;
}

#endif