summaryrefslogtreecommitdiff
path: root/src/apk_io.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-09-30 14:11:37 +0300
committerTimo Teräs <timo.teras@iki.fi>2020-10-09 16:09:19 +0300
commitefe0c4afecb9fd3da2ab4849d2b8edd5bea14d08 (patch)
treeb04a9d2533148a1fcb4a28560ffd76c4bbc5e5ad /src/apk_io.h
parent81782bfc150225df75b11efa4fa0ade428ae3676 (diff)
downloadapk-tools-efe0c4afecb9fd3da2ab4849d2b8edd5bea14d08.tar.gz
apk-tools-efe0c4afecb9fd3da2ab4849d2b8edd5bea14d08.tar.bz2
apk-tools-efe0c4afecb9fd3da2ab4849d2b8edd5bea14d08.tar.xz
apk-tools-efe0c4afecb9fd3da2ab4849d2b8edd5bea14d08.zip
adb: introduce apk-tools database format, and few applets
This is a flat buffers inspired format that allows fast mmaped access to the data with low overhead, signature support and relatively good forward support.
Diffstat (limited to 'src/apk_io.h')
-rw-r--r--src/apk_io.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/apk_io.h b/src/apk_io.h
index 18b8ecc..87b953e 100644
--- a/src/apk_io.h
+++ b/src/apk_io.h
@@ -141,6 +141,7 @@ struct apk_ostream_ops {
struct apk_ostream {
const struct apk_ostream_ops *ops;
+ int rc;
};
struct apk_ostream *apk_ostream_gzip(struct apk_ostream *);
@@ -149,13 +150,15 @@ struct apk_ostream *apk_ostream_to_fd(int fd);
struct apk_ostream *apk_ostream_to_file(int atfd, const char *file, const char *tmpfile, mode_t mode);
struct apk_ostream *apk_ostream_to_file_gz(int atfd, const char *file, const char *tmpfile, mode_t mode);
size_t apk_ostream_write_string(struct apk_ostream *ostream, const char *string);
+static inline void apk_ostream_cancel(struct apk_ostream *os, int rc) { if (!os->rc) os->rc = rc; }
static inline ssize_t apk_ostream_write(struct apk_ostream *os, const void *buf, size_t size)
{
return os->ops->write(os, buf, size);
}
static inline int apk_ostream_close(struct apk_ostream *os)
{
- return os->ops->close(os);
+ int rc = os->rc;
+ return os->ops->close(os) ?: rc;
}
apk_blob_t apk_blob_from_istream(struct apk_istream *istream, size_t size);