1 /* compression_utils_portable.h 2 * 3 * Copyright 2019 The Chromium Authors. All rights reserved. 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the Chromium source repository LICENSE file. 6 */ 7 #ifndef THIRD_PARTY_ZLIB_GOOGLE_COMPRESSION_UTILS_PORTABLE_H_ 8 #define THIRD_PARTY_ZLIB_GOOGLE_COMPRESSION_UTILS_PORTABLE_H_ 9 10 #include <stdint.h> 11 12 #if defined(USE_SYSTEM_ZLIB) 13 #include <zlib.h> 14 #else 15 #include "third_party/zlib/zlib.h" 16 #endif 17 18 namespace zlib_internal { 19 20 enum WrapperType { 21 ZLIB, 22 GZIP, 23 ZRAW, 24 }; 25 26 uLongf GzipExpectedCompressedSize(uLongf input_size); 27 28 uint32_t GetGzipUncompressedSize(const Bytef* compressed_data, size_t length); 29 30 int GzipCompressHelper(Bytef* dest, 31 uLongf* dest_length, 32 const Bytef* source, 33 uLong source_length, 34 void* (*malloc_fn)(size_t), 35 void (*free_fn)(void*)); 36 37 int CompressHelper(WrapperType wrapper_type, 38 Bytef* dest, 39 uLongf* dest_length, 40 const Bytef* source, 41 uLong source_length, 42 int compression_level, 43 void* (*malloc_fn)(size_t), 44 void (*free_fn)(void*)); 45 46 int GzipUncompressHelper(Bytef* dest, 47 uLongf* dest_length, 48 const Bytef* source, 49 uLong source_length); 50 51 int UncompressHelper(WrapperType wrapper_type, 52 Bytef* dest, 53 uLongf* dest_length, 54 const Bytef* source, 55 uLong source_length); 56 57 } // namespace zlib_internal 58 59 #endif // THIRD_PARTY_ZLIB_GOOGLE_COMPRESSION_UTILS_PORTABLE_H_ 60