summaryrefslogtreecommitdiff
path: root/src/libstddjb/allreadwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/allreadwrite.c')
-rw-r--r--src/libstddjb/allreadwrite.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libstddjb/allreadwrite.c b/src/libstddjb/allreadwrite.c
new file mode 100644
index 0000000..7e7867b
--- /dev/null
+++ b/src/libstddjb/allreadwrite.c
@@ -0,0 +1,19 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/allreadwrite.h>
+
+unsigned int allreadwrite (iofunc_t_ref op, int fd, register char *buf, register unsigned int len)
+{
+ register unsigned int written = 0 ;
+ while (len)
+ {
+ register int w = (*op)(fd, buf, len) ;
+ if (!w) errno = EPIPE ;
+ if (w <= 0) break ;
+ written += w ;
+ buf += w ;
+ len -= w ;
+ }
+ return written ;
+}