From d65a3ae8790ae28a90f0ebcf0bc4dc078c67dc35 Mon Sep 17 00:00:00 2001 From: jakob Date: Sun, 19 Feb 2017 20:49:43 -0500 Subject: Implemented eliF parsing. --- src/io.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/io.c') diff --git a/src/io.c b/src/io.c index be894dd..c9627d3 100644 --- a/src/io.c +++ b/src/io.c @@ -18,6 +18,7 @@ along with Nekopack. If not, see . */ #include +#include #include #include @@ -86,9 +87,21 @@ size_t stream_tell(struct stream *s) { } -/* Sets the stream's position indicator to the given `pos`. */ -void stream_seek(struct stream *s, size_t pos) { - s->_cur = s->_start + pos; +/* Sets the stream's position indicator to the given `pos`. If `whence` + is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to + the start of the file, the current position indicator, or + end-of-file, respectively. */ +void stream_seek(struct stream *s, size_t pos, int whence) { + switch (whence) { + case SEEK_SET: + s->_cur = s->_start + pos; + break; + case SEEK_CUR: + s->_cur += pos; + break; + case SEEK_END: + s->_cur = s->_start + s->len - pos; + } } -- cgit v1.3