blob: 8de4b133d4c9fee2e6488625989b849609eab8f1 [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Craig Tiller6169d5f2016-03-31 07:46:18 -07003 * Copyright 2015, Google Inc.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
David Garcia Quintasca281372015-06-08 20:07:39 -070034#ifndef GRPC_COMPRESSION_H
35#define GRPC_COMPRESSION_H
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080036
David Garcia Quintas1c604fd2015-07-21 16:22:58 -070037#include <stdlib.h>
38
David Garcia Quintas2425bbb2016-01-25 17:32:48 -080039#include <grpc/impl/codegen/compression_types.h>
Craig Tillerf40df232016-03-25 13:38:14 -070040#include <grpc/impl/codegen/port_platform.h>
David Garcia Quintasa4c4f022015-08-21 00:05:42 -070041
David Garcia Quintasd7d9ce22015-06-30 23:29:03 -070042#ifdef __cplusplus
43extern "C" {
44#endif
45
David Garcia Quintas1c604fd2015-07-21 16:22:58 -070046/** Parses the first \a name_length bytes of \a name as a
47 * grpc_compression_algorithm instance, updating \a algorithm. Returns 1 upon
48 * success, 0 otherwise. */
Nicolas "Pixel" Noblecd41a0b2016-02-08 22:53:14 +010049GRPCAPI int grpc_compression_algorithm_parse(
Craig Tillerd6546c92016-01-29 07:59:35 -080050 const char *name, size_t name_length,
51 grpc_compression_algorithm *algorithm);
David Garcia Quintasfc0fa332015-06-25 18:11:07 -070052
53/** Updates \a name with the encoding name corresponding to a valid \a
David Garcia Quintasa4c4f022015-08-21 00:05:42 -070054 * algorithm. Returns 1 upon success, 0 otherwise. */
Nicolas "Pixel" Noblecd41a0b2016-02-08 22:53:14 +010055GRPCAPI int grpc_compression_algorithm_name(
Craig Tillerd6546c92016-01-29 07:59:35 -080056 grpc_compression_algorithm algorithm, char **name);
David Garcia Quintasfc0fa332015-06-25 18:11:07 -070057
David Garcia Quintas13c2f6e2016-03-17 22:51:52 -070058/** Returns the compression algorithm corresponding to \a level for the
59 * compression algorithms encoded in the \a accepted_encodings bitset.
David Garcia Quintasfc0fa332015-06-25 18:11:07 -070060 *
61 * It abort()s for unknown levels . */
Craig Tillerf40df232016-03-25 13:38:14 -070062GRPCAPI grpc_compression_algorithm grpc_compression_algorithm_for_level(
63 grpc_compression_level level, uint32_t accepted_encodings);
David Garcia Quintase29feb22015-06-15 18:08:13 -070064
Nicolas "Pixel" Noblecd41a0b2016-02-08 22:53:14 +010065GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts);
David Garcia Quintasa4c4f022015-08-21 00:05:42 -070066
67/** Mark \a algorithm as enabled in \a opts. */
Nicolas "Pixel" Noblecd41a0b2016-02-08 22:53:14 +010068GRPCAPI void grpc_compression_options_enable_algorithm(
Craig Tillerddf3a512015-09-24 13:03:44 -070069 grpc_compression_options *opts, grpc_compression_algorithm algorithm);
David Garcia Quintasa4c4f022015-08-21 00:05:42 -070070
71/** Mark \a algorithm as disabled in \a opts. */
Nicolas "Pixel" Noblecd41a0b2016-02-08 22:53:14 +010072GRPCAPI void grpc_compression_options_disable_algorithm(
David Garcia Quintasa4c4f022015-08-21 00:05:42 -070073 grpc_compression_options *opts, grpc_compression_algorithm algorithm);
74
75/** Returns true if \a algorithm is marked as enabled in \a opts. */
Nicolas "Pixel" Noblecd41a0b2016-02-08 22:53:14 +010076GRPCAPI int grpc_compression_options_is_algorithm_enabled(
David Garcia Quintasa4c4f022015-08-21 00:05:42 -070077 const grpc_compression_options *opts, grpc_compression_algorithm algorithm);
78
David Garcia Quintasd7d9ce22015-06-30 23:29:03 -070079#ifdef __cplusplus
80}
81#endif
82
Craig Tiller9a576332015-06-17 10:21:49 -070083#endif /* GRPC_COMPRESSION_H */