diff options
author | Timo Teräs <timo.teras@iki.fi> | 2019-12-18 12:58:32 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-02-14 16:45:13 +0200 |
commit | 72be8139303d55463e470ee608a27eb4af950aff (patch) | |
tree | 1c71000e79b609fc8da3e537c08818489d5732e6 /src/apk_io.h | |
parent | d60477751f374a2d58dc73f64dca4ff95ea39a00 (diff) | |
download | apk-tools-72be8139303d55463e470ee608a27eb4af950aff.tar.gz apk-tools-72be8139303d55463e470ee608a27eb4af950aff.tar.bz2 apk-tools-72be8139303d55463e470ee608a27eb4af950aff.tar.xz apk-tools-72be8139303d55463e470ee608a27eb4af950aff.zip |
io: add stream copy helper
Diffstat (limited to 'src/apk_io.h')
-rw-r--r-- | src/apk_io.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/apk_io.h b/src/apk_io.h index e943a8c..fb784c3 100644 --- a/src/apk_io.h +++ b/src/apk_io.h @@ -74,6 +74,8 @@ struct apk_istream { const struct apk_istream_ops *ops; }; +#define APK_IO_ALL ((size_t)-1) + struct apk_istream *apk_istream_from_file(int atfd, const char *file); struct apk_istream *apk_istream_from_file_gz(int atfd, const char *file); struct apk_istream *apk_istream_from_fd(int fd); @@ -81,12 +83,13 @@ struct apk_istream *apk_istream_from_fd_url_if_modified(int atfd, const char *ur struct apk_istream *apk_istream_from_url_gz(const char *url); ssize_t apk_istream_read(struct apk_istream *is, void *ptr, size_t size); apk_blob_t apk_istream_get(struct apk_istream *is, size_t len); -apk_blob_t apk_istream_get_all(struct apk_istream *is); +apk_blob_t apk_istream_get_max(struct apk_istream *is, size_t size); apk_blob_t apk_istream_get_delim(struct apk_istream *is, apk_blob_t token); - -#define APK_SPLICE_ALL 0xffffffff +static inline apk_blob_t apk_istream_get_all(struct apk_istream *is) { return apk_istream_get_max(is, APK_IO_ALL); } ssize_t apk_istream_splice(struct apk_istream *is, int fd, size_t size, apk_progress_cb cb, void *cb_ctx); +ssize_t apk_stream_copy(struct apk_istream *is, struct apk_ostream *os, size_t size, + apk_progress_cb cb, void *cb_ctx, EVP_MD_CTX *mdctx); static inline struct apk_istream *apk_istream_from_url(const char *url) { |