aboutsummaryrefslogtreecommitdiff
path: root/lib/io/src
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-12 21:21:40 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-15 13:38:25 +0200
commitba99ef34e7b073c03519ef74f017091de6c9bee8 (patch)
tree8c134f72990200550ac96e46bd47d4cc0ba85810 /lib/io/src
parente811851deba9c45f3d9b3c5b4ad5eaa7945382d5 (diff)
Move sqfs_istream_t & sqfs_ostream_t into libsquashfs
For now, only the interfaces and helper functions are moved, the concrete implementations remain in libio. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io/src')
-rw-r--r--lib/io/src/get_line.c1
-rw-r--r--lib/io/src/internal.h1
-rw-r--r--lib/io/src/istream.c97
-rw-r--r--lib/io/src/mem.c1
-rw-r--r--lib/io/src/unix/istream.c1
-rw-r--r--lib/io/src/win32/istream.c1
-rw-r--r--lib/io/src/xfrm/istream.c1
-rw-r--r--lib/io/src/xfrm/ostream.c1
8 files changed, 6 insertions, 98 deletions
diff --git a/lib/io/src/get_line.c b/lib/io/src/get_line.c
index 9ab4928..ad37be6 100644
--- a/lib/io/src/get_line.c
+++ b/lib/io/src/get_line.c
@@ -5,6 +5,7 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "internal.h"
+#include "sqfs/io.h"
static void ltrim(char *buffer)
{
diff --git a/lib/io/src/internal.h b/lib/io/src/internal.h
index 1e51012..e010727 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/istream.h"
-#include "io/ostream.h"
#include "io/file.h"
#include "io/xfrm.h"
#include "io/std.h"
diff --git a/lib/io/src/istream.c b/lib/io/src/istream.c
deleted file mode 100644
index 6fbc67b..0000000
--- a/lib/io/src/istream.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * istream.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "internal.h"
-
-
-sqfs_s32 istream_read(sqfs_istream_t *strm, void *data, size_t size)
-{
- sqfs_s32 total = 0;
-
- if (size > 0x7FFFFFFF)
- size = 0x7FFFFFFF;
-
- while (size > 0) {
- const sqfs_u8 *ptr;
- size_t diff;
- int ret;
-
- ret = strm->get_buffered_data(strm, &ptr, &diff, size);
- if (ret > 0)
- break;
- if (ret < 0)
- return ret;
-
- if (diff > size)
- diff = size;
-
- memcpy(data, ptr, diff);
- strm->advance_buffer(strm, diff);
- data = (char *)data + diff;
- size -= diff;
- total += diff;
- }
-
- return total;
-}
-
-int istream_skip(sqfs_istream_t *strm, sqfs_u64 size)
-{
- while (size > 0) {
- const sqfs_u8 *ptr;
- size_t diff;
- int ret;
-
- ret = strm->get_buffered_data(strm, &ptr, &diff, size);
- if (ret < 0)
- return ret;
- if (ret > 0) {
- fprintf(stderr, "%s: unexpected end-of-file\n",
- strm->get_filename(strm));
- return -1;
- }
-
- if ((sqfs_u64)diff > size)
- diff = size;
-
- size -= diff;
- strm->advance_buffer(strm, diff);
- }
-
- return 0;
-}
-
-sqfs_s32 istream_splice(sqfs_istream_t *in, sqfs_ostream_t *out, sqfs_u32 size)
-{
- sqfs_s32 total = 0;
-
- if (size > 0x7FFFFFFF)
- size = 0x7FFFFFFF;
-
- while (size > 0) {
- const sqfs_u8 *ptr;
- size_t diff;
- int ret;
-
- ret = in->get_buffered_data(in, &ptr, &diff, size);
- if (ret < 0)
- return ret;
- if (ret > 0)
- break;
-
- if (diff > size)
- diff = size;
-
- if (out->append(out, ptr, diff))
- return -1;
-
- total += diff;
- size -= diff;
- in->advance_buffer(in, diff);
- }
-
- return total;
-}
diff --git a/lib/io/src/mem.c b/lib/io/src/mem.c
index 435a169..7150d1f 100644
--- a/lib/io/src/mem.c
+++ b/lib/io/src/mem.c
@@ -7,6 +7,7 @@
#include "config.h"
#include "io/mem.h"
#include "compat.h"
+#include "sqfs/io.h"
#include <stdlib.h>
#include <string.h>
diff --git a/lib/io/src/unix/istream.c b/lib/io/src/unix/istream.c
index fc76bab..39d570f 100644
--- a/lib/io/src/unix/istream.c
+++ b/lib/io/src/unix/istream.c
@@ -5,6 +5,7 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "../internal.h"
+#include "sqfs/io.h"
typedef struct {
sqfs_istream_t base;
diff --git a/lib/io/src/win32/istream.c b/lib/io/src/win32/istream.c
index 223b20d..e6cb266 100644
--- a/lib/io/src/win32/istream.c
+++ b/lib/io/src/win32/istream.c
@@ -5,6 +5,7 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "../internal.h"
+#include "sqfs/io.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
diff --git a/lib/io/src/xfrm/istream.c b/lib/io/src/xfrm/istream.c
index 5c23d28..c499f6c 100644
--- a/lib/io/src/xfrm/istream.c
+++ b/lib/io/src/xfrm/istream.c
@@ -5,6 +5,7 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "../internal.h"
+#include "sqfs/io.h"
typedef struct istream_xfrm_t {
sqfs_istream_t base;
diff --git a/lib/io/src/xfrm/ostream.c b/lib/io/src/xfrm/ostream.c
index 81c19dd..4c77f42 100644
--- a/lib/io/src/xfrm/ostream.c
+++ b/lib/io/src/xfrm/ostream.c
@@ -5,6 +5,7 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "../internal.h"
+#include "sqfs/io.h"
typedef struct ostream_xfrm_t {
sqfs_ostream_t base;