diff options
author | Robbie Shade <rjshade@google.com> | 2015-09-14 13:18:14 -0400 |
---|---|---|
committer | Robbie Shade <rjshade@google.com> | 2015-09-14 13:18:14 -0400 |
commit | f798b779fc35e0be603f07589f3f27efa316da7f (patch) | |
tree | 7c9e0b908218f6ed6207139c2065c6b78358fa5a /src/core/compression/algorithm.c | |
parent | 780b07e6442b06039a936382ce10fe0c4a30f4af (diff) | |
parent | 261666696496174f824d9e43a60559040eda3055 (diff) |
Merge remote-tracking branch 'upstream/master' into rename_callback
Diffstat (limited to 'src/core/compression/algorithm.c')
-rw-r--r-- | src/core/compression/algorithm.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/compression/algorithm.c b/src/core/compression/algorithm.c index 6ed6dbe93f..76d42fde0f 100644 --- a/src/core/compression/algorithm.c +++ b/src/core/compression/algorithm.c @@ -33,7 +33,9 @@ #include <stdlib.h> #include <string.h> + #include <grpc/compression.h> +#include <grpc/support/useful.h> int grpc_compression_algorithm_parse(const char *name, size_t name_length, grpc_compression_algorithm *algorithm) { @@ -102,3 +104,24 @@ grpc_compression_level grpc_compression_level_for_algorithm( } abort(); } + +void grpc_compression_options_init(grpc_compression_options *opts) { + opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT)-1; + opts->default_compression_algorithm = GRPC_COMPRESS_NONE; +} + +void grpc_compression_options_enable_algorithm( + grpc_compression_options *opts, grpc_compression_algorithm algorithm) { + GPR_BITSET(&opts->enabled_algorithms_bitset, algorithm); +} + +void grpc_compression_options_disable_algorithm( + grpc_compression_options *opts, grpc_compression_algorithm algorithm) { + GPR_BITCLEAR(&opts->enabled_algorithms_bitset, algorithm); +} + +int grpc_compression_options_is_algorithm_enabled( + const grpc_compression_options *opts, + grpc_compression_algorithm algorithm) { + return GPR_BITGET(opts->enabled_algorithms_bitset, algorithm); +} |