Lines Matching defs:file
5 * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
35 FILE *fdopen(int, const char *);
49 #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
52 #define ORIG_NAME 0x08 /* bit 3 set: original file name present */
53 #define COMMENT 0x10 /* bit 4 set: file comment present */
59 int z_eof; /* set if end of input file */
60 FILE *file; /* .gz file */
66 int transparent; /* 1 if input file is not a .gz file */
68 z_off_t start; /* start of compressed data in file (header skipped) */
77 local int do_flush OF((gzFile file, int flush));
81 local void putLong OF((FILE *file, uLong x));
85 Opens a gzip (.gz) file for reading or writing. The mode parameter
86 is as in fopen ("rb" or "wb"). The file is given either by file descriptor
88 gz_open returns NULL if the file could not be opened or if there was
117 s->file = NULL;
181 s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
183 if (s->file == NULL) {
189 fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
192 /* We use 10L instead of ftell(s->file) to because ftell causes an
199 s->start = ftell(s->file) - s->stream.avail_in;
206 Opens a gzip (.gz) file for reading or writing.
216 Associate a gzFile with the file descriptor fd. fd is not dup'ed here
234 int ZEXPORT gzsetparams (file, level, strategy)
235 gzFile file;
239 gz_stream *s = (gz_stream*)file;
247 if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
258 for end of file.
267 s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
270 if (ferror(s->file)) s->z_err = Z_ERRNO;
303 len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
304 if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
339 if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
342 if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
375 if (s->file != NULL && fclose(s->file)) {
391 Reads the given number of uncompressed bytes from the compressed file.
392 gzread returns the number of bytes actually read (0 for end of file).
394 int ZEXPORT gzread (file, buf, len)
395 gzFile file;
399 gz_stream *s = (gz_stream*)file;
441 (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
452 s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
455 if (ferror(s->file)) {
500 Reads one byte from the compressed file. gzgetc returns this byte
501 or -1 in case of end of file or error.
503 int ZEXPORT gzgetc(file)
504 gzFile file;
508 return gzread(file, &c, 1) == 1 ? c : -1;
515 int ZEXPORT gzungetc(c, file)
517 gzFile file;
519 gz_stream *s = (gz_stream*)file;
532 Reads bytes from the compressed file until len-1 characters are
534 end-of-file condition is encountered. The string is then terminated
540 char * ZEXPORT gzgets(file, buf, len)
541 gzFile file;
548 while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
556 Writes the given number of uncompressed bytes into the compressed file.
559 int ZEXPORT gzwrite (file, buf, len)
560 gzFile file;
564 gz_stream *s = (gz_stream*)file;
576 if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
596 Converts, formats, and writes the args to the compressed file under
603 int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
633 return gzwrite(file, buf, (unsigned)len);
637 int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
639 gzFile file;
670 return gzwrite(file, buf, len);
675 Writes c, converted to an unsigned char, into the compressed file.
678 int ZEXPORT gzputc(file, c)
679 gzFile file;
684 return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
689 Writes the given null-terminated string to the compressed file, excluding
693 int ZEXPORT gzputs(file, s)
694 gzFile file;
697 return gzwrite(file, (char*)s, (unsigned)strlen(s));
702 Flushes all pending output into the compressed file. The parameter
705 local int do_flush (file, flush)
706 gzFile file;
711 gz_stream *s = (gz_stream*)file;
721 if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
746 int ZEXPORT gzflush (file, flush)
747 gzFile file;
750 gz_stream *s = (gz_stream*)file;
751 int err = do_flush (file, flush);
754 fflush(s->file);
761 compressed file. The offset represents a number of bytes in the
767 z_off_t ZEXPORT gzseek (file, offset, whence)
768 gzFile file;
772 gz_stream *s = (gz_stream*)file;
798 size = gzwrite(file, s->inbuf, size);
819 if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
828 } else if (gzrewind(file) < 0) {
847 size = gzread(file, s->outbuf, (uInt)size);
855 Rewinds input file.
857 int ZEXPORT gzrewind (file)
858 gzFile file;
860 gz_stream *s = (gz_stream*)file;
873 return fseek(s->file, s->start, SEEK_SET);
878 given compressed file. This position represents a number of bytes in the
881 z_off_t ZEXPORT gztell (file)
882 gzFile file;
884 return gzseek(file, 0L, SEEK_CUR);
891 int ZEXPORT gzeof (file)
892 gzFile file;
894 gz_stream *s = (gz_stream*)file;
908 int ZEXPORT gzdirect (file)
909 gzFile file;
911 gz_stream *s = (gz_stream*)file;
918 Outputs a long in LSB order to the given file
920 local void putLong (file, x)
921 FILE *file;
926 fputc((int)(x & 0xff), file);
950 Flushes all pending output if necessary, closes the compressed file
953 int ZEXPORT gzclose (file)
954 gzFile file;
956 gz_stream *s = (gz_stream*)file;
964 if (do_flush (file, Z_FINISH) != Z_OK)
965 return destroy((gz_stream*)file);
967 putLong (s->file, s->crc);
968 putLong (s->file, (uLong)(s->in & 0xffffffff));
971 return destroy((gz_stream*)file);
982 given compressed file. errnum is set to zlib error number. If an
983 error occurred in the file system and not in the compression library,
987 const char * ZEXPORT gzerror (file, errnum)
988 gzFile file;
992 gz_stream *s = (gz_stream*)file;
1015 Clear the error and end-of-file flags, and do the same for the real file.
1017 void ZEXPORT gzclearerr (file)
1018 gzFile file;
1020 gz_stream *s = (gz_stream*)file;
1025 clearerr(s->file);