From 690f160e36849a41199023c5addd54afd00f01fd Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sun, 7 Feb 2010 17:05:25 -0500 Subject: [PATCH] liblbx: Add file operations for handling LBX archive members. This allows, for example, the image handling code to read directly from the archive. --- src/fops.c | 27 +++++++++++++++++++++++++++ src/lbx.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/src/fops.c b/src/fops.c index 834c8b2..2a3db82 100644 --- a/src/fops.c +++ b/src/fops.c @@ -115,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, +}; diff --git a/src/lbx.h b/src/lbx.h index 72532aa..29a4083 100644 --- a/src/lbx.h +++ b/src/lbx.h @@ -31,6 +31,9 @@ extern const struct lbx_file_ops lbx_default_fops; /* I/O operations for un-seekable files (e.g. pipes). */ extern const struct lbx_file_ops lbx_pipe_fops; +/* I/O operations for LBX archive members. */ +extern const struct lbx_file_ops lbx_arch_fops; + /* Opaque */ typedef struct lbx_state LBX; typedef struct lbx_file_state LBXfile; -- 2.43.2