blob: e0b3c36cf003b22d0079d5af2d2523db175f256e [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stdbool.h>
#include <stddef.h>
#include <zircon/compiler.h>
// Initializes decompression resources.
// Only one decompression can be running at a time, and decompress_stop() must
// be called when finished.
// Currently only supports LZ4 decompression but more formats may be added
// in the future.
// input: the compressed input.
// size: input size.
// Returns true on success.
bool decompress_start(const void* input, size_t size);
// Cleans up any open decompression resources.
// No-op if no decompression is currently running.
void decompress_stop(void);
// Decompression status codes. See decompress_next_chunk() for details.
// Decompresses the next input chunk.
// |output| is a static buffer so contents will change on the next call. The
// caller must handle or copy the decompressed data before then.
// output: filled with a pointer to the decompressed data.
// size: filled with the decompressed size.
// Returns:
// DECOMPRESS_FAILURE on error; |output| and |size| will be unchanged.
// DECOMPRESS_CONTINUE on success when there's more data to process.
// DECOMPRESS_FINISHED on success when all data has been decompressed.
decompress_result_t decompress_next_chunk(void** output, size_t* size);