summaryrefslogtreecommitdiff
path: root/src/libstddjb/iobufferk_finish.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2014-09-18 18:55:44 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2014-09-18 18:55:44 +0000
commit3534b428629be185e096be99e3bd5fdfe32d5544 (patch)
tree210ef3198ed66bc7f7b7bf6a85e4579f455e5a36 /src/libstddjb/iobufferk_finish.c
downloadskalibs-3534b428629be185e096be99e3bd5fdfe32d5544.tar.xz
initial commit with rc for skalibs-2.0.0.0
Diffstat (limited to 'src/libstddjb/iobufferk_finish.c')
-rw-r--r--src/libstddjb/iobufferk_finish.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/libstddjb/iobufferk_finish.c b/src/libstddjb/iobufferk_finish.c
new file mode 100644
index 0000000..ef20d57
--- /dev/null
+++ b/src/libstddjb/iobufferk_finish.c
@@ -0,0 +1,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_ref k)
+{
+ (void)k ;
+}
+
+static void iobufferk_finish_0 (iobufferk_ref k)
+{
+ register int e = errno ;
+ fd_close(k->p[1]) ;
+ errno = e ;
+}
+
+static void iobufferk_finish_3 (iobufferk_ref 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_ref k)
+{
+ (void)k ;
+}
+
+iobufferk_finish_func_t_ref const iobufferk_finish_f[4] =
+{
+ &iobufferk_nop, &iobufferk_nop, &iobufferk_nop, &iobufferk_nop
+} ;
+
+#endif