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 19 #ifndef GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H 20 #define GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H 21 22 // utility function to split/merge slices together to help create test 23 // cases 24 25 #include <stddef.h> 26 27 #include <grpc/slice.h> 28 29 typedef enum { 30 // merge all input slices into a single slice 31 GRPC_SLICE_SPLIT_MERGE_ALL, 32 // leave slices as is 33 GRPC_SLICE_SPLIT_IDENTITY, 34 // split slices into one byte chunks 35 GRPC_SLICE_SPLIT_ONE_BYTE 36 } grpc_slice_split_mode; 37 38 // allocates *dst_slices; caller must unref all slices in dst_slices then free 39 // it 40 void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices, 41 size_t src_slice_count, grpc_slice** dst_slices, 42 size_t* dst_slice_count); 43 44 void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, 45 grpc_slice* src_slices, size_t src_slice_count, 46 grpc_slice_buffer* dst); 47 void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src, 48 grpc_slice_buffer* dst); 49 50 grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices); 51 52 const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode); 53 54 #endif // GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H 55