summaryrefslogtreecommitdiffstats
path: root/src/streams-gzip.h
blob: ace1b884d2b1738a394f68705602d3d98e65365c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * IO layer : gzip streambuf and streams
 *
 * Authors:
 *   Johan Ceuppens <jceuppen at easynet dot be>
 *
 * Copyright (C) 2004 Johan Ceuppens
 *
 * Released under GNU LGPL, read the file 'COPYING.LIB' for more information
 */

#ifndef __STREAMS_GZIP_H_
#define __STREAMS_GZIP_H_

#include "streams-zlib.h"

namespace Inkscape {

class GZipHeaderException : public ZlibBufferException
{
public:
    const char *what() const throw() { return "Invalid gzip file"; }
};

/**
 * GZipBuffer
 */

class GZipBuffer : public ZlibBuffer
{
public:
    
    GZipBuffer(URIHandle& urih) //throws GZipHeaderException
	: ZlibBuffer(urih)
    { consume_header(); } 
    ~GZipBuffer() {}
    
private:
    
    void consume_header() throw(GZipHeaderException);
    void check_signature(guint8 *data) throw(GZipHeaderException);
    void check_flags(guint8 *data) throw(GZipHeaderException);
    gchar *get_filename();
    gchar *get_comment();
    guint16 get_crc();
    void get_extrafield();
    gchar *read_string() throw(GZipHeaderException);
    
    GZipBuffer& operator=(GZipBuffer const& rhs);
    GZipBuffer(GZipBuffer const& rhs);

};

} // namespace Inkscape
#endif // header guard

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :