aboutsummaryrefslogtreecommitdiff
path: root/include/io
diff options
context:
space:
mode:
Diffstat (limited to 'include/io')
-rw-r--r--include/io/istream.h21
1 files changed, 5 insertions, 16 deletions
diff --git a/include/io/istream.h b/include/io/istream.h
index fca1440..8e86891 100644
--- a/include/io/istream.h
+++ b/include/io/istream.h
@@ -20,10 +20,10 @@
typedef struct istream_t {
sqfs_object_t base;
- size_t buffer_used;
- const sqfs_u8 *buffer;
+ int (*get_buffered_data)(struct istream_t *strm, const sqfs_u8 **out,
+ size_t *size, size_t want);
- int (*precache)(struct istream_t *strm);
+ void (*advance_buffer)(struct istream_t *strm, size_t count);
const char *(*get_filename)(struct istream_t *strm);
} istream_t;
@@ -121,17 +121,7 @@ SQFS_INLINE const char *istream_get_filename(istream_t *strm)
SQFS_INLINE int istream_get_buffered_data(istream_t *strm, const sqfs_u8 **out,
size_t *size, size_t want)
{
- if (strm->buffer_used == 0 || strm->buffer_used < want) {
- int ret = strm->precache(strm);
- if (ret)
- return ret;
- if (strm->buffer_used == 0)
- return 1;
- }
-
- *out = strm->buffer;
- *size = strm->buffer_used;
- return 0;
+ return strm->get_buffered_data(strm, out, size, want);
}
/**
@@ -148,8 +138,7 @@ SQFS_INLINE int istream_get_buffered_data(istream_t *strm, const sqfs_u8 **out,
*/
SQFS_INLINE void istream_advance_buffer(istream_t *strm, size_t count)
{
- strm->buffer += count;
- strm->buffer_used -= count;
+ strm->advance_buffer(strm, count);
}
/**