blob: e4b1f273d35e760c60f04b6928d722ba7fa88f1f [file] [log] [blame]
William Lallemand82fe75c2012-10-23 10:25:10 +02001/*
2 * include/types/compression.h
3 * This file defines everything related to compression.
4 *
5 * Copyright 2012 Exceliance, David Du Colombier <dducolombier@exceliance.fr>
6 William Lallemand <wlallemand@exceliance.fr>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation, version 2.1
11 * exclusively.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef _TYPES_COMP_H
24#define _TYPES_COMP_H
25
William Lallemand08289f12012-10-31 11:19:18 +010026#ifdef USE_ZLIB
27
William Lallemand82fe75c2012-10-23 10:25:10 +020028#include <zlib.h>
29
William Lallemand08289f12012-10-31 11:19:18 +010030#endif /* USE_ZLIB */
31
William Lallemand82fe75c2012-10-23 10:25:10 +020032struct comp {
33 struct comp_algo *algos;
34 struct comp_type *types;
Willy Tarreau70737d12012-10-27 00:34:28 +020035 unsigned int offload;
William Lallemand82fe75c2012-10-23 10:25:10 +020036};
37
William Lallemand1c2d6222012-10-30 15:52:53 +010038struct comp_ctx {
William Lallemand08289f12012-10-31 11:19:18 +010039#ifdef USE_ZLIB
William Lallemand1c2d6222012-10-30 15:52:53 +010040 z_stream strm; /* zlib stream */
William Lallemand2b502472012-10-30 14:30:39 +010041 void *zlib_deflate_state;
42 void *zlib_window;
43 void *zlib_prev;
44 void *zlib_pending_buf;
45 void *zlib_head;
William Lallemand08289f12012-10-31 11:19:18 +010046#endif /* USE_ZLIB */
William Lallemandf3747832012-11-09 12:33:10 +010047 int cur_lvl;
William Lallemand1c2d6222012-10-30 15:52:53 +010048};
49
William Lallemand82fe75c2012-10-23 10:25:10 +020050struct comp_algo {
51 char *name;
52 int name_len;
William Lallemand8b52bb32012-11-16 18:06:41 +010053 int (*init)(struct comp_ctx **comp_ctx, int level);
William Lallemandbf3ae612012-11-19 12:35:37 +010054 int (*add_data)(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out);
William Lallemand1c2d6222012-10-30 15:52:53 +010055 int (*flush)(struct comp_ctx *comp_ctx, struct buffer *out, int flag);
56 int (*reset)(struct comp_ctx *comp_ctx);
William Lallemand8b52bb32012-11-16 18:06:41 +010057 int (*end)(struct comp_ctx **comp_ctx);
William Lallemand82fe75c2012-10-23 10:25:10 +020058 struct comp_algo *next;
59};
60
William Lallemand82fe75c2012-10-23 10:25:10 +020061struct comp_type {
62 char *name;
63 int name_len;
64 struct comp_type *next;
65};
66
67
68#endif /* _TYPES_COMP_H */
69
70/*
71 * Local variables:
72 * c-indent-level: 8
73 * c-basic-offset: 8
74 * End:
75 */
76