1 #ifndef __STREAMS_JAR_H_
2 #define __STREAMS_JAR_H_
4 #include "streams-zlib.h"
6 namespace Inkscape {
8 //#define DEBUG_STREAMS 1;
10 class JarHeaderException
11 {
12 public:
13 const char *what() const throw() { return "Invalid file header in jar"; }
14 };
16 /**
17 * JarBuffer
18 */
20 class JarBuffer : public ZlibBuffer
21 {
22 public:
24 JarBuffer(URIHandle& urih) //throws JarHeaderException
25 : ZlibBuffer(urih), compressed_size(0), compressed_left(0), method(0),
26 flags(0)
27 { consume_header(); }
28 virtual ~JarBuffer() {}
30 protected:
32 virtual void consume_header() throw(JarHeaderException);
33 virtual void check_signature(guint8 *data) throw(JarHeaderException);
34 virtual unsigned int get_compressed_size() const { return compressed_size; }
35 virtual unsigned int get_compressed_left() const { return compressed_left; }
36 virtual GByteArray *inflate(guint8 *data, int nbytes);
37 virtual int consume_and_inflate();
38 virtual void reset();
39 virtual bool is_compressed() const { return (method == 8 || flags & 0x0008);}
40 virtual int consume_compressed(int nbytes);
41 virtual int consume_uncompressed(int nbytes);
42 guint32 unpack_4bytes(guint8 *data, const int offset);
43 guint16 unpack_2bytes(guint8 *data, const int offset);
45 private:
47 JarBuffer& operator=(JarBuffer const& rhs);
48 JarBuffer(JarBuffer const& rhs);
50 guint32 compressed_size;
51 guint32 compressed_left;
52 guint16 method;
53 guint16 flags;
54 guint16 eflen;
55 };
57 } // namespace Inkscape
58 #endif // header guard
60 /*
61 Local Variables:
62 mode:c++
63 c-file-style:"stroustrup"
64 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
65 indent-tabs-mode:nil
66 fill-column:99
67 End:
68 */
69 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :