2 * Copyright (c) 2001, Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 #ifndef SETUP_COMPRESS_GZ_H
17 #define SETUP_COMPRESS_GZ_H
22 class compress_gz
:public compress
25 /* assumes decompression */
26 compress_gz (io_stream
*);
27 /* the mode allows control, but this implementation only does compression */
28 compress_gz (io_stream
*, const char *);
29 /* read data (duh!) */
30 virtual ssize_t
read (void *buffer
, size_t len
);
31 /* provide data to (double duh!) */
32 virtual ssize_t
write (const void *buffer
, size_t len
);
33 /* read data without removing it from the class's internal buffer */
34 virtual ssize_t
peek (void *buffer
, size_t len
);
35 virtual off_t
tell ();
36 virtual off_t
seek (off_t where
, io_stream_seek_t whence
);
37 /* try guessing this one */
39 /* Find out the next stream name -
40 * ie for foo.tar.gz, at offset 0, next_file_name = foo.tar
41 * for foobar that is an compress, next_file_name is the next
42 * extractable filename.
44 virtual const char *next_file_name ()
48 virtual int set_mtime (time_t);
49 virtual time_t get_mtime ();
50 virtual mode_t
get_mode ();
51 /* Use seek EOF, then tell (). get_size won't do this incase you are sucking down
53 virtual size_t get_size () {return 0;};
54 virtual void release_original (); /* give up ownership of original io_stream */
55 /* if you are still needing these hints... give up now! */
56 virtual ~ compress_gz ();
66 unsigned long getLong ();
67 void putLong (unsigned long);
75 int z_err
; /* error code for last stream operation */
76 int z_eof
; /* set if end of input file */
77 unsigned char *inbuf
; /* input buffer */
78 unsigned char *outbuf
; /* output buffer */
79 uLong crc
; /* crc32 of uncompressed data */
80 char *msg
; /* error message */
81 int transparent
; /* 1 if input file is not a .gz file */
82 char mode
; /* 'w' or 'r' */
83 off_t startpos
; /* start of compressed data in file (header skipped) */
86 #endif /* SETUP_COMPRESS_GZ_H */