aboutsummaryrefslogtreecommitdiff
path: root/gzread.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2025-05-11 14:49:04 -0700
committerMark Adler <git@madler.net>2025-12-06 17:39:14 -0800
commit1ab1026a20282383d9cd2282f81461655bea4028 (patch)
tree511ef0996f9beb4c83ba15e72d7cc62d6252bb56 /gzread.c
parent473f78532aed8f5a8d55cd6e7b305160db9cf742 (diff)
downloadzlib-1ab1026a20282383d9cd2282f81461655bea4028.tar.gz
zlib-1ab1026a20282383d9cd2282f81461655bea4028.tar.bz2
zlib-1ab1026a20282383d9cd2282f81461655bea4028.zip
Add a "G" option to force gzip, disabling transparency in gzread().
If the input is not a gzip stream with this option, an error will be returned.
Diffstat (limited to 'gzread.c')
-rw-r--r--gzread.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gzread.c b/gzread.c
index 5edecbfc..6fefe89d 100644
--- a/gzread.c
+++ b/gzread.c
@@ -106,6 +106,14 @@ local int gz_look(gz_statep state) {
106 } 106 }
107 } 107 }
108 108
109 /* if transparent reading is disabled, simply read as gzip */
110 if (state->direct == -1) {
111 inflateReset(strm);
112 state->how = GZIP;
113 state->direct = 0;
114 return 0;
115 }
116
109 /* get at least the magic bytes in the input buffer */ 117 /* get at least the magic bytes in the input buffer */
110 if (strm->avail_in < 2) { 118 if (strm->avail_in < 2) {
111 if (gz_avail(state) == -1) 119 if (gz_avail(state) == -1)
@@ -567,7 +575,7 @@ int ZEXPORT gzdirect(gzFile file) {
567 (void)gz_look(state); 575 (void)gz_look(state);
568 576
569 /* return 1 if transparent, 0 if processing a gzip stream */ 577 /* return 1 if transparent, 0 if processing a gzip stream */
570 return state->direct; 578 return state->direct == 1;
571} 579}
572 580
573/* -- see zlib.h -- */ 581/* -- see zlib.h -- */