diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common/Makemodule.am | 11 | ||||
-rw-r--r-- | lib/common/src/stream.c (renamed from lib/io/src/mem.c) | 27 | ||||
-rw-r--r-- | lib/common/test/istream_mem.c (renamed from lib/io/test/istream_mem.c) | 2 | ||||
-rw-r--r-- | lib/io/Makemodule.am | 23 | ||||
-rw-r--r-- | lib/io/src/internal.h | 1 | ||||
-rw-r--r-- | lib/io/src/std.c | 35 | ||||
-rw-r--r-- | lib/io/test/xfrm.c | 2 | ||||
-rw-r--r-- | lib/sqfs/Makemodule.am | 10 | ||||
-rw-r--r-- | lib/sqfs/test/istream_read.c | 2 | ||||
-rw-r--r-- | lib/sqfs/test/istream_skip.c | 2 | ||||
-rw-r--r-- | lib/sqfs/test/stream_splice.c | 2 | ||||
-rw-r--r-- | lib/util/Makemodule.am | 4 | ||||
-rw-r--r-- | lib/util/test/get_line.c | 2 |
13 files changed, 56 insertions, 67 deletions
diff --git a/lib/common/Makemodule.am b/lib/common/Makemodule.am index 7c07d48..9438d3a 100644 --- a/lib/common/Makemodule.am +++ b/lib/common/Makemodule.am @@ -6,7 +6,8 @@ libcommon_a_SOURCES = include/common.h include/simple_writer.h \ lib/common/src/writer/init.c lib/common/src/writer/cleanup.c \ lib/common/src/writer/serialize_fstree.c lib/common/src/writer/finish.c\ lib/common/src/fstree_cli.c lib/common/src/perror.c \ - lib/common/src/dir_tree.c lib/common/src/read_tree.c + lib/common/src/dir_tree.c lib/common/src/read_tree.c \ + lib/common/src/stream.c libcommon_a_CFLAGS = $(AM_CFLAGS) $(LZO_CFLAGS) if WITH_LZO @@ -15,14 +16,18 @@ endif noinst_LIBRARIES += libcommon.a +test_istream_mem_SOURCES = lib/common/test/istream_mem.c +test_istream_mem_LDADD = libcommon.a libsquashfs.la libcompat.a +test_istream_mem_CPPFLAGS = $(AM_CPPFLAGS) + test_fstree_cli_SOURCES = lib/common/test/fstree_cli.c -test_fstree_cli_LDADD = libcommon.a libio.a libutil.a libcompat.a +test_fstree_cli_LDADD = libcommon.a libutil.a libcompat.a test_get_node_path_SOURCES = lib/common/test/get_node_path.c test_get_node_path_LDADD = libcommon.a libsquashfs.la libcompat.a LIBCOMMON_TESTS = \ - test_fstree_cli test_get_node_path + test_istream_mem test_fstree_cli test_get_node_path check_PROGRAMS += $(LIBCOMMON_TESTS) TESTS += $(LIBCOMMON_TESTS) diff --git a/lib/io/src/mem.c b/lib/common/src/stream.c index 7150d1f..a557360 100644 --- a/lib/io/src/mem.c +++ b/lib/common/src/stream.c @@ -5,14 +5,24 @@ * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at> */ #include "config.h" -#include "io/mem.h" #include "compat.h" +#include "common.h" #include "sqfs/io.h" #include <stdlib.h> #include <string.h> #include <assert.h> +#if defined(_WIN32) || defined(__WINDOWS__) +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#else +#include <unistd.h> +#define STD_INPUT_HANDLE STDIN_FILENO +#define STD_OUTPUT_HANDLE STDOUT_FILENO +#define GetStdHandle(hnd) hnd +#endif + typedef struct { sqfs_istream_t base; @@ -108,3 +118,18 @@ sqfs_istream_t *istream_memory_create(const char *name, size_t bufsz, strm->get_filename = mem_in_get_filename; return strm; } + +int istream_open_stdin(sqfs_istream_t **out) +{ + sqfs_file_handle_t hnd = GetStdHandle(STD_INPUT_HANDLE); + + return sqfs_istream_open_handle(out, "stdin", hnd, 0); +} + +int ostream_open_stdout(sqfs_ostream_t **out) +{ + sqfs_file_handle_t hnd = GetStdHandle(STD_OUTPUT_HANDLE); + + return sqfs_ostream_open_handle(out, "stdout", hnd, + SQFS_FILE_OPEN_NO_SPARSE); +} diff --git a/lib/io/test/istream_mem.c b/lib/common/test/istream_mem.c index d5e0c2c..2213168 100644 --- a/lib/io/test/istream_mem.c +++ b/lib/common/test/istream_mem.c @@ -7,8 +7,8 @@ #include "config.h" #include "util/test.h" -#include "io/mem.h" #include "sqfs/io.h" +#include "common.h" static const size_t end0 = 449; /* region 1: filled with 'A' */ static const size_t end1 = 521; /* region 2: filled with 'B' */ diff --git a/lib/io/Makemodule.am b/lib/io/Makemodule.am index d342063..2f6fb1c 100644 --- a/lib/io/Makemodule.am +++ b/lib/io/Makemodule.am @@ -1,20 +1,14 @@ -libio_a_SOURCES = include/io/xfrm.h include/io/std.h \ - include/io/dir_iterator.h include/io/mem.h lib/io/src/internal.h \ - lib/io/src/xfrm/ostream.c \ - lib/io/src/xfrm/istream.c lib/io/src/dir_tree_iterator.c \ - lib/io/src/mem.c lib/io/src/std.c +libio_a_SOURCES = include/io/xfrm.h include/io/dir_iterator.h \ + lib/io/src/internal.h lib/io/src/xfrm/ostream.c \ + lib/io/src/xfrm/istream.c lib/io/src/dir_tree_iterator.c libio_a_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) $(XZ_CFLAGS) libio_a_CFLAGS += $(ZSTD_CFLAGS) $(BZIP2_CFLAGS) noinst_LIBRARIES += libio.a -LIBIO_TESTS = test_istream_mem test_dir_iterator \ +LIBIO_TESTS = test_dir_iterator \ test_dir_tree_iterator test_dir_tree_iterator2 test_dir_tree_iterator3 -test_istream_mem_SOURCES = lib/io/test/istream_mem.c -test_istream_mem_LDADD = libio.a libcompat.a -test_istream_mem_CPPFLAGS = $(AM_CPPFLAGS) - test_dir_iterator_SOURCES = lib/io/test/dir_iterator.c test_dir_iterator_LDADD = libio.a libsquashfs.la libutil.a libcompat.a test_dir_iterator_CPPFLAGS = $(AM_CPPFLAGS) @@ -37,7 +31,8 @@ test_dir_tree_iterator3_CPPFLAGS += -DTESTPATH=$(top_srcdir)/lib/io/test/testdir if WITH_XZ test_io_xfrm_xz_SOURCES = lib/io/test/xfrm.c -test_io_xfrm_xz_LDADD = libsquashfs.la libio.a libxfrm.a libcompat.a $(XZ_LIBS) +test_io_xfrm_xz_LDADD = libcommon.a libsquashfs.la libio.a libxfrm.a \ + libcompat.a $(XZ_LIBS) test_io_xfrm_xz_CPPFLAGS = $(AM_CPPFLAGS) -DDO_XZ=1 LIBIO_TESTS += test_io_xfrm_xz @@ -45,7 +40,7 @@ endif if WITH_BZIP2 test_io_xfrm_bzip2_SOURCES = lib/io/test/xfrm.c -test_io_xfrm_bzip2_LDADD = libsquashfs.la libio.a libxfrm.a \ +test_io_xfrm_bzip2_LDADD = libcommon.a libsquashfs.la libio.a libxfrm.a \ libcompat.a $(BZIP2_LIBS) test_io_xfrm_bzip2_CPPFLAGS = $(AM_CPPFLAGS) -DDO_BZIP2=1 @@ -54,7 +49,7 @@ endif if WITH_GZIP test_io_xfrm_gzip_SOURCES = lib/io/test/xfrm.c -test_io_xfrm_gzip_LDADD = libsquashfs.la libio.a libxfrm.a \ +test_io_xfrm_gzip_LDADD = libcommon.a libsquashfs.la libio.a libxfrm.a \ libcompat.a $(ZLIB_LIBS) test_io_xfrm_gzip_CPPFLAGS = $(AM_CPPFLAGS) -DDO_GZIP=1 @@ -64,7 +59,7 @@ endif if WITH_ZSTD if HAVE_ZSTD_STREAM test_io_xfrm_zstd_SOURCES = lib/io/test/xfrm.c -test_io_xfrm_zstd_LDADD = libsquashfs.la libio.a libxfrm.a \ +test_io_xfrm_zstd_LDADD = libcommon.a libsquashfs.la libio.a libxfrm.a \ libcompat.a $(ZSTD_LIBS) test_io_xfrm_zstd_CPPFLAGS = $(AM_CPPFLAGS) -DDO_ZSTD=1 diff --git a/lib/io/src/internal.h b/lib/io/src/internal.h index e9804b9..7c2b1df 100644 --- a/lib/io/src/internal.h +++ b/lib/io/src/internal.h @@ -10,7 +10,6 @@ #include "config.h" #include "compat.h" #include "io/xfrm.h" -#include "io/std.h" #include "xfrm/compress.h" #include <string.h> diff --git a/lib/io/src/std.c b/lib/io/src/std.c deleted file mode 100644 index 62635ec..0000000 --- a/lib/io/src/std.c +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * std.c - * - * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" -#include "compat.h" -#include "io/std.h" -#include "sqfs/io.h" - -#if defined(_WIN32) || defined(__WINDOWS__) -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#else -#include <unistd.h> -#define STD_INPUT_HANDLE STDIN_FILENO -#define STD_OUTPUT_HANDLE STDOUT_FILENO -#define GetStdHandle(hnd) hnd -#endif - -int istream_open_stdin(sqfs_istream_t **out) -{ - sqfs_file_handle_t hnd = GetStdHandle(STD_INPUT_HANDLE); - - return sqfs_istream_open_handle(out, "stdin", hnd, 0); -} - -int ostream_open_stdout(sqfs_ostream_t **out) -{ - sqfs_file_handle_t hnd = GetStdHandle(STD_OUTPUT_HANDLE); - - return sqfs_ostream_open_handle(out, "stdout", hnd, - SQFS_FILE_OPEN_NO_SPARSE); -} diff --git a/lib/io/test/xfrm.c b/lib/io/test/xfrm.c index b871610..26eee87 100644 --- a/lib/io/test/xfrm.c +++ b/lib/io/test/xfrm.c @@ -9,7 +9,7 @@ #include "util/test.h" #include "sqfs/io.h" #include "io/xfrm.h" -#include "io/mem.h" +#include "common.h" static const sqfs_u8 blob_in[] = { #if defined(DO_XZ) diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am index b40473e..41ea608 100644 --- a/lib/sqfs/Makemodule.am +++ b/lib/sqfs/Makemodule.am @@ -125,19 +125,19 @@ xattr_benchmark_SOURCES = lib/sqfs/test/xattr_benchmark.c xattr_benchmark_LDADD = libcommon.a libsquashfs.la libcompat.a test_istream_read_SOURCES = lib/sqfs/test/istream_read.c -test_istream_read_LDADD = libio.a libsquashfs.la libutil.a libcompat.a +test_istream_read_LDADD = libcommon.a libsquashfs.la libutil.a libcompat.a test_istream_skip_SOURCES = lib/sqfs/test/istream_skip.c -test_istream_skip_LDADD = libsquashfs.la libio.a libutil.a libcompat.a +test_istream_skip_LDADD = libcommon.a libsquashfs.la libutil.a libcompat.a test_stream_splice_SOURCES = lib/sqfs/test/stream_splice.c -test_stream_splice_LDADD = libsquashfs.la libio.a libutil.a libcompat.a +test_stream_splice_LDADD = libcommon.a libsquashfs.la libutil.a libcompat.a test_rec_dir_SOURCES = lib/sqfs/test/rec_dir.c -test_rec_dir_LDADD = libsquashfs.la libio.a libutil.a libcompat.a +test_rec_dir_LDADD = libsquashfs.la libutil.a libcompat.a test_hl_dir_SOURCES = lib/sqfs/test/hl_dir.c -test_hl_dir_LDADD = libsquashfs.la libio.a libutil.a libcompat.a +test_hl_dir_LDADD = libsquashfs.la libutil.a libcompat.a LIBSQFS_TESTS = \ test_abi test_xattr test_table test_xattr_writer \ diff --git a/lib/sqfs/test/istream_read.c b/lib/sqfs/test/istream_read.c index f8facea..dc17c8e 100644 --- a/lib/sqfs/test/istream_read.c +++ b/lib/sqfs/test/istream_read.c @@ -8,7 +8,7 @@ #include "util/test.h" #include "sqfs/io.h" -#include "io/mem.h" +#include "common.h" static const sqfs_u64 end0 = 449; /* region 1: filled with 'A' */ static const sqfs_u64 end1 = 521; /* region 2: filled with 'B' */ diff --git a/lib/sqfs/test/istream_skip.c b/lib/sqfs/test/istream_skip.c index d8a81f2..8ce2fd9 100644 --- a/lib/sqfs/test/istream_skip.c +++ b/lib/sqfs/test/istream_skip.c @@ -8,7 +8,7 @@ #include "sqfs/io.h" #include "util/test.h" -#include "io/mem.h" +#include "common.h" static const sqfs_u64 end0 = 449; /* region 1: filled with 'A' */ static const sqfs_u64 end1 = 521; /* region 2: filled with 'B' */ diff --git a/lib/sqfs/test/stream_splice.c b/lib/sqfs/test/stream_splice.c index 6f40d1f..1b58ea0 100644 --- a/lib/sqfs/test/stream_splice.c +++ b/lib/sqfs/test/stream_splice.c @@ -6,9 +6,9 @@ */ #include "config.h" -#include "io/mem.h" #include "util/test.h" #include "sqfs/io.h" +#include "common.h" static const sqfs_u64 end0 = 449; /* region 1: filled with 'A' */ static const sqfs_u64 end1 = 521; /* region 2: filled with 'B' */ diff --git a/lib/util/Makemodule.am b/lib/util/Makemodule.am index 24fb50b..d7b5021 100644 --- a/lib/util/Makemodule.am +++ b/lib/util/Makemodule.am @@ -36,7 +36,7 @@ endif noinst_LIBRARIES += libutil.a test_str_table_SOURCES = lib/util/test/str_table.c -test_str_table_LDADD = libio.a libsquashfs.la libutil.a libcompat.a +test_str_table_LDADD = libcommon.a libsquashfs.la libutil.a libcompat.a test_str_table_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/lib/util/test test_rbtree_SOURCES = lib/util/test/rbtree.c @@ -79,7 +79,7 @@ test_base64_decode_SOURCES = lib/util/test/base64_decode.c test_base64_decode_LDADD = libutil.a libcompat.a test_get_line_SOURCES = lib/util/test/get_line.c -test_get_line_LDADD = libutil.a libio.a libcompat.a +test_get_line_LDADD = libcommon.a libsquashfs.la libutil.a libcompat.a test_split_line_SOURCES = lib/util/test/split_line.c test_split_line_LDADD = libutil.a libcompat.a diff --git a/lib/util/test/get_line.c b/lib/util/test/get_line.c index 6189d31..2ea5687 100644 --- a/lib/util/test/get_line.c +++ b/lib/util/test/get_line.c @@ -5,8 +5,8 @@ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> */ #include "util/parse.h" -#include "io/mem.h" #include "util/test.h" +#include "common.h" typedef struct { size_t line_num; |