From 4fbf50ddfeeb0e9d99d271e31dd35d545fb42ab6 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 21 Apr 2020 10:40:03 -0700 Subject: feat: added wrapper for io --- sys/libn/bufio.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 sys/libn/bufio.c (limited to 'sys/libn/bufio.c') 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 +#include + +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; +}; -- cgit v1.2.1