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