root/branches/3.00/src/compress_bz.h

Revision 644, 2.3 kB (checked in by fujii, 3 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_BZ_H
17 #define SETUP_COMPRESS_BZ_H
18
19 /* this is the bz2 class for all compressed IO operations.
20  */
21
22 #ifdef _WIN32
23 #undef _WIN32
24 /* If we are going to hide the fact that we are _WIN32 from bzlib,
25  +   then we need to #undef small for it as well (bad windows.h clash). */
26 #undef small
27 #include <bzlib.h>
28 #define _WIN32
29 /* What do we redefine small as? - RBC */
30 #else
31 #include <bzlib.h>
32 #endif
33
34 class compress_bz:public compress
35 {
36 public:
37   /* assumes decompression */
38   compress_bz (io_stream *);
39   /* allows comp/decomp but this implementation only handles comp */
40   compress_bz (io_stream *, const char *);
41   /* read data (duh!) */
42   virtual ssize_t read (void *buffer, size_t len);
43   /* provide data to (double duh!) */
44   virtual ssize_t write (const void *buffer, size_t len);
45   /* read data without removing it from the class's internal buffer */
46   virtual ssize_t peek (void *buffer, size_t len);
47   virtual long tell ();
48   virtual int seek (long where, io_stream_seek_t whence);
49   /* try guessing this one */
50   virtual int error ();
51   /* Find out the next stream name -
52    * ie for foo.tar.bz, at offset 0, next_file_name = foo.tar
53    * for foobar that is an compress, next_file_name is the next
54    * extractable filename.
55    */
56   virtual const char *next_file_name ()
57   {
58     return NULL;
59   };
60   virtual int set_mtime (int);
61   /* Use seek EOF, then tell (). get_size won't do this incase you are sucking dow
62       * over a WAN :} */
63   virtual size_t get_size () {return 0;};
64   virtual int get_mtime ();
65   /* if you are still needing these hints... give up now! */
66     virtual ~ compress_bz ();
67 private:
68   io_stream *original;
69   char peekbuf[512];
70   size_t peeklen;
71   int lasterr;
72   bz_stream strm;
73   int initialisedOk;
74   int bufN;
75   char buf[4096];
76   int writing;
77   size_t position;
78 };
79
80 #endif /* SETUP_COMPRESS_BZ_H */
Note: See TracBrowser for help on using the browser.