45 #define ZIP_OUT_BUF 8192
46 #define ZIP_IN_BLOCK 8192
58 z_alloc(
void *priv,
unsigned n_items,
unsigned item_len)
60 return palloc(n_items * item_len);
64 z_free(
void *priv,
void *addr)
84 st->buf_len = ZIP_OUT_BUF;
85 st->stream.zalloc = z_alloc;
86 st->stream.zfree = z_free;
90 Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
111 struct ZipStat *st = priv;
116 st->stream.next_in =
data;
117 st->stream.avail_in =
len;
118 while (st->stream.avail_in > 0)
120 st->stream.next_out = st->buf;
121 st->stream.avail_out = st->buf_len;
122 res = deflate(&st->stream, Z_NO_FLUSH);
126 n_out = st->buf_len - st->stream.avail_out;
144 struct ZipStat *st = priv;
146 st->stream.next_in = NULL;
147 st->stream.avail_in = 0;
150 st->stream.next_out = st->buf;
151 st->stream.avail_out = st->buf_len;
152 zres = deflate(&st->stream, Z_FINISH);
153 if (zres != Z_STREAM_END && zres != Z_OK)
156 n_out = st->buf_len - st->stream.avail_out;
163 if (zres == Z_STREAM_END)
170 compress_free(
void *priv)
172 struct ZipStat *st = priv;
174 deflateEnd(&st->stream);
181 compress_init, compress_process, compress_flush, compress_free
207 struct DecomprData *dec;
215 dec->buf_len = ZIP_OUT_BUF;
218 dec->stream.zalloc = z_alloc;
219 dec->stream.zfree = z_free;
222 res = inflateInit2(&dec->stream, -15);
224 res = inflateInit(&dec->stream);
228 px_debug(
"decompress_init: inflateInit error");
241 struct DecomprData *dec = priv;
244 if (dec->buf_data > 0)
246 if (
len > dec->buf_data)
250 dec->buf_data -=
len;
257 if (dec->stream.avail_in == 0)
264 dec->stream.next_in = tmp;
265 dec->stream.avail_in =
res;
268 dec->stream.next_out = dec->buf;
269 dec->stream.avail_out = dec->buf_len;
277 flush = dec->stream.avail_in ? Z_SYNC_FLUSH : Z_FINISH;
278 res = inflate(&dec->stream, flush);
279 if (
res != Z_OK &&
res != Z_STREAM_END)
281 px_debug(
"decompress_read: inflate error: %d",
res);
285 dec->buf_data = dec->buf_len - dec->stream.avail_out;
286 if (
res == Z_STREAM_END)
304 px_debug(
"decompress_read: extra bytes after end of stream");
313 decompress_free(
void *priv)
315 struct DecomprData *dec = priv;
317 inflateEnd(&dec->stream);
323 decompress_filter = {
324 decompress_init, decompress_read, decompress_free
static void PGresult * res
int pullf_create(PullFilter **pf_p, const PullFilterOps *op, void *init_arg, PullFilter *src)
int pushf_write(PushFilter *mp, const uint8 *data, int len)
int pushf_create(PushFilter **mp_p, const PushFilterOps *op, void *init_arg, PushFilter *next)
int pullf_read(PullFilter *pf, int len, uint8 **data_p)
void pfree(void *pointer)
void * palloc0(Size size)
int pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst)
int pgp_decompress_filter(PullFilter **res, PGP_Context *ctx, PullFilter *src)
void px_debug(const char *fmt,...)
void px_memset(void *ptr, int c, size_t len)
#define PXE_PGP_UNSUPPORTED_COMPR
#define PXE_PGP_COMPRESSION_ERROR
#define PXE_PGP_CORRUPT_DATA