aboutsummaryrefslogtreecommitdiff
path: root/src/bufio/impl.h
blob: f5c3bcfe1c4dddcadf5c51871aac03110abbfddc (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
#pragma once

#include <u.h>
#include <io.h>
#include <bufio.h>

enum
{
    BUF·max    = 4 * 8096,
    BUF·size   = 4 * 4096,
    BUF·ungets = 8,
    BUF·err    = -1,
    BUF·eof    = +1,
};

typedef struct Buffer
{
    uint8 eof;
    int64 off;
    int64 size;

    byte* base;
    byte* pos;
    byte* end;
    byte  b[];
} Buffer;

void* newbuffer(uintptr off, uintptr size);

struct bufio·Scanner
{
    io·Reader r;
    Buffer    buf;
};