]> gitweb.factorcode.org Git - factor.git/blob - basis/compression/zstd/ffi/ffi.factor
Fixes #2966
[factor.git] / basis / compression / zstd / ffi / ffi.factor
1 ! Copyright (C) 2021 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3
4 USING: alien alien.c-types alien.destructors alien.libraries
5 alien.syntax classes.struct combinators system ;
6
7 IN: compression.zstd.ffi
8
9 << "zstd" {
10     { [ os windows? ] [ "zstd-1.dll" ] }
11     { [ os macosx? ] [ "libzstd.dylib" ] }
12     { [ os unix? ] [ "libzstd.so" ] }
13 } cond cdecl add-library >>
14
15 LIBRARY: zstd
16
17 FUNCTION: uint ZSTD_versionNumber ( )
18
19 FUNCTION: c-string ZSTD_versionString ( )
20
21 ! Simple API
22
23 FUNCTION: size_t ZSTD_compress ( void* dst, size_t dstCapacity,
24                                  void* src, size_t srcSize,
25                                  int compressionLevel )
26
27 FUNCTION: size_t ZSTD_decompress ( void* dst, size_t dstCapacity,
28                                void* src, size_t compressedSize )
29
30 FUNCTION: ulonglong ZSTD_getFrameContentSize ( void *src, size_t srcSize )
31
32 FUNCTION: size_t ZSTD_findFrameContentSize ( void *src, size_t srcSize )
33
34 ! Helper functions
35
36 FUNCTION: size_t ZSTD_compressBounds ( size_t srcSize )
37
38 FUNCTION: uint ZSTD_isError ( size_t code )
39
40 FUNCTION: c-string ZSTD_getErrorName ( size_t code )
41
42 FUNCTION: int ZSTD_minCLevel ( )
43
44 FUNCTION: int ZSTD_maxCLevel ( )
45
46 FUNCTION: int ZSTD_defaultCLevel ( )
47
48 ! Explicit context
49
50 TYPEDEF: void ZSTD_CCtx
51 FUNCTION: ZSTD_CCtx* ZSTD_createCCtx ( )
52 FUNCTION: size_t ZSTD_freeCCtx ( ZSTD_CCtx* cctx )
53 DESTRUCTOR: ZSTD_freeCCtx
54
55 FUNCTION: size_t ZSTD_compressCCtx ( ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, void* src, size_t srcSize, int compressionLevel )
56
57 TYPEDEF: void ZSTD_DCtx
58 FUNCTION: ZSTD_DCtx* ZSTD_createDCtx ( )
59 FUNCTION: size_t ZSTD_freeDCtx ( ZSTD_DCtx* dctx )
60 DESTRUCTOR: ZSTD_freeDCtx
61
62 FUNCTION: size_t ZSTD_decompressCCtx ( ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, void* src, size_t srcSize )
63 FUNCTION: size_t ZSTD_decompressStream_simpleArgs ( ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, size_t* dstPos, void* src, size_t srcSize, size_t* srcPos )
64
65 ! Streaming
66
67 STRUCT: ZSTD_inBuffer
68     { src void* }
69     { size size_t }
70     { pos size_t }
71 ;
72
73 STRUCT: ZSTD_outBuffer
74     { dst void* }
75     { size size_t }
76     { pos size_t }
77 ;
78
79 ! Streaming compression
80
81 TYPEDEF: void ZSTD_CStream
82
83 FUNCTION: ZSTD_CStream* ZSTD_createCStream ( )
84 FUNCTION: size_t ZSTD_freeCStream ( ZSTD_CStream* zcs )
85
86 ENUM: ZSTD_EndDirective
87     ZSTD_e_continue
88     ZSTD_e_flush
89     ZSTD_e_end ;
90
91 FUNCTION: size_t ZSTD_compressStream2 ( ZSTD_CCtx* cctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input, ZSTD_EndDirective endOp )
92 FUNCTION: size_t ZSTD_CStreamInSize ( )
93 FUNCTION: size_t ZSTD_CStreamOutSize ( )
94
95 FUNCTION: size_t ZSTD_initCStream ( ZSTD_CStream* zcs, int compressionLevel )
96 FUNCTION: size_t ZSTD_compressStream ( ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input )
97 FUNCTION: size_t ZSTD_flushStream ( ZSTD_CStream* zcs, ZSTD_outBuffer* output )
98 FUNCTION: size_t ZSTD_endStream ( ZSTD_CStream* zcs, ZSTD_outBuffer* output )
99
100 ! Streaming decompression
101
102 TYPEDEF: void ZSTD_DStream
103
104 FUNCTION: ZSTD_DStream* ZSTD_createDStream ( )
105 FUNCTION: size_t ZSTD_freeDStream ( ZSTD_DStream* zds )
106 FUNCTION: size_t ZSTD_initDStream ( ZSTD_DStream* zds )
107 FUNCTION: size_t ZSTD_decompressStream ( ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input )
108 FUNCTION: size_t ZSTD_DStreamInSize ( )
109 FUNCTION: size_t ZSTD_DStreamOutSize ( )
110
111 DESTRUCTOR: ZSTD_freeDStream