summaryrefslogtreecommitdiff
path: root/src/libstddjb/iobufferk_finish.c
blob: f7433284ada2ef167359359e935ac46110877134 (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
40
41
42
43
44
45
46
47
48
49
50
/* ISC license. */

#include <skalibs/sysdeps.h>

#ifdef SKALIBS_HASSPLICE

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

static void iobufferk_nop (iobufferk *k)
{
  (void)k ;
}

static void iobufferk_finish_0 (iobufferk *k)
{
  register int e = errno ;
  fd_close(k->p[1]) ;
  errno = e ;
}

static void iobufferk_finish_3 (iobufferk *k)
{
  register int e = errno ;
  fd_close(k->p[1]) ;
  fd_close(k->p[0]) ;
  errno = e ;
}

iobufferk_finish_func_t_ref const iobufferk_finish_f[4] =
{
  &iobufferk_finish_0, &iobufferk_nop, &iobufferk_nop, &iobufferk_finish_3
} ;

#else

#include <skalibs/iobuffer.h>

static void iobufferk_nop (iobufferk *k)
{
  (void)k ;
}

iobufferk_finish_func_t_ref const iobufferk_finish_f[4] =
{
  &iobufferk_nop, &iobufferk_nop, &iobufferk_nop, &iobufferk_nop
} ;

#endif