#include <zlib.h>
Go to the source code of this file.
|
gzFile ZEXPORT | c4_gzopen (const char *path, const char *mode) |
|
gzFile ZEXPORT | c4_gzdopen (int fd, const char *mode) |
|
int ZEXPORT | c4_gzsetparams (gzFile file, int level, int strategy) |
|
int ZEXPORT | c4_gzread (gzFile file, voidp buf, unsigned len) |
|
int ZEXPORT | c4_gzgetc (gzFile file) |
|
int ZEXPORT | c4_gzungetc (int c, gzFile file) |
|
char *ZEXPORT | c4_gzgets (gzFile file, char *buf, int len) |
|
int ZEXPORT | c4_gzwrite (gzFile file, voidpc buf, unsigned len) |
|
int ZEXPORTVA | c4_gzprintf (gzFile file, const char *format,...) |
|
int ZEXPORT | c4_gzputc (gzFile file, int c) |
|
int ZEXPORT | c4_gzputs (gzFile file, const char *s) |
|
int ZEXPORT | c4_gzflush (gzFile file, int flush) |
|
z_off_t ZEXPORT | c4_gzseek (gzFile file, z_off_t offset, int whence) |
|
int ZEXPORT | c4_gzrewind (gzFile file) |
|
z_off_t ZEXPORT | c4_gztell (gzFile file) |
|
int ZEXPORT | c4_gzeof (gzFile file) |
|
int ZEXPORT | c4_gzdirect (gzFile file) |
|
int ZEXPORT | c4_gzclose (gzFile file) |
|
void ZEXPORT | c4_gzclearerr (gzFile file) |
|
◆ c4_gzclearerr()
void ZEXPORT c4_gzclearerr |
( |
gzFile |
file | ) |
|
Definition at line 1030 of file gzio.c.
1035 if (
s == NULL)
return;
1036 if (
s->z_err != Z_STREAM_END)
s->z_err = Z_OK;
References s.
◆ c4_gzclose()
int ZEXPORT c4_gzclose |
( |
gzFile |
file | ) |
|
◆ c4_gzdirect()
int ZEXPORT c4_gzdirect |
( |
gzFile |
file | ) |
|
Definition at line 919 of file gzio.c.
924 if (
s == NULL ||
s->mode !=
'r')
return 0;
925 return s->transparent;
References s.
Referenced by CStdFile::Open().
◆ c4_gzdopen()
gzFile ZEXPORT c4_gzdopen |
( |
int |
fd, |
|
|
const char * |
mode |
|
) |
| |
◆ c4_gzeof()
int ZEXPORT c4_gzeof |
( |
gzFile |
file | ) |
|
Definition at line 902 of file gzio.c.
911 if (
s == NULL ||
s->mode !=
'r')
return 0;
912 if (
s->z_eof)
return 1;
913 return s->z_err == Z_STREAM_END;
References s.
◆ c4_gzflush()
int ZEXPORT c4_gzflush |
( |
gzFile |
file, |
|
|
int |
flush |
|
) |
| |
Definition at line 757 of file gzio.c.
766 return s->z_err == Z_STREAM_END ? Z_OK :
s->z_err;
References do_flush(), and s.
◆ c4_gzgetc()
int ZEXPORT c4_gzgetc |
( |
gzFile |
file | ) |
|
Definition at line 514 of file gzio.c.
519 return gzread(file, &c, 1) == 1 ? c : -1;
◆ c4_gzgets()
char* ZEXPORT c4_gzgets |
( |
gzFile |
file, |
|
|
char * |
buf, |
|
|
int |
len |
|
) |
| |
Definition at line 551 of file gzio.c.
557 if (buf == Z_NULL || len <= 0)
return Z_NULL;
559 while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ !=
'\n') ;
561 return b == buf && len > 0 ? Z_NULL :
b;
References b.
◆ c4_gzopen()
gzFile ZEXPORT c4_gzopen |
( |
const char * |
path, |
|
|
const char * |
mode |
|
) |
| |
◆ c4_gzprintf()
int ZEXPORTVA c4_gzprintf |
( |
gzFile |
file, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
◆ c4_gzputc()
int ZEXPORT c4_gzputc |
( |
gzFile |
file, |
|
|
int |
c |
|
) |
| |
Definition at line 689 of file gzio.c.
693 unsigned char cc = (
unsigned char) c;
695 return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
◆ c4_gzputs()
int ZEXPORT c4_gzputs |
( |
gzFile |
file, |
|
|
const char * |
s |
|
) |
| |
Definition at line 704 of file gzio.c.
708 return gzwrite(file,
s, (
unsigned)strlen(
s));
References s.
◆ c4_gzread()
int ZEXPORT c4_gzread |
( |
gzFile |
file, |
|
|
voidp |
buf, |
|
|
unsigned |
len |
|
) |
| |
Definition at line 405 of file gzio.c.
411 Bytef *start = (Bytef*)buf;
414 if (
s == NULL ||
s->mode !=
'r')
return Z_STREAM_ERROR;
416 if (
s->z_err == Z_DATA_ERROR ||
s->z_err == Z_ERRNO)
return -1;
417 if (
s->z_err == Z_STREAM_END)
return 0;
419 next_out = (Byte*)buf;
420 s->stream.next_out = (Bytef*)buf;
421 s->stream.avail_out = len;
423 if (
s->stream.avail_out &&
s->back != EOF) {
424 *next_out++ =
s->back;
425 s->stream.next_out++;
426 s->stream.avail_out--;
431 s->z_err = Z_STREAM_END;
436 while (
s->stream.avail_out != 0) {
438 if (
s->transparent) {
440 uInt n =
s->stream.avail_in;
441 if (n >
s->stream.avail_out) n =
s->stream.avail_out;
443 zmemcpy(
s->stream.next_out,
s->stream.next_in, n);
445 s->stream.next_out = next_out;
446 s->stream.next_in += n;
447 s->stream.avail_out -= n;
448 s->stream.avail_in -= n;
450 if (
s->stream.avail_out > 0) {
451 s->stream.avail_out -=
452 (uInt)fread(next_out, 1,
s->stream.avail_out,
s->file);
454 len -=
s->stream.avail_out;
457 if (len == 0)
s->z_eof = 1;
460 if (
s->stream.avail_in == 0 && !
s->z_eof) {
463 s->stream.avail_in = (uInt)fread(
s->inbuf, 1,
Z_BUFSIZE,
s->file);
464 if (
s->stream.avail_in == 0) {
466 if (ferror(
s->file)) {
471 s->stream.next_in =
s->inbuf;
473 s->in +=
s->stream.avail_in;
474 s->out +=
s->stream.avail_out;
475 s->z_err = inflate(&(
s->stream), Z_NO_FLUSH);
476 s->in -=
s->stream.avail_in;
477 s->out -=
s->stream.avail_out;
479 if (
s->z_err == Z_STREAM_END) {
481 s->crc = crc32(
s->crc, start, (uInt)(
s->stream.next_out - start));
482 start =
s->stream.next_out;
485 s->z_err = Z_DATA_ERROR;
493 if (
s->z_err == Z_OK) {
494 inflateReset(&(
s->stream));
495 s->crc = crc32(0L, Z_NULL, 0);
499 if (
s->z_err != Z_OK ||
s->z_eof)
break;
501 s->crc = crc32(
s->crc, start, (uInt)(
s->stream.next_out - start));
503 if (len ==
s->stream.avail_out &&
504 (
s->z_err == Z_DATA_ERROR ||
s->z_err == Z_ERRNO))
506 return (
int)(len -
s->stream.avail_out);
void check_header(gz_stream *s)
uLong getLong(gz_stream *s)
References check_header(), getLong(), s, and Z_BUFSIZE.
Referenced by CStdFile::LoadBuffer(), and UncompressedFileSize().
◆ c4_gzrewind()
int ZEXPORT c4_gzrewind |
( |
gzFile |
file | ) |
|
Definition at line 868 of file gzio.c.
873 if (
s == NULL ||
s->mode !=
'r')
return -1;
878 s->stream.avail_in = 0;
879 s->stream.next_in =
s->inbuf;
880 s->crc = crc32(0L, Z_NULL, 0);
881 if (!
s->transparent) (void)inflateReset(&
s->stream);
884 return fseek(
s->file,
s->start, SEEK_SET);
References s.
Referenced by CStdFile::Rewind().
◆ c4_gzseek()
z_off_t ZEXPORT c4_gzseek |
( |
gzFile |
file, |
|
|
z_off_t |
offset, |
|
|
int |
whence |
|
) |
| |
Definition at line 778 of file gzio.c.
785 if (
s == NULL || whence == SEEK_END ||
786 s->z_err == Z_ERRNO ||
s->z_err == Z_DATA_ERROR) {
790 if (
s->mode ==
'w') {
794 if (whence == SEEK_SET) {
797 if (offset < 0)
return -1L;
800 if (
s->inbuf == Z_NULL) {
802 if (
s->inbuf == Z_NULL)
return -1L;
807 if (offset <
Z_BUFSIZE) size = (uInt)offset;
809 size = gzwrite(file,
s->inbuf, size);
810 if (size == 0)
return -1L;
820 if (whence == SEEK_CUR) {
823 if (offset < 0)
return -1L;
825 if (
s->transparent) {
828 s->stream.avail_in = 0;
829 s->stream.next_in =
s->inbuf;
830 if (fseek(
s->file, offset, SEEK_SET) < 0)
return -1L;
832 s->in =
s->out = offset;
837 if (offset >=
s->out) {
839 }
else if (gzrewind(file) < 0) {
844 if (offset != 0 &&
s->outbuf == Z_NULL) {
846 if (
s->outbuf == Z_NULL)
return -1L;
848 if (offset &&
s->back != EOF) {
852 if (
s->last)
s->z_err = Z_STREAM_END;
856 if (offset <
Z_BUFSIZE) size = (int)offset;
858 size = gzread(file,
s->outbuf, (uInt)size);
859 if (size <= 0)
return -1L;
References ALLOC, s, and Z_BUFSIZE.
◆ c4_gzsetparams()
int ZEXPORT c4_gzsetparams |
( |
gzFile |
file, |
|
|
int |
level, |
|
|
int |
strategy |
|
) |
| |
Definition at line 243 of file gzio.c.
250 if (
s == NULL ||
s->mode !=
'w')
return Z_STREAM_ERROR;
253 if (
s->stream.avail_out == 0) {
255 s->stream.next_out =
s->outbuf;
262 return deflateParams (&(
s->stream), level, strategy);
References s, and Z_BUFSIZE.
◆ c4_gztell()
z_off_t ZEXPORT c4_gztell |
( |
gzFile |
file | ) |
|
Definition at line 892 of file gzio.c.
895 return gzseek(file, 0L, SEEK_CUR);
◆ c4_gzungetc()
int ZEXPORT c4_gzungetc |
( |
int |
c, |
|
|
gzFile |
file |
|
) |
| |
Definition at line 526 of file gzio.c.
532 if (
s == NULL ||
s->mode !=
'r' || c == EOF ||
s->back != EOF)
return EOF;
535 s->last = (
s->z_err == Z_STREAM_END);
536 if (
s->last)
s->z_err = Z_OK;
References s.
◆ c4_gzwrite()
int ZEXPORT c4_gzwrite |
( |
gzFile |
file, |
|
|
voidpc |
buf, |
|
|
unsigned |
len |
|
) |
| |
Definition at line 570 of file gzio.c.
577 if (
s == NULL ||
s->mode !=
'w')
return Z_STREAM_ERROR;
579 s->stream.next_in = *(Bytef**)(
void*)&buf;
580 s->stream.avail_in = len;
582 while (
s->stream.avail_in != 0) {
584 if (
s->stream.avail_out == 0) {
586 s->stream.next_out =
s->outbuf;
593 s->in +=
s->stream.avail_in;
594 s->out +=
s->stream.avail_out;
595 s->z_err = deflate(&(
s->stream), Z_NO_FLUSH);
596 s->in -=
s->stream.avail_in;
597 s->out -=
s->stream.avail_out;
598 if (
s->z_err != Z_OK)
break;
600 s->crc = crc32(
s->crc, (
const Bytef *)buf, len);
602 return (
int)(len -
s->stream.avail_in);
References s, and Z_BUFSIZE.
Referenced by CStdFile::SaveBuffer().