X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/blobdiff_plain/a6ae4dd126e7b2b678e0db31b68bba51311282cc..9311c2e7ce657110da33c9bc5ebc529b320484b9:/src/fops.c diff --git a/src/fops.c b/src/fops.c index 2ae6c61..2a3db82 100644 --- a/src/fops.c +++ b/src/fops.c @@ -66,7 +66,18 @@ static int pipe_seek(void *handle, long offset, int whence) struct lbx_pipe_state *state = handle; long distance; - distance = offset - state->offset; + switch (whence) { + case SEEK_SET: + distance = offset - state->offset; + break; + case SEEK_CUR: + distance = offset; + break; + case SEEK_END: + distance = -1; + break; + } + if (distance < 0) return -1; @@ -104,3 +115,30 @@ const struct lbx_file_ops lbx_pipe_fops = { .tell = pipe_tell, .eof = pipe_eof, }; + +static size_t lbx_read(void *buf, size_t size, void *handle) +{ + return lbx_file_read(handle, buf, size); +} + +static int lbx_seek(void *handle, long offset, int whence) +{ + return lbx_file_seek(handle, offset, whence); +} + +static long lbx_tell(void *handle) +{ + return lbx_file_tell(handle); +} + +static int lbx_eof(void *handle) +{ + return lbx_file_eof(handle); +} + +const struct lbx_file_ops lbx_arch_fops = { + .read = lbx_read, + .seek = lbx_seek, + .tell = lbx_tell, + .eof = lbx_eof, +};