diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-12 20:14:44 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-15 13:38:25 +0200 |
commit | e811851deba9c45f3d9b3c5b4ad5eaa7945382d5 (patch) | |
tree | 4a5084324ab2a76d3c205f34bb0871de58ac192a | |
parent | 2694532a5479d157903b6c600d9b1d5c145a4e4c (diff) |
Mass rename istream_t/ostream_t with sqfs_ prefix
istream_t becomes sqfs_istream_t and ostream_t becomes sqfs_ostream_t
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
65 files changed, 224 insertions, 211 deletions
diff --git a/bin/gensquashfs/src/filemap_xattr.c b/bin/gensquashfs/src/filemap_xattr.c index 4adc24f..89624f4 100644 --- a/bin/gensquashfs/src/filemap_xattr.c +++ b/bin/gensquashfs/src/filemap_xattr.c @@ -159,7 +159,7 @@ xattr_open_map_file(const char *path) { struct XattrMap *map; size_t line_num = 1; char *p = NULL; - istream_t *file = istream_open_file(path); + sqfs_istream_t *file = istream_open_file(path); if (file == NULL) { return NULL; } diff --git a/bin/gensquashfs/src/fstree_from_file.c b/bin/gensquashfs/src/fstree_from_file.c index 325bce2..efb5d43 100644 --- a/bin/gensquashfs/src/fstree_from_file.c +++ b/bin/gensquashfs/src/fstree_from_file.c @@ -273,7 +273,8 @@ out_desc: return -1; } -int fstree_from_file_stream(fstree_t *fs, istream_t *fp, const char *basepath) +int fstree_from_file_stream(fstree_t *fs, sqfs_istream_t *fp, + const char *basepath) { const char *filename; size_t line_num = 1; @@ -309,7 +310,7 @@ fail_line: int fstree_from_file(fstree_t *fs, const char *filename, const char *basepath) { - istream_t *fp; + sqfs_istream_t *fp; int ret; fp = istream_open_file(filename); diff --git a/bin/gensquashfs/src/mkfs.c b/bin/gensquashfs/src/mkfs.c index b64a217..cdef359 100644 --- a/bin/gensquashfs/src/mkfs.c +++ b/bin/gensquashfs/src/mkfs.c @@ -137,7 +137,7 @@ static void override_owner_dfs(const options_t *opt, tree_node_t *n) int main(int argc, char **argv) { int status = EXIT_FAILURE; - istream_t *sortfile = NULL; + sqfs_istream_t *sortfile = NULL; void *sehnd = NULL; void *xattrmap = NULL; sqfs_writer_t sqfs; diff --git a/bin/gensquashfs/src/mkfs.h b/bin/gensquashfs/src/mkfs.h index 0a9a3b3..5c97750 100644 --- a/bin/gensquashfs/src/mkfs.h +++ b/bin/gensquashfs/src/mkfs.h @@ -104,7 +104,7 @@ void selinux_close_context_file(void *sehnd); int fstree_from_file(fstree_t *fs, const char *filename, const char *basepath); -int fstree_from_file_stream(fstree_t *fs, istream_t *file, +int fstree_from_file_stream(fstree_t *fs, sqfs_istream_t *file, const char *basepath); /* @@ -114,7 +114,7 @@ int fstree_from_file_stream(fstree_t *fs, istream_t *file, */ int fstree_from_dir(fstree_t *fs, dir_iterator_t *dir); -int fstree_sort_files(fstree_t *fs, istream_t *sortfile); +int fstree_sort_files(fstree_t *fs, sqfs_istream_t *sortfile); int glob_files(fstree_t *fs, const char *filename, size_t line_num, const dir_entry_t *ent, diff --git a/bin/gensquashfs/src/sort_by_file.c b/bin/gensquashfs/src/sort_by_file.c index e2b6338..6e96d5b 100644 --- a/bin/gensquashfs/src/sort_by_file.c +++ b/bin/gensquashfs/src/sort_by_file.c @@ -232,7 +232,7 @@ static void sort_file_list(fstree_t *fs) fs->files = out; } -int fstree_sort_files(fstree_t *fs, istream_t *sortfile) +int fstree_sort_files(fstree_t *fs, sqfs_istream_t *sortfile) { const char *filename; size_t line_num = 1; diff --git a/bin/gensquashfs/test/fstree_from_file.c b/bin/gensquashfs/test/fstree_from_file.c index e54111c..a5500dc 100644 --- a/bin/gensquashfs/test/fstree_from_file.c +++ b/bin/gensquashfs/test/fstree_from_file.c @@ -25,7 +25,7 @@ const char *listing = int main(int argc, char **argv) { fstree_defaults_t fsd; - istream_t *file; + sqfs_istream_t *file; tree_node_t *n; fstree_t fs; (void)argc; (void)argv; diff --git a/bin/gensquashfs/test/sort_file.c b/bin/gensquashfs/test/sort_file.c index af50260..063f95d 100644 --- a/bin/gensquashfs/test/sort_file.c +++ b/bin/gensquashfs/test/sort_file.c @@ -111,8 +111,8 @@ static int flags[] = { int main(int argc, char **argv) { + sqfs_istream_t *memstream; fstree_defaults_t fsd; - istream_t *memstream; tree_node_t *n; fstree_t fs; size_t i; diff --git a/bin/rdsquashfs/src/fill_files.c b/bin/rdsquashfs/src/fill_files.c index f482abe..e692ee3 100644 --- a/bin/rdsquashfs/src/fill_files.c +++ b/bin/rdsquashfs/src/fill_files.c @@ -136,7 +136,7 @@ static int gen_file_list_dfs(const sqfs_tree_node_t *n) static int fill_files(sqfs_data_reader_t *data, int flags) { int ret, openflags; - ostream_t *fp; + sqfs_ostream_t *fp; size_t i; openflags = SQFS_FILE_OPEN_OVERWRITE; diff --git a/bin/rdsquashfs/src/rdsquashfs.c b/bin/rdsquashfs/src/rdsquashfs.c index bdcc5a0..ad85e68 100644 --- a/bin/rdsquashfs/src/rdsquashfs.c +++ b/bin/rdsquashfs/src/rdsquashfs.c @@ -207,7 +207,7 @@ int main(int argc, char **argv) goto out; break; case OP_CAT: { - ostream_t *fp; + sqfs_ostream_t *fp; if (!S_ISREG(n->inode->base.mode)) { fprintf(stderr, "/%s: not a regular file\n", diff --git a/bin/sqfs2tar/src/sqfs2tar.c b/bin/sqfs2tar/src/sqfs2tar.c index fd8d5fa..e90aa56 100644 --- a/bin/sqfs2tar/src/sqfs2tar.c +++ b/bin/sqfs2tar/src/sqfs2tar.c @@ -9,7 +9,7 @@ sqfs_xattr_reader_t *xr; sqfs_data_reader_t *data; sqfs_super_t super; -ostream_t *out_file = NULL; +sqfs_ostream_t *out_file = NULL; static sqfs_file_t *file; @@ -125,7 +125,7 @@ int main(int argc, char **argv) if (compressor > 0) { xfrm_stream_t *xfrm = compressor_stream_create(compressor,NULL); - ostream_t *strm; + sqfs_ostream_t *strm; if (xfrm == NULL) goto out; diff --git a/bin/sqfs2tar/src/sqfs2tar.h b/bin/sqfs2tar/src/sqfs2tar.h index e176008..bb07092 100644 --- a/bin/sqfs2tar/src/sqfs2tar.h +++ b/bin/sqfs2tar/src/sqfs2tar.h @@ -42,7 +42,7 @@ void process_args(int argc, char **argv); extern sqfs_xattr_reader_t *xr; extern sqfs_data_reader_t *data; extern sqfs_super_t super; -extern ostream_t *out_file; +extern sqfs_ostream_t *out_file; char *assemble_tar_path(char *name, bool is_dir); diff --git a/bin/sqfsdiff/src/extract.c b/bin/sqfsdiff/src/extract.c index 3c8b568..43e9b97 100644 --- a/bin/sqfsdiff/src/extract.c +++ b/bin/sqfsdiff/src/extract.c @@ -10,7 +10,7 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, const char *prefix, const char *path, size_t block_size) { char *ptr, *temp; - ostream_t *fp; + sqfs_ostream_t *fp; temp = alloca(strlen(prefix) + strlen(path) + 2); sprintf(temp, "%s/%s", prefix, path); diff --git a/bin/tar2sqfs/src/process_tarball.c b/bin/tar2sqfs/src/process_tarball.c index 69d430d..5e7f030 100644 --- a/bin/tar2sqfs/src/process_tarball.c +++ b/bin/tar2sqfs/src/process_tarball.c @@ -10,8 +10,8 @@ static int write_file(sqfs_writer_t *sqfs, dir_iterator_t *it, const dir_entry_t *ent, tree_node_t *n) { int flags = 0, ret = 0; - ostream_t *out; - istream_t *in; + sqfs_ostream_t *out; + sqfs_istream_t *in; if (no_tail_pack && ent->size > cfg.block_size) flags |= SQFS_BLK_DONT_FRAGMENT; diff --git a/bin/tar2sqfs/src/tar2sqfs.c b/bin/tar2sqfs/src/tar2sqfs.c index b09f920..f7ed060 100644 --- a/bin/tar2sqfs/src/tar2sqfs.c +++ b/bin/tar2sqfs/src/tar2sqfs.c @@ -9,7 +9,7 @@ int main(int argc, char **argv) { int status = EXIT_FAILURE; - istream_t *input_file = NULL; + sqfs_istream_t *input_file = NULL; dir_iterator_t *tar = NULL; sqfs_writer_t sqfs; diff --git a/include/common.h b/include/common.h index 30c30fe..c289458 100644 --- a/include/common.h +++ b/include/common.h @@ -36,7 +36,7 @@ typedef struct sqfs_hard_link_t { int sqfs_data_reader_dump(const char *name, sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, - ostream_t *fp, size_t block_size); + sqfs_ostream_t *fp, size_t block_size); int write_data_from_file(const char *filename, sqfs_block_processor_t *data, sqfs_inode_generic_t **inode, @@ -64,10 +64,10 @@ int parse_size(const char *what, size_t *out, const char *str, void print_size(sqfs_u64 size, char *buffer, bool round_to_int); -ostream_t *data_writer_ostream_create(const char *filename, - sqfs_block_processor_t *proc, - sqfs_inode_generic_t **inode, - int flags); +sqfs_ostream_t *data_writer_ostream_create(const char *filename, + sqfs_block_processor_t *proc, + sqfs_inode_generic_t **inode, + int flags); /* Parse a comma separated list (e.g. "uid=...,gid=..." of defaults for diff --git a/include/io/dir_iterator.h b/include/io/dir_iterator.h index cc64680..152eb93 100644 --- a/include/io/dir_iterator.h +++ b/include/io/dir_iterator.h @@ -73,11 +73,11 @@ typedef struct dir_iterator_t { * to read from it. * * @param it A pointer to the iterator itself. - * @param out Returns a pointer to a @ref istream_t on success. + * @param out Returns a pointer to a @ref sqfs_istream_t on success. * * @return Zero on success, negative @ref SQFS_ERROR value on failure. */ - int (*open_file_ro)(struct dir_iterator_t *it, istream_t **out); + int (*open_file_ro)(struct dir_iterator_t *it, sqfs_istream_t **out); /** * @brief Read extended attributes associated with the current entry diff --git a/include/io/file.h b/include/io/file.h index d4f6fc1..1072b6a 100644 --- a/include/io/file.h +++ b/include/io/file.h @@ -25,7 +25,7 @@ extern "C" { /** * @brief Create an input stream for an OS native file handle. * - * @memberof istream_t + * @memberof sqfs_istream_t * * The functions takes up ownership of the file handle and takes care * of cleaning it up. On failure, the handle remains usable, and ownership @@ -36,12 +36,13 @@ extern "C" { * * @return A pointer to an output stream on success, NULL on failure. */ -SQFS_INTERNAL istream_t *istream_open_handle(const char *path, os_file_t fd); +SQFS_INTERNAL +sqfs_istream_t *istream_open_handle(const char *path, os_file_t fd); /** * @brief Create an output stream that writes to an OS native file handle. * - * @memberof ostream_t + * @memberof sqfs_ostream_t * * If the flag SQFS_FILE_OPEN_NO_SPARSE is set, the underlying implementation * always writes chunks of zero bytes when passing a NULL pointer to append. @@ -54,24 +55,25 @@ SQFS_INTERNAL istream_t *istream_open_handle(const char *path, os_file_t fd); * * @return A pointer to an output stream on success, NULL on failure. */ -SQFS_INTERNAL ostream_t *ostream_open_handle(const char *path, os_file_t hnd, - int flags); +SQFS_INTERNAL sqfs_ostream_t *ostream_open_handle(const char *path, + os_file_t hnd, + int flags); /** * @brief Create an input stream that reads from a file. * - * @memberof istream_t + * @memberof sqfs_istream_t * * @param path A path to the file to open or create. * * @return A pointer to an output stream on success, NULL on failure. */ -SQFS_INTERNAL istream_t *istream_open_file(const char *path); +SQFS_INTERNAL sqfs_istream_t *istream_open_file(const char *path); /** * @brief Create an output stream that writes to a file. * - * @memberof ostream_t + * @memberof sqfs_ostream_t * * If the file does not yet exist, it is created. If it does exist this * function fails, unless the flag SQFS_FILE_OPEN_OVERWRITE is set, in which @@ -87,7 +89,7 @@ SQFS_INTERNAL istream_t *istream_open_file(const char *path); * * @return A pointer to an output stream on success, NULL on failure. */ -SQFS_INTERNAL ostream_t *ostream_open_file(const char *path, int flags); +SQFS_INTERNAL sqfs_ostream_t *ostream_open_file(const char *path, int flags); #ifdef __cplusplus } diff --git a/include/io/istream.h b/include/io/istream.h index 90d6e0d..f4ffcb2 100644 --- a/include/io/istream.h +++ b/include/io/istream.h @@ -10,14 +10,16 @@ #include "sqfs/predef.h" #include "io/ostream.h" +typedef struct sqfs_istream_t sqfs_istream_t; + /** - * @struct istream_t + * @interface sqfs_istream_t * * @extends sqfs_object_t * * @brief A sequential, read-only data stream. */ -typedef struct istream_t { +struct sqfs_istream_t { sqfs_object_t base; /** @@ -32,7 +34,7 @@ typedef struct istream_t { * 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 istream_t implementation. + * @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. @@ -42,7 +44,7 @@ typedef struct istream_t { * @return Zero on success, a negative error code on failure, * a postive number on EOF. */ - int (*get_buffered_data)(struct istream_t *strm, const sqfs_u8 **out, + int (*get_buffered_data)(sqfs_istream_t *strm, const sqfs_u8 **out, size_t *size, size_t want); /** @@ -52,10 +54,10 @@ typedef struct istream_t { * forcing get_buffered_data to return data afterwards and potentially * try to load more data. * - * @param strm A pointer to an istream_t implementation. + * @param strm A pointer to an sqfs_istream_t implementation. * @param count The number of bytes used up. */ - void (*advance_buffer)(struct istream_t *strm, size_t count); + void (*advance_buffer)(sqfs_istream_t *strm, size_t count); /** * @brief Get the underlying filename of an input stream. @@ -64,8 +66,8 @@ typedef struct istream_t { * * @return A string holding the underlying filename. */ - const char *(*get_filename)(struct istream_t *strm); -} istream_t; + const char *(*get_filename)(sqfs_istream_t *strm); +}; enum { ISTREAM_LINE_LTRIM = 0x01, @@ -80,7 +82,7 @@ extern "C" { /** * @brief Read a line of text from an input stream * - * @memberof istream_t + * @memberof sqfs_istream_t * * The line returned is allocated using malloc and must subsequently be * freed when it is no longer needed. The line itself is always null-terminated @@ -103,13 +105,13 @@ extern "C" { * @return Zero on success, a negative value on error, a positive value if * end-of-file was reached without reading any data. */ -SQFS_INTERNAL int istream_get_line(istream_t *strm, char **out, +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 istream_t + * @memberof sqfs_istream_t * * @param strm A pointer to an input stream. * @param data A buffer to read into. @@ -118,24 +120,25 @@ SQFS_INTERNAL int istream_get_line(istream_t *strm, char **out, * @return The number of bytes actually read on success, -1 on failure, * 0 on end-of-file. */ -SQFS_INTERNAL sqfs_s32 istream_read(istream_t *strm, void *data, size_t size); +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 istream_t + * @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(istream_t *strm, sqfs_u64 size); +SQFS_INTERNAL int istream_skip(sqfs_istream_t *strm, sqfs_u64 size); /** * @brief Dump data from an input stream to an output stream * - * @memberof istream_t + * @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. @@ -144,7 +147,7 @@ SQFS_INTERNAL int istream_skip(istream_t *strm, sqfs_u64 size); * @return The number of bytes copied on success, -1 on failure, * 0 on end-of-file. */ -SQFS_INTERNAL sqfs_s32 istream_splice(istream_t *in, ostream_t *out, +SQFS_INTERNAL sqfs_s32 istream_splice(sqfs_istream_t *in, sqfs_ostream_t *out, sqfs_u32 size); #ifdef __cplusplus diff --git a/include/io/mem.h b/include/io/mem.h index 1efd007..c848ef0 100644 --- a/include/io/mem.h +++ b/include/io/mem.h @@ -13,8 +13,9 @@ extern "C" { #endif -SQFS_INTERNAL istream_t *istream_memory_create(const char *name, size_t bufsz, - const void *data, size_t size); +SQFS_INTERNAL +sqfs_istream_t *istream_memory_create(const char *name, size_t bufsz, + const void *data, size_t size); #ifdef __cplusplus } diff --git a/include/io/ostream.h b/include/io/ostream.h index 7a57e48..d1781d2 100644 --- a/include/io/ostream.h +++ b/include/io/ostream.h @@ -9,14 +9,16 @@ #include "sqfs/predef.h" +typedef struct sqfs_ostream_t sqfs_ostream_t; + /** - * @struct ostream_t + * @interface sqfs_ostream_t * * @extends sqfs_object_t * * @brief An append-only data stream. */ -typedef struct ostream_t { +struct sqfs_ostream_t { sqfs_object_t base; /** @@ -29,7 +31,7 @@ typedef struct ostream_t { * * @return Zero on success, -1 on failure. */ - int (*append)(struct ostream_t *strm, const void *data, size_t size); + int (*append)(sqfs_ostream_t *strm, const void *data, size_t size); /** * @brief Process all pending, buffered data and flush it to disk. @@ -43,7 +45,7 @@ typedef struct ostream_t { * * @return Zero on success, -1 on failure. */ - int (*flush)(struct ostream_t *strm); + int (*flush)(sqfs_ostream_t *strm); /** * @brief Get the underlying filename of a output stream. @@ -52,7 +54,7 @@ typedef struct ostream_t { * * @return A string holding the underlying filename. */ - const char *(*get_filename)(struct ostream_t *strm); -} ostream_t; + const char *(*get_filename)(sqfs_ostream_t *strm); +}; #endif /* IO_OSTREAM_H */ diff --git a/include/io/std.h b/include/io/std.h index 805bebd..3a8bbf8 100644 --- a/include/io/std.h +++ b/include/io/std.h @@ -17,20 +17,20 @@ extern "C" { /** * @brief Create an input stream that reads from standard input. * - * @memberof istream_t + * @memberof sqfs_istream_t * * @return A pointer to an input stream on success, NULL on failure. */ -SQFS_INTERNAL istream_t *istream_open_stdin(void); +SQFS_INTERNAL sqfs_istream_t *istream_open_stdin(void); /** * @brief Create an output stream that writes to standard output. * - * @memberof ostream_t + * @memberof sqfs_ostream_t * * @return A pointer to an output stream on success, NULL on failure. */ -SQFS_INTERNAL ostream_t *ostream_open_stdout(void); +SQFS_INTERNAL sqfs_ostream_t *ostream_open_stdout(void); #ifdef __cplusplus } diff --git a/include/io/xfrm.h b/include/io/xfrm.h index 3e601ea..c54bc9f 100644 --- a/include/io/xfrm.h +++ b/include/io/xfrm.h @@ -18,7 +18,7 @@ extern "C" { /** * @brief Create an input stream that transparently decodes data. * - * @memberof istream_t + * @memberof sqfs_istream_t * * This function creates an input stream that wraps an underlying input stream * that is encoded/compressed and transparently decodes the data when reading @@ -29,13 +29,13 @@ extern "C" { * * @return A pointer to an input stream on success, NULL on failure. */ -SQFS_INTERNAL istream_t *istream_xfrm_create(istream_t *strm, - xfrm_stream_t *xfrm); +SQFS_INTERNAL sqfs_istream_t *istream_xfrm_create(sqfs_istream_t *strm, + xfrm_stream_t *xfrm); /** * @brief Create an output stream that transparently encodes data. * - * @memberof ostream_t + * @memberof sqfs_ostream_t * * This function creates an output stream that transparently encodes * (e.g. compresses) all data appended to it and writes it to an @@ -46,8 +46,8 @@ SQFS_INTERNAL istream_t *istream_xfrm_create(istream_t *strm, * * @return A pointer to an output stream on success, NULL on failure. */ -SQFS_INTERNAL ostream_t *ostream_xfrm_create(ostream_t *strm, - xfrm_stream_t *xfrm); +SQFS_INTERNAL sqfs_ostream_t *ostream_xfrm_create(sqfs_ostream_t *strm, + xfrm_stream_t *xfrm); #ifdef __cplusplus } diff --git a/include/tar/tar.h b/include/tar/tar.h index 24ec408..60c2a3d 100644 --- a/include/tar/tar.h +++ b/include/tar/tar.h @@ -51,25 +51,26 @@ extern "C" { The counter is an incremental record counter used if additional headers need to be generated. */ -int write_tar_header(ostream_t *fp, const struct stat *sb, const char *name, +int write_tar_header(sqfs_ostream_t *fp, + const struct stat *sb, const char *name, const char *slink_target, const sqfs_xattr_t *xattr, unsigned int counter); -int write_hard_link(ostream_t *fp, const struct stat *sb, const char *name, +int write_hard_link(sqfs_ostream_t *fp, const struct stat *sb, const char *name, const char *target, unsigned int counter); /* round up to block size and skip the entire entry */ -int read_header(istream_t *fp, tar_header_decoded_t *out); +int read_header(sqfs_istream_t *fp, tar_header_decoded_t *out); void clear_header(tar_header_decoded_t *hdr); -dir_iterator_t *tar_open_stream(istream_t *stream); +dir_iterator_t *tar_open_stream(sqfs_istream_t *stream); /* Write zero bytes to an output file to padd it to the tar record size. Returns 0 on success. On failure, prints error message to stderr. */ -int padd_file(ostream_t *fp, sqfs_u64 size); +int padd_file(sqfs_ostream_t *fp, sqfs_u64 size); void free_sparse_list(sparse_map_t *sparse); diff --git a/lib/common/src/data_reader_dump.c b/lib/common/src/data_reader_dump.c index 8f38bd2..e3cbb87 100644 --- a/lib/common/src/data_reader_dump.c +++ b/lib/common/src/data_reader_dump.c @@ -13,7 +13,7 @@ int sqfs_data_reader_dump(const char *name, sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, - ostream_t *fp, size_t block_size) + sqfs_ostream_t *fp, size_t block_size) { size_t i, diff, chunk_size; sqfs_u64 filesz; diff --git a/lib/common/src/data_writer_ostream.c b/lib/common/src/data_writer_ostream.c index fbd0431..59abd7a 100644 --- a/lib/common/src/data_writer_ostream.c +++ b/lib/common/src/data_writer_ostream.c @@ -10,13 +10,13 @@ #include <stdlib.h> typedef struct{ - ostream_t base; + sqfs_ostream_t base; sqfs_block_processor_t *proc; const char *filename; } data_writer_ostream_t; -static int stream_append(ostream_t *base, const void *data, size_t size) +static int stream_append(sqfs_ostream_t *base, const void *data, size_t size) { data_writer_ostream_t *strm = (data_writer_ostream_t *)base; int ret; @@ -31,7 +31,7 @@ static int stream_append(ostream_t *base, const void *data, size_t size) return 0; } -static int stream_flush(ostream_t *base) +static int stream_flush(sqfs_ostream_t *base) { data_writer_ostream_t *strm = (data_writer_ostream_t *)base; int ret; @@ -46,7 +46,7 @@ static int stream_flush(ostream_t *base) return 0; } -static const char *stream_get_filename(ostream_t *base) +static const char *stream_get_filename(sqfs_ostream_t *base) { data_writer_ostream_t *strm = (data_writer_ostream_t *)base; @@ -58,13 +58,13 @@ static void stream_destroy(sqfs_object_t *base) free(base); } -ostream_t *data_writer_ostream_create(const char *filename, - sqfs_block_processor_t *proc, - sqfs_inode_generic_t **inode, - int flags) +sqfs_ostream_t *data_writer_ostream_create(const char *filename, + sqfs_block_processor_t *proc, + sqfs_inode_generic_t **inode, + int flags) { data_writer_ostream_t *strm = calloc(1, sizeof(*strm)); - ostream_t *base = (ostream_t *)strm; + sqfs_ostream_t *base = (sqfs_ostream_t *)strm; int ret; if (strm == NULL) { diff --git a/lib/io/src/dir_tree_iterator.c b/lib/io/src/dir_tree_iterator.c index 25cb1d9..4303817 100644 --- a/lib/io/src/dir_tree_iterator.c +++ b/lib/io/src/dir_tree_iterator.c @@ -272,7 +272,7 @@ static void ignore_subdir(dir_iterator_t *base) pop(it); } -static int open_file_ro(dir_iterator_t *base, istream_t **out) +static int open_file_ro(dir_iterator_t *base, sqfs_istream_t **out) { dir_tree_iterator_t *it = (dir_tree_iterator_t *)base; diff --git a/lib/io/src/get_line.c b/lib/io/src/get_line.c index 7ebce0e..9ab4928 100644 --- a/lib/io/src/get_line.c +++ b/lib/io/src/get_line.c @@ -38,7 +38,7 @@ static size_t trim(char *buffer, int flags) return strlen(buffer); } -int istream_get_line(istream_t *strm, char **out, +int istream_get_line(sqfs_istream_t *strm, char **out, size_t *line_num, int flags) { char *line = NULL, *new; diff --git a/lib/io/src/istream.c b/lib/io/src/istream.c index 473f1af..6fbc67b 100644 --- a/lib/io/src/istream.c +++ b/lib/io/src/istream.c @@ -7,7 +7,7 @@ #include "internal.h" -sqfs_s32 istream_read(istream_t *strm, void *data, size_t size) +sqfs_s32 istream_read(sqfs_istream_t *strm, void *data, size_t size) { sqfs_s32 total = 0; @@ -38,7 +38,7 @@ sqfs_s32 istream_read(istream_t *strm, void *data, size_t size) return total; } -int istream_skip(istream_t *strm, sqfs_u64 size) +int istream_skip(sqfs_istream_t *strm, sqfs_u64 size) { while (size > 0) { const sqfs_u8 *ptr; @@ -64,7 +64,7 @@ int istream_skip(istream_t *strm, sqfs_u64 size) return 0; } -sqfs_s32 istream_splice(istream_t *in, ostream_t *out, sqfs_u32 size) +sqfs_s32 istream_splice(sqfs_istream_t *in, sqfs_ostream_t *out, sqfs_u32 size) { sqfs_s32 total = 0; diff --git a/lib/io/src/mem.c b/lib/io/src/mem.c index bbb186a..435a169 100644 --- a/lib/io/src/mem.c +++ b/lib/io/src/mem.c @@ -13,7 +13,7 @@ #include <assert.h> typedef struct { - istream_t base; + sqfs_istream_t base; sqfs_u8 *buffer; size_t bufsz; @@ -26,7 +26,7 @@ typedef struct { char *name; } mem_istream_t; -static int mem_get_buffered_data(istream_t *strm, const sqfs_u8 **out, +static int mem_get_buffered_data(sqfs_istream_t *strm, const sqfs_u8 **out, size_t *size, size_t want) { mem_istream_t *mem = (mem_istream_t *)strm; @@ -50,7 +50,7 @@ static int mem_get_buffered_data(istream_t *strm, const sqfs_u8 **out, return (mem->visible == 0) ? 1 : 0; } -static void mem_advance_buffer(istream_t *strm, size_t count) +static void mem_advance_buffer(sqfs_istream_t *strm, size_t count) { mem_istream_t *mem = (mem_istream_t *)strm; @@ -68,7 +68,7 @@ static void mem_advance_buffer(istream_t *strm, size_t count) } } -static const char *mem_in_get_filename(istream_t *strm) +static const char *mem_in_get_filename(sqfs_istream_t *strm) { return ((mem_istream_t *)strm)->name; } @@ -80,11 +80,11 @@ static void mem_in_destroy(sqfs_object_t *obj) free(obj); } -istream_t *istream_memory_create(const char *name, size_t bufsz, - const void *data, size_t size) +sqfs_istream_t *istream_memory_create(const char *name, size_t bufsz, + const void *data, size_t size) { mem_istream_t *mem = calloc(1, sizeof(*mem)); - istream_t *strm = (istream_t *)mem; + sqfs_istream_t *strm = (sqfs_istream_t *)mem; if (mem == NULL) return NULL; diff --git a/lib/io/src/unix/dir_iterator.c b/lib/io/src/unix/dir_iterator.c index 9ba200f..5129eb0 100644 --- a/lib/io/src/unix/dir_iterator.c +++ b/lib/io/src/unix/dir_iterator.c @@ -127,7 +127,7 @@ static void dir_ignore_subdir(dir_iterator_t *it) (void)it; } -static int dir_open_file_ro(dir_iterator_t *it, istream_t **out) +static int dir_open_file_ro(dir_iterator_t *it, sqfs_istream_t **out) { (void)it; *out = NULL; diff --git a/lib/io/src/unix/istream.c b/lib/io/src/unix/istream.c index e96bc6c..fc76bab 100644 --- a/lib/io/src/unix/istream.c +++ b/lib/io/src/unix/istream.c @@ -7,7 +7,7 @@ #include "../internal.h" typedef struct { - istream_t base; + sqfs_istream_t base; char *path; int fd; @@ -17,7 +17,7 @@ typedef struct { sqfs_u8 buffer[BUFSZ]; } file_istream_t; -static int precache(istream_t *strm) +static int precache(sqfs_istream_t *strm) { file_istream_t *file = (file_istream_t *)strm; @@ -56,7 +56,7 @@ static int precache(istream_t *strm) return 0; } -static int file_get_buffered_data(istream_t *strm, const sqfs_u8 **out, +static int file_get_buffered_data(sqfs_istream_t *strm, const sqfs_u8 **out, size_t *size, size_t want) { file_istream_t *file = (file_istream_t *)strm; @@ -76,7 +76,7 @@ static int file_get_buffered_data(istream_t *strm, const sqfs_u8 **out, return (file->eof && *size == 0) ? 1 : 0; } -static void file_advance_buffer(istream_t *strm, size_t count) +static void file_advance_buffer(sqfs_istream_t *strm, size_t count) { file_istream_t *file = (file_istream_t *)strm; @@ -87,7 +87,7 @@ static void file_advance_buffer(istream_t *strm, size_t count) assert(file->buffer_offset <= file->buffer_used); } -static const char *file_get_filename(istream_t *strm) +static const char *file_get_filename(sqfs_istream_t *strm) { file_istream_t *file = (file_istream_t *)strm; @@ -105,10 +105,10 @@ static void file_destroy(sqfs_object_t *obj) free(file); } -istream_t *istream_open_handle(const char *path, int fd) +sqfs_istream_t *istream_open_handle(const char *path, int fd) { file_istream_t *file = calloc(1, sizeof(*file)); - istream_t *strm = (istream_t *)file; + sqfs_istream_t *strm = (sqfs_istream_t *)file; if (file == NULL) { perror(path); @@ -141,9 +141,9 @@ fail_free: return NULL; } -istream_t *istream_open_file(const char *path) +sqfs_istream_t *istream_open_file(const char *path) { - istream_t *out; + sqfs_istream_t *out; int fd; fd = open(path, O_RDONLY); @@ -159,7 +159,7 @@ istream_t *istream_open_file(const char *path) return out; } -istream_t *istream_open_stdin(void) +sqfs_istream_t *istream_open_stdin(void) { return istream_open_handle("stdin", STDIN_FILENO); } diff --git a/lib/io/src/unix/ostream.c b/lib/io/src/unix/ostream.c index 7093cc2..0e95167 100644 --- a/lib/io/src/unix/ostream.c +++ b/lib/io/src/unix/ostream.c @@ -8,7 +8,7 @@ #include "sqfs/io.h" typedef struct { - ostream_t base; + sqfs_ostream_t base; char *path; int flags; int fd; @@ -85,7 +85,7 @@ fail: return -1; } -static int file_append(ostream_t *strm, const void *data, size_t size) +static int file_append(sqfs_ostream_t *strm, const void *data, size_t size) { file_ostream_t *file = (file_ostream_t *)strm; @@ -104,7 +104,7 @@ static int file_append(ostream_t *strm, const void *data, size_t size) return write_all(file, data, size); } -static int file_flush(ostream_t *strm) +static int file_flush(sqfs_ostream_t *strm) { file_ostream_t *file = (file_ostream_t *)strm; @@ -130,17 +130,17 @@ static void file_destroy(sqfs_object_t *obj) free(file); } -static const char *file_get_filename(ostream_t *strm) +static const char *file_get_filename(sqfs_ostream_t *strm) { file_ostream_t *file = (file_ostream_t *)strm; return file->path; } -ostream_t *ostream_open_handle(const char *path, int fd, int flags) +sqfs_ostream_t *ostream_open_handle(const char *path, int fd, int flags) { file_ostream_t *file = calloc(1, sizeof(*file)); - ostream_t *strm = (ostream_t *)file; + sqfs_ostream_t *strm = (sqfs_ostream_t *)file; if (file == NULL) { perror(path); @@ -175,9 +175,9 @@ fail_free: return NULL; } -ostream_t *ostream_open_file(const char *path, int flags) +sqfs_ostream_t *ostream_open_file(const char *path, int flags) { - ostream_t *out; + sqfs_ostream_t *out; int fd; if (flags & SQFS_FILE_OPEN_OVERWRITE) { @@ -193,7 +193,7 @@ ostream_t *ostream_open_file(const char *path, int flags) return out; } -ostream_t *ostream_open_stdout(void) +sqfs_ostream_t *ostream_open_stdout(void) { return ostream_open_handle("stdout", STDOUT_FILENO, SQFS_FILE_OPEN_NO_SPARSE); diff --git a/lib/io/src/win32/dir_iterator.c b/lib/io/src/win32/dir_iterator.c index b1045f1..c99fd64 100644 --- a/lib/io/src/win32/dir_iterator.c +++ b/lib/io/src/win32/dir_iterator.c @@ -115,7 +115,7 @@ static void dir_iterator_ignore_subdir(dir_iterator_t *it) (void)it; } -static int dir_iterator_open_file_ro(dir_iterator_t *it, istream_t **out) +static int dir_iterator_open_file_ro(dir_iterator_t *it, sqfs_istream_t **out) { (void)it; *out = NULL; diff --git a/lib/io/src/win32/istream.c b/lib/io/src/win32/istream.c index d140142..223b20d 100644 --- a/lib/io/src/win32/istream.c +++ b/lib/io/src/win32/istream.c @@ -10,7 +10,7 @@ #include <windows.h> typedef struct { - istream_t base; + sqfs_istream_t base; char *path; HANDLE hnd; @@ -20,7 +20,7 @@ typedef struct { sqfs_u8 buffer[BUFSZ]; } file_istream_t; -static int precache(istream_t *strm) +static int precache(sqfs_istream_t *strm) { file_istream_t *file = (file_istream_t *)strm; DWORD diff, actual; @@ -66,7 +66,7 @@ static int precache(istream_t *strm) return 0; } -static int file_get_buffered_data(istream_t *strm, const sqfs_u8 **out, +static int file_get_buffered_data(sqfs_istream_t *strm, const sqfs_u8 **out, size_t *size, size_t want) { file_istream_t *file = (file_istream_t *)strm; @@ -86,7 +86,7 @@ static int file_get_buffered_data(istream_t *strm, const sqfs_u8 **out, return (file->eof && *size == 0) ? 1 : 0; } -static void file_advance_buffer(istream_t *strm, size_t count) +static void file_advance_buffer(sqfs_istream_t *strm, size_t count) { file_istream_t *file = (file_istream_t *)strm; @@ -97,7 +97,7 @@ static void file_advance_buffer(istream_t *strm, size_t count) assert(file->buffer_offset <= file->buffer_used); } -static const char *file_get_filename(istream_t *strm) +static const char *file_get_filename(sqfs_istream_t *strm) { return ((file_istream_t *)strm)->path; } @@ -111,10 +111,10 @@ static void file_destroy(sqfs_object_t *obj) free(file); } -istream_t *istream_open_handle(const char *path, HANDLE hnd) +sqfs_istream_t *istream_open_handle(const char *path, HANDLE hnd) { file_istream_t *file = calloc(1, sizeof(*file)); - istream_t *strm = (istream_t *)file; + sqfs_istream_t *strm = (sqfs_istream_t *)file; BOOL ret; if (file == NULL) { @@ -151,10 +151,10 @@ fail_free: return NULL; } -istream_t *istream_open_file(const char *path) +sqfs_istream_t *istream_open_file(const char *path) { WCHAR *wpath = NULL; - istream_t *out; + sqfs_istream_t *out; HANDLE hnd; wpath = path_to_windows(path); @@ -179,7 +179,7 @@ istream_t *istream_open_file(const char *path) return out; } -istream_t *istream_open_stdin(void) +sqfs_istream_t *istream_open_stdin(void) { HANDLE hnd = GetStdHandle(STD_INPUT_HANDLE); diff --git a/lib/io/src/win32/ostream.c b/lib/io/src/win32/ostream.c index 26d6f96..5b099a4 100644 --- a/lib/io/src/win32/ostream.c +++ b/lib/io/src/win32/ostream.c @@ -11,7 +11,7 @@ #include <windows.h> typedef struct { - ostream_t base; + sqfs_ostream_t base; sqfs_u64 sparse_count; char *path; HANDLE hnd; @@ -84,7 +84,7 @@ fail: return -1; } -static int file_append(ostream_t *strm, const void *data, size_t size) +static int file_append(sqfs_ostream_t *strm, const void *data, size_t size) { file_ostream_t *file = (file_ostream_t *)strm; @@ -102,7 +102,7 @@ static int file_append(ostream_t *strm, const void *data, size_t size) return write_data(file, data, size); } -static int file_flush(ostream_t *strm) +static int file_flush(sqfs_ostream_t *strm) { file_ostream_t *file = (file_ostream_t *)strm; @@ -126,17 +126,17 @@ static void file_destroy(sqfs_object_t *obj) free(file); } -static const char *file_get_filename(ostream_t *strm) +static const char *file_get_filename(sqfs_ostream_t *strm) { file_ostream_t *file = (file_ostream_t *)strm; return file->path; } -ostream_t *ostream_open_handle(const char *path, HANDLE hnd, int flags) +sqfs_ostream_t *ostream_open_handle(const char *path, HANDLE hnd, int flags) { file_ostream_t *file = calloc(1, sizeof(*file)); - ostream_t *strm = (ostream_t *)file; + sqfs_ostream_t *strm = (sqfs_ostream_t *)file; BOOL ret; if (file == NULL) { @@ -174,11 +174,11 @@ fail_free: return NULL; } -ostream_t *ostream_open_file(const char *path, int flags) +sqfs_ostream_t *ostream_open_file(const char *path, int flags) { int access_flags, creation_mode; WCHAR *wpath = NULL; - ostream_t *out; + sqfs_ostream_t *out; HANDLE hnd; access_flags = GENERIC_WRITE; @@ -216,7 +216,7 @@ ostream_t *ostream_open_file(const char *path, int flags) return out; } -ostream_t *ostream_open_stdout(void) +sqfs_ostream_t *ostream_open_stdout(void) { HANDLE hnd = GetStdHandle(STD_OUTPUT_HANDLE); diff --git a/lib/io/src/xfrm/istream.c b/lib/io/src/xfrm/istream.c index 632409c..5c23d28 100644 --- a/lib/io/src/xfrm/istream.c +++ b/lib/io/src/xfrm/istream.c @@ -7,9 +7,9 @@ #include "../internal.h" typedef struct istream_xfrm_t { - istream_t base; + sqfs_istream_t base; - istream_t *wrapped; + sqfs_istream_t *wrapped; xfrm_stream_t *xfrm; size_t buffer_offset; @@ -17,7 +17,7 @@ typedef struct istream_xfrm_t { sqfs_u8 uncompressed[BUFSZ]; } istream_xfrm_t; -static int precache(istream_t *base) +static int precache(sqfs_istream_t *base) { istream_xfrm_t *xfrm = (istream_xfrm_t *)base; int ret; @@ -70,7 +70,7 @@ static int precache(istream_t *base) return 0; } -static int xfrm_get_buffered_data(istream_t *strm, const sqfs_u8 **out, +static int xfrm_get_buffered_data(sqfs_istream_t *strm, const sqfs_u8 **out, size_t *size, size_t want) { istream_xfrm_t *xfrm = (istream_xfrm_t *)strm; @@ -90,7 +90,7 @@ static int xfrm_get_buffered_data(istream_t *strm, const sqfs_u8 **out, return (*size == 0) ? 1 : 0; } -static void xfrm_advance_buffer(istream_t *strm, size_t count) +static void xfrm_advance_buffer(sqfs_istream_t *strm, size_t count) { istream_xfrm_t *xfrm = (istream_xfrm_t *)strm; @@ -101,7 +101,7 @@ static void xfrm_advance_buffer(istream_t *strm, size_t count) assert(xfrm->buffer_offset <= xfrm->buffer_used); } -static const char *xfrm_get_filename(istream_t *strm) +static const char *xfrm_get_filename(sqfs_istream_t *strm) { istream_xfrm_t *xfrm = (istream_xfrm_t *)strm; @@ -117,10 +117,10 @@ static void xfrm_destroy(sqfs_object_t *obj) free(xfrm); } -istream_t *istream_xfrm_create(istream_t *strm, xfrm_stream_t *xfrm) +sqfs_istream_t *istream_xfrm_create(sqfs_istream_t *strm, xfrm_stream_t *xfrm) { istream_xfrm_t *stream = calloc(1, sizeof(*stream)); - istream_t *base = (istream_t *)stream; + sqfs_istream_t *base = (sqfs_istream_t *)stream; if (stream == NULL) goto fail; diff --git a/lib/io/src/xfrm/ostream.c b/lib/io/src/xfrm/ostream.c index e55e38c..81c19dd 100644 --- a/lib/io/src/xfrm/ostream.c +++ b/lib/io/src/xfrm/ostream.c @@ -7,9 +7,9 @@ #include "../internal.h" typedef struct ostream_xfrm_t { - ostream_t base; + sqfs_ostream_t base; - ostream_t *wrapped; + sqfs_ostream_t *wrapped; xfrm_stream_t *xfrm; size_t inbuf_used; @@ -66,7 +66,7 @@ static int flush_inbuf(ostream_xfrm_t *xfrm, bool finish) return 0; } -static int xfrm_append(ostream_t *strm, const void *data, size_t size) +static int xfrm_append(sqfs_ostream_t *strm, const void *data, size_t size) { ostream_xfrm_t *xfrm = (ostream_xfrm_t *)strm; size_t diff; @@ -96,7 +96,7 @@ static int xfrm_append(ostream_t *strm, const void *data, size_t size) return 0; } -static int xfrm_flush(ostream_t *strm) +static int xfrm_flush(sqfs_ostream_t *strm) { ostream_xfrm_t *xfrm = (ostream_xfrm_t *)strm; @@ -108,7 +108,7 @@ static int xfrm_flush(ostream_t *strm) return xfrm->wrapped->flush(xfrm->wrapped); } -static const char *xfrm_get_filename(ostream_t *strm) +static const char *xfrm_get_filename(sqfs_ostream_t *strm) { ostream_xfrm_t *xfrm = (ostream_xfrm_t *)strm; @@ -124,10 +124,10 @@ static void xfrm_destroy(sqfs_object_t *obj) free(xfrm); } -ostream_t *ostream_xfrm_create(ostream_t *strm, xfrm_stream_t *xfrm) +sqfs_ostream_t *ostream_xfrm_create(sqfs_ostream_t *strm, xfrm_stream_t *xfrm) { ostream_xfrm_t *stream = calloc(1, sizeof(*stream)); - ostream_t *base = (ostream_t *)stream; + sqfs_ostream_t *base = (sqfs_ostream_t *)stream; if (stream == NULL) goto fail; diff --git a/lib/io/test/get_line.c b/lib/io/test/get_line.c index 0ce67ac..d300a3a 100644 --- a/lib/io/test/get_line.c +++ b/lib/io/test/get_line.c @@ -16,7 +16,7 @@ static void run_test_case(const char *raw, const line_t *lines, size_t count, int flags) { size_t i, line_num, old_line_num; - istream_t *fp; + sqfs_istream_t *fp; char *line; int ret; diff --git a/lib/io/test/istream_mem.c b/lib/io/test/istream_mem.c index ca5146c..f364fd3 100644 --- a/lib/io/test/istream_mem.c +++ b/lib/io/test/istream_mem.c @@ -35,7 +35,7 @@ int main(int argc, char **argv) size_t i, diff, size; bool eat_all = true; const sqfs_u8 *ptr; - istream_t *in; + sqfs_istream_t *in; int ret; (void)argc; (void)argv; diff --git a/lib/io/test/istream_read.c b/lib/io/test/istream_read.c index 8ba4540..66fec4b 100644 --- a/lib/io/test/istream_read.c +++ b/lib/io/test/istream_read.c @@ -35,7 +35,7 @@ int main(int argc, char **argv) { sqfs_u8 read_buffer[61]; sqfs_u64 read_off = 0; - istream_t *dummy; + sqfs_istream_t *dummy; (void)argc; (void)argv; init_rd_buffer(); diff --git a/lib/io/test/istream_skip.c b/lib/io/test/istream_skip.c index 3a02c8c..0fc3e11 100644 --- a/lib/io/test/istream_skip.c +++ b/lib/io/test/istream_skip.c @@ -35,7 +35,7 @@ int main(int argc, char **argv) { sqfs_u8 read_buffer[61]; sqfs_u64 read_off = 0; - istream_t *dummy; + sqfs_istream_t *dummy; (void)argc; (void)argv; init_rd_buffer(); diff --git a/lib/io/test/stream_splice.c b/lib/io/test/stream_splice.c index 754f9cb..a9edd76 100644 --- a/lib/io/test/stream_splice.c +++ b/lib/io/test/stream_splice.c @@ -34,11 +34,11 @@ static void init_rd_buffer(void) /*****************************************************************************/ -static int out_append(ostream_t *strm, const void *data, size_t size); +static int out_append(sqfs_ostream_t *strm, const void *data, size_t size); static sqfs_u64 out_offset = 0; -static ostream_t out = { +static sqfs_ostream_t out = { { 1, NULL, NULL }, out_append, NULL, @@ -46,7 +46,7 @@ static ostream_t out = { NULL, }; -static int out_append(ostream_t *strm, const void *data, size_t size) +static int out_append(sqfs_ostream_t *strm, const void *data, size_t size) { const sqfs_u8 *ptr = data; @@ -69,7 +69,7 @@ static int out_append(ostream_t *strm, const void *data, size_t size) int main(int argc, char **argv) { sqfs_u64 total = 0; - istream_t *in; + sqfs_istream_t *in; sqfs_s32 ret; (void)argc; (void)argv; diff --git a/lib/io/test/xfrm.c b/lib/io/test/xfrm.c index 184db9e..1b48e6f 100644 --- a/lib/io/test/xfrm.c +++ b/lib/io/test/xfrm.c @@ -368,17 +368,17 @@ static size_t mo_written = 0; static sqfs_u8 mo_buffer[1024]; static bool mo_flushed = false; -static int mem_append(ostream_t *strm, const void *data, size_t size); -static int mem_flush(ostream_t *strm); +static int mem_append(sqfs_ostream_t *strm, const void *data, size_t size); +static int mem_flush(sqfs_ostream_t *strm); -static ostream_t mem_ostream = { +static sqfs_ostream_t mem_ostream = { { 1, NULL, NULL, }, mem_append, mem_flush, NULL, }; -static int mem_append(ostream_t *strm, const void *data, size_t size) +static int mem_append(sqfs_ostream_t *strm, const void *data, size_t size) { TEST_ASSERT(strm == &mem_ostream); TEST_ASSERT(size > 0); @@ -396,7 +396,7 @@ static int mem_append(ostream_t *strm, const void *data, size_t size) return 0; } -static int mem_flush(ostream_t *strm) +static int mem_flush(sqfs_ostream_t *strm) { TEST_ASSERT(strm == &mem_ostream); TEST_ASSERT(!mo_flushed); @@ -408,7 +408,7 @@ static int mem_flush(ostream_t *strm) static void run_unpack_test(const void *blob, size_t size) { - istream_t *istream, *mem_istream; + sqfs_istream_t *istream, *mem_istream; xfrm_stream_t *xfrm; sqfs_s32 ret; size_t i; @@ -450,8 +450,8 @@ static void run_unpack_test(const void *blob, size_t size) static void run_pack_test(void) { + sqfs_ostream_t *ostream; xfrm_stream_t *xfrm; - ostream_t *ostream; size_t i; int ret; diff --git a/lib/tar/src/internal.h b/lib/tar/src/internal.h index c5483fe..56613d3 100644 --- a/lib/tar/src/internal.h +++ b/lib/tar/src/internal.h @@ -34,13 +34,15 @@ enum { ETV_POSIX, }; -sparse_map_t *read_gnu_old_sparse(istream_t *fp, tar_header_t *hdr); +sparse_map_t *read_gnu_old_sparse(sqfs_istream_t *fp, tar_header_t *hdr); -sparse_map_t *read_gnu_new_sparse(istream_t *fp, tar_header_decoded_t *out); +sparse_map_t *read_gnu_new_sparse(sqfs_istream_t *fp, + tar_header_decoded_t *out); -char *record_to_memory(istream_t *fp, size_t size); +char *record_to_memory(sqfs_istream_t *fp, size_t size); -int read_pax_header(istream_t *fp, sqfs_u64 entsize, unsigned int *set_by_pax, +int read_pax_header(sqfs_istream_t *fp, sqfs_u64 entsize, + unsigned int *set_by_pax, tar_header_decoded_t *out); #endif /* INTERNAL_H */ diff --git a/lib/tar/src/iterator.c b/lib/tar/src/iterator.c index 1f26e76..5920b46 100644 --- a/lib/tar/src/iterator.c +++ b/lib/tar/src/iterator.c @@ -20,7 +20,7 @@ typedef struct { dir_iterator_t base; tar_header_decoded_t current; - istream_t *stream; + sqfs_istream_t *stream; int state; /* File I/O wrapper related */ @@ -35,7 +35,7 @@ typedef struct { } tar_iterator_t; typedef struct { - istream_t base; + sqfs_istream_t base; tar_iterator_t *parent; int state; @@ -89,12 +89,12 @@ static void drop_parent(tar_istream_t *tar, int state) tar->state = state; } -static const char *strm_get_filename(istream_t *strm) +static const char *strm_get_filename(sqfs_istream_t *strm) { return ((tar_istream_t *)strm)->parent->current.name; } -static int strm_get_buffered_data(istream_t *strm, const sqfs_u8 **out, +static int strm_get_buffered_data(sqfs_istream_t *strm, const sqfs_u8 **out, size_t *size, size_t want) { tar_istream_t *tar = (tar_istream_t *)strm; @@ -142,7 +142,7 @@ out_eof: return 1; } -static void strm_advance_buffer(istream_t *strm, size_t count) +static void strm_advance_buffer(sqfs_istream_t *strm, size_t count) { tar_istream_t *tar = (tar_istream_t *)strm; @@ -263,7 +263,7 @@ static void it_ignore_subdir(dir_iterator_t *it) /* TODO: skip list */ } -static int it_open_file_ro(dir_iterator_t *it, istream_t **out) +static int it_open_file_ro(dir_iterator_t *it, sqfs_istream_t **out) { tar_iterator_t *tar = (tar_iterator_t *)it; tar_istream_t *strm; @@ -285,12 +285,12 @@ static int it_open_file_ro(dir_iterator_t *it, istream_t **out) sqfs_object_init(strm, strm_destroy, NULL); strm->parent = sqfs_grab(tar); - ((istream_t *)strm)->get_buffered_data = strm_get_buffered_data; - ((istream_t *)strm)->advance_buffer = strm_advance_buffer; - ((istream_t *)strm)->get_filename = strm_get_filename; + ((sqfs_istream_t *)strm)->get_buffered_data = strm_get_buffered_data; + ((sqfs_istream_t *)strm)->advance_buffer = strm_advance_buffer; + ((sqfs_istream_t *)strm)->get_filename = strm_get_filename; tar->locked = true; - *out = (istream_t *)strm; + *out = (sqfs_istream_t *)strm; return 0; } @@ -351,7 +351,7 @@ static int tar_probe(const sqfs_u8 *data, size_t size) return 0; } -dir_iterator_t *tar_open_stream(istream_t *strm) +dir_iterator_t *tar_open_stream(sqfs_istream_t *strm) { tar_iterator_t *tar = calloc(1, sizeof(*tar)); dir_iterator_t *it = (dir_iterator_t *)tar; diff --git a/lib/tar/src/padd_file.c b/lib/tar/src/padd_file.c index 0f6ee0a..814b666 100644 --- a/lib/tar/src/padd_file.c +++ b/lib/tar/src/padd_file.c @@ -8,7 +8,7 @@ #include "tar/tar.h" #include "tar/format.h" -int padd_file(ostream_t *fp, sqfs_u64 size) +int padd_file(sqfs_ostream_t *fp, sqfs_u64 size) { size_t padd_sz = size % TAR_RECORD_SIZE; diff --git a/lib/tar/src/pax_header.c b/lib/tar/src/pax_header.c index 74a1b24..5ed9c4b 100644 --- a/lib/tar/src/pax_header.c +++ b/lib/tar/src/pax_header.c @@ -293,8 +293,8 @@ static int apply_handler(tar_header_decoded_t *out, return 0; } -int read_pax_header(istream_t *fp, sqfs_u64 entsize, unsigned int *set_by_pax, - tar_header_decoded_t *out) +int read_pax_header(sqfs_istream_t *fp, sqfs_u64 entsize, + unsigned int *set_by_pax, tar_header_decoded_t *out) { char *buffer, *line, *key, *ptr, *value, *end; sparse_map_t *sparse_last = NULL, *sparse; diff --git a/lib/tar/src/read_header.c b/lib/tar/src/read_header.c index 751c5dc..3117d8a 100644 --- a/lib/tar/src/read_header.c +++ b/lib/tar/src/read_header.c @@ -164,7 +164,7 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax, return 0; } -int read_header(istream_t *fp, tar_header_decoded_t *out) +int read_header(sqfs_istream_t *fp, tar_header_decoded_t *out) { unsigned int set_by_pax = 0; bool prev_was_zero = false; diff --git a/lib/tar/src/read_sparse_map_new.c b/lib/tar/src/read_sparse_map_new.c index de1b6a4..a1f37fd 100644 --- a/lib/tar/src/read_sparse_map_new.c +++ b/lib/tar/src/read_sparse_map_new.c @@ -31,7 +31,7 @@ static int decode(const char *str, size_t len, size_t *out) return (*str == '\n') ? ((int)count + 1) : -1; } -sparse_map_t *read_gnu_new_sparse(istream_t *fp, tar_header_decoded_t *out) +sparse_map_t *read_gnu_new_sparse(sqfs_istream_t *fp, tar_header_decoded_t *out) { sparse_map_t *last = NULL, *list = NULL, *ent = NULL; size_t i, count, value; diff --git a/lib/tar/src/read_sparse_map_old.c b/lib/tar/src/read_sparse_map_old.c index 8f193d4..832329b 100644 --- a/lib/tar/src/read_sparse_map_old.c +++ b/lib/tar/src/read_sparse_map_old.c @@ -45,7 +45,7 @@ static int parse(const gnu_old_sparse_t *in, size_t count, return 0; } -sparse_map_t *read_gnu_old_sparse(istream_t *fp, tar_header_t *hdr) +sparse_map_t *read_gnu_old_sparse(sqfs_istream_t *fp, tar_header_t *hdr) { sparse_map_t *list = NULL, *end = NULL; gnu_old_sparse_record_t sph; diff --git a/lib/tar/src/record_to_memory.c b/lib/tar/src/record_to_memory.c index 43fd44c..1bd31aa 100644 --- a/lib/tar/src/record_to_memory.c +++ b/lib/tar/src/record_to_memory.c @@ -10,7 +10,7 @@ #include "internal.h" #include <stdlib.h> -char *record_to_memory(istream_t *fp, size_t size) +char *record_to_memory(sqfs_istream_t *fp, size_t size) { char *buffer = malloc(size + 1); int ret; diff --git a/lib/tar/src/write_header.c b/lib/tar/src/write_header.c index 726b15d..1183c9a 100644 --- a/lib/tar/src/write_header.c +++ b/lib/tar/src/write_header.c @@ -63,8 +63,8 @@ static void write_number_signed(char *dst, sqfs_s64 value, int digits) } } -static int write_header(ostream_t *fp, const struct stat *sb, const char *name, - const char *slink_target, int type) +static int write_header(sqfs_ostream_t *fp, const struct stat *sb, + const char *name, const char *slink_target, int type) { int maj = 0, min = 0; sqfs_u64 size = 0; @@ -101,7 +101,7 @@ static int write_header(ostream_t *fp, const struct stat *sb, const char *name, return fp->append(fp, &hdr, sizeof(hdr)); } -static int write_ext_header(ostream_t *fp, const struct stat *orig, +static int write_ext_header(sqfs_ostream_t *fp, const struct stat *orig, const char *payload, size_t payload_len, int type, const char *name) { @@ -144,7 +144,7 @@ static size_t prefix_digit_len(size_t len) return ndigit; } -static int write_schily_xattr(ostream_t *fp, const struct stat *orig, +static int write_schily_xattr(sqfs_ostream_t *fp, const struct stat *orig, const char *name, const sqfs_xattr_t *xattr) { static const char *prefix = "SCHILY.xattr."; @@ -183,7 +183,8 @@ static int write_schily_xattr(ostream_t *fp, const struct stat *orig, return ret; } -int write_tar_header(ostream_t *fp, const struct stat *sb, const char *name, +int write_tar_header(sqfs_ostream_t *fp, + const struct stat *sb, const char *name, const char *slink_target, const sqfs_xattr_t *xattr, unsigned int counter) { @@ -242,7 +243,7 @@ out_skip: return 1; } -int write_hard_link(ostream_t *fp, const struct stat *sb, const char *name, +int write_hard_link(sqfs_ostream_t *fp, const struct stat *sb, const char *name, const char *target, unsigned int counter) { tar_header_t hdr; diff --git a/lib/tar/test/tar_big_file.c b/lib/tar/test/tar_big_file.c index deb41f4..444548b 100644 --- a/lib/tar/test/tar_big_file.c +++ b/lib/tar/test/tar_big_file.c @@ -12,7 +12,7 @@ int main(int argc, char **argv) { tar_header_decoded_t hdr; - istream_t *fp; + sqfs_istream_t *fp; (void)argc; (void)argv; fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE)); diff --git a/lib/tar/test/tar_fuzz.c b/lib/tar/test/tar_fuzz.c index 21e6978..bdea98e 100644 --- a/lib/tar/test/tar_fuzz.c +++ b/lib/tar/test/tar_fuzz.c @@ -15,7 +15,7 @@ int main(int argc, char **argv) { tar_header_decoded_t hdr; - istream_t *fp; + sqfs_istream_t *fp; int ret; if (argc != 2) { diff --git a/lib/tar/test/tar_iterator.c b/lib/tar/test/tar_iterator.c index 21bd3e6..25e1389 100644 --- a/lib/tar/test/tar_iterator.c +++ b/lib/tar/test/tar_iterator.c @@ -30,7 +30,7 @@ static const char *fname = STRVALUE(TESTFNAME); int main(int argc, char **argv) { - istream_t *fp, *ti, *ti2; + sqfs_istream_t *fp, *ti, *ti2; dir_iterator_t *it; dir_entry_t *ent; char buffer[100]; diff --git a/lib/tar/test/tar_iterator2.c b/lib/tar/test/tar_iterator2.c index 7f1f3bf..6f472ae 100644 --- a/lib/tar/test/tar_iterator2.c +++ b/lib/tar/test/tar_iterator2.c @@ -44,8 +44,8 @@ static int byte_from_offset(uint64_t offset) int main(int argc, char **argv) { unsigned char buffer[941]; + sqfs_istream_t *fp, *ti; dir_iterator_t *it; - istream_t *fp, *ti; dir_entry_t *ent; uint64_t offset; sqfs_s32 i, ret; diff --git a/lib/tar/test/tar_iterator3.c b/lib/tar/test/tar_iterator3.c index b2ad6f9..39e7b42 100644 --- a/lib/tar/test/tar_iterator3.c +++ b/lib/tar/test/tar_iterator3.c @@ -13,8 +13,8 @@ int main(int argc, char **argv) { + sqfs_istream_t *fp, *ti; dir_iterator_t *it; - istream_t *fp, *ti; char buffer[100]; dir_entry_t *ent; char *link; diff --git a/lib/tar/test/tar_simple.c b/lib/tar/test/tar_simple.c index cb38abb..656e59b 100644 --- a/lib/tar/test/tar_simple.c +++ b/lib/tar/test/tar_simple.c @@ -37,9 +37,9 @@ static const char *fname = STRVALUE(TESTFNAME); int main(int argc, char **argv) { tar_header_decoded_t hdr; + sqfs_istream_t *fp; char buffer[6]; sqfs_s64 ts; - istream_t *fp; (void)argc; (void)argv; fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE)); diff --git a/lib/tar/test/tar_sparse.c b/lib/tar/test/tar_sparse.c index 27ce053..99d4639 100644 --- a/lib/tar/test/tar_sparse.c +++ b/lib/tar/test/tar_sparse.c @@ -13,7 +13,7 @@ static void test_case_sparse(const char *path) { tar_header_decoded_t hdr; sparse_map_t *sparse; - istream_t *fp; + sqfs_istream_t *fp; fp = istream_open_file(path); TEST_NOT_NULL(fp); diff --git a/lib/tar/test/tar_sparse_gnu.c b/lib/tar/test/tar_sparse_gnu.c index 19ddd0a..675ef9a 100644 --- a/lib/tar/test/tar_sparse_gnu.c +++ b/lib/tar/test/tar_sparse_gnu.c @@ -13,7 +13,7 @@ int main(int argc, char **argv) { tar_header_decoded_t hdr; sparse_map_t *sparse; - istream_t *fp; + sqfs_istream_t *fp; (void)argc; (void)argv; TEST_ASSERT(chdir(TEST_PATH) == 0); diff --git a/lib/tar/test/tar_target_filled.c b/lib/tar/test/tar_target_filled.c index e2e1798..815728a 100644 --- a/lib/tar/test/tar_target_filled.c +++ b/lib/tar/test/tar_target_filled.c @@ -12,8 +12,8 @@ int main(int argc, char **argv) { tar_header_decoded_t hdr; + sqfs_istream_t *fp; char buffer[16]; - istream_t *fp; (void)argc; (void)argv; TEST_ASSERT(chdir(TEST_PATH) == 0); diff --git a/lib/tar/test/tar_write_simple.c b/lib/tar/test/tar_write_simple.c index b34c9c5..98ac25b 100644 --- a/lib/tar/test/tar_write_simple.c +++ b/lib/tar/test/tar_write_simple.c @@ -14,10 +14,10 @@ /*****************************************************************************/ -static int buffer_append(ostream_t *strm, const void *data, size_t size); -static const char *buffer_get_filename(ostream_t *strm); +static int buffer_append(sqfs_ostream_t *strm, const void *data, size_t size); +static const char *buffer_get_filename(sqfs_ostream_t *strm); -static ostream_t mem_stream = { +static sqfs_ostream_t mem_stream = { { 1, NULL, NULL }, buffer_append, NULL, @@ -29,7 +29,7 @@ static size_t wr_offset = 0; static sqfs_u8 rd_buffer[1024 * 10]; -static int buffer_append(ostream_t *strm, const void *data, size_t size) +static int buffer_append(sqfs_ostream_t *strm, const void *data, size_t size) { TEST_ASSERT(strm == &mem_stream); TEST_ASSERT(wr_offset < sizeof(wr_buffer)); @@ -46,7 +46,7 @@ static int buffer_append(ostream_t *strm, const void *data, size_t size) return 0; } -static const char *buffer_get_filename(ostream_t *strm) +static const char *buffer_get_filename(sqfs_ostream_t *strm) { TEST_ASSERT(strm == &mem_stream); return "dummy"; @@ -79,8 +79,8 @@ static sqfs_xattr_t *mkxattr_chain(void) int main(int argc, char **argv) { sqfs_xattr_t *xattr; + sqfs_istream_t *fp; struct stat sb; - istream_t *fp; int ret; (void)argc; (void)argv; diff --git a/lib/tar/test/tar_xattr.c b/lib/tar/test/tar_xattr.c index 1577fc7..657b73d 100644 --- a/lib/tar/test/tar_xattr.c +++ b/lib/tar/test/tar_xattr.c @@ -13,8 +13,8 @@ int main(int argc, char **argv) { tar_header_decoded_t hdr; + sqfs_istream_t *fp; char buffer[6]; - istream_t *fp; (void)argc; (void)argv; fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE)); diff --git a/lib/tar/test/tar_xattr_bin.c b/lib/tar/test/tar_xattr_bin.c index 129d227..f897bce 100644 --- a/lib/tar/test/tar_xattr_bin.c +++ b/lib/tar/test/tar_xattr_bin.c @@ -21,8 +21,8 @@ static const uint8_t value[] = { int main(int argc, char **argv) { tar_header_decoded_t hdr; + sqfs_istream_t *fp; char buffer[6]; - istream_t *fp; (void)argc; (void)argv; fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE)); diff --git a/lib/util/test/str_table.c b/lib/util/test/str_table.c index d4160eb..5408fc0 100644 --- a/lib/util/test/str_table.c +++ b/lib/util/test/str_table.c @@ -15,7 +15,7 @@ static char *strings[1000]; static int read_strings(void) { - istream_t *fp; + sqfs_istream_t *fp; ssize_t ret; char *line; int i; |