blob: 92b033e889f7f8afabeafe7108a1341a610ed832 [file] [log] [blame]
Fairphone ODM25c12f52023-12-15 17:24:06 +08001/* compression_utils_portable.h
2 *
3 * Copyright 2019 The Chromium Authors
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
22namespace zlib_internal {
23
24enum WrapperType {
25 ZLIB,
26 GZIP,
27 ZRAW,
28};
29
30uLongf GzipExpectedCompressedSize(uLongf input_size);
31
32uint32_t GetGzipUncompressedSize(const Bytef* compressed_data, size_t length);
33
34int 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
41int 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
50int GzipUncompressHelper(Bytef* dest,
51 uLongf* dest_length,
52 const Bytef* source,
53 uLong source_length);
54
55int 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_