monotone

monotone Mtn Source Tree

Root/gzip.hh

1/*************************************************
2* Gzip Compressor Header File *
3* (C) 1999-2004 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_EXT_GZIP_H__
7#define BOTAN_EXT_GZIP_H__
8
9#include <botan/filter.h>
10#include <botan/pipe.h>
11
12namespace Botan {
13
14namespace GZIP {
15
16 /* A basic header - we only need to set the IDs and compression method */
17 const byte GZIP_HEADER[] = {
18 0x1f, 0x8b, /* Magic ID bytes */
19 0x08, /* Compression method of 'deflate' */
20 0x00, /* Flags all empty */
21 0x00, 0x00, 0x00, 0x00, /* MTIME */
22 0x00, /* Extra flags */
23 0xff, /* Operating system (unknown) */
24 };
25
26 const unsigned int HEADER_POS_OS = 9;
27
28 const unsigned int FOOTER_LENGTH = 8;
29
30}
31
32/*************************************************
33* Gzip Compression Filter *
34*************************************************/
35class Gzip_Compression : public Filter
36 {
37 public:
38 void write(const byte input[], u32bit length);
39 void start_msg();
40 void end_msg();
41
42 Gzip_Compression(u32bit = 1);
43 ~Gzip_Compression();
44 private:
45 void clear();
46 void put_header();
47 void put_footer();
48 const u32bit level;
49 SecureVector<byte> buffer;
50 class Zlib_Stream* zlib;
51 Pipe pipe; /* A pipe for the crc32 processing */
52 u32bit count;
53 };
54
55/*************************************************
56* Gzip Decompression Filter *
57*************************************************/
58class Gzip_Decompression : public Filter
59 {
60 public:
61 void write(const byte input[], u32bit length);
62 void start_msg();
63 void end_msg();
64
65 Gzip_Decompression();
66 ~Gzip_Decompression();
67 private:
68 u32bit eat_footer(const byte input[], u32bit length);
69 void check_footer();
70 void clear();
71 SecureVector<byte> buffer;
72 class Zlib_Stream* zlib;
73 bool no_writes;
74 u32bit pos; /* Current position in the message */
75 Pipe pipe; /* A pipe for the crc32 processing */
76 u32bit datacount; /* Amount of uncompressed output */
77 SecureVector<byte> footer;
78 bool in_footer;
79 };
80
81}
82
83#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status