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 /* TODO(cavalcantii): remove support for Chromium ever building with a system 13 * zlib. 14 */ 15 #if defined(USE_SYSTEM_ZLIB) 16 #include <zlib.h> 17 /* AOSP build requires relative paths. */ 18 #else 19 #include "zlib.h" 20 #endif 21 22 namespace zlib_internal { 23 24 enum WrapperType { 25 ZLIB, 26 GZIP, 27 ZRAW, 28 }; 29 30 uLongf GzipExpectedCompressedSize(uLongf input_size); 31 32 uint32_t GetGzipUncompressedSize(const Bytef* compressed_data, size_t length); 33 34 int GzipCompressHelper(Bytef* dest, 35 uLongf* dest_length, 36 const Bytef* source, 37 uLong source_length, 38 void* (*malloc_fn)(size_t), 39 void (*free_fn)(void*)); 40 41 int CompressHelper(WrapperType wrapper_type, 42 Bytef* dest, 43 uLongf* dest_length, 44 const Bytef* source, 45 uLong source_length, 46 int compression_level, 47 void* (*malloc_fn)(size_t), 48 void (*free_fn)(void*)); 49 50 int GzipUncompressHelper(Bytef* dest, 51 uLongf* dest_length, 52 const Bytef* source, 53 uLong source_length); 54 55 int UncompressHelper(WrapperType wrapper_type, 56 Bytef* dest, 57 uLongf* dest_length, 58 const Bytef* source, 59 uLong source_length); 60 61 } // namespace zlib_internal 62 63 #endif // THIRD_PARTY_ZLIB_GOOGLE_COMPRESSION_UTILS_PORTABLE_H_ 64