lz4-hs-0.1.2.0: src/Codec/Lz4/Foreign.chs
module Codec.Lz4.Foreign ( -- * Blocks
lZ4VersionNumber
, lZ4VersionString
, lZ4CompressDefault
, lZ4DecompressSafe
, lZ4CompressBound
-- * Frames
, lZ4FIsError
, lZ4FGetErrorName
, lZ4FGetVersion
, lZ4FCreateCompressionContext
, lZ4FFreeCompressionContext
, lZ4FHeaderSizeMax
, lZ4FCompressBegin
, lZ4FCompressBound
, lZ4FCompressUpdate
, lZ4FCompressEnd
, lZ4FCreateDecompressionContext
, lZ4FFreeDecompressionContext
, lZ4FDecompress
, lZ4MaxInputSize
, lZ4CompressHC
, lZ4HCClevelMax
-- * Types
, LZ4FErrorCode
, LzCtx
, LzCtxPtr
, LzDecompressionCtx
, LzDecompressionCtxPtr
) where
import Data.Coerce (coerce)
import Foreign.C.String (CString)
import Foreign.C.Types (CInt, CUInt, CSize (..))
import Foreign.Marshal.Alloc (alloca)
import Foreign.Ptr (castPtr, Ptr)
import Foreign.Storable (peek)
#include <lz4.h>
#include <lz4frame.h>
#include <lz4hc.h>
{# fun pure LZ4_versionNumber as ^ {} -> `CInt' #}
-- | @since 0.1.1.0
{# fun pure LZ4_versionString as ^ {} -> `String' #}
{# fun LZ4_compress_default as ^ { `CString', `CString', `CInt' , `CInt' } -> `CInt' #}
{# fun LZ4_decompress_safe as ^ { `CString', `CString', `CInt' , `CInt' } -> `CInt' #}
{# fun pure LZ4_compressBound as ^ { `CInt' } -> `CInt' #}
type LZ4FErrorCode = CSize -- {# type LZ4F_errorCode_t #}
{# typedef LZ4F_errorCode_t LZ4FErrorCode #}
{# fun pure LZ4F_isError as ^ { `LZ4FErrorCode' } -> `Bool' #}
{# fun pure LZ4F_getErrorName as ^ { `LZ4FErrorCode' } -> `String' #}
{# fun pure LZ4F_getVersion as ^ {} -> `CUInt' #}
data LzCtx
{# pointer *LZ4F_cctx as LzCtxPtr foreign finalizer LZ4F_freeCompressionContext as ^ -> LzCtx #}
{# fun LZ4F_createCompressionContext as ^ { alloca- `Ptr LzCtx' peek*, `CUInt' } -> `LZ4FErrorCode' #}
data LzPreferences
{# pointer *LZ4F_preferences_t as LzPreferencesPtr -> LzPreferences #}
lZ4FHeaderSizeMax :: Integral a => a
lZ4FHeaderSizeMax = {# const LZ4F_HEADER_SIZE_MAX #}
{# fun LZ4F_compressBegin as ^ { `LzCtxPtr', castPtr `Ptr a', coerce `CSize', `LzPreferencesPtr' } -> `CSize' coerce #}
{# fun pure LZ4F_compressBound as ^ { coerce `CSize', `LzPreferencesPtr' } -> `CSize' coerce #}
data LzCompressOptions
{# pointer *LZ4F_compressOptions_t as LzCompressOptionsPtr -> LzCompressOptions #}
{# fun LZ4F_compressUpdate as ^
{ `LzCtxPtr'
, castPtr `Ptr a'
, coerce `CSize'
, castPtr `Ptr b'
, coerce `CSize'
, `LzCompressOptionsPtr'
} -> `CSize' coerce
#}
{# fun LZ4F_compressEnd as ^
{ `LzCtxPtr', castPtr `Ptr a', coerce `CSize', `LzCompressOptionsPtr' } -> `CSize' coerce #}
data LzDecompressionCtx
{# pointer *LZ4F_dctx as LzDecompressionCtxPtr foreign finalizer LZ4F_freeDecompressionContext as ^ -> LzDecompressionCtx #}
{# fun LZ4F_createDecompressionContext as ^ { alloca- `Ptr LzDecompressionCtx' peek*, `CUInt' } -> `LZ4FErrorCode' #}
data LzDecompressOptions
{# pointer *LZ4F_decompressOptions_t as LzDecompressOptionsPtr -> LzDecompressOptions #}
{# fun LZ4F_decompress as ^
{ `LzDecompressionCtxPtr'
, castPtr `Ptr a'
, castPtr `Ptr CSize'
, castPtr `Ptr b'
, castPtr `Ptr CSize'
, `LzDecompressOptionsPtr'
} -> `CSize' coerce
#}
-- | @since 0.1.1.0
lZ4MaxInputSize :: Integral a => a
lZ4MaxInputSize = {# const LZ4_MAX_INPUT_SIZE #}
{# fun LZ4_compress_HC as ^
{ `CString', `CString', `CInt', `CInt', `CInt' } -> `CInt' #}
-- | @since 0.1.1.0
lZ4HCClevelMax :: Integral a => a
lZ4HCClevelMax = {# const LZ4HC_CLEVEL_MAX #}