diff options
| author | jakob <jakob@memeware.net> | 2017-02-19 20:49:43 -0500 |
|---|---|---|
| committer | jakob <jakob@memeware.net> | 2017-02-19 20:49:43 -0500 |
| commit | d65a3ae8790ae28a90f0ebcf0bc4dc078c67dc35 (patch) | |
| tree | 3eb2ad7f78f55cde5b809bc75904b36c5a747502 /src/io.c | |
| parent | 32fb7b11d83138cc288d62c1f1674d95cc94e8de (diff) | |
Implemented eliF parsing.
Diffstat (limited to 'src/io.c')
| -rw-r--r-- | src/io.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -18,6 +18,7 @@ along with Nekopack. If not, see <http://www.gnu.org/licenses/>. */ #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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; + } } |