Commit be0547a5 authored by Jeffrey Lee's avatar Jeffrey Lee

Fix gzgetheader()

Detail:
  c/gzread - In order for gzgetheader() to work, gz_head() needs to create the stream with a positive windowBits value with bit 4 set, in order to enable zlib's gzip header parsing code.
  Once the header is parsed the stream is switched back to raw mode, to allow the gzip code to handle the gzip footer.
  Also made gzgetheader() report errors instead of always returning 0.
Admin:
  Tested with reading gzip files using ZLib module


Version 1.20. Tagged as 'zlib-1_20'
parent 523b4e33
/* (1.19)
/* (1.20)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.19
#define Module_MajorVersion_CMHG 1.20
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 04 Feb 2012
#define Module_Date_CMHG 30 Mar 2012
#define Module_MajorVersion "1.19"
#define Module_Version 119
#define Module_MajorVersion "1.20"
#define Module_Version 120
#define Module_MinorVersion ""
#define Module_Date "04 Feb 2012"
#define Module_Date "30 Mar 2012"
#define Module_ApplicationDate "04-Feb-12"
#define Module_ApplicationDate "30-Mar-12"
#define Module_ComponentName "zlib"
#define Module_ComponentPath "mixed/RiscOS/Sources/Lib/zlib"
#define Module_FullVersion "1.19"
#define Module_HelpVersion "1.19 (04 Feb 2012)"
#define Module_LibraryVersionInfo "1:19"
#define Module_FullVersion "1.20"
#define Module_HelpVersion "1.20 (30 Mar 2012)"
#define Module_LibraryVersionInfo "1:20"
......@@ -138,7 +138,7 @@ int ZLIB_INTERNAL gz_head(state, head)
state->strm.opaque = Z_NULL;
state->strm.avail_in = 0;
state->strm.next_in = Z_NULL;
if (inflateInit2(&(state->strm), -15) != Z_OK) { /* raw inflate */
if (inflateInit2(&(state->strm), (head?15+16:-15)) != Z_OK) { /* raw inflate, or gzip inflate if we want the header */
free(state->out);
free(state->in);
state->size = 0;
......@@ -239,8 +239,8 @@ int ZLIB_INTERNAL gz_head(state, head)
be noticed on the first request for uncompressed data */
}
/* set up for decompression */
inflateReset(strm);
/* set up for raw decompression */
inflateReset2(strm,-15);
strm->adler = crc32(0L, Z_NULL, 0);
state->how = GZIP;
state->direct = 0;
......@@ -715,19 +715,25 @@ int ZEXPORT gzgetheader(file, head)
/* get internal structure */
if (file == NULL)
return 0;
return Z_STREAM_ERROR;
state = (gz_statep)file;
/* check that we're reading */
if (state->mode != GZ_READ)
return 0;
{
gz_error(state, Z_STREAM_ERROR, "File not opened for read");
return state->err;
}
/* check that we're looking for a header */
if (state->how != LOOK)
return 0;
{
gz_error(state, Z_STREAM_ERROR, "Header already read");
return state->err;
}
/* get the header */
gz_head(state, head);
return 0;
return state->err;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment