summaryrefslogtreecommitdiff
path: root/src/libstddjb/iobufferk_isworking.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_isworking.c
downloadskalibs-3534b428629be185e096be99e3bd5fdfe32d5544.tar.xz
initial commit with rc for skalibs-2.0.0.0
Diffstat (limited to 'src/libstddjb/iobufferk_isworking.c')
-rw-r--r--src/libstddjb/iobufferk_isworking.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libstddjb/iobufferk_isworking.c b/src/libstddjb/iobufferk_isworking.c
new file mode 100644
index 0000000..f02b7e0
--- /dev/null
+++ b/src/libstddjb/iobufferk_isworking.c
@@ -0,0 +1,48 @@
+/* ISC license. */
+
+#include <skalibs/sysdeps.h>
+
+#ifdef SKALIBS_HASSPLICE
+
+#include <skalibs/nonposix.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <skalibs/iobuffer.h>
+
+int iobufferk_isworking (iobufferk_ref k)
+{
+ /* for now splice() with a length of 0 returns 0 no matter what, so this */
+ /* test is useless. splice() should test the underlying filesystems even */
+ /* if the length is 0. */
+
+# if 0
+
+ register int e = errno ;
+ if (splice(k->fd[0], 0, k->p[1], 0, 0, 0) < 0) goto no ;
+ if (splice(k->p[0], 0, k->fd[1], 0, 0, 0) < 0) goto no ;
+ errno = e ;
+ return 1 ;
+ no:
+ errno = e ;
+ return 0 ;
+
+# else
+
+ (void)k ;
+ return 1 ;
+
+# endif
+}
+
+#else
+
+#include <skalibs/iobuffer.h>
+
+int iobufferk_isworking (iobufferk_ref k)
+{
+ (void)k ;
+ return 0 ;
+}
+
+#endif
+