• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/zlib-55/zlib/examples/

Lines Matching +defs:file +defs:name

1 /* gzappend -- command to append to a gzip file
36 * - Simplfy and unify file operations
37 * - Finish off gzip file in gztack()
39 * - Keep gzip file clean on appended file read errors
45 gzappend takes a gzip file and appends to it, compressing files from the
46 command line or data from stdin. The gzip file is written to directly, to
47 avoid copying that file, in case it's large. Note that this results in the
48 unfriendly behavior that if gzappend fails, the gzip file is corrupted.
58 gzappend first decompresses the gzip file internally, discarding all but
64 Then the last block bit is cleared by seeking back in the file and rewriting
69 data from the gzip file to initialize the dictionary. If the total
73 append is simply compressed using deflate, and written to the gzip file.
75 as the trailer of the gzip file.
167 /* structure for gzip file read operations */
169 int fd; /* file descriptor */
174 char *name; /* file name for error messages */
175 } file;
178 local int readin(file *in)
183 if (len == -1) bye("error reading ", in->name);
189 /* read from file in, exit if end-of-file */
190 local int readmore(file *in)
192 if (readin(in) == 0) bye("unexpected end of ", in->name);
200 local void skip(file *in, unsigned n)
209 bye("seeking ", in->name);
214 bye("unexpected end of ", in->name);
221 unsigned long read4(file *in)
233 local void gzheader(file *in)
238 if (read1(in) != 31 || read1(in) != 139) bye(in->name, " not a gzip file");
239 if (read1(in) != 8) bye("unknown compression method in", in->name);
241 if (flags & 0xe0) bye("unknown header flags set in", in->name);
253 /* decompress gzip file "name", return strm with a deflate stream ready to
254 continue compression of the data in the gzip file, and return a file
257 local int gzscan(char *name, z_stream *strm, int level)
264 file gz;
266 /* open gzip file */
267 gz.name = name;
268 gz.fd = open(name, O_RDWR, 0);
269 if (gz.fd == -1) bye("cannot open ", name);
312 bye("invalid compressed data--format violated in", name);
342 bye("invalid compressed data--crc mismatch in ", name);
345 bye("invalid compressed data--length mismatch in", name);
347 /* if not at end of file, warn */
350 "gzappend warning: junk at end of gzip file overwritten\n");
354 if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name);
357 if (write(gz.fd, gz.buf, 1) != 1) bye("writing after seek to ", name);
373 if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name);
384 /* append file "name" to gzip file gd using deflate stream strm -- if last
386 local void gztack(char *name, int gd, z_stream *strm, int last)
392 /* open file to compress and append */
394 if (name != NULL) {
395 fd = open(name, O_RDONLY, 0);
398 name);
406 /* compress input file and append to gzip file */
413 name);
428 if (len == -1) bye("writing gzip file", "");
448 if (ret == -1) bye("writing gzip file", "");
460 /* process the compression level option if present, scan the gzip file, and
461 append the specified files, or append the data from stdin if no other file
462 names are provided on the command line -- the gzip file must be writable
469 /* ignore command name */
476 "usage: gzappend [-level] file.gz [ addthis [ andthis ... ]]\n");
486 if (*++argv == NULL) bye("no gzip file name after options", "");
489 /* prepare to append to gzip file */