diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-04-21 10:40:03 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-04-21 10:40:03 -0700 |
commit | 4fbf50ddfeeb0e9d99d271e31dd35d545fb42ab6 (patch) | |
tree | 2a9664a6c9d8aa57102bbe40a306fddf3d86ff2b /sys/libn/bufio.c | |
parent | 82885d35ea1b52982ebcf3a58e9d328cfa4e933a (diff) |
feat: added wrapper for io
Diffstat (limited to 'sys/libn/bufio.c')
-rw-r--r-- | sys/libn/bufio.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/libn/bufio.c b/sys/libn/bufio.c new file mode 100644 index 0000000..6b15760 --- /dev/null +++ b/sys/libn/bufio.c @@ -0,0 +1,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; +}; |