Lines Matching defs:file

6  * This file contains Original Code and/or Modifications of Original Code
8 * Version 2.0 (the 'License'). You may not use this file except in
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
32 * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
76 #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
79 #define ORIG_NAME 0x08 /* bit 3 set: original file name present */
80 #define COMMENT 0x10 /* bit 4 set: file comment present */
86 int z_eof; /* set if end of input file */
87 FILE *file; /* .gz file */
93 int transparent; /* 1 if input file is not a .gz file */
95 z_off_t start; /* start of compressed data in file (header skipped) */
104 local int do_flush OF((gzFile file, int flush));
108 local void putLong OF((FILE *file, uLong x));
112 Opens a gzip (.gz) file for reading or writing. The mode parameter
113 is as in fopen ("rb" or "wb"). The file is given either by file descriptor
115 gz_open returns NULL if the file could not be opened or if there was
144 s->file = NULL;
208 s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
210 if (s->file == NULL) {
216 fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
219 /* We use 10L instead of ftell(s->file) to because ftell causes an
226 s->start = ftell(s->file) - s->stream.avail_in;
233 Opens a gzip (.gz) file for reading or writing.
243 Associate a gzFile with the file descriptor fd. fd is not dup'ed here
261 int ZEXPORT gzsetparams (file, level, strategy)
262 gzFile file;
266 gz_stream *s = (gz_stream*)file;
274 if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
285 for end of file.
294 s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
297 if (ferror(s->file)) s->z_err = Z_ERRNO;
330 len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
331 if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
366 if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
369 if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
402 if (s->file != NULL && fclose(s->file)) {
418 Reads the given number of uncompressed bytes from the compressed file.
419 gzread returns the number of bytes actually read (0 for end of file).
421 int ZEXPORT gzread (file, buf, len)
422 gzFile file;
426 gz_stream *s = (gz_stream*)file;
468 (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
479 s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
482 if (ferror(s->file)) {
527 Reads one byte from the compressed file. gzgetc returns this byte
528 or -1 in case of end of file or error.
530 int ZEXPORT gzgetc(file)
531 gzFile file;
535 return gzread(file, &c, 1) == 1 ? c : -1;
542 int ZEXPORT gzungetc(c, file)
544 gzFile file;
546 gz_stream *s = (gz_stream*)file;
559 Reads bytes from the compressed file until len-1 characters are
561 end-of-file condition is encountered. The string is then terminated
567 char * ZEXPORT gzgets(file, buf, len)
568 gzFile file;
575 while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
583 Writes the given number of uncompressed bytes into the compressed file.
586 int ZEXPORT gzwrite (file, buf, len)
587 gzFile file;
591 gz_stream *s = (gz_stream*)file;
603 if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
623 Converts, formats, and writes the args to the compressed file under
630 int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
660 return gzwrite(file, buf, (unsigned)len);
664 int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
666 gzFile file;
697 return gzwrite(file, buf, len);
702 Writes c, converted to an unsigned char, into the compressed file.
705 int ZEXPORT gzputc(file, c)
706 gzFile file;
711 return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
716 Writes the given null-terminated string to the compressed file, excluding
720 int ZEXPORT gzputs(file, s)
721 gzFile file;
724 return gzwrite(file, (char*)s, (unsigned)strlen(s));
729 Flushes all pending output into the compressed file. The parameter
732 local int do_flush (file, flush)
733 gzFile file;
738 gz_stream *s = (gz_stream*)file;
748 if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
773 int ZEXPORT gzflush (file, flush)
774 gzFile file;
777 gz_stream *s = (gz_stream*)file;
778 int err = do_flush (file, flush);
781 fflush(s->file);
788 compressed file. The offset represents a number of bytes in the
794 z_off_t ZEXPORT gzseek (file, offset, whence)
795 gzFile file;
799 gz_stream *s = (gz_stream*)file;
825 size = gzwrite(file, s->inbuf, size);
846 if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
855 } else if (gzrewind(file) < 0) {
874 size = gzread(file, s->outbuf, (uInt)size);
882 Rewinds input file.
884 int ZEXPORT gzrewind (file)
885 gzFile file;
887 gz_stream *s = (gz_stream*)file;
900 return fseek(s->file, s->start, SEEK_SET);
905 given compressed file. This position represents a number of bytes in the
908 z_off_t ZEXPORT gztell (file)
909 gzFile file;
911 return gzseek(file, 0L, SEEK_CUR);
918 int ZEXPORT gzeof (file)
919 gzFile file;
921 gz_stream *s = (gz_stream*)file;
935 int ZEXPORT gzdirect (file)
936 gzFile file;
938 gz_stream *s = (gz_stream*)file;
945 Outputs a long in LSB order to the given file
947 local void putLong (file, x)
948 FILE *file;
953 fputc((int)(x & 0xff), file);
977 Flushes all pending output if necessary, closes the compressed file
980 int ZEXPORT gzclose (file)
981 gzFile file;
983 gz_stream *s = (gz_stream*)file;
991 if (do_flush (file, Z_FINISH) != Z_OK)
992 return destroy((gz_stream*)file);
994 putLong (s->file, s->crc);
995 putLong (s->file, (uLong)(s->in & 0xffffffff));
998 return destroy((gz_stream*)file);
1009 given compressed file. errnum is set to zlib error number. If an
1010 error occurred in the file system and not in the compression library,
1014 const char * ZEXPORT gzerror (file, errnum)
1015 gzFile file;
1019 gz_stream *s = (gz_stream*)file;
1042 Clear the error and end-of-file flags, and do the same for the real file.
1044 void ZEXPORT gzclearerr (file)
1045 gzFile file;
1047 gz_stream *s = (gz_stream*)file;
1052 clearerr(s->file);