William Lallemand | 82fe75c | 2012-10-23 10:25:10 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
Willy Tarreau | 418b8c0 | 2015-03-29 03:32:06 +0200 | [diff] [blame] | 26 | #if defined(USE_SLZ) |
| 27 | #include <slz.h> |
| 28 | #elif defined(USE_ZLIB) |
William Lallemand | 82fe75c | 2012-10-23 10:25:10 +0200 | [diff] [blame] | 29 | #include <zlib.h> |
Willy Tarreau | 418b8c0 | 2015-03-29 03:32:06 +0200 | [diff] [blame] | 30 | #endif |
William Lallemand | 08289f1 | 2012-10-31 11:19:18 +0100 | [diff] [blame] | 31 | |
William Lallemand | 82fe75c | 2012-10-23 10:25:10 +0200 | [diff] [blame] | 32 | struct comp { |
| 33 | struct comp_algo *algos; |
| 34 | struct comp_type *types; |
Willy Tarreau | 70737d1 | 2012-10-27 00:34:28 +0200 | [diff] [blame] | 35 | unsigned int offload; |
William Lallemand | 82fe75c | 2012-10-23 10:25:10 +0200 | [diff] [blame] | 36 | }; |
| 37 | |
William Lallemand | 1c2d622 | 2012-10-30 15:52:53 +0100 | [diff] [blame] | 38 | struct comp_ctx { |
Willy Tarreau | 418b8c0 | 2015-03-29 03:32:06 +0200 | [diff] [blame] | 39 | #if defined(USE_SLZ) |
| 40 | struct slz_stream strm; |
| 41 | const void *direct_ptr; /* NULL or pointer to beginning of data */ |
| 42 | int direct_len; /* length of direct_ptr if not NULL */ |
| 43 | struct buffer *queued; /* if not NULL, data already queued */ |
| 44 | #elif defined(USE_ZLIB) |
William Lallemand | 1c2d622 | 2012-10-30 15:52:53 +0100 | [diff] [blame] | 45 | z_stream strm; /* zlib stream */ |
William Lallemand | 2b50247 | 2012-10-30 14:30:39 +0100 | [diff] [blame] | 46 | void *zlib_deflate_state; |
| 47 | void *zlib_window; |
| 48 | void *zlib_prev; |
| 49 | void *zlib_pending_buf; |
| 50 | void *zlib_head; |
Willy Tarreau | 418b8c0 | 2015-03-29 03:32:06 +0200 | [diff] [blame] | 51 | #endif |
William Lallemand | f374783 | 2012-11-09 12:33:10 +0100 | [diff] [blame] | 52 | int cur_lvl; |
William Lallemand | 1c2d622 | 2012-10-30 15:52:53 +0100 | [diff] [blame] | 53 | }; |
| 54 | |
Willy Tarreau | 615105e | 2015-03-28 16:40:46 +0100 | [diff] [blame] | 55 | /* Thanks to MSIE/IIS, the "deflate" name is ambigous, as according to the RFC |
| 56 | * it's a zlib-wrapped deflate stream, but MSIE only understands a raw deflate |
| 57 | * stream. For this reason some people prefer to emit a raw deflate stream on |
| 58 | * "deflate" and we'll need two algos for the same name, they are distinguished |
| 59 | * with the config name. |
| 60 | */ |
William Lallemand | 82fe75c | 2012-10-23 10:25:10 +0200 | [diff] [blame] | 61 | struct comp_algo { |
Willy Tarreau | 615105e | 2015-03-28 16:40:46 +0100 | [diff] [blame] | 62 | char *cfg_name; /* config name */ |
| 63 | int cfg_name_len; |
| 64 | |
| 65 | char *ua_name; /* name for the user-agent */ |
| 66 | int ua_name_len; |
| 67 | |
William Lallemand | 8b52bb3 | 2012-11-16 18:06:41 +0100 | [diff] [blame] | 68 | int (*init)(struct comp_ctx **comp_ctx, int level); |
William Lallemand | bf3ae61 | 2012-11-19 12:35:37 +0100 | [diff] [blame] | 69 | int (*add_data)(struct comp_ctx *comp_ctx, const char *in_data, int in_len, struct buffer *out); |
Willy Tarreau | 9787efa | 2015-03-28 19:17:31 +0100 | [diff] [blame] | 70 | int (*flush)(struct comp_ctx *comp_ctx, struct buffer *out); |
| 71 | int (*finish)(struct comp_ctx *comp_ctx, struct buffer *out); |
William Lallemand | 8b52bb3 | 2012-11-16 18:06:41 +0100 | [diff] [blame] | 72 | int (*end)(struct comp_ctx **comp_ctx); |
William Lallemand | 82fe75c | 2012-10-23 10:25:10 +0200 | [diff] [blame] | 73 | struct comp_algo *next; |
| 74 | }; |
| 75 | |
William Lallemand | 82fe75c | 2012-10-23 10:25:10 +0200 | [diff] [blame] | 76 | struct comp_type { |
| 77 | char *name; |
| 78 | int name_len; |
| 79 | struct comp_type *next; |
| 80 | }; |
| 81 | |
| 82 | |
| 83 | #endif /* _TYPES_COMP_H */ |
| 84 | |
| 85 | /* |
| 86 | * Local variables: |
| 87 | * c-indent-level: 8 |
| 88 | * c-basic-offset: 8 |
| 89 | * End: |
| 90 | */ |
| 91 | |