summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-05-07 11:28:40 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-05-07 11:28:40 (EDT)
commitb6d36859246e1ea432911169d1f325df1479eac7 (patch)
tree072c54d02c292dc1a909a6b19e7c259e0f30b9e4 /src
parent757f6e4d2dd1df1a89c425200b15753d606e3748 (diff)
gzip: Count and report bytes written
Diffstat (limited to 'src')
-rw-r--r--src/gzip.c9
-rw-r--r--src/gzip.h3
2 files changed, 12 insertions, 0 deletions
diff --git a/src/gzip.c b/src/gzip.c
index 531294b..ef4d4aa 100644
--- a/src/gzip.c
+++ b/src/gzip.c
@@ -37,6 +37,7 @@ struct opkg_opk_gzip {
void *user_data;
FILE *write_fp;
char write_buffer[512];
+ size_t written;
z_stream stream;
gz_header gz_header;
};
@@ -81,6 +82,7 @@ opkg_opk_gzip_init_write(FILE *write_fp)
gzip->dir = _OPKG_OPK_GZIP_DIR_WRITE;
gzip->write_fp = write_fp;
+ gzip->written = 0;
gzip->stream.zalloc = Z_NULL;
gzip->stream.zfree = Z_NULL;
@@ -196,6 +198,7 @@ _opkg_opk_gzip_write(struct opkg_opk_gzip *gzip, void *record, size_t size,
if (fwrite(gzip->write_buffer, 1, len, gzip->write_fp) != len) {
return OPKG_OPK_ERROR;
}
+ gzip->written += len;
} while (gzip->stream.avail_out == 0);
if (gzip->stream.avail_in != 0) {
@@ -219,6 +222,12 @@ opkg_opk_gzip_write(struct opkg_opk_gzip *gzip, void *record, size_t size)
}
}
+size_t
+opkg_opk_gzip_written(struct opkg_opk_gzip *gzip)
+{
+ return gzip->written;
+}
+
int
opkg_opk_gzip_free(struct opkg_opk_gzip *gzip)
{
diff --git a/src/gzip.h b/src/gzip.h
index d42a969..6eddd6a 100644
--- a/src/gzip.h
+++ b/src/gzip.h
@@ -65,6 +65,9 @@ opkg_opk_gzip_read(struct opkg_opk_gzip *gzip, void *record);
int
opkg_opk_gzip_write(struct opkg_opk_gzip *gzip, void *record, size_t size);
+size_t
+opkg_opk_gzip_written(struct opkg_opk_gzip *gzip);
+
/*
* Frees a decompression structure.
* Parameters: