From 788ddbd8e113cd4f9694aee779c5b5dcca26e30b Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Sat, 25 Apr 2020 11:38:29 -0700 Subject: feat: updated fasta code to allow for iteration --- include/libn.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'include/libn.h') diff --git a/include/libn.h b/include/libn.h index 43600c0..99e4fdb 100644 --- a/include/libn.h +++ b/include/libn.h @@ -113,6 +113,8 @@ error coro·free(Coro *c); // I/O typedef FILE Stream; +typedef struct stat io·Stat; + enum SeekPos { seek·CUR = SEEK_CUR, @@ -121,11 +123,13 @@ enum SeekPos }; Stream *io·open(byte *name, byte *mode); +int io·fd(Stream *s); +error io·stat(Stream *s, io·Stat *buf); error io·close(Stream *s); byte io·getbyte(Stream *s); error io·ungetbyte(Stream *s, byte c); int io·read(Stream *s, int sz, int n, void *buf); -int io·readln(Stream *s, int n, byte* buf); +int io·readln(Stream *s, int n, byte *buf); error io·putbyte(Stream *s, byte c); int io·putstring(Stream *s, string str); int io·write(Stream *s, int sz, int n, void *buf); @@ -139,6 +143,11 @@ typedef struct io·Reader int (*read)(void*, int sz, int n, void *buf); } io·Reader; +typedef struct io·LineReader +{ + int (*readln)(void*, int n, void *buf); +} io·LineReader; + typedef struct io·Peeker { byte (*get)(void*); @@ -174,6 +183,18 @@ typedef struct io·ReadWriter io·Writer; } io·ReadWriter; +// ----------------------------------------------------------------------------- +// memory mapped files + +typedef struct mmap·Reader +{ + vlong len; + void* buf; +} mmap·Reader; + +mmap·Reader mmap·open(byte *name); +error mmap·close(mmap·Reader rdr); + // ----------------------------------------------------------------------------- // libflate // NOTE: Experimental! -- cgit v1.2.1