2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version three of the GNU Affero General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf <at> fsfeurope.org.
29 * Bacula zlib compression wrappers
39 * Deflate or compress and input buffer. You must supply an
40 * output buffer sufficiently long and the length of the
41 * output buffer. Generally, if the output buffer is the
42 * same size as the input buffer, it should work (at least
45 int Zdeflate(char *in, int in_len, char *out, int &out_len)
51 /* allocate deflate state */
55 ret = deflateInit(&strm, 9);
57 Dmsg0(200, "deflateInit error\n");
58 (void)deflateEnd(&strm);
62 strm.next_in = (Bytef *)in;
63 strm.avail_in = in_len;
64 Dmsg1(200, "In: %d bytes\n", strm.avail_in);
65 strm.avail_out = out_len;
66 strm.next_out = (Bytef *)out;
67 ret = deflate(&strm, Z_FINISH);
68 out_len = out_len - strm.avail_out;
69 Dmsg1(200, "compressed=%d\n", out_len);
70 (void)deflateEnd(&strm);
78 * Inflate or uncompress an input buffer. You must supply
79 * and output buffer and an output length sufficiently long
80 * or there will be an error. This uncompresses in one call.
82 int Zinflate(char *in, int in_len, char *out, int &out_len)
88 /* allocate deflate state */
92 strm.next_in = (Bytef *)in;
93 strm.avail_in = in_len;
94 ret = inflateInit(&strm);
96 Dmsg0(200, "inflateInit error\n");
97 (void)inflateEnd(&strm);
101 Dmsg1(200, "In len: %d bytes\n", strm.avail_in);
102 strm.avail_out = out_len;
103 strm.next_out = (Bytef *)out;
104 ret = inflate(&strm, Z_FINISH);
105 out_len -= strm.avail_out;
106 Dmsg1(200, "Uncompressed=%d\n", out_len);
107 (void)inflateEnd(&strm);