1 | /* This file is part of the KDE libraries |
2 | SPDX-FileCopyrightText: 2000, 2009 David Faure <faure@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef __kgzipfilter__h |
8 | #define __kgzipfilter__h |
9 | |
10 | #include "kfilterbase.h" |
11 | |
12 | /** |
13 | * Internal class used by KCompressionDevice |
14 | * |
15 | * This header is not installed. |
16 | * |
17 | * @internal |
18 | */ |
19 | class KGzipFilter : public KFilterBase |
20 | { |
21 | public: |
22 | KGzipFilter(); |
23 | ~KGzipFilter() override; |
24 | |
25 | bool init(int mode) override; |
26 | |
27 | // The top of zlib.h explains it: there are three cases. |
28 | // - Raw deflate, no header (e.g. inside a ZIP file) |
29 | // - Thin zlib header (1) (which is normally what HTTP calls "deflate" (2)) |
30 | // - Gzip header, implemented here by readHeader |
31 | // |
32 | // (1) as written out by compress()/compress2() |
33 | // (2) see https://www.zlib.net/zlib_faq.html#faq39 |
34 | enum Flag { |
35 | RawDeflate = 0, // raw deflate data |
36 | = 1, // zlib headers (HTTP deflate) |
37 | = 2, |
38 | }; |
39 | bool init(int mode, Flag flag); // for direct users of KGzipFilter |
40 | int mode() const override; |
41 | bool terminate() override; |
42 | void reset() override; |
43 | bool () override; // this is about the GZIP header |
44 | bool (const QByteArray &fileName) override; |
45 | void (); |
46 | void setOutBuffer(char *data, uint maxlen) override; |
47 | void setInBuffer(const char *data, uint size) override; |
48 | int inBufferAvailable() const override; |
49 | int outBufferAvailable() const override; |
50 | Result uncompress() override; |
51 | Result compress(bool finish) override; |
52 | |
53 | private: |
54 | Result uncompress_noop(); |
55 | class Private; |
56 | Private *const d; |
57 | }; |
58 | |
59 | #endif |
60 | |