Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | * 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 Quintas | ca28137 | 2015-06-08 20:07:39 -0700 | [diff] [blame] | 34 | #ifndef GRPC_COMPRESSION_H |
| 35 | #define GRPC_COMPRESSION_H |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 36 | |
Craig Tiller | 5e01e2a | 2017-01-20 18:11:52 -0800 | [diff] [blame] | 37 | #include <grpc/impl/codegen/port_platform.h> |
| 38 | |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 39 | #include <stdlib.h> |
| 40 | |
David Garcia Quintas | 8c5424f | 2016-08-01 22:49:00 -0700 | [diff] [blame] | 41 | #include <grpc/impl/codegen/compression_types.h> |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 42 | #include <grpc/slice.h> |
David Garcia Quintas | 8c5424f | 2016-08-01 22:49:00 -0700 | [diff] [blame] | 43 | |
David Garcia Quintas | d7d9ce2 | 2015-06-30 23:29:03 -0700 | [diff] [blame] | 44 | #ifdef __cplusplus |
| 45 | extern "C" { |
| 46 | #endif |
| 47 | |
David Garcia Quintas | 1c604fd | 2015-07-21 16:22:58 -0700 | [diff] [blame] | 48 | /** Parses the first \a name_length bytes of \a name as a |
| 49 | * grpc_compression_algorithm instance, updating \a algorithm. Returns 1 upon |
| 50 | * success, 0 otherwise. */ |
Nicolas "Pixel" Noble | cd41a0b | 2016-02-08 22:53:14 +0100 | [diff] [blame] | 51 | GRPCAPI int grpc_compression_algorithm_parse( |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 52 | grpc_slice value, grpc_compression_algorithm *algorithm); |
David Garcia Quintas | fc0fa33 | 2015-06-25 18:11:07 -0700 | [diff] [blame] | 53 | |
| 54 | /** Updates \a name with the encoding name corresponding to a valid \a |
David Garcia Quintas | 73dcbda | 2016-04-23 00:17:05 -0700 | [diff] [blame] | 55 | * algorithm. Note that \a name is statically allocated and must *not* be freed. |
| 56 | * Returns 1 upon success, 0 otherwise. */ |
Nicolas "Pixel" Noble | cd41a0b | 2016-02-08 22:53:14 +0100 | [diff] [blame] | 57 | GRPCAPI int grpc_compression_algorithm_name( |
Craig Tiller | d6546c9 | 2016-01-29 07:59:35 -0800 | [diff] [blame] | 58 | grpc_compression_algorithm algorithm, char **name); |
David Garcia Quintas | fc0fa33 | 2015-06-25 18:11:07 -0700 | [diff] [blame] | 59 | |
David Garcia Quintas | 13c2f6e | 2016-03-17 22:51:52 -0700 | [diff] [blame] | 60 | /** Returns the compression algorithm corresponding to \a level for the |
| 61 | * compression algorithms encoded in the \a accepted_encodings bitset. |
David Garcia Quintas | fc0fa33 | 2015-06-25 18:11:07 -0700 | [diff] [blame] | 62 | * |
| 63 | * It abort()s for unknown levels . */ |
Craig Tiller | f40df23 | 2016-03-25 13:38:14 -0700 | [diff] [blame] | 64 | GRPCAPI grpc_compression_algorithm grpc_compression_algorithm_for_level( |
| 65 | grpc_compression_level level, uint32_t accepted_encodings); |
David Garcia Quintas | e29feb2 | 2015-06-15 18:08:13 -0700 | [diff] [blame] | 66 | |
Nicolas "Pixel" Noble | cd41a0b | 2016-02-08 22:53:14 +0100 | [diff] [blame] | 67 | GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts); |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 68 | |
| 69 | /** Mark \a algorithm as enabled in \a opts. */ |
Nicolas "Pixel" Noble | cd41a0b | 2016-02-08 22:53:14 +0100 | [diff] [blame] | 70 | GRPCAPI void grpc_compression_options_enable_algorithm( |
Craig Tiller | ddf3a51 | 2015-09-24 13:03:44 -0700 | [diff] [blame] | 71 | grpc_compression_options *opts, grpc_compression_algorithm algorithm); |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 72 | |
| 73 | /** Mark \a algorithm as disabled in \a opts. */ |
Nicolas "Pixel" Noble | cd41a0b | 2016-02-08 22:53:14 +0100 | [diff] [blame] | 74 | GRPCAPI void grpc_compression_options_disable_algorithm( |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 75 | grpc_compression_options *opts, grpc_compression_algorithm algorithm); |
| 76 | |
| 77 | /** Returns true if \a algorithm is marked as enabled in \a opts. */ |
Nicolas "Pixel" Noble | cd41a0b | 2016-02-08 22:53:14 +0100 | [diff] [blame] | 78 | GRPCAPI int grpc_compression_options_is_algorithm_enabled( |
David Garcia Quintas | a4c4f02 | 2015-08-21 00:05:42 -0700 | [diff] [blame] | 79 | const grpc_compression_options *opts, grpc_compression_algorithm algorithm); |
| 80 | |
David Garcia Quintas | d7d9ce2 | 2015-06-30 23:29:03 -0700 | [diff] [blame] | 81 | #ifdef __cplusplus |
| 82 | } |
| 83 | #endif |
| 84 | |
Craig Tiller | 9a57633 | 2015-06-17 10:21:49 -0700 | [diff] [blame] | 85 | #endif /* GRPC_COMPRESSION_H */ |