]> cygwin.com Git - cygwin-apps/setup.git/blame - compress_gz.h
2002-04-23 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / compress_gz.h
CommitLineData
b24c88b3
RC
1/*
2 * Copyright (c) 2001, Robert Collins.
3 *
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.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins <rbtcollins@hotmail.com>
13 *
14 */
15
16#ifndef _COMPRESS_GZ_H_
17#define _COMPRESS_GZ_H_
18
19/* this is the parent class for all compress IO operations.
20 * It
21 */
22
23class compress_gz:public compress
24{
25public:
26 /* assumes decompression */
27 compress_gz (io_stream *);
28 /* the mode allows control, but this implementation only does compression */
29 compress_gz (io_stream *, const char *);
30 /* read data (duh!) */
31 virtual ssize_t read (void *buffer, size_t len);
32 /* provide data to (double duh!) */
ca9506cc 33 virtual ssize_t write (const void *buffer, size_t len);
b24c88b3
RC
34 /* read data without removing it from the class's internal buffer */
35 virtual ssize_t peek (void *buffer, size_t len);
36 virtual long tell ();
ca9506cc 37 virtual int seek (long where, io_stream_seek_t whence);
b24c88b3
RC
38 /* try guessing this one */
39 virtual int error ();
40 /* Find out the next stream name -
41 * ie for foo.tar.gz, at offset 0, next_file_name = foo.tar
42 * for foobar that is an compress, next_file_name is the next
43 * extractable filename.
44 */
45 virtual const char *next_file_name ()
46 {
47 return NULL;
48 };
49 virtual int set_mtime (int);
50 virtual int get_mtime ();
341988b9
RC
51 /* Use seek EOF, then tell (). get_size won't do this incase you are sucking down
52 * over a WAN :} */
53 virtual size_t get_size () {return 0;};
b24c88b3 54 /* if you are still needing these hints... give up now! */
341988b9 55 virtual ~ compress_gz ();
b24c88b3
RC
56private:
57 compress_gz ()
58 {
59 };
60 char peekbuf[512];
61 size_t peeklen;
62 void construct (io_stream *, const char *);
63 void check_header ();
64 int get_byte ();
65 unsigned long getLong ();
66 void putLong (unsigned long);
67 void destroy ();
68 int do_flush (int);
69 io_stream *original;
70 /* from zlib */
71 z_stream stream;
72 int z_err; /* error code for last stream operation */
73 int z_eof; /* set if end of input file */
74 unsigned char *inbuf; /* input buffer */
75 unsigned char *outbuf; /* output buffer */
76 uLong crc; /* crc32 of uncompressed data */
77 char *msg; /* error message */
78 int transparent; /* 1 if input file is not a .gz file */
79 char mode; /* 'w' or 'r' */
80 long startpos; /* start of compressed data in file (header skipped) */
81};
82
83#endif /* _COMPRESS_GZ_H_ */
This page took 0.029237 seconds and 5 git commands to generate.