slice_splitter.h 1.8 KB

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