From f268a8871a061395633d943e6f177fa8f8008963 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sat, 25 Sep 2021 19:48:26 +0000 Subject: Axe iobuffer Signed-off-by: Laurent Bercot --- src/include/skalibs/djbunix.h | 4 +- src/include/skalibs/iobuffer.h | 120 ----------------------------------------- src/include/skalibs/stddjb.h | 1 - 3 files changed, 2 insertions(+), 123 deletions(-) delete mode 100644 src/include/skalibs/iobuffer.h (limited to 'src/include') 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 - -#include -#include - -#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 #include #include -#include #include #include #include -- cgit v1.2.3