aboutsummaryrefslogtreecommitdiff
path: root/include/iobuf.h
blob: 79f5195282bf22cd7fb061e27417c91c9a1daa63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// iobuf.h --- Input/Output buffer                                     -*- C -*-
//
// Copyright (c) 2026 Martin Michalec <martin@michalec.dev>
//
// 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