aboutsummaryrefslogtreecommitdiff
path: root/sys/libn/bufio.c
blob: 6b1576029e441108ff98c01bfd533afa3eaf8bb9 (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
#include <u.h>
#include <libn.h>

enum
{
    BUF·size   = 8 * 2048,
    BUF·ungets = 8,

    BUF·bad = -2,
    BUF·eof = -1,

    BUF·inactive = 0,
    BUF·rdractive,
    BUF·wtractive,

    BUF·END,
} bmode;

typedef struct Buffer
{
    uint8 state;
    vlong off;
    vlong size;

    byte *bbuf, *ebuf;
    byte  b[BUF·size + BUF·ungets];
} Buffer;

struct bufio·Stream
{
    Stream    *s;
    Buffer    buf;
};