diff options
| -rw-r--r-- | Makefile.am | 2 | ||||
| -rw-r--r-- | bin/gensquashfs/Makemodule.am | 2 | ||||
| -rw-r--r-- | bin/rdsquashfs/Makemodule.am | 2 | ||||
| -rw-r--r-- | bin/sqfs2tar/Makemodule.am | 2 | ||||
| -rw-r--r-- | bin/sqfs2tar/options.c | 12 | ||||
| -rw-r--r-- | bin/sqfs2tar/sqfs2tar.h | 2 | ||||
| -rw-r--r-- | bin/sqfsdiff/Makemodule.am | 2 | ||||
| -rw-r--r-- | bin/tar2sqfs/Makemodule.am | 2 | ||||
| -rw-r--r-- | bin/tar2sqfs/options.c | 8 | ||||
| -rw-r--r-- | bin/tar2sqfs/tar2sqfs.c | 4 | ||||
| -rw-r--r-- | bin/tar2sqfs/tar2sqfs.h | 2 | ||||
| -rw-r--r-- | include/common.h | 4 | ||||
| -rw-r--r-- | include/compat.h | 2 | ||||
| -rw-r--r-- | include/fstream.h | 402 | ||||
| -rw-r--r-- | include/fstree.h | 2 | ||||
| -rw-r--r-- | include/io/file.h | 52 | ||||
| -rw-r--r-- | include/io/istream.h | 128 | ||||
| -rw-r--r-- | include/io/ostream.h | 138 | ||||
| -rw-r--r-- | include/io/std.h | 39 | ||||
| -rw-r--r-- | include/io/xfrm.h | 128 | ||||
| -rw-r--r-- | include/tar.h | 3 | ||||
| -rw-r--r-- | lib/fstream/Makemodule.am | 45 | ||||
| -rw-r--r-- | lib/fstree/fstree_from_file.c | 2 | ||||
| -rw-r--r-- | lib/io/Makemodule.am | 45 | ||||
| -rw-r--r-- | lib/io/compress/bzip2.c (renamed from lib/fstream/compress/bzip2.c) | 0 | ||||
| -rw-r--r-- | lib/io/compress/gzip.c (renamed from lib/fstream/compress/gzip.c) | 0 | ||||
| -rw-r--r-- | lib/io/compress/ostream_compressor.c (renamed from lib/fstream/compress/ostream_compressor.c) | 8 | ||||
| -rw-r--r-- | lib/io/compress/xz.c (renamed from lib/fstream/compress/xz.c) | 0 | ||||
| -rw-r--r-- | lib/io/compress/zstd.c (renamed from lib/fstream/compress/zstd.c) | 0 | ||||
| -rw-r--r-- | lib/io/get_line.c (renamed from lib/fstream/get_line.c) | 0 | ||||
| -rw-r--r-- | lib/io/internal.h (renamed from lib/fstream/internal.h) | 6 | ||||
| -rw-r--r-- | lib/io/istream.c (renamed from lib/fstream/istream.c) | 0 | ||||
| -rw-r--r-- | lib/io/ostream.c (renamed from lib/fstream/ostream.c) | 0 | ||||
| -rw-r--r-- | lib/io/printf.c (renamed from lib/fstream/printf.c) | 0 | ||||
| -rw-r--r-- | lib/io/uncompress/autodetect.c (renamed from lib/fstream/uncompress/autodetect.c) | 8 | ||||
| -rw-r--r-- | lib/io/uncompress/bzip2.c (renamed from lib/fstream/uncompress/bzip2.c) | 0 | ||||
| -rw-r--r-- | lib/io/uncompress/gzip.c (renamed from lib/fstream/uncompress/gzip.c) | 0 | ||||
| -rw-r--r-- | lib/io/uncompress/istream_compressor.c (renamed from lib/fstream/uncompress/istream_compressor.c) | 8 | ||||
| -rw-r--r-- | lib/io/uncompress/xz.c (renamed from lib/fstream/uncompress/xz.c) | 0 | ||||
| -rw-r--r-- | lib/io/uncompress/zstd.c (renamed from lib/fstream/uncompress/zstd.c) | 0 | ||||
| -rw-r--r-- | lib/io/unix/istream.c (renamed from lib/fstream/unix/istream.c) | 0 | ||||
| -rw-r--r-- | lib/io/unix/ostream.c (renamed from lib/fstream/unix/ostream.c) | 0 | ||||
| -rw-r--r-- | lib/io/win32/istream.c (renamed from lib/fstream/win32/istream.c) | 0 | ||||
| -rw-r--r-- | lib/io/win32/ostream.c (renamed from lib/fstream/win32/ostream.c) | 0 | ||||
| -rw-r--r-- | lib/io/xfrm.c (renamed from lib/fstream/compressor.c) | 30 | ||||
| -rw-r--r-- | tests/Makemodule.am | 2 | ||||
| -rw-r--r-- | tests/libfstree/Makemodule.am | 12 | ||||
| -rw-r--r-- | tests/libio/Makemodule.am (renamed from tests/libfstream/Makemodule.am) | 36 | ||||
| -rw-r--r-- | tests/libio/get_line.c (renamed from tests/libfstream/get_line.c) | 2 | ||||
| -rw-r--r-- | tests/libio/get_line.txt (renamed from tests/libfstream/get_line.txt) | 0 | ||||
| -rw-r--r-- | tests/libio/uncompress.c (renamed from tests/libfstream/uncompress.c) | 17 | ||||
| -rw-r--r-- | tests/libtar/Makemodule.am | 60 | ||||
| -rw-r--r-- | tests/libtar/tar_big_file.c | 1 | ||||
| -rw-r--r-- | tests/libtar/tar_fuzz.c | 1 | ||||
| -rw-r--r-- | tests/libtar/tar_simple.c | 1 | ||||
| -rw-r--r-- | tests/libtar/tar_sparse.c | 1 | ||||
| -rw-r--r-- | tests/libtar/tar_sparse_gnu.c | 1 | ||||
| -rw-r--r-- | tests/libtar/tar_target_filled.c | 1 | ||||
| -rw-r--r-- | tests/libtar/tar_xattr.c | 1 | ||||
| -rw-r--r-- | tests/libtar/tar_xattr_bin.c | 1 | ||||
| -rw-r--r-- | tests/libutil/Makemodule.am | 2 | ||||
| -rw-r--r-- | tests/libutil/str_table.c | 2 | 
62 files changed, 667 insertions, 564 deletions
| diff --git a/Makefile.am b/Makefile.am index 33efeb7..bbb48f0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,7 +29,7 @@ TESTS =  include lib/lz4/Makemodule.am  include lib/sqfs/Makemodule.am  include lib/util/Makemodule.am -include lib/fstream/Makemodule.am +include lib/io/Makemodule.am  if BUILD_TOOLS  include lib/fstree/Makemodule.am diff --git a/bin/gensquashfs/Makemodule.am b/bin/gensquashfs/Makemodule.am index 11a3535..03f4f4c 100644 --- a/bin/gensquashfs/Makemodule.am +++ b/bin/gensquashfs/Makemodule.am @@ -1,7 +1,7 @@  gensquashfs_SOURCES = bin/gensquashfs/mkfs.c bin/gensquashfs/mkfs.h  gensquashfs_SOURCES += bin/gensquashfs/options.c bin/gensquashfs/selinux.c  gensquashfs_SOURCES += bin/gensquashfs/dirscan_xattr.c -gensquashfs_LDADD = libcommon.a libsquashfs.la libfstree.a libfstream.a +gensquashfs_LDADD = libcommon.a libsquashfs.la libfstree.a libio.a  gensquashfs_LDADD += libcompat.a $(LZO_LIBS) $(PTHREAD_LIBS)  gensquashfs_CPPFLAGS = $(AM_CPPFLAGS)  gensquashfs_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) diff --git a/bin/rdsquashfs/Makemodule.am b/bin/rdsquashfs/Makemodule.am index 094771c..974e7bc 100644 --- a/bin/rdsquashfs/Makemodule.am +++ b/bin/rdsquashfs/Makemodule.am @@ -4,7 +4,7 @@ rdsquashfs_SOURCES += bin/rdsquashfs/restore_fstree.c bin/rdsquashfs/describe.c  rdsquashfs_SOURCES += bin/rdsquashfs/fill_files.c bin/rdsquashfs/dump_xattrs.c  rdsquashfs_SOURCES += bin/rdsquashfs/stat.c  rdsquashfs_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -rdsquashfs_LDADD = libcommon.a libfstream.a libcompat.a libsquashfs.la +rdsquashfs_LDADD = libcommon.a libio.a libcompat.a libsquashfs.la  rdsquashfs_LDADD += libfstree.a $(LZO_LIBS) $(PTHREAD_LIBS)  dist_man1_MANS += bin/rdsquashfs/rdsquashfs.1 diff --git a/bin/sqfs2tar/Makemodule.am b/bin/sqfs2tar/Makemodule.am index 5355157..22d523e 100644 --- a/bin/sqfs2tar/Makemodule.am +++ b/bin/sqfs2tar/Makemodule.am @@ -3,7 +3,7 @@ sqfs2tar_SOURCES += bin/sqfs2tar/options.c bin/sqfs2tar/write_tree.c  sqfs2tar_SOURCES += bin/sqfs2tar/xattr.c  sqfs2tar_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)  sqfs2tar_LDADD = libcommon.a libutil.a libsquashfs.la libtar.a -sqfs2tar_LDADD += libfstream.a libcompat.a libfstree.a +sqfs2tar_LDADD += libio.a libcompat.a libfstree.a  sqfs2tar_LDADD += $(ZLIB_LIBS) $(XZ_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(BZIP2_LIBS)  sqfs2tar_LDADD += $(PTHREAD_LIBS) diff --git a/bin/sqfs2tar/options.c b/bin/sqfs2tar/options.c index 1b652b5..4f783e0 100644 --- a/bin/sqfs2tar/options.c +++ b/bin/sqfs2tar/options.c @@ -91,14 +91,14 @@ void process_args(int argc, char **argv)  		switch (i) {  		case 'c': -			compressor = fstream_compressor_id_from_name(optarg); +			compressor = io_compressor_id_from_name(optarg);  			if (compressor <= 0) {  				fprintf(stderr, "unknown compressor '%s'.\n",  					optarg);  				goto fail;  			} -			if (!fstream_compressor_exists(compressor)) { +			if (!io_compressor_exists(compressor)) {  				fprintf(stderr,  					"%s compressor is not supported.\n",  					optarg); @@ -163,11 +163,11 @@ void process_args(int argc, char **argv)  		case 'h':  			fputs(usagestr, stdout); -			i = FSTREAM_COMPRESSOR_MIN; +			i = IO_COMPRESSOR_MIN; -			while (i <= FSTREAM_COMPRESSOR_MAX) { -				name = fstream_compressor_name_from_id(i); -				if (fstream_compressor_exists(i)) +			while (i <= IO_COMPRESSOR_MAX) { +				name = io_compressor_name_from_id(i); +				if (io_compressor_exists(i))  					printf("\t%s\n", name);  				++i;  			} diff --git a/bin/sqfs2tar/sqfs2tar.h b/bin/sqfs2tar/sqfs2tar.h index 1986c56..587e8ad 100644 --- a/bin/sqfs2tar/sqfs2tar.h +++ b/bin/sqfs2tar/sqfs2tar.h @@ -11,6 +11,8 @@  #include "common.h"  #include "tar.h" +#include "io/xfrm.h" +  #include <getopt.h>  #include <string.h>  #include <stdlib.h> diff --git a/bin/sqfsdiff/Makemodule.am b/bin/sqfsdiff/Makemodule.am index 8331f25..bd93a74 100644 --- a/bin/sqfsdiff/Makemodule.am +++ b/bin/sqfsdiff/Makemodule.am @@ -4,7 +4,7 @@ sqfsdiff_SOURCES += bin/sqfsdiff/compare_dir.c bin/sqfsdiff/node_compare.c  sqfsdiff_SOURCES += bin/sqfsdiff/compare_files.c bin/sqfsdiff/super.c  sqfsdiff_SOURCES += bin/sqfsdiff/extract.c  sqfsdiff_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -sqfsdiff_LDADD = libcommon.a libsquashfs.la libfstream.a libcompat.a +sqfsdiff_LDADD = libcommon.a libsquashfs.la libio.a libcompat.a  sqfsdiff_LDADD += $(LZO_LIBS) libfstree.a $(PTHREAD_LIBS)  dist_man1_MANS += bin/sqfsdiff/sqfsdiff.1 diff --git a/bin/tar2sqfs/Makemodule.am b/bin/tar2sqfs/Makemodule.am index 6db3628..818f6e2 100644 --- a/bin/tar2sqfs/Makemodule.am +++ b/bin/tar2sqfs/Makemodule.am @@ -1,7 +1,7 @@  tar2sqfs_SOURCES = bin/tar2sqfs/tar2sqfs.c bin/tar2sqfs/tar2sqfs.h  tar2sqfs_SOURCES += bin/tar2sqfs/options.c bin/tar2sqfs/process_tarball.c  tar2sqfs_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -tar2sqfs_LDADD = libcommon.a libsquashfs.la libtar.a libfstream.a +tar2sqfs_LDADD = libcommon.a libsquashfs.la libtar.a libio.a  tar2sqfs_LDADD += libfstree.a libcompat.a libfstree.a $(LZO_LIBS)  tar2sqfs_LDADD += $(ZLIB_LIBS) $(XZ_LIBS) $(ZSTD_LIBS) $(BZIP2_LIBS)  tar2sqfs_LDADD += $(PTHREAD_LIBS) diff --git a/bin/tar2sqfs/options.c b/bin/tar2sqfs/options.c index 7727a47..94e7036 100644 --- a/bin/tar2sqfs/options.c +++ b/bin/tar2sqfs/options.c @@ -94,15 +94,15 @@ char *root_becomes = NULL;  static void input_compressor_print_available(void)  { -	int i = FSTREAM_COMPRESSOR_MIN; +	int i = IO_COMPRESSOR_MIN;  	const char *name;  	fputs("\nSupported tar compression formats:\n", stdout); -	while (i <= FSTREAM_COMPRESSOR_MAX) { -		name = fstream_compressor_name_from_id(i); +	while (i <= IO_COMPRESSOR_MAX) { +		name = io_compressor_name_from_id(i); -		if (fstream_compressor_exists(i)) +		if (io_compressor_exists(i))  			printf("\t%s\n", name);  		++i; diff --git a/bin/tar2sqfs/tar2sqfs.c b/bin/tar2sqfs/tar2sqfs.c index 603ee25..4e9ade9 100644 --- a/bin/tar2sqfs/tar2sqfs.c +++ b/bin/tar2sqfs/tar2sqfs.c @@ -50,11 +50,11 @@ int main(int argc, char **argv)  		goto out_if;  	if (ret > 0) { -		if (!fstream_compressor_exists(ret)) { +		if (!io_compressor_exists(ret)) {  			fprintf(stderr,  				"%s: %s compression is not supported.\n",  				istream_get_filename(input_file), -				fstream_compressor_name_from_id(ret)); +				io_compressor_name_from_id(ret));  			goto out_if;  		} diff --git a/bin/tar2sqfs/tar2sqfs.h b/bin/tar2sqfs/tar2sqfs.h index 915d89c..d5a4ada 100644 --- a/bin/tar2sqfs/tar2sqfs.h +++ b/bin/tar2sqfs/tar2sqfs.h @@ -12,6 +12,8 @@  #include "compat.h"  #include "tar.h" +#include "io/xfrm.h" +  #include <stdlib.h>  #include <getopt.h>  #include <string.h> diff --git a/include/common.h b/include/common.h index df3017a..ab07461 100644 --- a/include/common.h +++ b/include/common.h @@ -20,7 +20,9 @@  #include "simple_writer.h"  #include "compress_cli.h" -#include "fstream.h" +#include "io/ostream.h" +#include "io/file.h" +#include "io/std.h"  #include "compat.h"  #include "fstree.h"  #include "tar.h" diff --git a/include/compat.h b/include/compat.h index 6b4d83d..8969d6c 100644 --- a/include/compat.h +++ b/include/compat.h @@ -8,7 +8,7 @@  #define COMPAT_H  #include "sqfs/predef.h" -#include "fstream.h" +#include "io/ostream.h"  #include "config.h"  #include <limits.h> diff --git a/include/fstream.h b/include/fstream.h deleted file mode 100644 index 0e8905e..0000000 --- a/include/fstream.h +++ /dev/null @@ -1,402 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * fstream.h - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#ifndef FSTREAM_H -#define FSTREAM_H - -#include "sqfs/predef.h" - -#if defined(__GNUC__) || defined(__clang__) -#	define PRINTF_ATTRIB(fmt, elipsis)			\ -		__attribute__ ((format (printf, fmt, elipsis))) -#else -#	define PRINTF_ATTRIB(fmt, elipsis) -#endif - -/** - * @struct ostream_t - * - * @extends sqfs_object_t - * - * @brief An append-only data stream. - */ -typedef struct ostream_t { -	sqfs_object_t base; - -	int (*append)(struct ostream_t *strm, const void *data, size_t size); - -	int (*append_sparse)(struct ostream_t *strm, size_t size); - -	int (*flush)(struct ostream_t *strm); - -	const char *(*get_filename)(struct ostream_t *strm); -} ostream_t; - -/** - * @struct istream_t - * - * @extends sqfs_object_t - * - * @brief A sequential, read-only data stream. - */ -typedef struct istream_t { -	sqfs_object_t base; - -	size_t buffer_used; -	size_t buffer_offset; -	bool eof; - -	sqfs_u8 *buffer; - -	int (*precache)(struct istream_t *strm); - -	const char *(*get_filename)(struct istream_t *strm); -} istream_t; - - -enum { -	OSTREAM_OPEN_OVERWRITE = 0x01, -	OSTREAM_OPEN_SPARSE = 0x02, -}; - -enum { -	ISTREAM_LINE_LTRIM = 0x01, -	ISTREAM_LINE_RTRIM = 0x02, -	ISTREAM_LINE_SKIP_EMPTY = 0x04, -}; - -enum { -	/** -	 * @brief Deflate compressor with gzip headers. -	 * -	 * This actually creates a gzip compatible file, including a -	 * gzip header and trailer. -	 */ -	FSTREAM_COMPRESSOR_GZIP = 1, - -	FSTREAM_COMPRESSOR_XZ = 2, - -	FSTREAM_COMPRESSOR_ZSTD = 3, - -	FSTREAM_COMPRESSOR_BZIP2 = 4, - -	FSTREAM_COMPRESSOR_MIN = 1, -	FSTREAM_COMPRESSOR_MAX = 4, -}; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Create an output stream that writes to a file. - * - * @memberof ostream_t - * - * If the file does not yet exist, it is created. If it does exist this - * function fails, unless the flag OSTREAM_OPEN_OVERWRITE is set, in which - * case the file is opened and its contents are discarded. - * - * If the flag OSTREAM_OPEN_SPARSE is set, the underlying implementation tries - * to support sparse output files. If the flag is not set, holes will always - * be filled with zero bytes. - * - * @param path A path to the file to open or create. - * @param flags A combination of flags controling how to open/create the file. - * - * @return A pointer to an output stream on success, NULL on failure. - */ -SQFS_INTERNAL ostream_t *ostream_open_file(const char *path, int flags); - -/** - * @brief Create an output stream that writes to standard output. - * - * @memberof ostream_t - * - * @return A pointer to an output stream on success, NULL on failure. - */ -SQFS_INTERNAL ostream_t *ostream_open_stdout(void); - -/** - * @brief Create an input stream that reads from a file. - * - * @memberof 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); - -/** - * @brief Create an input stream that reads from standard input. - * - * @memberof istream_t - * - * @return A pointer to an input stream on success, NULL on failure. - */ -SQFS_INTERNAL istream_t *istream_open_stdin(void); - -/** - * @brief Create an output stream that transparently compresses data. - * - * @memberof ostream_t - * - * This function creates an output stream that transparently compresses all - * data appended to it and writes the compressed data to an underlying, wrapped - * output stream. - * - * The new stream takes ownership of the wrapped stream and destroys it when - * the compressor stream is destroyed. If this function fails, the wrapped - * stream is also destroyed. - * - * @param strm A pointer to another stream that should be wrapped. - * @param comp_id An identifier describing the compressor to use. - * - * @return A pointer to an output stream on success, NULL on failure. - */ -SQFS_INTERNAL ostream_t *ostream_compressor_create(ostream_t *strm, -						   int comp_id); - -/** - * @brief Create an input stream that transparently uncompresses data. - * - * @memberof istream_t - * - * This function creates an input stream that wraps an underlying input stream - * that is compressed and transparently uncompresses the data when reading - * from it. - * - * The new stream takes ownership of the wrapped stream and destroys it when - * the compressor stream is destroyed. If this function fails, the wrapped - * stream is also destroyed. - * - * @param strm A pointer to another stream that should be wrapped. - * @param comp_id An identifier describing the compressor to use. - * - * @return A pointer to an input stream on success, NULL on failure. - */ -SQFS_INTERNAL istream_t *istream_compressor_create(istream_t *strm, -						   int comp_id); - -/** - * @brief Probe the buffered data in an istream to check if it is compressed. - * - * @memberof istream_t - * - * This function peeks into the internal buffer of an input stream to check - * for magic signatures of various compressors. - * - * @param strm A pointer to an input stream to check - * @param probe A callback used to check if raw/decoded data matches an - *              expected format. Returns 0 if not, -1 on failure and +1 - *              on success. - * - * @return A compressor ID on success, 0 if no match was found, -1 on failure. - */ -SQFS_INTERNAL int istream_detect_compressor(istream_t *strm, -					    int (*probe)(const sqfs_u8 *data, -							 size_t size)); - -/** - * @brief Append a block of data to an output stream. - * - * @memberof ostream_t - * - * @param strm A pointer to an output stream. - * @param data A pointer to the data block to append. - * @param size The number of bytes to append. - * - * @return Zero on success, -1 on failure. - */ -SQFS_INTERNAL int ostream_append(ostream_t *strm, const void *data, -				 size_t size); - -/** - * @brief Append a number of zero bytes to an output stream. - * - * @memberof ostream_t - * - * If the unerlying implementation supports sparse files, this function can be - * used to create a "hole". If the implementation does not support it, a - * fallback is used that just appends a block of zeros manualy. - * - * @param strm A pointer to an output stream. - * @param size The number of zero bytes to append. - * - * @return Zero on success, -1 on failure. - */ -SQFS_INTERNAL int ostream_append_sparse(ostream_t *strm, size_t size); - -/** - * @brief Process all pending, buffered data and flush it to disk. - * - * @memberof ostream_t - * - * If the stream performs some kind of transformation (e.g. transparent data - * compression), flushing caues the wrapped format to insert a termination - * token. Only call this function when you are absolutely DONE appending data, - * shortly before destroying the stream. - * - * @param strm A pointer to an output stream. - * - * @return Zero on success, -1 on failure. - */ -SQFS_INTERNAL int ostream_flush(ostream_t *strm); - -/** - * @brief Get the underlying filename of a output stream. - * - * @memberof ostream_t - * - * @param strm The output stream to get the filename from. - * - * @return A string holding the underlying filename. - */ -SQFS_INTERNAL const char *ostream_get_filename(ostream_t *strm); - -/** - * @brief Printf like function that appends to an output stream - * - * @memberof ostream_t - * - * @param strm The output stream to append to. - * @param fmt A printf style format string. - * - * @return The number of characters written on success, -1 on failure. - */ -SQFS_INTERNAL int ostream_printf(ostream_t *strm, const char *fmt, ...) -	PRINTF_ATTRIB(2, 3); - -/** - * @brief Read a line of text from an input stream - * - * @memberof 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 - * and never includes the line break characters (LF or CR-LF). - * - * If the flag @ref ISTREAM_LINE_LTRIM is set, leading white space characters - * are removed. If the flag @ref ISTREAM_LINE_RTRIM is set, trailing white space - * characters are remvoed. - * - * If the flag @ref ISTREAM_LINE_SKIP_EMPTY is set and a line is discovered to - * be empty (after the optional trimming), the function discards the empty line - * and retries. The given line_num pointer is used to increment the line - * number. - * - * @param strm A pointer to an input stream. - * @param out Returns a pointer to a line on success. - * @param line_num This is incremented if lines are skipped. - * @param flags A combination of flags controling the functions behaviour. - * - * @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, -				   size_t *line_num, int flags); - -/** - * @brief Read data from an input stream - * - * @memberof 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(istream_t *strm, void *data, size_t size); - -/** - * @brief Adjust and refill the internal buffer of an input stream - * - * @memberof istream_t - * - * This function resets the buffer offset of an input stream (moving any unread - * data up front if it has to) and calls an internal callback of the input - * stream to fill the rest of the buffer to the extent possible. - * - * @param strm A pointer to an input stream. - * - * @return 0 on success, -1 on failure. - */ -SQFS_INTERNAL int istream_precache(istream_t *strm); - -/** - * @brief Get the underlying filename of an input stream. - * - * @memberof istream_t - * - * @param strm The input stream to get the filename from. - * - * @return A string holding the underlying filename. - */ -SQFS_INTERNAL const char *istream_get_filename(istream_t *strm); - -/** - * @brief Skip over a number of bytes in an input stream. - * - * @memberof 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); - -/** - * @brief Read data from an input stream and append it to an output stream - * - * @memberof ostream_t - * - * @param out A pointer to an output stream to append to. - * @param in A pointer to an input stream to read from. - * @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 ostream_append_from_istream(ostream_t *out, -						   istream_t *in, -						   sqfs_u32 size); - -/** - * @brief Resolve a compressor name to an ID. - * - * @param name A compressor name. - * - * @return A compressor ID on success, -1 on failure. - */ -SQFS_INTERNAL int fstream_compressor_id_from_name(const char *name); - -/** - * @brief Resolve a id to a  compressor name. - * - * @param id A compressor ID. - * - * @return A compressor name on success, NULL on failure. - */ -SQFS_INTERNAL const char *fstream_compressor_name_from_id(int id); - -/** - * @brief Check if support for a given compressor has been built in. - * - * @param id A compressor ID. - * - * @return True if the compressor is supported, false if not. - */ -SQFS_INTERNAL bool fstream_compressor_exists(int id); - -#ifdef __cplusplus -} -#endif - -#endif /* FSTREAM_H */ diff --git a/include/fstree.h b/include/fstree.h index 58936d7..3fb4f47 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -15,7 +15,7 @@  #include <stdio.h>  #include "sqfs/predef.h" -#include "fstream.h" +#include "io/istream.h"  #include "compat.h"  enum { diff --git a/include/io/file.h b/include/io/file.h new file mode 100644 index 0000000..8c6e851 --- /dev/null +++ b/include/io/file.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * file.h + * + * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> + */ +#ifndef IO_FILE_H +#define IO_FILE_H + +#include "io/istream.h" +#include "io/ostream.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create an input stream that reads from a file. + * + * @memberof 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); + +/** + * @brief Create an output stream that writes to a file. + * + * @memberof ostream_t + * + * If the file does not yet exist, it is created. If it does exist this + * function fails, unless the flag OSTREAM_OPEN_OVERWRITE is set, in which + * case the file is opened and its contents are discarded. + * + * If the flag OSTREAM_OPEN_SPARSE is set, the underlying implementation tries + * to support sparse output files. If the flag is not set, holes will always + * be filled with zero bytes. + * + * @param path A path to the file to open or create. + * @param flags A combination of flags controling how to open/create the file. + * + * @return A pointer to an output stream on success, NULL on failure. + */ +SQFS_INTERNAL ostream_t *ostream_open_file(const char *path, int flags); + +#ifdef __cplusplus +} +#endif + +#endif /* IO_FILE_H */ diff --git a/include/io/istream.h b/include/io/istream.h new file mode 100644 index 0000000..567d7e3 --- /dev/null +++ b/include/io/istream.h @@ -0,0 +1,128 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * istream.h + * + * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> + */ +#ifndef IO_ISTREAM_H +#define IO_ISTREAM_H + +#include "sqfs/predef.h" + +/** + * @struct istream_t + * + * @extends sqfs_object_t + * + * @brief A sequential, read-only data stream. + */ +typedef struct istream_t { +	sqfs_object_t base; + +	size_t buffer_used; +	size_t buffer_offset; +	bool eof; + +	sqfs_u8 *buffer; + +	int (*precache)(struct istream_t *strm); + +	const char *(*get_filename)(struct istream_t *strm); +} istream_t; + +enum { +	ISTREAM_LINE_LTRIM = 0x01, +	ISTREAM_LINE_RTRIM = 0x02, +	ISTREAM_LINE_SKIP_EMPTY = 0x04, +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Read a line of text from an input stream + * + * @memberof 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 + * and never includes the line break characters (LF or CR-LF). + * + * If the flag @ref ISTREAM_LINE_LTRIM is set, leading white space characters + * are removed. If the flag @ref ISTREAM_LINE_RTRIM is set, trailing white space + * characters are remvoed. + * + * If the flag @ref ISTREAM_LINE_SKIP_EMPTY is set and a line is discovered to + * be empty (after the optional trimming), the function discards the empty line + * and retries. The given line_num pointer is used to increment the line + * number. + * + * @param strm A pointer to an input stream. + * @param out Returns a pointer to a line on success. + * @param line_num This is incremented if lines are skipped. + * @param flags A combination of flags controling the functions behaviour. + * + * @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, +				   size_t *line_num, int flags); + +/** + * @brief Read data from an input stream + * + * @memberof 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(istream_t *strm, void *data, size_t size); + +/** + * @brief Adjust and refill the internal buffer of an input stream + * + * @memberof istream_t + * + * This function resets the buffer offset of an input stream (moving any unread + * data up front if it has to) and calls an internal callback of the input + * stream to fill the rest of the buffer to the extent possible. + * + * @param strm A pointer to an input stream. + * + * @return 0 on success, -1 on failure. + */ +SQFS_INTERNAL int istream_precache(istream_t *strm); + +/** + * @brief Get the underlying filename of an input stream. + * + * @memberof istream_t + * + * @param strm The input stream to get the filename from. + * + * @return A string holding the underlying filename. + */ +SQFS_INTERNAL const char *istream_get_filename(istream_t *strm); + +/** + * @brief Skip over a number of bytes in an input stream. + * + * @memberof 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); + +#ifdef __cplusplus +} +#endif + +#endif /* IO_ISTREAM_H */ diff --git a/include/io/ostream.h b/include/io/ostream.h new file mode 100644 index 0000000..15585f9 --- /dev/null +++ b/include/io/ostream.h @@ -0,0 +1,138 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * ostream.h + * + * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> + */ +#ifndef IO_OSTREAM_H +#define IO_OSTREAM_H + +#include "sqfs/predef.h" +#include "io/istream.h" + +#if defined(__GNUC__) || defined(__clang__) +#	define PRINTF_ATTRIB(fmt, elipsis)			\ +		__attribute__ ((format (printf, fmt, elipsis))) +#else +#	define PRINTF_ATTRIB(fmt, elipsis) +#endif + +/** + * @struct ostream_t + * + * @extends sqfs_object_t + * + * @brief An append-only data stream. + */ +typedef struct ostream_t { +	sqfs_object_t base; + +	int (*append)(struct ostream_t *strm, const void *data, size_t size); + +	int (*append_sparse)(struct ostream_t *strm, size_t size); + +	int (*flush)(struct ostream_t *strm); + +	const char *(*get_filename)(struct ostream_t *strm); +} ostream_t; + +enum { +	OSTREAM_OPEN_OVERWRITE = 0x01, +	OSTREAM_OPEN_SPARSE = 0x02, +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Append a block of data to an output stream. + * + * @memberof ostream_t + * + * @param strm A pointer to an output stream. + * @param data A pointer to the data block to append. + * @param size The number of bytes to append. + * + * @return Zero on success, -1 on failure. + */ +SQFS_INTERNAL int ostream_append(ostream_t *strm, const void *data, +				 size_t size); + +/** + * @brief Append a number of zero bytes to an output stream. + * + * @memberof ostream_t + * + * If the unerlying implementation supports sparse files, this function can be + * used to create a "hole". If the implementation does not support it, a + * fallback is used that just appends a block of zeros manualy. + * + * @param strm A pointer to an output stream. + * @param size The number of zero bytes to append. + * + * @return Zero on success, -1 on failure. + */ +SQFS_INTERNAL int ostream_append_sparse(ostream_t *strm, size_t size); + +/** + * @brief Process all pending, buffered data and flush it to disk. + * + * @memberof ostream_t + * + * If the stream performs some kind of transformation (e.g. transparent data + * compression), flushing caues the wrapped format to insert a termination + * token. Only call this function when you are absolutely DONE appending data, + * shortly before destroying the stream. + * + * @param strm A pointer to an output stream. + * + * @return Zero on success, -1 on failure. + */ +SQFS_INTERNAL int ostream_flush(ostream_t *strm); + +/** + * @brief Get the underlying filename of a output stream. + * + * @memberof ostream_t + * + * @param strm The output stream to get the filename from. + * + * @return A string holding the underlying filename. + */ +SQFS_INTERNAL const char *ostream_get_filename(ostream_t *strm); + +/** + * @brief Printf like function that appends to an output stream + * + * @memberof ostream_t + * + * @param strm The output stream to append to. + * @param fmt A printf style format string. + * + * @return The number of characters written on success, -1 on failure. + */ +SQFS_INTERNAL int ostream_printf(ostream_t *strm, const char *fmt, ...) +	PRINTF_ATTRIB(2, 3); + +/** + * @brief Read data from an input stream and append it to an output stream + * + * @memberof ostream_t + * + * @param out A pointer to an output stream to append to. + * @param in A pointer to an input stream to read from. + * @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 ostream_append_from_istream(ostream_t *out, +						   istream_t *in, +						   sqfs_u32 size); + +#ifdef __cplusplus +} +#endif + +#endif /* IO_OSTREAM_H */ diff --git a/include/io/std.h b/include/io/std.h new file mode 100644 index 0000000..805bebd --- /dev/null +++ b/include/io/std.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * std.h + * + * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> + */ +#ifndef IO_STD_H +#define IO_STD_H + +#include "io/istream.h" +#include "io/ostream.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create an input stream that reads from standard input. + * + * @memberof istream_t + * + * @return A pointer to an input stream on success, NULL on failure. + */ +SQFS_INTERNAL istream_t *istream_open_stdin(void); + +/** + * @brief Create an output stream that writes to standard output. + * + * @memberof ostream_t + * + * @return A pointer to an output stream on success, NULL on failure. + */ +SQFS_INTERNAL ostream_t *ostream_open_stdout(void); + +#ifdef __cplusplus +} +#endif + +#endif /* IO_STD_H */ diff --git a/include/io/xfrm.h b/include/io/xfrm.h new file mode 100644 index 0000000..22a42b6 --- /dev/null +++ b/include/io/xfrm.h @@ -0,0 +1,128 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * xfrm.h + * + * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> + */ +#ifndef IO_XFRM_H +#define IO_XFRM_H + +#include "io/istream.h" +#include "io/ostream.h" + +enum { +	/** +	 * @brief Deflate compressor with gzip headers. +	 * +	 * This actually creates a gzip compatible file, including a +	 * gzip header and trailer. +	 */ +	IO_COMPRESSOR_GZIP = 1, + +	IO_COMPRESSOR_XZ = 2, + +	IO_COMPRESSOR_ZSTD = 3, + +	IO_COMPRESSOR_BZIP2 = 4, + +	IO_COMPRESSOR_MIN = 1, +	IO_COMPRESSOR_MAX = 4, +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create an input stream that transparently uncompresses data. + * + * @memberof istream_t + * + * This function creates an input stream that wraps an underlying input stream + * that is compressed and transparently uncompresses the data when reading + * from it. + * + * The new stream takes ownership of the wrapped stream and destroys it when + * the compressor stream is destroyed. If this function fails, the wrapped + * stream is also destroyed. + * + * @param strm A pointer to another stream that should be wrapped. + * @param comp_id An identifier describing the compressor to use. + * + * @return A pointer to an input stream on success, NULL on failure. + */ +SQFS_INTERNAL istream_t *istream_compressor_create(istream_t *strm, +						   int comp_id); + +/** + * @brief Create an output stream that transparently compresses data. + * + * @memberof ostream_t + * + * This function creates an output stream that transparently compresses all + * data appended to it and writes the compressed data to an underlying, wrapped + * output stream. + * + * The new stream takes ownership of the wrapped stream and destroys it when + * the compressor stream is destroyed. If this function fails, the wrapped + * stream is also destroyed. + * + * @param strm A pointer to another stream that should be wrapped. + * @param comp_id An identifier describing the compressor to use. + * + * @return A pointer to an output stream on success, NULL on failure. + */ +SQFS_INTERNAL ostream_t *ostream_compressor_create(ostream_t *strm, +						   int comp_id); + +/** + * @brief Probe the buffered data in an istream to check if it is compressed. + * + * @memberof istream_t + * + * This function peeks into the internal buffer of an input stream to check + * for magic signatures of various compressors. + * + * @param strm A pointer to an input stream to check + * @param probe A callback used to check if raw/decoded data matches an + *              expected format. Returns 0 if not, -1 on failure and +1 + *              on success. + * + * @return A compressor ID on success, 0 if no match was found, -1 on failure. + */ +SQFS_INTERNAL int istream_detect_compressor(istream_t *strm, +					    int (*probe)(const sqfs_u8 *data, +							 size_t size)); + +/** + * @brief Resolve a compressor name to an ID. + * + * @param name A compressor name. + * + * @return A compressor ID on success, -1 on failure. + */ +SQFS_INTERNAL int io_compressor_id_from_name(const char *name); + +/** + * @brief Resolve a id to a  compressor name. + * + * @param id A compressor ID. + * + * @return A compressor name on success, NULL on failure. + */ +SQFS_INTERNAL const char *io_compressor_name_from_id(int id); + +/** + * @brief Check if support for a given compressor has been built in. + * + * @param id A compressor ID. + * + * @return True if the compressor is supported, false if not. + */ +SQFS_INTERNAL bool io_compressor_exists(int id); + +#ifdef __cplusplus +} +#endif + +#endif /* IO_XFRM_H */ diff --git a/include/tar.h b/include/tar.h index 41be57f..dadc16e 100644 --- a/include/tar.h +++ b/include/tar.h @@ -9,7 +9,8 @@  #include "config.h"  #include "compat.h" -#include "fstream.h" +#include "io/istream.h" +#include "io/ostream.h"  #include <stdbool.h>  #include <stdint.h> diff --git a/lib/fstream/Makemodule.am b/lib/fstream/Makemodule.am deleted file mode 100644 index ad5f426..0000000 --- a/lib/fstream/Makemodule.am +++ /dev/null @@ -1,45 +0,0 @@ -libfstream_a_SOURCES = include/fstream.h -libfstream_a_SOURCES += lib/fstream/internal.h -libfstream_a_SOURCES += lib/fstream/ostream.c lib/fstream/printf.c -libfstream_a_SOURCES += lib/fstream/istream.c lib/fstream/get_line.c -libfstream_a_SOURCES += lib/fstream/compressor.c -libfstream_a_SOURCES += lib/fstream/compress/ostream_compressor.c -libfstream_a_SOURCES += lib/fstream/uncompress/istream_compressor.c -libfstream_a_SOURCES += lib/fstream/uncompress/autodetect.c -libfstream_a_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) $(XZ_CFLAGS) -libfstream_a_CFLAGS += $(ZSTD_CFLAGS) $(BZIP2_CFLAGS) -libfstream_a_CPPFLAGS = $(AM_CPPFLAGS) - -if WINDOWS -libfstream_a_SOURCES += lib/fstream/win32/ostream.c -libfstream_a_SOURCES += lib/fstream/win32/istream.c -libfstream_a_CFLAGS += -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -else -libfstream_a_SOURCES += lib/fstream/unix/ostream.c -libfstream_a_SOURCES += lib/fstream/unix/istream.c -endif - -if WITH_XZ -libfstream_a_SOURCES += lib/fstream/compress/xz.c lib/fstream/uncompress/xz.c -libfstream_a_CPPFLAGS += -DWITH_XZ -endif - -if WITH_GZIP -libfstream_a_SOURCES += lib/fstream/compress/gzip.c -libfstream_a_SOURCES += lib/fstream/uncompress/gzip.c -libfstream_a_CPPFLAGS += -DWITH_GZIP -endif - -if WITH_ZSTD -libfstream_a_SOURCES += lib/fstream/compress/zstd.c -libfstream_a_SOURCES += lib/fstream/uncompress/zstd.c -libfstream_a_CPPFLAGS += -DWITH_ZSTD -endif - -if WITH_BZIP2 -libfstream_a_SOURCES += lib/fstream/compress/bzip2.c -libfstream_a_SOURCES += lib/fstream/uncompress/bzip2.c -libfstream_a_CPPFLAGS += -DWITH_BZIP2 -endif - -noinst_LIBRARIES += libfstream.a diff --git a/lib/fstree/fstree_from_file.c b/lib/fstree/fstree_from_file.c index e77f19a..dd289bc 100644 --- a/lib/fstree/fstree_from_file.c +++ b/lib/fstree/fstree_from_file.c @@ -6,8 +6,8 @@   */  #include "config.h" +#include "io/file.h"  #include "fstree.h" -#include "fstream.h"  #include "compat.h"  #include <stdlib.h> diff --git a/lib/io/Makemodule.am b/lib/io/Makemodule.am new file mode 100644 index 0000000..63ce958 --- /dev/null +++ b/lib/io/Makemodule.am @@ -0,0 +1,45 @@ +libio_a_SOURCES = lib/io/internal.h +libio_a_SOURCES += include/io/istream.h lib/io/ostream.c lib/io/printf.c +libio_a_SOURCES += include/io/ostream.h lib/io/istream.c lib/io/get_line.c +libio_a_SOURCES += include/io/xfrm.h lib/io/xfrm.c +libio_a_SOURCES += include/io/file.h include/io/std.h +libio_a_SOURCES += lib/io/compress/ostream_compressor.c +libio_a_SOURCES += lib/io/uncompress/istream_compressor.c +libio_a_SOURCES += lib/io/uncompress/autodetect.c +libio_a_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) $(XZ_CFLAGS) +libio_a_CFLAGS += $(ZSTD_CFLAGS) $(BZIP2_CFLAGS) +libio_a_CPPFLAGS = $(AM_CPPFLAGS) + +if WINDOWS +libio_a_SOURCES += lib/io/win32/ostream.c +libio_a_SOURCES += lib/io/win32/istream.c +libio_a_CFLAGS += -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 +else +libio_a_SOURCES += lib/io/unix/ostream.c +libio_a_SOURCES += lib/io/unix/istream.c +endif + +if WITH_XZ +libio_a_SOURCES += lib/io/compress/xz.c lib/io/uncompress/xz.c +libio_a_CPPFLAGS += -DWITH_XZ +endif + +if WITH_GZIP +libio_a_SOURCES += lib/io/compress/gzip.c +libio_a_SOURCES += lib/io/uncompress/gzip.c +libio_a_CPPFLAGS += -DWITH_GZIP +endif + +if WITH_ZSTD +libio_a_SOURCES += lib/io/compress/zstd.c +libio_a_SOURCES += lib/io/uncompress/zstd.c +libio_a_CPPFLAGS += -DWITH_ZSTD +endif + +if WITH_BZIP2 +libio_a_SOURCES += lib/io/compress/bzip2.c +libio_a_SOURCES += lib/io/uncompress/bzip2.c +libio_a_CPPFLAGS += -DWITH_BZIP2 +endif + +noinst_LIBRARIES += libio.a diff --git a/lib/fstream/compress/bzip2.c b/lib/io/compress/bzip2.c index 7f0c09a..7f0c09a 100644 --- a/lib/fstream/compress/bzip2.c +++ b/lib/io/compress/bzip2.c diff --git a/lib/fstream/compress/gzip.c b/lib/io/compress/gzip.c index b73a258..b73a258 100644 --- a/lib/fstream/compress/gzip.c +++ b/lib/io/compress/gzip.c diff --git a/lib/fstream/compress/ostream_compressor.c b/lib/io/compress/ostream_compressor.c index 30ff7eb..314ce6b 100644 --- a/lib/fstream/compress/ostream_compressor.c +++ b/lib/io/compress/ostream_compressor.c @@ -67,22 +67,22 @@ ostream_t *ostream_compressor_create(ostream_t *strm, int comp_id)  	ostream_t *base;  	switch (comp_id) { -	case FSTREAM_COMPRESSOR_GZIP: +	case IO_COMPRESSOR_GZIP:  #ifdef WITH_GZIP  		comp = ostream_gzip_create(strm->get_filename(strm));  #endif  		break; -	case FSTREAM_COMPRESSOR_XZ: +	case IO_COMPRESSOR_XZ:  #ifdef WITH_XZ  		comp = ostream_xz_create(strm->get_filename(strm));  #endif  		break; -	case FSTREAM_COMPRESSOR_ZSTD: +	case IO_COMPRESSOR_ZSTD:  #if defined(WITH_ZSTD) && defined(HAVE_ZSTD_STREAM)  		comp = ostream_zstd_create(strm->get_filename(strm));  #endif  		break; -	case FSTREAM_COMPRESSOR_BZIP2: +	case IO_COMPRESSOR_BZIP2:  #ifdef WITH_BZIP2  		comp = ostream_bzip2_create(strm->get_filename(strm));  #endif diff --git a/lib/fstream/compress/xz.c b/lib/io/compress/xz.c index 65bda0b..65bda0b 100644 --- a/lib/fstream/compress/xz.c +++ b/lib/io/compress/xz.c diff --git a/lib/fstream/compress/zstd.c b/lib/io/compress/zstd.c index c0b002e..c0b002e 100644 --- a/lib/fstream/compress/zstd.c +++ b/lib/io/compress/zstd.c diff --git a/lib/fstream/get_line.c b/lib/io/get_line.c index f7e0b59..f7e0b59 100644 --- a/lib/fstream/get_line.c +++ b/lib/io/get_line.c diff --git a/lib/fstream/internal.h b/lib/io/internal.h index 4f02f8c..4ac38f5 100644 --- a/lib/fstream/internal.h +++ b/lib/io/internal.h @@ -9,7 +9,11 @@  #include "config.h"  #include "compat.h" -#include "fstream.h" +#include "io/istream.h" +#include "io/ostream.h" +#include "io/file.h" +#include "io/xfrm.h" +#include "io/std.h"  #include <string.h>  #include <stdlib.h> diff --git a/lib/fstream/istream.c b/lib/io/istream.c index 6318a23..6318a23 100644 --- a/lib/fstream/istream.c +++ b/lib/io/istream.c diff --git a/lib/fstream/ostream.c b/lib/io/ostream.c index afe76e8..afe76e8 100644 --- a/lib/fstream/ostream.c +++ b/lib/io/ostream.c diff --git a/lib/fstream/printf.c b/lib/io/printf.c index 3850487..3850487 100644 --- a/lib/fstream/printf.c +++ b/lib/io/printf.c diff --git a/lib/fstream/uncompress/autodetect.c b/lib/io/uncompress/autodetect.c index 61628f8..dde33c8 100644 --- a/lib/fstream/uncompress/autodetect.c +++ b/lib/io/uncompress/autodetect.c @@ -11,10 +11,10 @@ static const struct {  	const sqfs_u8 *value;  	size_t len;  } magic[] = { -	{ FSTREAM_COMPRESSOR_GZIP, (const sqfs_u8 *)"\x1F\x8B\x08", 3 }, -	{ FSTREAM_COMPRESSOR_XZ, (const sqfs_u8 *)("\xFD" "7zXZ"), 6 }, -	{ FSTREAM_COMPRESSOR_ZSTD, (const sqfs_u8 *)"\x28\xB5\x2F\xFD", 4 }, -	{ FSTREAM_COMPRESSOR_BZIP2, (const sqfs_u8 *)"BZh", 3 }, +	{ IO_COMPRESSOR_GZIP, (const sqfs_u8 *)"\x1F\x8B\x08", 3 }, +	{ IO_COMPRESSOR_XZ, (const sqfs_u8 *)("\xFD" "7zXZ"), 6 }, +	{ IO_COMPRESSOR_ZSTD, (const sqfs_u8 *)"\x28\xB5\x2F\xFD", 4 }, +	{ IO_COMPRESSOR_BZIP2, (const sqfs_u8 *)"BZh", 3 },  };  int istream_detect_compressor(istream_t *strm, diff --git a/lib/fstream/uncompress/bzip2.c b/lib/io/uncompress/bzip2.c index 3b44383..3b44383 100644 --- a/lib/fstream/uncompress/bzip2.c +++ b/lib/io/uncompress/bzip2.c diff --git a/lib/fstream/uncompress/gzip.c b/lib/io/uncompress/gzip.c index 1d6274c..1d6274c 100644 --- a/lib/fstream/uncompress/gzip.c +++ b/lib/io/uncompress/gzip.c diff --git a/lib/fstream/uncompress/istream_compressor.c b/lib/io/uncompress/istream_compressor.c index 75edd1b..ab9ad8b 100644 --- a/lib/fstream/uncompress/istream_compressor.c +++ b/lib/io/uncompress/istream_compressor.c @@ -29,22 +29,22 @@ istream_t *istream_compressor_create(istream_t *strm, int comp_id)  	istream_t *base;  	switch (comp_id) { -	case FSTREAM_COMPRESSOR_GZIP: +	case IO_COMPRESSOR_GZIP:  #ifdef WITH_GZIP  		comp = istream_gzip_create(strm->get_filename(strm));  #endif  		break; -	case FSTREAM_COMPRESSOR_XZ: +	case IO_COMPRESSOR_XZ:  #ifdef WITH_XZ  		comp = istream_xz_create(strm->get_filename(strm));  #endif  		break; -	case FSTREAM_COMPRESSOR_ZSTD: +	case IO_COMPRESSOR_ZSTD:  #if defined(WITH_ZSTD) && defined(HAVE_ZSTD_STREAM)  		comp = istream_zstd_create(strm->get_filename(strm));  #endif  		break; -	case FSTREAM_COMPRESSOR_BZIP2: +	case IO_COMPRESSOR_BZIP2:  #ifdef WITH_BZIP2  		comp = istream_bzip2_create(strm->get_filename(strm));  #endif diff --git a/lib/fstream/uncompress/xz.c b/lib/io/uncompress/xz.c index 0fd9ce6..0fd9ce6 100644 --- a/lib/fstream/uncompress/xz.c +++ b/lib/io/uncompress/xz.c diff --git a/lib/fstream/uncompress/zstd.c b/lib/io/uncompress/zstd.c index fd22cbf..fd22cbf 100644 --- a/lib/fstream/uncompress/zstd.c +++ b/lib/io/uncompress/zstd.c diff --git a/lib/fstream/unix/istream.c b/lib/io/unix/istream.c index 5898141..5898141 100644 --- a/lib/fstream/unix/istream.c +++ b/lib/io/unix/istream.c diff --git a/lib/fstream/unix/ostream.c b/lib/io/unix/ostream.c index 17f1998..17f1998 100644 --- a/lib/fstream/unix/ostream.c +++ b/lib/io/unix/ostream.c diff --git a/lib/fstream/win32/istream.c b/lib/io/win32/istream.c index b591584..b591584 100644 --- a/lib/fstream/win32/istream.c +++ b/lib/io/win32/istream.c diff --git a/lib/fstream/win32/ostream.c b/lib/io/win32/ostream.c index 2bd78c8..2bd78c8 100644 --- a/lib/fstream/win32/ostream.c +++ b/lib/io/win32/ostream.c diff --git a/lib/fstream/compressor.c b/lib/io/xfrm.c index 48f9567..22fd953 100644 --- a/lib/fstream/compressor.c +++ b/lib/io/xfrm.c @@ -6,57 +6,57 @@   */  #include "internal.h" -int fstream_compressor_id_from_name(const char *name) +int io_compressor_id_from_name(const char *name)  {  	if (strcmp(name, "gzip") == 0) -		return FSTREAM_COMPRESSOR_GZIP; +		return IO_COMPRESSOR_GZIP;  	if (strcmp(name, "xz") == 0) -		return FSTREAM_COMPRESSOR_XZ; +		return IO_COMPRESSOR_XZ;  	if (strcmp(name, "zstd") == 0) -		return FSTREAM_COMPRESSOR_ZSTD; +		return IO_COMPRESSOR_ZSTD;  	if (strcmp(name, "bzip2") == 0) -		return FSTREAM_COMPRESSOR_BZIP2; +		return IO_COMPRESSOR_BZIP2;  	return -1;  } -const char *fstream_compressor_name_from_id(int id) +const char *io_compressor_name_from_id(int id)  { -	if (id == FSTREAM_COMPRESSOR_GZIP) +	if (id == IO_COMPRESSOR_GZIP)  		return "gzip"; -	if (id == FSTREAM_COMPRESSOR_XZ) +	if (id == IO_COMPRESSOR_XZ)  		return "xz"; -	if (id == FSTREAM_COMPRESSOR_ZSTD) +	if (id == IO_COMPRESSOR_ZSTD)  		return "zstd"; -	if (id == FSTREAM_COMPRESSOR_BZIP2) +	if (id == IO_COMPRESSOR_BZIP2)  		return "bzip2";  	return NULL;  } -bool fstream_compressor_exists(int id) +bool io_compressor_exists(int id)  {  	switch (id) {  #ifdef WITH_GZIP -	case FSTREAM_COMPRESSOR_GZIP: +	case IO_COMPRESSOR_GZIP:  		return true;  #endif  #ifdef WITH_XZ -	case FSTREAM_COMPRESSOR_XZ: +	case IO_COMPRESSOR_XZ:  		return true;  #endif  #if defined(WITH_ZSTD) && defined(HAVE_ZSTD_STREAM) -	case FSTREAM_COMPRESSOR_ZSTD: +	case IO_COMPRESSOR_ZSTD:  		return true;  #endif  #ifdef WITH_BZIP2 -	case FSTREAM_COMPRESSOR_BZIP2: +	case IO_COMPRESSOR_BZIP2:  		return true;  #endif  	default: diff --git a/tests/Makemodule.am b/tests/Makemodule.am index 3165889..0ae3f8b 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -1,5 +1,5 @@  include tests/libutil/Makemodule.am -include tests/libfstream/Makemodule.am +include tests/libio/Makemodule.am  include tests/libfstree/Makemodule.am  include tests/libtar/Makemodule.am  include tests/libsqfs/Makemodule.am diff --git a/tests/libfstree/Makemodule.am b/tests/libfstree/Makemodule.am index 594ef7e..6b45ece 100644 --- a/tests/libfstree/Makemodule.am +++ b/tests/libfstree/Makemodule.am @@ -28,16 +28,16 @@ test_get_path_LDADD = libfstree.a libcompat.a  test_fstree_sort_SOURCES = tests/libfstree/fstree_sort.c tests/test.h  test_fstree_sort_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/fstree -test_fstree_sort_LDADD = libfstree.a libfstream.a libcompat.a +test_fstree_sort_LDADD = libfstree.a libio.a libcompat.a  test_fstree_from_file_SOURCES = tests/libfstree/fstree_from_file.c tests/test.h  test_fstree_from_file_CPPFLAGS = $(AM_CPPFLAGS)  test_fstree_from_file_CPPFLAGS += -DTESTPATH=$(FSTDATADIR)/fstree1.txt -test_fstree_from_file_LDADD = libfstree.a libfstream.a libcompat.a +test_fstree_from_file_LDADD = libfstree.a libio.a libcompat.a  test_fstree_glob1_SOURCES = tests/libfstree/fstree_glob1.c tests/test.h  test_fstree_glob1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(FSTDATADIR) -test_fstree_glob1_LDADD = libfstree.a libfstream.a libcompat.a +test_fstree_glob1_LDADD = libfstree.a libio.a libcompat.a  test_fstree_from_dir_SOURCES = tests/libfstree/fstree_from_dir.c tests/test.h  test_fstree_from_dir_CPPFLAGS = $(AM_CPPFLAGS) @@ -46,7 +46,7 @@ test_fstree_from_dir_LDADD = libfstree.a libcompat.a  test_fstree_init_SOURCES = tests/libfstree/fstree_init.c tests/test.h  test_fstree_init_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/fstree -test_fstree_init_LDADD = libfstree.a libfstream.a libcompat.a +test_fstree_init_LDADD = libfstree.a libio.a libcompat.a  test_filename_sane_SOURCES = tests/libfstree/filename_sane.c  test_filename_sane_SOURCES += lib/fstree/filename_sane.c @@ -63,10 +63,10 @@ test_fstree_epoch_SOURCES += lib/fstree/source_date_epoch.c  test_fstree_epoch_LDADD = libcompat.a  test_sort_file_SOURCES = tests/libfstree/sort_file.c -test_sort_file_LDADD = libfstree.a libfstream.a libcompat.a +test_sort_file_LDADD = libfstree.a libio.a libcompat.a  fstree_fuzz_SOURCES = tests/libfstree/fstree_fuzz.c -fstree_fuzz_LDADD = libfstree.a libfstream.a libcompat.a +fstree_fuzz_LDADD = libfstree.a libio.a libcompat.a  FSTREE_TESTS = \  	test_canonicalize_name test_mknode_simple test_mknode_slink \ diff --git a/tests/libfstream/Makemodule.am b/tests/libio/Makemodule.am index 57a98bc..86f2e3a 100644 --- a/tests/libfstream/Makemodule.am +++ b/tests/libio/Makemodule.am @@ -1,40 +1,40 @@ -test_get_line_SOURCES = tests/libfstream/get_line.c tests/test.h -test_get_line_LDADD = libfstream.a libcompat.a +test_get_line_SOURCES = tests/libio/get_line.c tests/test.h +test_get_line_LDADD = libio.a libcompat.a  test_get_line_CPPFLAGS = $(AM_CPPFLAGS) -test_get_line_CPPFLAGS += -DTESTFILE=$(top_srcdir)/tests/libfstream/get_line.txt +test_get_line_CPPFLAGS += -DTESTFILE=$(top_srcdir)/tests/libio/get_line.txt -test_xfrm_bzip2_SOURCES = tests/libfstream/uncompress.c tests/test.h -test_xfrm_bzip2_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS) +test_xfrm_bzip2_SOURCES = tests/libio/uncompress.c tests/test.h +test_xfrm_bzip2_LDADD = libio.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)  test_xfrm_bzip2_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)  test_xfrm_bzip2_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_BZIP2=1 -test_xfrm_bzip22_SOURCES = tests/libfstream/uncompress.c tests/test.h -test_xfrm_bzip22_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS) +test_xfrm_bzip22_SOURCES = tests/libio/uncompress.c tests/test.h +test_xfrm_bzip22_LDADD = libio.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)  test_xfrm_bzip22_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)  test_xfrm_bzip22_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_BZIP22=1 -test_xfrm_xz_SOURCES = tests/libfstream/uncompress.c tests/test.h -test_xfrm_xz_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS) +test_xfrm_xz_SOURCES = tests/libio/uncompress.c tests/test.h +test_xfrm_xz_LDADD = libio.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)  test_xfrm_xz_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)  test_xfrm_xz_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_XZ=1 -test_xfrm_xz2_SOURCES = tests/libfstream/uncompress.c tests/test.h -test_xfrm_xz2_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS) +test_xfrm_xz2_SOURCES = tests/libio/uncompress.c tests/test.h +test_xfrm_xz2_LDADD = libio.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)  test_xfrm_xz2_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)  test_xfrm_xz2_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_XZ2=1 -test_xfrm_gzip_SOURCES = tests/libfstream/uncompress.c tests/test.h -test_xfrm_gzip_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS) +test_xfrm_gzip_SOURCES = tests/libio/uncompress.c tests/test.h +test_xfrm_gzip_LDADD = libio.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)  test_xfrm_gzip_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)  test_xfrm_gzip_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_GZIP=1 -test_xfrm_zstd_SOURCES = tests/libfstream/uncompress.c tests/test.h -test_xfrm_zstd_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS) +test_xfrm_zstd_SOURCES = tests/libio/uncompress.c tests/test.h +test_xfrm_zstd_LDADD = libio.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)  test_xfrm_zstd_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)  test_xfrm_zstd_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_ZSTD=1 -test_xfrm_zstd2_SOURCES = tests/libfstream/uncompress.c tests/test.h -test_xfrm_zstd2_LDADD = libfstream.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS) +test_xfrm_zstd2_SOURCES = tests/libio/uncompress.c tests/test.h +test_xfrm_zstd2_LDADD = libio.a libcompat.a $(BZIP2_LIBS) $(ZLIB_LIBS)  test_xfrm_zstd2_LDADD += $(XZ_LIBS) $(ZSTD_LIBS)  test_xfrm_zstd2_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_ZSTD2=1 @@ -65,4 +65,4 @@ endif  endif  endif -EXTRA_DIST += $(top_srcdir)/tests/libfstream/get_line.txt +EXTRA_DIST += $(top_srcdir)/tests/libio/get_line.txt diff --git a/tests/libfstream/get_line.c b/tests/libio/get_line.c index 7d9a26a..66fced5 100644 --- a/tests/libfstream/get_line.c +++ b/tests/libio/get_line.c @@ -6,7 +6,7 @@   */  #include "config.h" -#include "fstream.h" +#include "io/file.h"  #include "../test.h"  typedef struct { diff --git a/tests/libfstream/get_line.txt b/tests/libio/get_line.txt index a1994f0..a1994f0 100644 --- a/tests/libfstream/get_line.txt +++ b/tests/libio/get_line.txt diff --git a/tests/libfstream/uncompress.c b/tests/libio/uncompress.c index 5f0cbec..9476877 100644 --- a/tests/libfstream/uncompress.c +++ b/tests/libio/uncompress.c @@ -4,7 +4,8 @@   *   * Copyright (C) 2021 David Oberhollenzer <goliath@infraroot.at>   */ -#include "fstream.h" +#include "io/istream.h" +#include "io/xfrm.h"  #include "../test.h"  static sqfs_u8 data_in[] = { @@ -341,16 +342,16 @@ static const char orig[] =  #if defined(TEST_BZIP2) || defined(TEST_BZIP22)  #define COMP_NAME "bzip2" -#define COMP_ID FSTREAM_COMPRESSOR_BZIP2 +#define COMP_ID IO_COMPRESSOR_BZIP2  #elif defined(TEST_XZ) || defined(TEST_XZ2)  #define COMP_NAME "xz" -#define COMP_ID FSTREAM_COMPRESSOR_XZ +#define COMP_ID IO_COMPRESSOR_XZ  #elif defined(TEST_GZIP)  #define COMP_NAME "gzip" -#define COMP_ID FSTREAM_COMPRESSOR_GZIP +#define COMP_ID IO_COMPRESSOR_GZIP  #elif defined(TEST_ZSTD) || defined(TEST_ZSTD2)  #define COMP_NAME "zstd" -#define COMP_ID FSTREAM_COMPRESSOR_ZSTD +#define COMP_ID IO_COMPRESSOR_ZSTD  #endif  static void destroy_noop(sqfs_object_t *obj) @@ -397,12 +398,12 @@ int main(int argc, char **argv)  	orig_sz = (sizeof(orig) / sizeof(orig[0])) - 1;  	/* generic API test */ -	TEST_ASSERT(fstream_compressor_exists(COMP_ID)); +	TEST_ASSERT(io_compressor_exists(COMP_ID)); -	name = fstream_compressor_name_from_id(COMP_ID); +	name = io_compressor_name_from_id(COMP_ID);  	TEST_STR_EQUAL(name, COMP_NAME); -	ret = fstream_compressor_id_from_name(name); +	ret = io_compressor_id_from_name(name);  	TEST_EQUAL_I(ret, COMP_ID);  	ret = istream_detect_compressor(&memstream, NULL); diff --git a/tests/libtar/Makemodule.am b/tests/libtar/Makemodule.am index bc829fb..b042f74 100644 --- a/tests/libtar/Makemodule.am +++ b/tests/libtar/Makemodule.am @@ -1,160 +1,160 @@  TARDATADIR=$(top_srcdir)/tests/libtar/data  test_tar_gnu0_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_gnu0_LDADD = libtar.a libfstream.a libcompat.a +test_tar_gnu0_LDADD = libtar.a libio.a libcompat.a  test_tar_gnu0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_gnu0_CPPFLAGS += -DTESTFILE=format-acceptance/gnu.tar  test_tar_gnu1_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_gnu1_LDADD = libtar.a libfstream.a libcompat.a +test_tar_gnu1_LDADD = libtar.a libio.a libcompat.a  test_tar_gnu1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_gnu1_CPPFLAGS += -DTESTFILE=format-acceptance/gnu-g.tar  test_tar_gnu2_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_gnu2_LDADD = libtar.a libfstream.a libcompat.a +test_tar_gnu2_LDADD = libtar.a libio.a libcompat.a  test_tar_gnu2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_gnu2_CPPFLAGS += -DTESTFILE=user-group-largenum/gnu.tar  test_tar_gnu2_CPPFLAGS += -DTESTUID=0x80000000  -DTESTGID=0x80000000  test_tar_gnu2_CPPFLAGS += -DTESTTS=1542995392  test_tar_gnu3_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_gnu3_LDADD = libtar.a libfstream.a libcompat.a +test_tar_gnu3_LDADD = libtar.a libio.a libcompat.a  test_tar_gnu3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_gnu3_CPPFLAGS += -DTESTFILE=negative-mtime/gnu.tar -DTESTTS=-315622800  test_tar_gnu4_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_gnu4_LDADD = libtar.a libfstream.a libcompat.a +test_tar_gnu4_LDADD = libtar.a libio.a libcompat.a  test_tar_gnu4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_gnu4_CPPFLAGS += -DTESTFILE=long-paths/gnu.tar -DLONG_NAME_TEST  test_tar_gnu4_CPPFLAGS += -DTESTTS=1542909670  test_tar_gnu5_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_gnu5_LDADD = libtar.a libfstream.a libcompat.a +test_tar_gnu5_LDADD = libtar.a libio.a libcompat.a  test_tar_gnu5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_gnu5_CPPFLAGS += -DTESTFILE=large-mtime/gnu.tar -DTESTTS=8589934592L  test_tar_gnu6_SOURCES = tests/libtar/tar_big_file.c tests/test.h -test_tar_gnu6_LDADD = libtar.a libfstream.a libcompat.a +test_tar_gnu6_LDADD = libtar.a libio.a libcompat.a  test_tar_gnu6_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_gnu6_CPPFLAGS += -DTESTFILE=file-size/gnu.tar  test_tar_pax0_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_pax0_LDADD = libtar.a libfstream.a libcompat.a +test_tar_pax0_LDADD = libtar.a libio.a libcompat.a  test_tar_pax0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_pax0_CPPFLAGS += -DTESTFILE=format-acceptance/pax.tar  test_tar_pax1_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_pax1_LDADD = libtar.a libfstream.a libcompat.a +test_tar_pax1_LDADD = libtar.a libio.a libcompat.a  test_tar_pax1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_pax1_CPPFLAGS += -DTESTFILE=user-group-largenum/pax.tar  test_tar_pax1_CPPFLAGS += -DTESTUID=2147483648UL -DTESTGID=2147483648UL  test_tar_pax1_CPPFLAGS += -DTESTTS=1542995392  test_tar_pax2_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_pax2_LDADD = libtar.a libfstream.a libcompat.a +test_tar_pax2_LDADD = libtar.a libio.a libcompat.a  test_tar_pax2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_pax2_CPPFLAGS += -DTESTFILE=large-mtime/pax.tar -DTESTTS=8589934592L  test_tar_pax3_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_pax3_LDADD = libtar.a libfstream.a libcompat.a +test_tar_pax3_LDADD = libtar.a libio.a libcompat.a  test_tar_pax3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_pax3_CPPFLAGS += -DTESTFILE=negative-mtime/pax.tar -DTESTTS=-315622800  test_tar_pax4_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_pax4_LDADD = libtar.a libfstream.a libcompat.a +test_tar_pax4_LDADD = libtar.a libio.a libcompat.a  test_tar_pax4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_pax4_CPPFLAGS += -DTESTFILE=long-paths/pax.tar  test_tar_pax4_CPPFLAGS += -DLONG_NAME_TEST -DTESTTS=1542909670  test_tar_pax5_SOURCES = tests/libtar/tar_big_file.c tests/test.h -test_tar_pax5_LDADD = libtar.a libfstream.a libcompat.a +test_tar_pax5_LDADD = libtar.a libio.a libcompat.a  test_tar_pax5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_pax5_CPPFLAGS += -DTESTFILE=file-size/pax.tar  test_tar_ustar0_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_ustar0_LDADD = libtar.a libfstream.a libcompat.a +test_tar_ustar0_LDADD = libtar.a libio.a libcompat.a  test_tar_ustar0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_ustar0_CPPFLAGS += -DTESTFILE=format-acceptance/ustar.tar  test_tar_ustar1_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_ustar1_LDADD = libtar.a libfstream.a libcompat.a +test_tar_ustar1_LDADD = libtar.a libio.a libcompat.a  test_tar_ustar1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_ustar1_CPPFLAGS += -DTESTFILE=format-acceptance/ustar-pre-posix.tar  test_tar_ustar2_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_ustar2_LDADD = libtar.a libfstream.a libcompat.a +test_tar_ustar2_LDADD = libtar.a libio.a libcompat.a  test_tar_ustar2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_ustar2_CPPFLAGS += -DTESTFILE=format-acceptance/v7.tar  test_tar_ustar3_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_ustar3_LDADD = libtar.a libfstream.a libcompat.a +test_tar_ustar3_LDADD = libtar.a libio.a libcompat.a  test_tar_ustar3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_ustar3_CPPFLAGS += -DTESTFILE=user-group-largenum/8-digit.tar  test_tar_ustar3_CPPFLAGS += -DTESTUID=8388608 -DTESTGID=8388608  test_tar_ustar3_CPPFLAGS += -DTESTTS=1542995392  test_tar_ustar4_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_ustar4_LDADD = libtar.a libfstream.a libcompat.a +test_tar_ustar4_LDADD = libtar.a libio.a libcompat.a  test_tar_ustar4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_ustar4_CPPFLAGS += -DTESTFILE=large-mtime/12-digit.tar  test_tar_ustar4_CPPFLAGS += -DTESTTS=8589934592L  test_tar_ustar5_SOURCES = tests/libtar/tar_simple.c tests/test.h -test_tar_ustar5_LDADD = libtar.a libfstream.a libcompat.a +test_tar_ustar5_LDADD = libtar.a libio.a libcompat.a  test_tar_ustar5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_ustar5_CPPFLAGS += -DTESTFILE=long-paths/ustar.tar  test_tar_ustar5_CPPFLAGS += -DLONG_NAME_TEST -DTESTTS=1542909670  test_tar_ustar6_SOURCES = tests/libtar/tar_big_file.c tests/test.h -test_tar_ustar6_LDADD = libtar.a libfstream.a libcompat.a +test_tar_ustar6_LDADD = libtar.a libio.a libcompat.a  test_tar_ustar6_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_ustar6_CPPFLAGS += -DTESTFILE=file-size/12-digit.tar  test_tar_target_filled_SOURCES = tests/libtar/tar_target_filled.c tests/test.h -test_tar_target_filled_LDADD = libtar.a libfstream.a libcompat.a +test_tar_target_filled_LDADD = libtar.a libio.a libcompat.a  test_tar_target_filled_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_sparse_gnu_SOURCES = tests/libtar/tar_sparse_gnu.c tests/test.h -test_tar_sparse_gnu_LDADD = libtar.a libfstream.a libcompat.a +test_tar_sparse_gnu_LDADD = libtar.a libio.a libcompat.a  test_tar_sparse_gnu_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_sparse_gnu0_SOURCES = tests/libtar/tar_sparse.c tests/test.h -test_tar_sparse_gnu0_LDADD = libtar.a libfstream.a libcompat.a +test_tar_sparse_gnu0_LDADD = libtar.a libio.a libcompat.a  test_tar_sparse_gnu0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_sparse_gnu0_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu0-0.tar  test_tar_sparse_gnu1_SOURCES = tests/libtar/tar_sparse.c tests/test.h -test_tar_sparse_gnu1_LDADD = libtar.a libfstream.a libcompat.a +test_tar_sparse_gnu1_LDADD = libtar.a libio.a libcompat.a  test_tar_sparse_gnu1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_sparse_gnu1_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu0-1.tar  test_tar_sparse_gnu2_SOURCES = tests/libtar/tar_sparse.c tests/test.h -test_tar_sparse_gnu2_LDADD = libtar.a libfstream.a libcompat.a +test_tar_sparse_gnu2_LDADD = libtar.a libio.a libcompat.a  test_tar_sparse_gnu2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_sparse_gnu2_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu1-0.tar  test_tar_sparse_gnu3_SOURCES = tests/libtar/tar_sparse.c tests/test.h -test_tar_sparse_gnu3_LDADD = libtar.a libfstream.a libcompat.a +test_tar_sparse_gnu3_LDADD = libtar.a libio.a libcompat.a  test_tar_sparse_gnu3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_sparse_gnu3_CPPFLAGS += -DTESTFILE=sparse-files/gnu.tar  test_tar_xattr_bsd_SOURCES = tests/libtar/tar_xattr.c tests/test.h -test_tar_xattr_bsd_LDADD = libtar.a libfstream.a libcompat.a +test_tar_xattr_bsd_LDADD = libtar.a libio.a libcompat.a  test_tar_xattr_bsd_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_xattr_bsd_CPPFLAGS += -DTESTFILE=xattr/xattr-libarchive.tar  test_tar_xattr_schily_SOURCES = tests/libtar/tar_xattr.c tests/test.h -test_tar_xattr_schily_LDADD = libtar.a libfstream.a libcompat.a +test_tar_xattr_schily_LDADD = libtar.a libio.a libcompat.a  test_tar_xattr_schily_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_xattr_schily_CPPFLAGS += -DTESTFILE=xattr/xattr-schily.tar  test_tar_xattr_schily_bin_SOURCES = tests/libtar/tar_xattr_bin.c tests/test.h -test_tar_xattr_schily_bin_LDADD = libtar.a libfstream.a libcompat.a +test_tar_xattr_schily_bin_LDADD = libtar.a libio.a libcompat.a  test_tar_xattr_schily_bin_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)  test_tar_xattr_schily_bin_CPPFLAGS += -DTESTFILE=xattr/xattr-schily-binary.tar  tar_fuzz_SOURCES = tests/libtar/tar_fuzz.c -tar_fuzz_LDADD = libtar.a libfstream.a libcompat.a +tar_fuzz_LDADD = libtar.a libio.a libcompat.a  LIBTAR_TESTS = \  	test_tar_ustar0 test_tar_ustar1 test_tar_ustar2 test_tar_ustar3 \ diff --git a/tests/libtar/tar_big_file.c b/tests/libtar/tar_big_file.c index 499805f..6e5af50 100644 --- a/tests/libtar/tar_big_file.c +++ b/tests/libtar/tar_big_file.c @@ -6,6 +6,7 @@   */  #include "config.h"  #include "tar.h" +#include "io/file.h"  #include "../test.h"  int main(int argc, char **argv) diff --git a/tests/libtar/tar_fuzz.c b/tests/libtar/tar_fuzz.c index d5728b5..e7ab2b4 100644 --- a/tests/libtar/tar_fuzz.c +++ b/tests/libtar/tar_fuzz.c @@ -6,6 +6,7 @@   */  #include "config.h" +#include "io/file.h"  #include "tar.h"  #include <stdlib.h> diff --git a/tests/libtar/tar_simple.c b/tests/libtar/tar_simple.c index e5f0137..4fc1b8b 100644 --- a/tests/libtar/tar_simple.c +++ b/tests/libtar/tar_simple.c @@ -5,6 +5,7 @@   * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>   */  #include "config.h" +#include "io/file.h"  #include "tar.h"  #include "../test.h" diff --git a/tests/libtar/tar_sparse.c b/tests/libtar/tar_sparse.c index 24f7a57..d868c80 100644 --- a/tests/libtar/tar_sparse.c +++ b/tests/libtar/tar_sparse.c @@ -5,6 +5,7 @@   * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>   */  #include "config.h" +#include "io/file.h"  #include "tar.h"  #include "../test.h" diff --git a/tests/libtar/tar_sparse_gnu.c b/tests/libtar/tar_sparse_gnu.c index 5d12478..c55f175 100644 --- a/tests/libtar/tar_sparse_gnu.c +++ b/tests/libtar/tar_sparse_gnu.c @@ -5,6 +5,7 @@   * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>   */  #include "config.h" +#include "io/file.h"  #include "tar.h"  #include "../test.h" diff --git a/tests/libtar/tar_target_filled.c b/tests/libtar/tar_target_filled.c index 57c6af9..34bf20f 100644 --- a/tests/libtar/tar_target_filled.c +++ b/tests/libtar/tar_target_filled.c @@ -5,6 +5,7 @@   * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>   */  #include "config.h" +#include "io/file.h"  #include "tar.h"  #include "../test.h" diff --git a/tests/libtar/tar_xattr.c b/tests/libtar/tar_xattr.c index 877bfba..7dde243 100644 --- a/tests/libtar/tar_xattr.c +++ b/tests/libtar/tar_xattr.c @@ -5,6 +5,7 @@   * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>   */  #include "config.h" +#include "io/file.h"  #include "tar.h"  #include "../test.h" diff --git a/tests/libtar/tar_xattr_bin.c b/tests/libtar/tar_xattr_bin.c index 51ca0b0..ea2bc28 100644 --- a/tests/libtar/tar_xattr_bin.c +++ b/tests/libtar/tar_xattr_bin.c @@ -5,6 +5,7 @@   * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>   */  #include "config.h" +#include "io/file.h"  #include "tar.h"  #include "../test.h" diff --git a/tests/libutil/Makemodule.am b/tests/libutil/Makemodule.am index 27d6341..557a65c 100644 --- a/tests/libutil/Makemodule.am +++ b/tests/libutil/Makemodule.am @@ -1,5 +1,5 @@  test_str_table_SOURCES = tests/libutil/str_table.c tests/test.h -test_str_table_LDADD = libutil.a libfstream.a libcompat.a +test_str_table_LDADD = libutil.a libio.a libcompat.a  test_str_table_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/libutil  test_rbtree_SOURCES = tests/libutil/rbtree.c tests/test.h diff --git a/tests/libutil/str_table.c b/tests/libutil/str_table.c index a69a9c4..509594c 100644 --- a/tests/libutil/str_table.c +++ b/tests/libutil/str_table.c @@ -7,7 +7,7 @@  #include "config.h"  #include "util/str_table.h" -#include "fstream.h" +#include "io/file.h"  #include "compat.h"  #include "../test.h" | 
