summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--doc/libstddjb/index.html1
-rw-r--r--doc/libstddjb/iobuffer.html28
-rw-r--r--doc/upgrade.html1
-rw-r--r--package/deps.mak22
-rw-r--r--src/include/skalibs/djbunix.h4
-rw-r--r--src/include/skalibs/iobuffer.h120
-rw-r--r--src/include/skalibs/stddjb.h1
-rw-r--r--src/libstddjb/fd_cat.c26
-rw-r--r--src/libstddjb/fd_catn.c39
-rw-r--r--src/libstddjb/iobuffer_fill.c14
-rw-r--r--src/libstddjb/iobuffer_flush.c14
-rw-r--r--src/libstddjb/iobuffer_init.c17
-rw-r--r--src/libstddjb/iobuffer_kfromu.c38
-rw-r--r--src/libstddjb/iobuffer_salvage.c19
-rw-r--r--src/libstddjb/iobuffer_ufromk.c40
-rw-r--r--src/libstddjb/iobufferk_fill.c56
-rw-r--r--src/libstddjb/iobufferk_finish.c45
-rw-r--r--src/libstddjb/iobufferk_flush.c67
-rw-r--r--src/libstddjb/iobufferk_init.c74
-rw-r--r--src/libstddjb/iobufferk_isworking.c47
-rw-r--r--src/libstddjb/iobufferu_fill.c11
-rw-r--r--src/libstddjb/iobufferu_finish.c9
-rw-r--r--src/libstddjb/iobufferu_flush.c11
-rw-r--r--src/libstddjb/iobufferu_init.c16
25 files changed, 33 insertions, 689 deletions
diff --git a/NEWS b/NEWS
index bd9610a..7fe6aee 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ In 2.11.0.0
- libbiguint removed.
- Obsolete skalibs/environ.h and skalibs/getpeereid.h removed.
- rc4 and md5 removed.
+ - iobuffer removed.
+ - fd_cat and fd_catn changed signatures.
- All *_t types renamed to avoid treading on POSIX namespace.
- subgetopt() renamed to lgetopt().
- signal functions reworked; skasigaction removed; sig_stack removed
diff --git a/doc/libstddjb/index.html b/doc/libstddjb/index.html
index e10482e..1a5e0dc 100644
--- a/doc/libstddjb/index.html
+++ b/doc/libstddjb/index.html
@@ -68,7 +68,6 @@ wrappers</a> around I/O functions, extra I/O functions </li>
<li> <a href="genwrite.html">skalibs/genwrite.h</a>: interface to generic writes either to strallocs or to buffers </li>
<li> <a href="getpeereid.html">skalibs/getpeereid.h</a>: the <tt>getpeereid()</tt> system call </li>
<li> <a href="iopause.html">skalibs/iopause.h</a>: the skalibs event loop selection function </li>
- <li> <a href="iobuffer.html">skalibs/iobuffer.h</a>: optimized data transfer from a fd to another </li>
<li> <a href="lolstdio.html">skalibs/lolstdio.h</a>:
<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html">printf</a>-like
functions writing into <a href="buffer.html">buffers</a> or <a href="bufalloc.html">bufallocs</a> </li>
diff --git a/doc/libstddjb/iobuffer.html b/doc/libstddjb/iobuffer.html
deleted file mode 100644
index 340fd1f..0000000
--- a/doc/libstddjb/iobuffer.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta http-equiv="Content-Language" content="en" />
- <title>skalibs: the iobuffer header</title>
- <meta name="Description" content="skalibs: the iobuffer header" />
- <meta name="Keywords" content="skalibs header iobuffer input output buffer splice zero-copy" />
- <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
- </head>
-<body>
-
-<p>
-<a href="index.html">libstddjb</a><br />
-<a href="../libskarnet.html">libskarnet</a><br />
-<a href="../index.html">skalibs</a><br />
-<a href="//skarnet.org/software/">Software</a><br />
-<a href="//skarnet.org/">skarnet.org</a>
-</p>
-
-<h1> The <tt>skalibs/iobuffer.h</tt> header </h1>
-
-<p>
- TODO: write this documentation page. (Sorry!)
-</p>
-
-</body>
-</html>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index 36a5598..4d5856e 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -22,6 +22,7 @@
<li> <tt>libbiguint</tt> removed. </li>
<li> Obsolete <tt>skalibs/environ.h</tt> and <tt>skalibs/getpeereid.h</tt> headers removed. </li>
<li> rc4 and md5 functions removed. </li>
+ <li> iobuffer removed. <tt>fd_cat()</tt> and <tt>fd_catn()</tt> changed signatures. </li>
<li> All <tt>*_t</tt> types renamed without the <tt>_t</tt> suffix,
in order to preserve POSIX namespace. </li>
<li> <tt>subgetopt()</tt> renamed to <tt>lgetopt()</tt>. </li>
diff --git a/package/deps.mak b/package/deps.mak
index 936734f..d20d007 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -28,7 +28,6 @@ src/include/skalibs/genalloc.h: src/include/skalibs/functypes.h src/include/skal
src/include/skalibs/genqdyn.h: src/include/skalibs/stralloc.h
src/include/skalibs/genset.h: src/include/skalibs/functypes.h
src/include/skalibs/gensetdyn.h: src/include/skalibs/functypes.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h
-src/include/skalibs/iobuffer.h: src/include/skalibs/buffer.h src/include/skalibs/djbunix.h
src/include/skalibs/iopause.h: src/include/skalibs/tai.h
src/include/skalibs/kolbak.h: src/include/skalibs/unixmessage.h
src/include/skalibs/lolstdio.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/strerr2.h
@@ -45,7 +44,7 @@ src/include/skalibs/skalibs.h: src/include/skalibs/datastruct.h src/include/skal
src/include/skalibs/skamisc.h: src/include/skalibs/buffer.h src/include/skalibs/stralloc.h
src/include/skalibs/socket.h: src/include/skalibs/gccattributes.h src/include/skalibs/posixplz.h src/include/skalibs/tai.h
src/include/skalibs/stdcrypto.h: src/include/skalibs/sha1.h src/include/skalibs/sha256.h src/include/skalibs/sha512.h
-src/include/skalibs/stddjb.h: src/include/skalibs/alarm.h src/include/skalibs/alloc.h src/include/skalibs/allreadwrite.h src/include/skalibs/bitarray.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/bytestr.h src/include/skalibs/cbuffer.h src/include/skalibs/cdb.h src/include/skalibs/cdbmake.h src/include/skalibs/direntry.h src/include/skalibs/disize.h src/include/skalibs/diuint.h src/include/skalibs/diuint32.h src/include/skalibs/djbtime.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/error.h src/include/skalibs/exec.h src/include/skalibs/fmtscan.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/genwrite.h src/include/skalibs/iobuffer.h src/include/skalibs/iopause.h src/include/skalibs/ip46.h src/include/skalibs/lolstdio.h src/include/skalibs/netstring.h src/include/skalibs/segfault.h src/include/skalibs/selfpipe.h src/include/skalibs/setgroups.h src/include/skalibs/sgetopt.h src/include/skalibs/sig.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/socket.h src/include/skalibs/stralloc.h src/include/skalibs/strerr.h src/include/skalibs/strerr2.h src/include/skalibs/tai.h src/include/skalibs/types.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h
+src/include/skalibs/stddjb.h: src/include/skalibs/alarm.h src/include/skalibs/alloc.h src/include/skalibs/allreadwrite.h src/include/skalibs/bitarray.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/bytestr.h src/include/skalibs/cbuffer.h src/include/skalibs/cdb.h src/include/skalibs/cdbmake.h src/include/skalibs/direntry.h src/include/skalibs/disize.h src/include/skalibs/diuint.h src/include/skalibs/diuint32.h src/include/skalibs/djbtime.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/error.h src/include/skalibs/exec.h src/include/skalibs/fmtscan.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/genwrite.h src/include/skalibs/iopause.h src/include/skalibs/ip46.h src/include/skalibs/lolstdio.h src/include/skalibs/netstring.h src/include/skalibs/segfault.h src/include/skalibs/selfpipe.h src/include/skalibs/setgroups.h src/include/skalibs/sgetopt.h src/include/skalibs/sig.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/socket.h src/include/skalibs/stralloc.h src/include/skalibs/strerr.h src/include/skalibs/strerr2.h src/include/skalibs/tai.h src/include/skalibs/types.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h
src/include/skalibs/strerr.h: src/include/skalibs/gccattributes.h
src/include/skalibs/strerr2.h: src/include/skalibs/strerr.h
src/include/skalibs/tai.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint64.h
@@ -305,8 +304,8 @@ src/libstddjb/dir_close.o src/libstddjb/dir_close.lo: src/libstddjb/dir_close.c
src/libstddjb/dir_fd.o src/libstddjb/dir_fd.lo: src/libstddjb/dir_fd.c src/include/skalibs/direntry.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h
src/libstddjb/error_isalready.o src/libstddjb/error_isalready.lo: src/libstddjb/error_isalready.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/error.h
src/libstddjb/error_temp.o src/libstddjb/error_temp.lo: src/libstddjb/error_temp.c src/include/skalibs/error.h
-src/libstddjb/fd_cat.o src/libstddjb/fd_cat.lo: src/libstddjb/fd_cat.c src/include/skalibs/djbunix.h src/include/skalibs/iobuffer.h
-src/libstddjb/fd_catn.o src/libstddjb/fd_catn.lo: src/libstddjb/fd_catn.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/iobuffer.h
+src/libstddjb/fd_cat.o src/libstddjb/fd_cat.lo: src/libstddjb/fd_cat.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h
+src/libstddjb/fd_catn.o src/libstddjb/fd_catn.lo: src/libstddjb/fd_catn.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h
src/libstddjb/fd_chdir.o src/libstddjb/fd_chdir.lo: src/libstddjb/fd_chdir.c src/include/skalibs/djbunix.h
src/libstddjb/fd_chmod.o src/libstddjb/fd_chmod.lo: src/libstddjb/fd_chmod.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h
src/libstddjb/fd_chown.o src/libstddjb/fd_chown.lo: src/libstddjb/fd_chown.c src/include/skalibs/djbunix.h
@@ -358,21 +357,6 @@ src/libstddjb/int64_fmtlist.o src/libstddjb/int64_fmtlist.lo: src/libstddjb/int6
src/libstddjb/int64_scan.o src/libstddjb/int64_scan.lo: src/libstddjb/int64_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h
src/libstddjb/int64_scan_base_max.o src/libstddjb/int64_scan_base_max.lo: src/libstddjb/int64_scan_base_max.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h
src/libstddjb/int64_scanlist.o src/libstddjb/int64_scanlist.lo: src/libstddjb/int64_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h
-src/libstddjb/iobuffer_fill.o src/libstddjb/iobuffer_fill.lo: src/libstddjb/iobuffer_fill.c src/include/skalibs/iobuffer.h
-src/libstddjb/iobuffer_flush.o src/libstddjb/iobuffer_flush.lo: src/libstddjb/iobuffer_flush.c src/include/skalibs/iobuffer.h
-src/libstddjb/iobuffer_init.o src/libstddjb/iobuffer_init.lo: src/libstddjb/iobuffer_init.c src/include/skalibs/iobuffer.h
-src/libstddjb/iobuffer_kfromu.o src/libstddjb/iobuffer_kfromu.lo: src/libstddjb/iobuffer_kfromu.c src/include/skalibs/buffer.h src/include/skalibs/iobuffer.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h
-src/libstddjb/iobuffer_salvage.o src/libstddjb/iobuffer_salvage.lo: src/libstddjb/iobuffer_salvage.c src/include/skalibs/iobuffer.h
-src/libstddjb/iobuffer_ufromk.o src/libstddjb/iobuffer_ufromk.lo: src/libstddjb/iobuffer_ufromk.c src/include/skalibs/iobuffer.h src/include/skalibs/sysdeps.h
-src/libstddjb/iobufferk_fill.o src/libstddjb/iobufferk_fill.lo: src/libstddjb/iobufferk_fill.c src/include/skalibs/iobuffer.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h
-src/libstddjb/iobufferk_finish.o src/libstddjb/iobufferk_finish.lo: src/libstddjb/iobufferk_finish.c src/include/skalibs/djbunix.h src/include/skalibs/iobuffer.h src/include/skalibs/sysdeps.h
-src/libstddjb/iobufferk_flush.o src/libstddjb/iobufferk_flush.lo: src/libstddjb/iobufferk_flush.c src/include/skalibs/iobuffer.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h
-src/libstddjb/iobufferk_init.o src/libstddjb/iobufferk_init.lo: src/libstddjb/iobufferk_init.c src/include/skalibs/djbunix.h src/include/skalibs/iobuffer.h src/include/skalibs/sysdeps.h
-src/libstddjb/iobufferk_isworking.o src/libstddjb/iobufferk_isworking.lo: src/libstddjb/iobufferk_isworking.c src/include/skalibs/iobuffer.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h
-src/libstddjb/iobufferu_fill.o src/libstddjb/iobufferu_fill.lo: src/libstddjb/iobufferu_fill.c src/include/skalibs/buffer.h src/include/skalibs/iobuffer.h
-src/libstddjb/iobufferu_finish.o src/libstddjb/iobufferu_finish.lo: src/libstddjb/iobufferu_finish.c src/include/skalibs/alloc.h src/include/skalibs/iobuffer.h
-src/libstddjb/iobufferu_flush.o src/libstddjb/iobufferu_flush.lo: src/libstddjb/iobufferu_flush.c src/include/skalibs/buffer.h src/include/skalibs/iobuffer.h
-src/libstddjb/iobufferu_init.o src/libstddjb/iobufferu_init.lo: src/libstddjb/iobufferu_init.c src/include/skalibs/alloc.h src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/iobuffer.h
src/libstddjb/iopause.o src/libstddjb/iopause.lo: src/libstddjb/iopause.c src/include/skalibs/config.h src/include/skalibs/iopause.h src/include/skalibs/sysdeps.h
src/libstddjb/iopause_poll.o src/libstddjb/iopause_poll.lo: src/libstddjb/iopause_poll.c src/include/skalibs/iopause.h src/include/skalibs/tai.h
src/libstddjb/iopause_ppoll.o src/libstddjb/iopause_ppoll.lo: src/libstddjb/iopause_ppoll.c src/include/skalibs/iopause.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h
index 45c5eb0..2d98074 100644
--- a/src/include/skalibs/djbunix.h
+++ b/src/include/skalibs/djbunix.h
@@ -27,8 +27,8 @@ extern void fd_close (int) ;
extern int fd_chmod (int, unsigned int) ;
extern int fd_chown (int, uid_t, gid_t) ;
extern int fd_sync (int) ;
-extern int fd_cat (int, int) ;
-extern size_t fd_catn (int, int, size_t) ;
+extern off_t fd_cat (int, int) ;
+extern off_t fd_catn (int, int, off_t) ;
extern int fd_ensure_open (int, int) ;
#define fd_sanitize() (fd_ensure_open(0, 0) && fd_ensure_open(1, 1) && fd_ensure_open(2, 1))
extern void fd_shutdown (int, int) ;
diff --git a/src/include/skalibs/iobuffer.h b/src/include/skalibs/iobuffer.h
deleted file mode 100644
index 3259c03..0000000
--- a/src/include/skalibs/iobuffer.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* ISC license. */
-
-#ifndef SKALIBS_IOBUFFER_H
-#define SKALIBS_IOBUFFER_H
-
-#define IOBUFFER_SIZE 65536U
-
- /* iobufferu */
-
-#include <sys/types.h>
-
-#include <skalibs/buffer.h>
-#include <skalibs/djbunix.h>
-
-#define IOBUFFERU_SIZE (IOBUFFER_SIZE+1)
-
-typedef struct iobufferu_s iobufferu, *iobufferu_ref ;
-struct iobufferu_s
-{
- buffer b[2] ;
- char *buf ;
-} ;
-
-extern int iobufferu_init (iobufferu *, int, int) ;
-extern ssize_t iobufferu_fill (iobufferu *) ;
-extern int iobufferu_flush (iobufferu *) ;
-extern void iobufferu_finish (iobufferu *) ;
-
-#define iobufferu_len(u) buffer_len(&(u)->b[0])
-#define iobufferu_available(u) buffer_available(&(u)->b[1])
-#define iobufferu_isempty(u) buffer_isempty(&(u)->b[0])
-#define iobufferu_isfull(u) buffer_isfull(&(u)->b[1])
-#define iobufferu_fd(u, h) buffer_fd((u)->b[h])
-#define iobufferu_isreadable(u) iobufferu_available(u)
-#define iobufferu_iswritable(u) iobufferu_len(u)
-#define iobufferu_nonblock(u, h) ndelay_on(iobufferu_fd(u, h))
-#define iobufferu_block(u, h) ndelay_off(iobufferu_fd(u, h))
-#define iobufferu_nbstate(u, h, j) (j ? iobufferu_nonblock(u, h) : iobufferu_block(u, h))
-
-
- /* iobufferk */
-
-#define IOBUFFERK_SIZE IOBUFFER_SIZE
-
-typedef struct iobufferk_s iobufferk, *iobufferk_ref ;
-struct iobufferk_s
-{
- int fd[2] ;
- int p[2] ;
- unsigned int n ;
- unsigned int type : 2 ;
- unsigned int nb : 2 ;
-} ;
-
-typedef int iobufferk_output_func (iobufferk *) ;
-typedef iobufferk_output_func *iobufferk_output_func_ref ;
-typedef ssize_t iobufferk_input_func (iobufferk *) ;
-typedef iobufferk_input_func *iobufferk_input_func_ref ;
-typedef void iobufferk_finish_func (iobufferk *) ;
-typedef iobufferk_finish_func *iobufferk_finish_func_ref ;
-
-extern iobufferk_output_func iobufferk_isworking ;
-
-extern int iobufferk_init (iobufferk *, int, int) ;
-extern iobufferk_input_func_ref const iobufferk_fill_f[4] ;
-extern iobufferk_output_func_ref const iobufferk_flush_f[4] ;
-extern iobufferk_finish_func_ref const iobufferk_finish_f[4] ;
-
-#define iobufferk_fill(k) (*iobufferk_fill_f[(k)->type])(k)
-#define iobufferk_flush(k) (*iobufferk_flush_f[(k)->type])(k)
-#define iobufferk_finish(k) (*iobufferk_finish_f[(k)->type])(k)
-#define iobufferk_len(k) ((k)->n)
-#define iobufferk_available(k) (IOBUFFERK_SIZE - (k)->n)
-#define iobufferk_isempty(k) (!iobufferk_len(k))
-#define iobufferk_isfull(k) (!iobufferk_available(k))
-#define iobufferk_fd(k, h) ((k)->fd[h])
-#define iobufferk_isreadable(k) iobufferk_available(k)
-#define iobufferk_iswritable(k) iobufferk_len(k)
-#define iobufferk_nonblock(k, h) ((k)->nb |= (1 << (h)), 0)
-#define iobufferk_block(k, h) ((k)->nb &= (3 - (1 << (h))), 0)
-#define iobufferk_nbstate(k, h, j) (j ? iobufferk_nonblock(k, h) : iobufferk_block(k, h))
-
-
- /* iobuffer */
-
-typedef union iobufferku_u iobufferku, *iobufferku_ref ;
-union iobufferku_u
-{
- iobufferk k ;
- iobufferu u ;
-} ;
-
-typedef struct iobuffer_s iobuffer, *iobuffer_ref ;
-struct iobuffer_s
-{
- iobufferku x ;
- unsigned int isk : 1 ;
-} ;
-
-extern int iobuffer_ufromk (iobufferu *, iobufferk *) ;
-extern int iobuffer_kfromu (iobufferk *, iobufferu *) ;
-extern int iobuffer_salvage (iobuffer *) ;
-
-extern int iobuffer_init (iobuffer *, int, int) ;
-extern ssize_t iobuffer_fill (iobuffer *) ;
-extern int iobuffer_flush (iobuffer *) ;
-
-#define iobuffer_finish(b) ((b)->isk ? iobufferk_finish(&(b)->x.k) : iobufferu_finish(&(b)->x.u))
-#define iobuffer_len(b) ((b)->isk ? iobufferk_len(&(b)->x.k) : iobufferu_len(&(b)->x.u))
-#define iobuffer_available(b) ((b)->isk ? iobufferk_available(&(b)->x.k) : iobufferu_available(&(b)->x.u))
-#define iobuffer_isempty(b) ((b)->isk ? iobufferk_isempty(&(b)->x.k) : iobufferu_isempty(&(b)->x.u))
-#define iobuffer_isfull(b) ((b)->isk ? iobufferk_isfull(&(b)->x.k) : iobufferu_isfull(&(b)->x.u))
-#define iobuffer_fd(b, h) ((b)->isk ? iobufferk_fd(&(b)->x.k, h) : iobufferu_fd(&(b)->x.u, h))
-#define iobuffer_isreadable(b) ((b)->isk ? iobufferk_isreadable(&(b)->x.k) : iobufferu_isreadable(&(b)->x.u))
-#define iobuffer_iswritable(b) ((b)->isk ? iobufferk_iswritable(&(b)->x.k) : iobufferu_iswritable(&(b)->x.u))
-#define iobuffer_nonblock(b, h) ((b)->isk ? iobufferk_nonblock(&(b)->x.k, h) : iobufferu_nonblock(&(b)->x.u, h))
-#define iobuffer_block(b, h) ((b)->isk ? iobufferk_block(&(b)->x.k, h) : iobufferu_block(&(b)->x.u, h))
-#define iobuffer_nbstate(b, h, j) ((b)->isk ? iobufferk_nbstate(&(b)->x.k, h, j) : iobufferu_nbstate(&(b)->x.u, h, j))
-
-#endif
diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h
index ad80a66..4f0d739 100644
--- a/src/include/skalibs/stddjb.h
+++ b/src/include/skalibs/stddjb.h
@@ -34,7 +34,6 @@
#include <skalibs/gccattributes.h>
#include <skalibs/genalloc.h>
#include <skalibs/genwrite.h>
-#include <skalibs/iobuffer.h>
#include <skalibs/iopause.h>
#include <skalibs/lolstdio.h>
#include <skalibs/netstring.h>
diff --git a/src/libstddjb/fd_cat.c b/src/libstddjb/fd_cat.c
index 4acc08a..d9d5c99 100644
--- a/src/libstddjb/fd_cat.c
+++ b/src/libstddjb/fd_cat.c
@@ -1,27 +1,23 @@
/* ISC license. */
-#include <sys/types.h>
+#include <unistd.h>
-#include <skalibs/iobuffer.h>
+#include <skalibs/allreadwrite.h>
#include <skalibs/djbunix.h>
-int fd_cat (int from, int to)
+#define BSIZE 65536
+
+off_t fd_cat (int from, int to)
{
- iobuffer b ;
- size_t n = 0 ;
- if (!iobuffer_init(&b, from, to)) return -1 ;
+ off_t n = 0 ;
+ char buf[BSIZE] ;
for (;;)
{
- ssize_t r = iobuffer_fill(&b) ;
- if (r < 0) goto err ;
- else if (!r) break ;
- if (!iobuffer_flush(&b)) goto err ;
+ ssize_t r = fd_read(from, buf, BSIZE) ;
+ if (r == -1) return -1 ;
+ if (!r) break ;
+ if (allwrite(to, buf, r) < r) return -1 ;
n += r ;
}
- iobuffer_finish(&b) ;
return n ;
-
- err:
- iobuffer_finish(&b) ;
- return -1 ;
}
diff --git a/src/libstddjb/fd_catn.c b/src/libstddjb/fd_catn.c
index c2ddd7a..182a054 100644
--- a/src/libstddjb/fd_catn.c
+++ b/src/libstddjb/fd_catn.c
@@ -1,39 +1,28 @@
/* ISC license. */
-#include <sys/types.h>
+#include <unistd.h>
#include <errno.h>
+
#include <skalibs/allreadwrite.h>
-#include <skalibs/iobuffer.h>
#include <skalibs/djbunix.h>
-size_t fd_catn (int from, int to, size_t n)
+#define BSIZE 65536
+
+off_t fd_catn (int from, int to, off_t n)
{
- size_t w = 0 ;
- if (n >= IOBUFFER_SIZE)
+ off_t w = 0 ;
+ char buf[BSIZE] ;
+ while (n >= BSIZE)
{
- iobuffer b ;
- if (!iobuffer_init(&b, from, to)) return 0 ;
- while (n >= IOBUFFER_SIZE)
- {
- ssize_t r = iobuffer_fill(&b) ;
- if (r <= 0)
- {
- iobuffer_finish(&b) ;
- if (!r) errno = EPIPE ;
- return w ;
- }
- if (!iobuffer_flush(&b))
- {
- iobuffer_finish(&b) ;
- return w ;
- }
- n -= r ; w += r ;
- }
- iobuffer_finish(&b) ;
+ ssize_t r = fd_read(from, buf, BSIZE) ;
+ if (r == -1) return w ;
+ if (!r) return (errno = EPIPE, w) ;
+ if (allwrite(to, buf, r) < r) return w ;
+ n -= r ; w += r ;
}
+ if (n)
{
- char buf[n] ;
size_t r = allread(from, buf, n) ;
size_t v = 0 ;
if (r) v = allwrite(to, buf, r) ;
diff --git a/src/libstddjb/iobuffer_fill.c b/src/libstddjb/iobuffer_fill.c
deleted file mode 100644
index b99e22d..0000000
--- a/src/libstddjb/iobuffer_fill.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-ssize_t iobuffer_fill (iobuffer_ref b)
-{
- if (b->isk)
- {
- ssize_t r = iobufferk_fill(&b->x.k) ;
- if (r >= 0 || errno != ENOSYS || !iobuffer_salvage(b)) return r ;
- }
- return iobufferu_fill(&b->x.u) ;
-}
diff --git a/src/libstddjb/iobuffer_flush.c b/src/libstddjb/iobuffer_flush.c
deleted file mode 100644
index 93efc9d..0000000
--- a/src/libstddjb/iobuffer_flush.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-int iobuffer_flush (iobuffer *b)
-{
- if (b->isk)
- {
- if (iobufferk_flush(&b->x.k)) return 1 ;
- if (errno != ENOSYS || !iobuffer_salvage(b)) return 0 ;
- }
- return iobufferu_flush(&b->x.u) ;
-}
diff --git a/src/libstddjb/iobuffer_init.c b/src/libstddjb/iobuffer_init.c
deleted file mode 100644
index fc699a0..0000000
--- a/src/libstddjb/iobuffer_init.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/iobuffer.h>
-
-int iobuffer_init (iobuffer *b, int fdin, int fdout)
-{
- if (!iobufferk_init(&b->x.k, fdin, fdout)) goto user ;
- if (!iobufferk_isworking(&b->x.k)) goto fk ;
- b->isk = 1 ;
- return 1 ;
- fk:
- iobufferk_finish(&b->x.k) ;
- user:
- if (!iobufferu_init(&b->x.u, fdin, fdout)) return 0 ;
- b->isk = 0 ;
- return 1 ;
-}
diff --git a/src/libstddjb/iobuffer_kfromu.c b/src/libstddjb/iobuffer_kfromu.c
deleted file mode 100644
index 91525a5..0000000
--- a/src/libstddjb/iobuffer_kfromu.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/sysdeps.h>
-
-#ifdef SKALIBS_HASSPLICE
-
-#include <skalibs/nonposix.h>
-#include <fcntl.h>
-#include <sys/uio.h>
-#include <skalibs/buffer.h>
-#include <skalibs/iobuffer.h>
-
-int iobuffer_kfromu (iobufferk *k, iobufferu *u)
-{
- struct iovec v[2] ;
- ssize_t r ;
- buffer_rpeek(&u->b[0], v) ;
- r = vmsplice(k->p[1], v, 2, 0) ;
- if (r < 0) return 0 ;
- k->n += r ;
- buffer_rseek(&u->b[0], r) ;
- u->b[1].c.p = u->b[0].c.p ;
- return iobufferu_isempty(u) ;
-}
-
-#else
-
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-int iobuffer_kfromu (iobufferk *k, iobufferu *u)
-{
- (void)k ;
- (void)u ;
- return (errno = ENOSYS, 0) ;
-}
-
-#endif
diff --git a/src/libstddjb/iobuffer_salvage.c b/src/libstddjb/iobuffer_salvage.c
deleted file mode 100644
index 6f2c5d8..0000000
--- a/src/libstddjb/iobuffer_salvage.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/iobuffer.h>
-
-int iobuffer_salvage (iobuffer *b)
-{
- iobufferu u ;
- if (!b->isk) return 1 ;
- if (!iobufferu_init(&u, b->x.k.fd[0], b->x.k.fd[1])) return 0 ;
- if (!iobuffer_ufromk(&u, &b->x.k)) goto err ;
- iobufferk_finish(&b->x.k) ;
- b->x.u = u ;
- b->isk = 0 ;
- return 1 ;
-
-err:
- iobufferu_finish(&u) ;
- return 0 ;
-}
diff --git a/src/libstddjb/iobuffer_ufromk.c b/src/libstddjb/iobuffer_ufromk.c
deleted file mode 100644
index 940818d..0000000
--- a/src/libstddjb/iobuffer_ufromk.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/sysdeps.h>
-
-#ifdef SKALIBS_HASSPLICE
-
-#include <sys/types.h>
-#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)
- {
- ssize_t 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
diff --git a/src/libstddjb/iobufferk_fill.c b/src/libstddjb/iobufferk_fill.c
deleted file mode 100644
index c24ceba..0000000
--- a/src/libstddjb/iobufferk_fill.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/sysdeps.h>
-
-#ifdef SKALIBS_HASSPLICE
-
-#include <skalibs/nonposix.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-static ssize_t iobufferk_tee (iobufferk *k)
-{
- ssize_t r = tee(k->fd[0], k->fd[1], IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ;
- if (r > 0) k->n += r ;
- return r ;
-}
-
-static ssize_t iobufferk_splice (iobufferk *k)
-{
- ssize_t r = splice(k->fd[0], 0, k->fd[1], 0, IOBUFFERK_SIZE, k->nb ? SPLICE_F_NONBLOCK : 0) ;
- if (r > 0) k->n += r ;
- if ((r < 0) && (errno == EINVAL)) errno = ENOSYS ;
- return r ;
-}
-
-static ssize_t iobufferk_fill_3 (iobufferk *k)
-{
- ssize_t r = splice(k->fd[0], 0, k->p[1], 0, IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ;
- if (r > 0) k->n += r ;
- if ((r < 0) && (errno == EINVAL)) errno = ENOSYS ;
- return r ;
-}
-
-iobufferk_input_func_ref const iobufferk_fill_f[4] =
-{
- &iobufferk_tee, &iobufferk_splice, &iobufferk_splice, &iobufferk_fill_3
-} ;
-
-#else
-
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-static ssize_t iobufferk_inosys (iobufferk *k)
-{
- (void)k ;
- return (errno = ENOSYS, -1) ;
-}
-
-iobufferk_input_func_ref const iobufferk_fill_f[4] =
-{
- &iobufferk_inosys, &iobufferk_inosys, &iobufferk_inosys, &iobufferk_inosys
-} ;
-
-#endif
diff --git a/src/libstddjb/iobufferk_finish.c b/src/libstddjb/iobufferk_finish.c
deleted file mode 100644
index 1640836..0000000
--- a/src/libstddjb/iobufferk_finish.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/sysdeps.h>
-
-#ifdef SKALIBS_HASSPLICE
-
-#include <skalibs/djbunix.h>
-#include <skalibs/iobuffer.h>
-
-static void iobufferk_nop (iobufferk *k)
-{
- (void)k ;
-}
-
-static void iobufferk_finish_0 (iobufferk *k)
-{
- fd_close(k->p[1]) ;
-}
-
-static void iobufferk_finish_3 (iobufferk *k)
-{
- fd_close(k->p[1]) ;
- fd_close(k->p[0]) ;
-}
-
-iobufferk_finish_func_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_ref const iobufferk_finish_f[4] =
-{
- &iobufferk_nop, &iobufferk_nop, &iobufferk_nop, &iobufferk_nop
-} ;
-
-#endif
diff --git a/src/libstddjb/iobufferk_flush.c b/src/libstddjb/iobufferk_flush.c
deleted file mode 100644
index 3f8d657..0000000
--- a/src/libstddjb/iobufferk_flush.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/sysdeps.h>
-
-#ifdef SKALIBS_HASSPLICE
-
-#include <skalibs/nonposix.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-static int iobufferk_flush_0 (iobufferk *k)
-{
- while (k->n)
- {
- ssize_t r = splice(k->fd[0], 0, k->p[1], 0, k->n, 0) ;
- if (r < 0) return 0 ;
- else if (!r) break ;
- k->n -= r ;
- }
- return 1 ;
-}
-
-static int fakeflush (iobufferk *k)
-{
- k->n = 0 ;
- return 1 ;
-}
-
-static int iobufferk_flush_3 (iobufferk *k)
-{
- while (k->n)
- {
- ssize_t r = splice(k->p[0], 0, k->fd[1], 0, k->n, SPLICE_F_MORE | (k->nb & 2 ? SPLICE_F_NONBLOCK : 0)) ;
- if (r < 0)
- {
- if (errno == EINVAL) errno = ENOSYS ;
- return 0 ;
- }
- else if (!r) return (errno = EPIPE, 0) ;
- k->n -= r ;
- }
- return 1 ;
-}
-
-iobufferk_output_func_ref const iobufferk_flush_f[4] =
-{
- &iobufferk_flush_0, &fakeflush, &fakeflush, &iobufferk_flush_3
-} ;
-
-#else
-
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-static int iobufferk_onosys (iobufferk *k)
-{
- (void)k ;
- return (errno = ENOSYS, -1) ;
-}
-
-iobufferk_output_func_ref const iobufferk_flush_f[4] =
-{
- &iobufferk_onosys, &iobufferk_onosys, &iobufferk_onosys, &iobufferk_onosys
-} ;
-
-#endif
diff --git a/src/libstddjb/iobufferk_init.c b/src/libstddjb/iobufferk_init.c
deleted file mode 100644
index b7a91d7..0000000
--- a/src/libstddjb/iobufferk_init.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/sysdeps.h>
-
-#ifdef SKALIBS_HASSPLICE
-
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <skalibs/djbunix.h>
-#include <skalibs/iobuffer.h>
-
-static int iobufferk_init_0 (iobufferk *k)
-{
- int fd = openc_write("/dev/null") ;
- if (fd < 0) return 0 ;
- k->p[0] = -1 ;
- k->p[1] = fd ;
- return 1 ;
-}
-
-static int iobufferk_nofd (iobufferk *k)
-{
- k->p[0] = k->p[1] = -1 ;
- return 1 ;
-}
-
-static int iobufferk_init_3 (iobufferk *k)
-{
- return (pipecoe(k->p) >= 0) ;
-}
-
-static iobufferk_output_func_ref iobufferk_init_f[4] =
-{
- &iobufferk_init_0, &iobufferk_nofd, &iobufferk_nofd, &iobufferk_init_3
-} ;
-
-int iobufferk_init (iobufferk *k, int fdin, int fdout)
-{
- iobufferk tmp ;
- struct stat st ;
- int r ;
- if (fstat(fdin, &st) < 0) return 0 ;
- r = fcntl(fdin, F_GETFL) ;
- if (r < 0) return 0 ;
- tmp.type = !S_ISFIFO(st.st_mode) ;
- tmp.nb = !!(r & O_NONBLOCK) ;
- if (fstat(fdout, &st) < 0) return 0 ;
- r = fcntl(fdout, F_GETFL) ;
- if (r < 0) return 0 ;
- tmp.type |= (!S_ISFIFO(st.st_mode) << 1) ;
- tmp.nb |= (r & O_NONBLOCK) ? 2 : 0 ;
- tmp.fd[0] = fdin ;
- tmp.fd[1] = fdout ;
- tmp.n = 0 ;
- if (!(*iobufferk_init_f[tmp.type])(&tmp)) return 0 ;
- *k = tmp ;
- return 1 ;
-}
-
-#else
-
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-int iobufferk_init (iobufferk *k, int fdin, int fdout)
-{
- (void)k ;
- (void)fdin ;
- (void)fdout ;
- return (errno = ENOSYS, 0) ;
-}
-
-#endif
diff --git a/src/libstddjb/iobufferk_isworking.c b/src/libstddjb/iobufferk_isworking.c
deleted file mode 100644
index 119d130..0000000
--- a/src/libstddjb/iobufferk_isworking.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* 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 *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
-
- 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 *k)
-{
- (void)k ;
- return 0 ;
-}
-
-#endif
diff --git a/src/libstddjb/iobufferu_fill.c b/src/libstddjb/iobufferu_fill.c
deleted file mode 100644
index 7867444..0000000
--- a/src/libstddjb/iobufferu_fill.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/buffer.h>
-#include <skalibs/iobuffer.h>
-
-ssize_t iobufferu_fill (iobufferu *b)
-{
- ssize_t r = buffer_fill(&b->b[0]) ;
- b->b[1].c.n = b->b[0].c.n ;
- return r ;
-}
diff --git a/src/libstddjb/iobufferu_finish.c b/src/libstddjb/iobufferu_finish.c
deleted file mode 100644
index 612ec18..0000000
--- a/src/libstddjb/iobufferu_finish.c
+++ /dev/null
@@ -1,9 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/alloc.h>
-#include <skalibs/iobuffer.h>
-
-void iobufferu_finish (iobufferu *b)
-{
- alloc_free(b->buf) ;
-}
diff --git a/src/libstddjb/iobufferu_flush.c b/src/libstddjb/iobufferu_flush.c
deleted file mode 100644
index ad0fd9e..0000000
--- a/src/libstddjb/iobufferu_flush.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/buffer.h>
-#include <skalibs/iobuffer.h>
-
-int iobufferu_flush (iobufferu *b)
-{
- int r = buffer_flush(&b->b[1]) ;
- b->b[0].c.p = b->b[1].c.p ;
- return r ;
-}
diff --git a/src/libstddjb/iobufferu_init.c b/src/libstddjb/iobufferu_init.c
deleted file mode 100644
index affd01b..0000000
--- a/src/libstddjb/iobufferu_init.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/alloc.h>
-#include <skalibs/allreadwrite.h>
-#include <skalibs/buffer.h>
-#include <skalibs/iobuffer.h>
-
-int iobufferu_init (iobufferu *b, int fdin, int fdout)
-{
- char *x = alloc(IOBUFFERU_SIZE) ;
- if (!x) return 0 ;
- b->buf = x ;
- buffer_init(&b->b[0], &fd_readv, fdin, x, IOBUFFERU_SIZE) ;
- buffer_init(&b->b[1], &fd_writev, fdout, x, IOBUFFERU_SIZE) ;
- return 1 ;
-}