compression.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. *
  3. * Copyright 2015 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #ifndef GRPC_COMPRESSION_H
  19. #define GRPC_COMPRESSION_H
  20. #include <grpc/impl/codegen/port_platform.h>
  21. #include <stdlib.h>
  22. #include <grpc/impl/codegen/compression_types.h>
  23. #include <grpc/slice.h>
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /** Return if an algorithm is message compression algorithm. */
  28. GRPCAPI int grpc_compression_algorithm_is_message(
  29. grpc_compression_algorithm algorithm);
  30. /** Return if an algorithm is stream compression algorithm. */
  31. GRPCAPI int grpc_compression_algorithm_is_stream(
  32. grpc_compression_algorithm algorithm);
  33. /** Parses the \a slice as a grpc_compression_algorithm instance and updating \a
  34. * algorithm. Returns 1 upon success, 0 otherwise. */
  35. GRPCAPI int grpc_compression_algorithm_parse(
  36. grpc_slice value, grpc_compression_algorithm *algorithm);
  37. /** Updates \a name with the encoding name corresponding to a valid \a
  38. * algorithm. Note that \a name is statically allocated and must *not* be freed.
  39. * Returns 1 upon success, 0 otherwise. */
  40. GRPCAPI int grpc_compression_algorithm_name(
  41. grpc_compression_algorithm algorithm, const char **name);
  42. /** Returns the compression algorithm corresponding to \a level for the
  43. * compression algorithms encoded in the \a accepted_encodings bitset.
  44. *
  45. * It abort()s for unknown levels. */
  46. GRPCAPI grpc_compression_algorithm grpc_compression_algorithm_for_level(
  47. grpc_compression_level level, uint32_t accepted_encodings);
  48. GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts);
  49. /** Mark \a algorithm as enabled in \a opts. */
  50. GRPCAPI void grpc_compression_options_enable_algorithm(
  51. grpc_compression_options *opts, grpc_compression_algorithm algorithm);
  52. /** Mark \a algorithm as disabled in \a opts. */
  53. GRPCAPI void grpc_compression_options_disable_algorithm(
  54. grpc_compression_options *opts, grpc_compression_algorithm algorithm);
  55. /** Returns true if \a algorithm is marked as enabled in \a opts. */
  56. GRPCAPI int grpc_compression_options_is_algorithm_enabled(
  57. const grpc_compression_options *opts, grpc_compression_algorithm algorithm);
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif /* GRPC_COMPRESSION_H */