1/* Copyright 2013 Google Inc. All Rights Reserved.
2
3   Licensed under the Apache License, Version 2.0 (the "License");
4   you may not use this file except in compliance with the License.
5   You may obtain a copy of the License at
6
7   http://www.apache.org/licenses/LICENSE-2.0
8
9   Unless required by applicable law or agreed to in writing, software
10   distributed under the License is distributed on an "AS IS" BASIS,
11   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   See the License for the specific language governing permissions and
13   limitations under the License.
14
15   API for Brotli decompression
16*/
17
18#ifndef BROTLI_DEC_DECODE_H_
19#define BROTLI_DEC_DECODE_H_
20
21#include "./streams.h"
22#include "./types.h"
23
24#if defined(__cplusplus) || defined(c_plusplus)
25extern "C" {
26#endif
27
28/* Sets *decoded_size to the decompressed size of the given encoded stream. */
29/* This function only works if the encoded buffer has a single meta block, */
30/* and this meta block must have the "is last" bit set. */
31/* Returns 1 on success, 0 on failure. */
32int BrotliDecompressedSize(size_t encoded_size,
33                           const uint8_t* encoded_buffer,
34                           size_t* decoded_size);
35
36/* Decompresses the data in encoded_buffer into decoded_buffer, and sets */
37/* *decoded_size to the decompressed length. */
38/* Returns 0 if there was either a bit stream error or memory allocation */
39/* error, and 1 otherwise. */
40/* If decoded size is zero, returns 1 and keeps decoded_buffer unchanged. */
41int BrotliDecompressBuffer(size_t encoded_size,
42                           const uint8_t* encoded_buffer,
43                           size_t* decoded_size,
44                           uint8_t* decoded_buffer);
45
46/* Same as above, but uses the specified input and output callbacks instead */
47/* of reading from and writing to pre-allocated memory buffers. */
48int BrotliDecompress(BrotliInput input, BrotliOutput output);
49
50#if defined(__cplusplus) || defined(c_plusplus)
51}    /* extern "C" */
52#endif
53
54#endif  /* BROTLI_DEC_DECODE_H_ */
55