@@ -21,30 +21,30 @@ namespace boost {
2121namespace http_proto {
2222namespace zlib {
2323
24- struct stream_t
24+ struct stream
2525{
2626 using alloc_func = void *(*)(void *, unsigned int , unsigned int );
2727 using free_func = void (*)(void *, void *);
2828
29- unsigned char * next_in; // next input byte
30- unsigned int avail_in; // number of bytes available at next_in
31- unsigned long total_in; // total number of input bytes read so far
29+ unsigned char const * next_in; // next input byte
30+ unsigned int avail_in; // number of bytes available at next_in
31+ unsigned long total_in; // total number of input bytes read so far
3232
33- unsigned char * next_out; // next output byte will go here
34- unsigned int avail_out; // remaining free space at next_out
35- unsigned long total_out; // total number of bytes output so far
33+ unsigned char * next_out; // next output byte will go here
34+ unsigned int avail_out; // remaining free space at next_out
35+ unsigned long total_out; // total number of bytes output so far
3636
37- char const * msg; // last error message, NULL if no error
38- void * state; // not visible by applications
37+ char const * msg; // last error message, NULL if no error
38+ void * state; // not visible by applications
3939
40- alloc_func zalloc; // used to allocate internal state
41- free_func zfree; // used to deallocate internal state
42- void * opaque; // private data object passed to zalloc and zfree
40+ alloc_func zalloc; // used to allocate internal state
41+ free_func zfree; // used to deallocate internal state
42+ void * opaque; // private data object passed to zalloc and zfree
4343
44- int data_type; // best guess about the data type: binary or text
44+ int data_type; // best guess about the data type: binary or text
4545 // for deflate, or the decoding state for inflate
46- unsigned long adler; // Adler-32 or CRC-32 value of the uncompressed data
47- unsigned long reserved; // reserved for future use
46+ unsigned long adler; // Adler-32 or CRC-32 value of the uncompressed data
47+ unsigned long reserved; // reserved for future use
4848};
4949
5050/* * Error codes returned from compression/decompression functions.
@@ -65,140 +65,51 @@ enum class error
6565 version_err = -6
6666};
6767
68- // / Flush methods.
69- enum class flush
68+ // / Flush methods
69+ enum flush
7070{
71- none ,
72- partial ,
73- sync ,
74- full ,
75- finish,
76- block,
77- trees
71+ no_flush = 0 ,
72+ partial_flush = 1 ,
73+ sync_flush = 2 ,
74+ full_flush = 3 ,
75+ finish = 4 ,
76+ block = 5 ,
77+ trees = 6
7878};
7979
80- /* * Input and output buffers.
81-
82- The application must update `next_in` and `avail_in` when `avail_in`
83- has dropped to zero. It must update `next_out` and `avail_out` when
84- `avail_out` has dropped to zero.
85- */
86- struct params
80+ // / Compression levels
81+ enum compression_level
8782{
88- // / Next input byte
89- void const * next_in;
90-
91- // / Number of bytes available at `next_in`
92- std::size_t avail_in;
93-
94- // / Next output byte
95- void * next_out;
96-
97- // / Number of bytes remaining free at `next_out`
98- std::size_t avail_out;
83+ default_compression = -1 ,
84+ no_compression = 0 ,
85+ best_speed = 1 ,
86+ best_compression = 9
9987};
10088
101- // / Abstract interface for deflator/inflator streams.
102- struct stream
89+ // / Compression strategy
90+ enum compression_strategy
10391{
104- /* * Call the underling compression/decompression algorithm.
105-
106- @param p The input and output buffers.
107-
108- @param f The flush method.
109-
110- @return The result of operation that contains a value
111- of @ref error.
112- */
113- virtual system::error_code
114- write (params& p, flush f) noexcept = 0 ;
92+ default_strategy = 0 ,
93+ filtered = 1 ,
94+ huffman_only = 2 ,
95+ rle = 3 ,
96+ fixed = 4
11597};
11698
117- /* * Provides in-memory compression and decompression functions
118- using zlib underneath.
119- */
120- struct BOOST_SYMBOL_VISIBLE
121- service
122- : http_proto::service
99+ // / Possible values of the data_type field for deflate
100+ enum data_type
123101{
124- /* * The memory requirements for deflator.
125-
126- @param window_bits The window size.
127-
128- @param mem_level The memory level.
129-
130- @return The memory requirements in bytes.
131- */
132- virtual
133- std::size_t
134- deflator_space_needed (
135- int window_bits,
136- int mem_level) const noexcept = 0 ;
137-
138- /* * The memory requirements for inflator.
139-
140- @param window_bits The window size.
141-
142- @return The memory requirements in bytes.
143- */
144- virtual
145- std::size_t
146- inflator_space_needed (
147- int window_bits) const noexcept = 0 ;
148-
149- /* * Create a deflator stream by calling zlib `deflateInit2()`.
150-
151- @param ws A reference to the workspace used for constructing the
152- deflator stream object and for storage used by zlib.
153-
154- @param level The compression level.
155-
156- @param window_bits The window size.
157-
158- @param mem_level Specifies how much memory should be allocated
159- for the internal compression state.
160-
161- @return A reference to the created deflator stream.
162-
163- @throws std::length_error If there is insufficient free space in
164- @ref `http_proto::detail::workspace`.
165- */
166- virtual stream&
167- make_deflator (
168- http_proto::detail::workspace& ws,
169- int level,
170- int window_bits,
171- int mem_level) const = 0 ;
172-
173- /* * Create an inflator stream by calling zlib `inflateInit2()`.
174-
175- @param ws A reference to the workspace used for constructing the
176- inflator stream object and for storage used by zlib.
177-
178- @param window_bits The window size.
179-
180- @return A reference to the created inflator stream.
181-
182- @throws std::length_error If there is insufficient free space in
183- @ref `http_proto::detail::workspace`.
184- */
185- virtual stream&
186- make_inflator (
187- http_proto::detail::workspace& ws,
188- int window_bits) const = 0 ;
102+ binary = 0 ,
103+ text = 1 ,
104+ ascii = 1 ,
105+ unknown = 2
189106};
190107
191- /* * Installs a zlib service on the provided context.
192-
193- @param ctx A reference to the @ref context where the service
194- will be installed.
195-
196- @throw std::invalid_argument If the zlib service already
197- exist on the context.
198- */
199- BOOST_HTTP_PROTO_ZLIB_DECL
200- void
201- install_service (context& ctx);
108+ // / Compression method
109+ enum compression_method
110+ {
111+ deflated = 8
112+ };
202113
203114} // zlib
204115} // http_proto
0 commit comments