diff options
Diffstat (limited to 'include/libn.h')
-rw-r--r-- | include/libn.h | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/include/libn.h b/include/libn.h index aad359e..64e2e70 100644 --- a/include/libn.h +++ b/include/libn.h @@ -11,9 +11,9 @@ #include <stdio.h> #include <unistd.h> +#include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> -#include <fcntl.h> // ---------------------------------------------------------------------------- // Dynamic array. @@ -50,15 +50,16 @@ void _bufpop(void*, int, vlong); // ----------------------------------------------------------------------------- // Co-routines -typedef struct coro coro; +typedef struct Coro Coro; -coro* coro·new(uintptr stk, uintptr (*func)(coro*, uintptr)); -uintptr coro·yield(coro *c, uintptr arg); -error coro·free(coro *c); +Coro* coro·new(uintptr stk, uintptr (*func)(Coro*, uintptr)); +uintptr coro·yield(Coro *c, uintptr arg); +error coro·free(Coro *c); // ----------------------------------------------------------------------------- // Strings +// TODO(nnoll): Move here? #include ".include/str.h" // ----------------------------------------------------------------------------- @@ -67,6 +68,30 @@ error coro·free(coro *c); #include ".include/map.h" // ----------------------------------------------------------------------------- +// I/O + +typedef FILE Stream; +enum SeekPos +{ + seek·CUR = SEEK_CUR, + seek·SET = SEEK_SET, + seek·END = SEEK_END +}; + +Stream *io·open(byte *name, byte *mode); +error io·close(Stream *s); +byte io·getbyte(Stream *s); +vlong io·read(Stream *s, int sz, int n, void *buf); +int io·readln(Stream *s, int n, byte* buf); +error io·putbyte(Stream *s, byte c); +int io·putstring(Stream *s, string str); +vlong io·write(Stream *s, int sz, int n, void *buf); +int io·seek(Stream *s, long off, enum SeekPos origin); + +// ----------------------------------------------------------------------------- +// Buffered I/O + +// ----------------------------------------------------------------------------- // Error handling functions. void errorf(const byte* fmt, ...); |