diff options
-rw-r--r-- | src/gzip.c | 32 | ||||
-rw-r--r-- | src/gzip.h | 7 |
2 files changed, 24 insertions, 15 deletions
@@ -41,7 +41,7 @@ struct opkg_opk_gzip { }; static struct opkg_opk_gzip * -_opkg_opk_gzip_init(enum _opkg_opk_gzip_dir dir, char *buffer, size_t size, +_opkg_opk_gzip_init(enum _opkg_opk_gzip_dir dir, opkg_opk_gzip_read_func *read_func, opkg_opk_gzip_write_func *write_func, void *user_data) { @@ -53,12 +53,10 @@ _opkg_opk_gzip_init(enum _opkg_opk_gzip_dir dir, char *buffer, size_t size, return NULL; } - gzip->dir = dir; - gzip->buffer = buffer; - gzip->buffer_size = size; - gzip->read_func = read_func; - gzip->write_func = write_func; - gzip->user_data = user_data; + gzip->dir = dir; + gzip->read_func = read_func; + gzip->write_func = write_func; + gzip->user_data = user_data; gzip->stream.zalloc = Z_NULL; gzip->stream.zfree = Z_NULL; @@ -73,8 +71,8 @@ _opkg_opk_gzip_init(enum _opkg_opk_gzip_dir dir, char *buffer, size_t size, return NULL; } } else { - gzip->stream.next_out = buffer; - gzip->stream.avail_out = size; + gzip->stream.next_out = Z_NULL; + gzip->stream.avail_out = 0; if (deflateInit2(&gzip->stream, 9, Z_DEFLATED, OPKG_OPK_GZIP_WINDOW_BITS_, 9, Z_DEFAULT_STRATEGY) != Z_OK) { @@ -101,19 +99,27 @@ _opkg_opk_gzip_init(enum _opkg_opk_gzip_dir dir, char *buffer, size_t size, struct opkg_opk_gzip * opkg_opk_gzip_init_read(opkg_opk_gzip_read_func *read, void *user_data) { - return _opkg_opk_gzip_init(_OPKG_OPK_GZIP_DIR_READ, NULL, 0, + return _opkg_opk_gzip_init(_OPKG_OPK_GZIP_DIR_READ, read, NULL, user_data); } struct opkg_opk_gzip * -opkg_opk_gzip_init_write(char *buffer, size_t size, - opkg_opk_gzip_write_func *write, void *user_data) +opkg_opk_gzip_init_write(opkg_opk_gzip_write_func *write, void *user_data) { - return _opkg_opk_gzip_init(_OPKG_OPK_GZIP_DIR_WRITE, buffer, size, + return _opkg_opk_gzip_init(_OPKG_OPK_GZIP_DIR_WRITE, NULL, write, user_data); } int +opkg_opk_gzip_set_write_buffer(struct opkg_opk_gzip *gzip, char *buffer, + size_t size) +{ + gzip->buffer = buffer; + gzip->buffer_size = size; + return OPKG_OPK_OK; +} + +int opkg_opk_gzip_read(struct opkg_opk_gzip *gzip, void *record) { int end; @@ -45,8 +45,11 @@ struct opkg_opk_gzip * opkg_opk_gzip_init_read(opkg_opk_gzip_read_func *read, void *user_data); struct opkg_opk_gzip * -opkg_opk_gzip_init_write(char *buffer, size_t size, - opkg_opk_gzip_write_func *write, void *user_data); +opkg_opk_gzip_init_write(opkg_opk_gzip_write_func *write, void *user_data); + +int +opkg_opk_gzip_set_write_buffer(struct opkg_opk_gzip *gzip, char *buffer, + size_t size); /* * Reads and decompresses data to output the next record (512 octets). |