]> git.draconx.ca Git - liblbx.git/commitdiff
liblbx: Add file operations for handling LBX archive members.
authorNick Bowler <nbowler@draconx.ca>
Sun, 7 Feb 2010 22:05:25 +0000 (17:05 -0500)
committerNick Bowler <nbowler@draconx.ca>
Mon, 8 Feb 2010 17:00:55 +0000 (12:00 -0500)
This allows, for example, the image handling code to read directly from
the archive.

src/fops.c
src/lbx.h

index 834c8b2e776ef0f7c22bdd0ff3b3cc080ced3e04..2a3db82854e56449ba63d100106ac442b2d0d01c 100644 (file)
@@ -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,
+};
index 72532aa96940bdf8b6081b76cb365f5fff85825b..29a4083982dcb549042abf04b4f2f388a976dbc0 100644 (file)
--- 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;