parent
9cc45c355b
commit
239b244640
|
@ -159,7 +159,7 @@ local size_t memRead(void *buffer, size_t size, size_t count, MEMFILE *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->available == 0)
|
if (file->available == 0)
|
||||||
return -1;
|
return SIZE_MAX;
|
||||||
|
|
||||||
if (total > (size_t)file->available) {
|
if (total > (size_t)file->available) {
|
||||||
total = file->available;
|
total = file->available;
|
||||||
|
@ -170,7 +170,7 @@ local size_t memRead(void *buffer, size_t size, size_t count, MEMFILE *file)
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
local int memPutc(int c, MEMFILE *file)
|
local int memPutc(char c, MEMFILE *file)
|
||||||
{
|
{
|
||||||
if (file->mode != 'w') {
|
if (file->mode != 'w') {
|
||||||
file->error = 1;
|
file->error = 1;
|
||||||
|
@ -227,9 +227,7 @@ local int memPrintf(MEMFILE *f, const char *format, ...)
|
||||||
can be checked to distinguish the two cases (if errno is zero, the
|
can be checked to distinguish the two cases (if errno is zero, the
|
||||||
zlib error is Z_MEM_ERROR).
|
zlib error is Z_MEM_ERROR).
|
||||||
*/
|
*/
|
||||||
local gzFile gz_open(memory, available, mode) char *memory;
|
local gzFile gz_open(char *memory, const int available, const char *mode)
|
||||||
const int available;
|
|
||||||
const char *mode;
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
int level = Z_DEFAULT_COMPRESSION; /* compression level */
|
int level = Z_DEFAULT_COMPRESSION; /* compression level */
|
||||||
|
@ -347,9 +345,7 @@ const char *mode;
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
Opens a gzip (.gz) file for reading or writing.
|
Opens a gzip (.gz) file for reading or writing.
|
||||||
*/
|
*/
|
||||||
gzFile ZEXPORT memgzopen(memory, available, mode) char *memory;
|
gzFile ZEXPORT memgzopen(char *memory, int available, const char *mode)
|
||||||
int available;
|
|
||||||
const char *mode;
|
|
||||||
{
|
{
|
||||||
return gz_open(memory, available, mode);
|
return gz_open(memory, available, mode);
|
||||||
}
|
}
|
||||||
|
@ -359,7 +355,7 @@ const char *mode;
|
||||||
for end of file.
|
for end of file.
|
||||||
IN assertion: the stream s has been sucessfully opened for reading.
|
IN assertion: the stream s has been sucessfully opened for reading.
|
||||||
*/
|
*/
|
||||||
local int get_byte(s) mem_stream *s;
|
local int get_byte(mem_stream *s)
|
||||||
{
|
{
|
||||||
if (s->z_eof)
|
if (s->z_eof)
|
||||||
return EOF;
|
return EOF;
|
||||||
|
@ -387,7 +383,7 @@ local int get_byte(s) mem_stream *s;
|
||||||
s->stream.avail_in is zero for the first time, but may be non-zero
|
s->stream.avail_in is zero for the first time, but may be non-zero
|
||||||
for concatenated .gz files.
|
for concatenated .gz files.
|
||||||
*/
|
*/
|
||||||
local void check_header(s) mem_stream *s;
|
local void check_header(mem_stream *s)
|
||||||
{
|
{
|
||||||
int method; /* method byte */
|
int method; /* method byte */
|
||||||
int flags; /* flags byte */
|
int flags; /* flags byte */
|
||||||
|
@ -445,7 +441,7 @@ local void check_header(s) mem_stream *s;
|
||||||
* Cleanup then free the given mem_stream. Return a zlib error code.
|
* Cleanup then free the given mem_stream. Return a zlib error code.
|
||||||
Try freeing in the reverse order of allocations.
|
Try freeing in the reverse order of allocations.
|
||||||
*/
|
*/
|
||||||
local int destroy(s) mem_stream *s;
|
local int destroy(mem_stream *s)
|
||||||
{
|
{
|
||||||
int err = Z_OK;
|
int err = Z_OK;
|
||||||
|
|
||||||
|
@ -484,9 +480,7 @@ local int destroy(s) mem_stream *s;
|
||||||
Reads the given number of uncompressed bytes from the compressed file.
|
Reads the given number of uncompressed bytes from the compressed file.
|
||||||
gzread returns the number of bytes actually read (0 for end of file).
|
gzread returns the number of bytes actually read (0 for end of file).
|
||||||
*/
|
*/
|
||||||
int ZEXPORT memgzread(file, buf, len) gzFile file;
|
int ZEXPORT memgzread(gzFile file, voidp buf, unsigned len)
|
||||||
voidp buf;
|
|
||||||
unsigned len;
|
|
||||||
{
|
{
|
||||||
mem_stream *s = (mem_stream *)file;
|
mem_stream *s = (mem_stream *)file;
|
||||||
Bytef *start = (Bytef *)buf; /* starting point for crc computation */
|
Bytef *start = (Bytef *)buf; /* starting point for crc computation */
|
||||||
|
@ -581,9 +575,7 @@ unsigned len;
|
||||||
Writes the given number of uncompressed bytes into the compressed file.
|
Writes the given number of uncompressed bytes into the compressed file.
|
||||||
gzwrite returns the number of bytes actually written (0 in case of error).
|
gzwrite returns the number of bytes actually written (0 in case of error).
|
||||||
*/
|
*/
|
||||||
int ZEXPORT memgzwrite(file, buf, len) gzFile file;
|
int ZEXPORT memgzwrite(gzFile file, const voidp buf, unsigned len)
|
||||||
const voidp buf;
|
|
||||||
unsigned len;
|
|
||||||
{
|
{
|
||||||
mem_stream *s = (mem_stream *)file;
|
mem_stream *s = (mem_stream *)file;
|
||||||
|
|
||||||
|
@ -615,8 +607,7 @@ unsigned len;
|
||||||
Flushes all pending output into the compressed file. The parameter
|
Flushes all pending output into the compressed file. The parameter
|
||||||
flush is as in the deflate() function.
|
flush is as in the deflate() function.
|
||||||
*/
|
*/
|
||||||
local int do_flush(file, flush) gzFile file;
|
local int do_flush(gzFile file, int flush)
|
||||||
int flush;
|
|
||||||
{
|
{
|
||||||
uInt len;
|
uInt len;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
@ -660,12 +651,11 @@ int flush;
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
Outputs a long in LSB order to the given file
|
Outputs a long in LSB order to the given file
|
||||||
*/
|
*/
|
||||||
local void putLong(file, x) MEMFILE *file;
|
local void putLong(MEMFILE *file, uLong x)
|
||||||
uLong x;
|
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
for (n = 0; n < 4; n++) {
|
for (n = 0; n < 4; n++) {
|
||||||
memPutc((int)(x & 0xff), file);
|
memPutc((char)(x & 0xff), file);
|
||||||
x >>= 8;
|
x >>= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -674,7 +664,7 @@ uLong x;
|
||||||
Reads a long in LSB order from the given mem_stream. Sets z_err in case
|
Reads a long in LSB order from the given mem_stream. Sets z_err in case
|
||||||
of error.
|
of error.
|
||||||
*/
|
*/
|
||||||
local uLong getLong(s) mem_stream *s;
|
local uLong getLong(mem_stream *s)
|
||||||
{
|
{
|
||||||
uLong x = (uLong)get_byte(s);
|
uLong x = (uLong)get_byte(s);
|
||||||
int c;
|
int c;
|
||||||
|
@ -692,7 +682,7 @@ local uLong getLong(s) mem_stream *s;
|
||||||
Flushes all pending output if necessary, closes the compressed file
|
Flushes all pending output if necessary, closes the compressed file
|
||||||
and deallocates all the (de)compression state.
|
and deallocates all the (de)compression state.
|
||||||
*/
|
*/
|
||||||
int ZEXPORT memgzclose(file) gzFile file;
|
int ZEXPORT memgzclose(gzFile file)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
mem_stream *s = (mem_stream *)file;
|
mem_stream *s = (mem_stream *)file;
|
||||||
|
@ -715,7 +705,7 @@ int ZEXPORT memgzclose(file) gzFile file;
|
||||||
return destroy((mem_stream *)file);
|
return destroy((mem_stream *)file);
|
||||||
}
|
}
|
||||||
|
|
||||||
long ZEXPORT memtell(file) gzFile file;
|
long ZEXPORT memtell(gzFile file)
|
||||||
{
|
{
|
||||||
mem_stream *s;
|
mem_stream *s;
|
||||||
do_flush(file, Z_FULL_FLUSH); // makes memtell to tell truth
|
do_flush(file, Z_FULL_FLUSH); // makes memtell to tell truth
|
||||||
|
|
Loading…
Reference in New Issue