summaryrefslogtreecommitdiffstats
path: root/src/gzip.c
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-13 00:43:17 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-13 01:28:59 (EDT)
commitb7e0e663765da3cc95ceefdde172110c690b6ee6 (patch)
tree1f9592464ddb74ee5a070dfc98f6e1e2460d729a /src/gzip.c
parent026161027dda2add2a5082d3de230069501b5b82 (diff)
gzip: Split out return value constants
Diffstat (limited to 'src/gzip.c')
-rw-r--r--src/gzip.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/gzip.c b/src/gzip.c
index 328f33a..05d4065 100644
--- a/src/gzip.c
+++ b/src/gzip.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <zlib.h>
+#include "defs.h"
#include "gzip.h"
#define OPKG_OPK_GZIP_BUFFER_SIZE 8192
@@ -36,9 +37,9 @@ _opkg_opk_gzip_init(struct opkg_opk_gzip_state *state)
state->stream.zfree = Z_NULL;
state->stream.opaque = Z_NULL;
if (inflateInit(&state->stream) != Z_OK) {
- return OPKG_OPK_GZIP_ERROR;
+ return OPKG_OPK_ERROR;
}
- return OPKG_OPK_GZIP_OK;
+ return OPKG_OPK_OK;
}
int
@@ -47,15 +48,15 @@ opkg_opk_gzip_init_from_file(struct opkg_opk_gzip_state *state,
{
state->input_file = fopen(file_name, "rb");
if (state->input_file == NULL) {
- return OPKG_OPK_GZIP_ERROR;
+ return OPKG_OPK_ERROR;
}
state->stream.next_in = Z_NULL;
state->stream.avail_in = 0;
- if (_opkg_opk_gzip_init(state) < OPKG_OPK_GZIP_OK) {
+ if (_opkg_opk_gzip_init(state) < OPKG_OPK_OK) {
fclose(state->input_file);
- return OPKG_OPK_GZIP_ERROR;
+ return OPKG_OPK_ERROR;
}
- return OPKG_OPK_GZIP_OK;
+ return OPKG_OPK_OK;
}
int
@@ -76,7 +77,7 @@ _opkg_opk_gzip_next_record_from_file(struct opkg_opk_gzip_state *state)
fclose(state->input_file);
state->input_file = NULL;
inflateEnd(&state->stream);
- return OPKG_OPK_GZIP_OK;
+ return OPKG_OPK_OK;
}
if (state->stream.avail_in == 0) {
state->stream.avail_in = fread(state->input_buffer,
@@ -86,12 +87,12 @@ _opkg_opk_gzip_next_record_from_file(struct opkg_opk_gzip_state *state)
fclose(state->input_file);
state->input_file = NULL;
inflateEnd(&state->stream);
- return OPKG_OPK_GZIP_ERROR;
+ return OPKG_OPK_ERROR;
}
state->stream.next_in = state->input_buffer;
}
if (state->stream.avail_out == 0) {
- return OPKG_OPK_GZIP_OK;
+ return OPKG_OPK_OK;
}
switch (inflate(&state->stream, Z_SYNC_FLUSH)) {
case Z_OK:
@@ -102,7 +103,7 @@ _opkg_opk_gzip_next_record_from_file(struct opkg_opk_gzip_state *state)
fclose(state->input_file);
state->input_file = NULL;
inflateEnd(&state->stream);
- return OPKG_OPK_GZIP_ERROR;
+ return OPKG_OPK_ERROR;
}
}
}
@@ -112,12 +113,12 @@ _opkg_opk_gzip_next_record_from_memory(struct opkg_opk_gzip_state *state)
{
switch (inflate(&state->stream, Z_SYNC_FLUSH)) {
case Z_OK:
- return OPKG_OPK_GZIP_OK;
+ return OPKG_OPK_OK;
case Z_STREAM_END:
- return OPKG_OPK_GZIP_END;
+ return OPKG_OPK_END;
default:
inflateEnd(&state->stream);
- return OPKG_OPK_GZIP_ERROR;
+ return OPKG_OPK_ERROR;
}
}