]>
Commit | Line | Data |
---|---|---|
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 | ||
c93bc6d0 MB |
16 | #ifndef SETUP_COMPRESS_H |
17 | #define SETUP_COMPRESS_H | |
b24c88b3 | 18 | |
b16e07fc | 19 | #include "io_stream.h" |
b24c88b3 RC |
20 | |
21 | class compress:public io_stream | |
22 | { | |
23 | public: | |
24 | /* Get a decompressed stream from a normal stream. If this function returns non-null | |
25 | * a valid compress header was found. The io_stream pointer passed to decompress | |
26 | * should be discarded. The old io_stream will be automatically closed when the | |
27 | * decompression stream is closed | |
28 | */ | |
29 | static io_stream *decompress (io_stream *); | |
30 | /* | |
31 | * To create a stream that will be compressed, you should open the url, and then get a new stream | |
32 | * from compress::compress. | |
33 | */ | |
34 | /* read data (duh!) */ | |
b16e07fc | 35 | virtual ssize_t read (void *buffer, size_t len) = 0; |
b24c88b3 | 36 | /* provide data to (double duh!) */ |
b16e07fc | 37 | virtual ssize_t write (const void *buffer, size_t len) = 0; |
b24c88b3 | 38 | /* read data without removing it from the class's internal buffer */ |
b16e07fc | 39 | virtual ssize_t peek (void *buffer, size_t len) = 0; |
44d31ea0 | 40 | virtual off_t tell () = 0; |
b24c88b3 | 41 | /* try guessing this one */ |
b16e07fc | 42 | virtual int error () = 0; |
b24c88b3 RC |
43 | /* Find out the next stream name - |
44 | * ie for foo.tar.gz, at offset 0, next_file_name = foo.tar | |
45 | * for foobar that is an compress, next_file_name is the next | |
46 | * extractable filename. | |
47 | */ | |
b16e07fc | 48 | virtual const char *next_file_name () = 0; |
b24c88b3 | 49 | /* if you are still needing these hints... give up now! */ |
b16e07fc | 50 | virtual ~compress () = 0; |
b24c88b3 RC |
51 | }; |
52 | ||
c93bc6d0 | 53 | #endif /* SETUP_COMPRESS_H */ |