From ba99ef34e7b073c03519ef74f017091de6c9bee8 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 12 Jun 2023 21:21:40 +0200 Subject: Move sqfs_istream_t & sqfs_ostream_t into libsquashfs For now, only the interfaces and helper functions are moved, the concrete implementations remain in libio. Signed-off-by: David Oberhollenzer --- include/io/istream.h | 102 --------------------------------------------------- 1 file changed, 102 deletions(-) (limited to 'include/io/istream.h') diff --git a/include/io/istream.h b/include/io/istream.h index f4ffcb2..f41be2e 100644 --- a/include/io/istream.h +++ b/include/io/istream.h @@ -8,66 +8,6 @@ #define IO_ISTREAM_H #include "sqfs/predef.h" -#include "io/ostream.h" - -typedef struct sqfs_istream_t sqfs_istream_t; - -/** - * @interface sqfs_istream_t - * - * @extends sqfs_object_t - * - * @brief A sequential, read-only data stream. - */ -struct sqfs_istream_t { - sqfs_object_t base; - - /** - * @brief Peek into the data buffered in an istream - * - * If the internal buffer is empty, the function tries to fetch more, - * which can block. It returns a positive return code if there is no - * more data to be read, a negative error code if reading failed. Since - * this and other functions can alter the buffer pointer and contents, - * do not store the pointers returned here across function calls. - * - * Higher level functions like @ref istream_read (providing a - * Unix read() style API) are built on top of this primitive. - * - * @param strm A pointer to an sqfs_istream_t implementation. - * @param out Returns a pointer into an internal buffer on success. - * @param size Returns the number of bytes available in the buffer. - * @param want A number of bytes that the reader would like to have. - * If there is less than this available, the implementation - * can choose to do a blocking precache. - * - * @return Zero on success, a negative error code on failure, - * a postive number on EOF. - */ - int (*get_buffered_data)(sqfs_istream_t *strm, const sqfs_u8 **out, - size_t *size, size_t want); - - /** - * @brief Mark a section of the internal buffer of an istream as used - * - * This marks the first `count` bytes of the internal buffer as used, - * forcing get_buffered_data to return data afterwards and potentially - * try to load more data. - * - * @param strm A pointer to an sqfs_istream_t implementation. - * @param count The number of bytes used up. - */ - void (*advance_buffer)(sqfs_istream_t *strm, size_t count); - - /** - * @brief Get the underlying filename of an input stream. - * - * @param strm The input stream to get the filename from. - * - * @return A string holding the underlying filename. - */ - const char *(*get_filename)(sqfs_istream_t *strm); -}; enum { ISTREAM_LINE_LTRIM = 0x01, @@ -108,48 +48,6 @@ extern "C" { SQFS_INTERNAL int istream_get_line(sqfs_istream_t *strm, char **out, size_t *line_num, int flags); -/** - * @brief Read data from an input stream - * - * @memberof sqfs_istream_t - * - * @param strm A pointer to an input stream. - * @param data A buffer to read into. - * @param size The number of bytes to read into the buffer. - * - * @return The number of bytes actually read on success, -1 on failure, - * 0 on end-of-file. - */ -SQFS_INTERNAL sqfs_s32 istream_read(sqfs_istream_t *strm, - void *data, size_t size); - -/** - * @brief Skip over a number of bytes in an input stream. - * - * @memberof sqfs_istream_t - * - * @param strm A pointer to an input stream. - * @param size The number of bytes to seek forward. - * - * @return Zero on success, -1 on failure. - */ -SQFS_INTERNAL int istream_skip(sqfs_istream_t *strm, sqfs_u64 size); - -/** - * @brief Dump data from an input stream to an output stream - * - * @memberof sqfs_istream_t - * - * @param in A pointer to an input stream to read from. - * @param out A pointer to an output stream to append to. - * @param size The number of bytes to copy over. - * - * @return The number of bytes copied on success, -1 on failure, - * 0 on end-of-file. - */ -SQFS_INTERNAL sqfs_s32 istream_splice(sqfs_istream_t *in, sqfs_ostream_t *out, - sqfs_u32 size); - #ifdef __cplusplus } #endif -- cgit v1.2.3