root/branches/3.00/src/compress_gz.h

Revision 644, 2.6 kB (checked in by fujii, 4 years ago)

Add new netinstall source.

Line 
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 SETUP_COMPRESS_GZ_H
17 #define SETUP_COMPRESS_GZ_H
18
19 /* this is the parent class for all compress IO operations.
20  * It
21  */
22
23 class compress_gz:public compress
24 {
25 public:
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!) */
33   virtual ssize_t write (const void *buffer, size_t len);
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 ();
37   virtual int seek (long where, io_stream_seek_t whence);
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 ();
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;};
54   /* if you are still needing these hints... give up now! */
55   virtual ~ compress_gz ();
56 private:
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 /* SETUP_COMPRESS_GZ_H */
Note: See TracBrowser for help on using the browser.