mirror of https://github.com/AxioDL/lzokay.git
Merge pull request #3 from robUx4/c-wrapper
Add a C wrapper for decompression
This commit is contained in:
commit
546a969527
|
@ -54,3 +54,5 @@ install(
|
||||||
FILES "${config_file}" "${version_config_file}"
|
FILES "${config_file}" "${version_config_file}"
|
||||||
DESTINATION ${config_install_dir}
|
DESTINATION ${config_install_dir}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_subdirectory("lzokay-c")
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
project(lzokay-c VERSION 0.1 LANGUAGES C CXX)
|
||||||
|
|
||||||
|
add_library(lzokay-c lzokay-c.cpp lzokay-c.h)
|
||||||
|
target_link_libraries(lzokay-c PRIVATE lzokay)
|
||||||
|
set_target_properties(lzokay-c PROPERTIES CXX_STANDARD 14)
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include "lzokay-c.h"
|
||||||
|
#include "../lzokay.hpp"
|
||||||
|
|
||||||
|
static_assert(EResult_LookbehindOverrun == lzokay_EResult(lzokay::EResult::LookbehindOverrun), "LookbehindOverrun mismatch");
|
||||||
|
static_assert(EResult_OutputOverrun == lzokay_EResult(lzokay::EResult::OutputOverrun), "OutputOverrun mismatch");
|
||||||
|
static_assert(EResult_InputOverrun == lzokay_EResult(lzokay::EResult::InputOverrun), "InputOverrun mismatch");
|
||||||
|
static_assert(EResult_Error == lzokay_EResult(lzokay::EResult::Error), "Error mismatch");
|
||||||
|
static_assert(EResult_Success == lzokay_EResult(lzokay::EResult::Success), "Success mismatch");
|
||||||
|
static_assert(EResult_InputNotConsumed == lzokay_EResult(lzokay::EResult::InputNotConsumed), "InputNotConsumed mismatch");
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
lzokay_EResult lzokay_decompress(const uint8_t * src, size_t src_size,
|
||||||
|
uint8_t *output, size_t *output_len)
|
||||||
|
{
|
||||||
|
size_t needed_size = 0;
|
||||||
|
lzokay::EResult error =
|
||||||
|
lzokay::decompress(src, src_size, output, *output_len, needed_size);
|
||||||
|
*output_len = needed_size;
|
||||||
|
return lzokay_EResult(error);
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef LZOKAY_C_INCLUDED
|
||||||
|
#define LZOKAY_C_INCLUDED
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
EResult_LookbehindOverrun = -4,
|
||||||
|
EResult_OutputOverrun = -3,
|
||||||
|
EResult_InputOverrun = -2,
|
||||||
|
EResult_Error = -1,
|
||||||
|
EResult_Success = 0,
|
||||||
|
EResult_InputNotConsumed = 1,
|
||||||
|
} lzokay_EResult;
|
||||||
|
|
||||||
|
lzokay_EResult lzokay_decompress(const uint8_t * src, size_t src_size,
|
||||||
|
uint8_t *output, size_t *output_len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // LZOKAY_C_INCLUDED
|
Loading…
Reference in New Issue