From 03a8f91651ed26c3db97ec5e94834ba6eba54cc2 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Fri, 6 Nov 2026 05:52:23 +0300 Subject: feat(iobuf): add I/O buffer --- include/iobuf.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 include/iobuf.h (limited to 'include') diff --git a/include/iobuf.h b/include/iobuf.h new file mode 100644 index 0000000..79f5195 --- /dev/null +++ b/include/iobuf.h @@ -0,0 +1,40 @@ +// iobuf.h --- Input/Output buffer -*- C -*- +// +// Copyright (c) 2026 Martin Michalec +// +// SPDX-License-Identifier: MIT +// +// This file is part of COSMOS Codebase. +// +// Commentary: +// +// Code: + +#ifndef INCLUDED_COSMOS_IOBUF_H +#define INCLUDED_COSMOS_IOBUF_H + +#include "ms.h" + +struct iobuf { + u8 *beg; + u8 *rhead; + u8 *whead; + u8 *end; +}; + +struct iobuf iobuf_from (struct ms ms); +usz iobuf_sz (struct iobuf); +struct mv *iobuf_rmv (struct iobuf *); +struct ms *iobuf_wms (struct iobuf *); + +void iobuf_compact (struct iobuf *); + +#ifndef IOBUF_NO_UNISTD + +int iobuf_read (struct iobuf *, int fd); + +#endif // IOBUF_NO_UNISTD + +#endif // INCLUDED_COSMOS_IOBUF_H + +// iobuf.h ends here -- cgit v1.3.1