aboutsummaryrefslogtreecommitdiff
path: root/include/libn.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libn.h')
-rw-r--r--include/libn.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/include/libn.h b/include/libn.h
index c8d510f..67d131d 100644
--- a/include/libn.h
+++ b/include/libn.h
@@ -107,6 +107,48 @@ vlong io·write(Stream *s, int sz, int n, void *buf);
int io·flush(Stream *s);
int io·seek(Stream *s, long off, enum SeekPos origin);
+/* Generic I/O interfaces */
+
+typedef struct io·Reader
+{
+ int (*read)(int n, void *buf);
+};
+
+typedef struct io·Peeker
+{
+ byte (*get)(void);
+ error (*unget)(byte);
+};
+
+typedef struct io·FullReader
+{
+ io·Reader;
+ io·Peeker;
+} io·FullReader;
+
+typedef struct io·Writer
+{
+ int (*write)(int n, void *buf);
+} io·Writer;
+
+typedef struct io·Putter
+{
+ error (*put)(byte);
+ int (*putstr)(string);
+} io·Putter;
+
+typedef struct io·FullWriter
+{
+ io·Writer;
+ io·Putter;
+} io·FullWriter;
+
+typedef struct io·ReadWriter
+{
+ io·Reader;
+ io·Writer;
+} io·ReadWriter;
+
// -----------------------------------------------------------------------------
// Buffered I/O