WIP optimize unused struct filter

This commit is contained in:
neuecc 2023-03-06 09:44:48 +09:00
parent 0df71f5423
commit 6d9e535975
16 changed files with 348858 additions and 216 deletions

View File

@ -1,7 +1,7 @@
// use std::error::Error; use std::error::Error;
// fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<(), Box<dyn Error>> {
fn main() { //fn main() {
// bindgen::Builder::default() // bindgen::Builder::default()
// .header("c/lz4/lz4.h") // .header("c/lz4/lz4.h")
// .header("c/lz4/lz4hc.h") // .header("c/lz4/lz4hc.h")
@ -21,24 +21,24 @@ fn main() {
]) ])
.compile("lz4"); .compile("lz4");
// bindgen::Builder::default() bindgen::Builder::default()
// .header("c/zstd/zstd.h") .header("c/zstd/zstd.h")
// .generate()? .generate()?
// .write_to_file("src/zstd.rs")?; .write_to_file("src/zstd.rs")?;
// bindgen::Builder::default() bindgen::Builder::default()
// .header("c/quiche/quiche.h") .header("c/quiche/quiche.h")
// .generate()? .generate()?
// .write_to_file("src/quiche.rs")?; .write_to_file("src/quiche.rs")?;
// bindgen::Builder::default() bindgen::Builder::default()
// .header("c/bullet3/PhysicsClientC_API.h") .header("c/bullet3/PhysicsClientC_API.h")
// .header("c/bullet3/PhysicsClientSharedMemory_C_API.h") .header("c/bullet3/PhysicsClientSharedMemory_C_API.h")
// .header("c/bullet3/PhysicsClientSharedMemory2_C_API.h") .header("c/bullet3/PhysicsClientSharedMemory2_C_API.h")
// .header("c/bullet3/PhysicsDirectC_API.h") .header("c/bullet3/PhysicsDirectC_API.h")
// .header("c/bullet3/SharedMemoryPublic.h") .header("c/bullet3/SharedMemoryPublic.h")
// .generate()? .generate()?
// .write_to_file("src/bullet3.rs")?; .write_to_file("src/bullet3.rs")?;
csbindgen::Builder::default() csbindgen::Builder::default()
.input_bindgen_file("src/lz4.rs") .input_bindgen_file("src/lz4.rs")
@ -65,26 +65,29 @@ fn main() {
.generate_csharp_file("../dotnet-sandbox/method_call.cs") .generate_csharp_file("../dotnet-sandbox/method_call.cs")
.unwrap(); .unwrap();
// csbindgen::Builder::new() csbindgen::Builder::new()
// .input_bindgen_file("src/zstd.rs") .input_bindgen_file("src/zstd.rs")
// .rust_method_prefix("csbindgen_zstd_") .method_filter(|x| x.starts_with("ZSTD_"))
// .csharp_class_name("LibZstd") .rust_method_prefix("csbindgen_zstd_")
// .csharp_dll_name("libzsd") .csharp_class_name("LibZstd")
// .generate_to_file("src/zstd_ffi.rs", "../dotnet-sandbox/zstd_bindgen.cs")?; .csharp_dll_name("libzsd")
.generate_to_file("src/zstd_ffi.rs", "../dotnet-sandbox/zstd_bindgen.cs")?;
// csbindgen::Builder::new() csbindgen::Builder::new()
// .input_bindgen_file("src/quiche.rs") .input_bindgen_file("src/quiche.rs")
// .rust_method_prefix("csbindgen_quiche_") .method_filter(|x| x.starts_with("quiche_"))
// .csharp_class_name("LibQuiche") .rust_method_prefix("csbindgen_quiche_")
// .csharp_dll_name("libquiche") .csharp_class_name("LibQuiche")
// .generate_to_file("src/quiche_ffi.rs", "../dotnet-sandbox/quiche_bindgen.cs")?; .csharp_dll_name("libquiche")
.generate_to_file("src/quiche_ffi.rs", "../dotnet-sandbox/quiche_bindgen.cs")?;
// csbindgen::Builder::new() csbindgen::Builder::new()
// .input_bindgen_file("src/bullet3.rs") .input_bindgen_file("src/bullet3.rs")
// .rust_method_prefix("csbindgen_bullet3_") .method_filter(|x| x.starts_with("b3"))
// .csharp_class_name("LibBullet3") .rust_method_prefix("csbindgen_bullet3_")
// .csharp_dll_name("libbullet3") .csharp_class_name("LibBullet3")
// .generate_to_file("src/bullet3_ffi.rs", "../dotnet-sandbox/bullet3_bindgen.cs")?; .csharp_dll_name("libbullet3")
.generate_to_file("src/bullet3_ffi.rs", "../dotnet-sandbox/bullet3_bindgen.cs")?;
// Ok(()) Ok(())
} }

7369
csbindgen-tests/src/bullet3.rs vendored Normal file

File diff suppressed because it is too large Load Diff

5943
csbindgen-tests/src/bullet3_ffi.rs vendored Normal file

File diff suppressed because it is too large Load Diff

329473
csbindgen-tests/src/quiche.rs vendored Normal file

File diff suppressed because it is too large Load Diff

1689
csbindgen-tests/src/quiche_ffi.rs vendored Normal file

File diff suppressed because it is too large Load Diff

688
csbindgen-tests/src/zstd.rs vendored Normal file
View File

@ -0,0 +1,688 @@
/* automatically generated by rust-bindgen 0.64.0 */
pub const _VCRT_COMPILER_PREPROCESSOR: u32 = 1;
pub const _SAL_VERSION: u32 = 20;
pub const __SAL_H_VERSION: u32 = 180000000;
pub const _USE_DECLSPECS_FOR_SAL: u32 = 0;
pub const _USE_ATTRIBUTES_FOR_SAL: u32 = 0;
pub const _CRT_PACKING: u32 = 8;
pub const _HAS_EXCEPTIONS: u32 = 1;
pub const _STL_LANG: u32 = 0;
pub const _HAS_CXX17: u32 = 0;
pub const _HAS_CXX20: u32 = 0;
pub const _HAS_CXX23: u32 = 0;
pub const _HAS_NODISCARD: u32 = 0;
pub const CHAR_BIT: u32 = 8;
pub const SCHAR_MIN: i32 = -128;
pub const SCHAR_MAX: u32 = 127;
pub const UCHAR_MAX: u32 = 255;
pub const CHAR_MIN: i32 = -128;
pub const CHAR_MAX: u32 = 127;
pub const MB_LEN_MAX: u32 = 5;
pub const SHRT_MIN: i32 = -32768;
pub const SHRT_MAX: u32 = 32767;
pub const USHRT_MAX: u32 = 65535;
pub const INT_MIN: i32 = -2147483648;
pub const INT_MAX: u32 = 2147483647;
pub const UINT_MAX: u32 = 4294967295;
pub const LONG_MIN: i32 = -2147483648;
pub const LONG_MAX: u32 = 2147483647;
pub const ULONG_MAX: u32 = 4294967295;
pub const ZSTD_VERSION_MAJOR: u32 = 1;
pub const ZSTD_VERSION_MINOR: u32 = 5;
pub const ZSTD_VERSION_RELEASE: u32 = 4;
pub const ZSTD_VERSION_NUMBER: u32 = 10504;
pub const ZSTD_CLEVEL_DEFAULT: u32 = 3;
pub const ZSTD_MAGICNUMBER: u32 = 4247762216;
pub const ZSTD_MAGIC_DICTIONARY: u32 = 3962610743;
pub const ZSTD_MAGIC_SKIPPABLE_START: u32 = 407710288;
pub const ZSTD_MAGIC_SKIPPABLE_MASK: u32 = 4294967280;
pub const ZSTD_BLOCKSIZELOG_MAX: u32 = 17;
pub const ZSTD_BLOCKSIZE_MAX: u32 = 131072;
pub const ZSTD_CONTENTSIZE_UNKNOWN: i32 = -1;
pub const ZSTD_CONTENTSIZE_ERROR: i32 = -2;
pub type va_list = *mut ::std::os::raw::c_char;
extern "C" {
pub fn __va_start(arg1: *mut *mut ::std::os::raw::c_char, ...);
}
pub type __vcrt_bool = bool;
pub type wchar_t = ::std::os::raw::c_ushort;
extern "C" {
pub fn __security_init_cookie();
}
extern "C" {
pub fn __security_check_cookie(_StackCookie: usize);
}
extern "C" {
pub fn __report_gsfailure(_StackCookie: usize) -> !;
}
extern "C" {
pub static mut __security_cookie: usize;
}
pub type max_align_t = f64;
extern "C" {
#[doc = " ZSTD_versionNumber() :\n Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE)."]
pub fn ZSTD_versionNumber() -> ::std::os::raw::c_uint;
}
extern "C" {
#[doc = " ZSTD_versionString() :\n Return runtime library version, like \"1.4.5\". Requires v1.3.0+."]
pub fn ZSTD_versionString() -> *const ::std::os::raw::c_char;
}
extern "C" {
#[doc = " Simple API\n/\n/*! ZSTD_compress() :\n Compresses `src` content as a single zstd compressed frame into already allocated `dst`.\n Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.\n @return : compressed size written into `dst` (<= `dstCapacity),\n or an error code if it fails (which can be tested using ZSTD_isError())."]
pub fn ZSTD_compress(
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
srcSize: usize,
compressionLevel: ::std::os::raw::c_int,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_decompress() :\n `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.\n `dstCapacity` is an upper bound of originalSize to regenerate.\n If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.\n @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),\n or an errorCode if it fails (which can be tested using ZSTD_isError())."]
pub fn ZSTD_decompress(
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
compressedSize: usize,
) -> usize;
}
extern "C" {
pub fn ZSTD_getFrameContentSize(
src: *const ::std::os::raw::c_void,
srcSize: usize,
) -> ::std::os::raw::c_ulonglong;
}
extern "C" {
#[doc = " ZSTD_getDecompressedSize() :\n NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize().\n Both functions work the same way, but ZSTD_getDecompressedSize() blends\n \"empty\", \"unknown\" and \"error\" results to the same return value (0),\n while ZSTD_getFrameContentSize() gives them separate return values.\n @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise."]
pub fn ZSTD_getDecompressedSize(
src: *const ::std::os::raw::c_void,
srcSize: usize,
) -> ::std::os::raw::c_ulonglong;
}
extern "C" {
#[doc = " ZSTD_findFrameCompressedSize() : Requires v1.4.0+\n `src` should point to the start of a ZSTD frame or skippable frame.\n `srcSize` must be >= first frame size\n @return : the compressed size of the first frame starting at `src`,\n suitable to pass as `srcSize` to `ZSTD_decompress` or similar,\n or an error code if input is invalid"]
pub fn ZSTD_findFrameCompressedSize(
src: *const ::std::os::raw::c_void,
srcSize: usize,
) -> usize;
}
extern "C" {
pub fn ZSTD_compressBound(srcSize: usize) -> usize;
}
extern "C" {
pub fn ZSTD_isError(code: usize) -> ::std::os::raw::c_uint;
}
extern "C" {
pub fn ZSTD_getErrorName(code: usize) -> *const ::std::os::raw::c_char;
}
extern "C" {
pub fn ZSTD_minCLevel() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ZSTD_maxCLevel() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ZSTD_defaultCLevel() -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ZSTD_CCtx_s {
_unused: [u8; 0],
}
#[doc = " Explicit context"]
pub type ZSTD_CCtx = ZSTD_CCtx_s;
extern "C" {
pub fn ZSTD_createCCtx() -> *mut ZSTD_CCtx;
}
extern "C" {
pub fn ZSTD_freeCCtx(cctx: *mut ZSTD_CCtx) -> usize;
}
extern "C" {
#[doc = " ZSTD_compressCCtx() :\n Same as ZSTD_compress(), using an explicit ZSTD_CCtx.\n Important : in order to behave similarly to `ZSTD_compress()`,\n this function compresses at requested compression level,\n __ignoring any other parameter__ .\n If any advanced parameter was set using the advanced API,\n they will all be reset. Only `compressionLevel` remains."]
pub fn ZSTD_compressCCtx(
cctx: *mut ZSTD_CCtx,
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
srcSize: usize,
compressionLevel: ::std::os::raw::c_int,
) -> usize;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ZSTD_DCtx_s {
_unused: [u8; 0],
}
pub type ZSTD_DCtx = ZSTD_DCtx_s;
extern "C" {
pub fn ZSTD_createDCtx() -> *mut ZSTD_DCtx;
}
extern "C" {
pub fn ZSTD_freeDCtx(dctx: *mut ZSTD_DCtx) -> usize;
}
extern "C" {
#[doc = " ZSTD_decompressDCtx() :\n Same as ZSTD_decompress(),\n requires an allocated ZSTD_DCtx.\n Compatible with sticky parameters."]
pub fn ZSTD_decompressDCtx(
dctx: *mut ZSTD_DCtx,
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
srcSize: usize,
) -> usize;
}
pub const ZSTD_strategy_ZSTD_fast: ZSTD_strategy = 1;
pub const ZSTD_strategy_ZSTD_dfast: ZSTD_strategy = 2;
pub const ZSTD_strategy_ZSTD_greedy: ZSTD_strategy = 3;
pub const ZSTD_strategy_ZSTD_lazy: ZSTD_strategy = 4;
pub const ZSTD_strategy_ZSTD_lazy2: ZSTD_strategy = 5;
pub const ZSTD_strategy_ZSTD_btlazy2: ZSTD_strategy = 6;
pub const ZSTD_strategy_ZSTD_btopt: ZSTD_strategy = 7;
pub const ZSTD_strategy_ZSTD_btultra: ZSTD_strategy = 8;
pub const ZSTD_strategy_ZSTD_btultra2: ZSTD_strategy = 9;
#[doc = " Advanced compression API (Requires v1.4.0+)"]
pub type ZSTD_strategy = ::std::os::raw::c_int;
pub const ZSTD_cParameter_ZSTD_c_compressionLevel: ZSTD_cParameter = 100;
pub const ZSTD_cParameter_ZSTD_c_windowLog: ZSTD_cParameter = 101;
pub const ZSTD_cParameter_ZSTD_c_hashLog: ZSTD_cParameter = 102;
pub const ZSTD_cParameter_ZSTD_c_chainLog: ZSTD_cParameter = 103;
pub const ZSTD_cParameter_ZSTD_c_searchLog: ZSTD_cParameter = 104;
pub const ZSTD_cParameter_ZSTD_c_minMatch: ZSTD_cParameter = 105;
pub const ZSTD_cParameter_ZSTD_c_targetLength: ZSTD_cParameter = 106;
pub const ZSTD_cParameter_ZSTD_c_strategy: ZSTD_cParameter = 107;
pub const ZSTD_cParameter_ZSTD_c_enableLongDistanceMatching: ZSTD_cParameter = 160;
pub const ZSTD_cParameter_ZSTD_c_ldmHashLog: ZSTD_cParameter = 161;
pub const ZSTD_cParameter_ZSTD_c_ldmMinMatch: ZSTD_cParameter = 162;
pub const ZSTD_cParameter_ZSTD_c_ldmBucketSizeLog: ZSTD_cParameter = 163;
pub const ZSTD_cParameter_ZSTD_c_ldmHashRateLog: ZSTD_cParameter = 164;
pub const ZSTD_cParameter_ZSTD_c_contentSizeFlag: ZSTD_cParameter = 200;
pub const ZSTD_cParameter_ZSTD_c_checksumFlag: ZSTD_cParameter = 201;
pub const ZSTD_cParameter_ZSTD_c_dictIDFlag: ZSTD_cParameter = 202;
pub const ZSTD_cParameter_ZSTD_c_nbWorkers: ZSTD_cParameter = 400;
pub const ZSTD_cParameter_ZSTD_c_jobSize: ZSTD_cParameter = 401;
pub const ZSTD_cParameter_ZSTD_c_overlapLog: ZSTD_cParameter = 402;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam1: ZSTD_cParameter = 500;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam2: ZSTD_cParameter = 10;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam3: ZSTD_cParameter = 1000;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam4: ZSTD_cParameter = 1001;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam5: ZSTD_cParameter = 1002;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam6: ZSTD_cParameter = 1003;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam7: ZSTD_cParameter = 1004;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam8: ZSTD_cParameter = 1005;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam9: ZSTD_cParameter = 1006;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam10: ZSTD_cParameter = 1007;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam11: ZSTD_cParameter = 1008;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam12: ZSTD_cParameter = 1009;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam13: ZSTD_cParameter = 1010;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam14: ZSTD_cParameter = 1011;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam15: ZSTD_cParameter = 1012;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam16: ZSTD_cParameter = 1013;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam17: ZSTD_cParameter = 1014;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam18: ZSTD_cParameter = 1015;
pub const ZSTD_cParameter_ZSTD_c_experimentalParam19: ZSTD_cParameter = 1016;
pub type ZSTD_cParameter = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ZSTD_bounds {
pub error: usize,
pub lowerBound: ::std::os::raw::c_int,
pub upperBound: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_ZSTD_bounds() {
const UNINIT: ::std::mem::MaybeUninit<ZSTD_bounds> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ZSTD_bounds>(),
16usize,
concat!("Size of: ", stringify!(ZSTD_bounds))
);
assert_eq!(
::std::mem::align_of::<ZSTD_bounds>(),
8usize,
concat!("Alignment of ", stringify!(ZSTD_bounds))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).error) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_bounds),
"::",
stringify!(error)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).lowerBound) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_bounds),
"::",
stringify!(lowerBound)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).upperBound) as usize - ptr as usize },
12usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_bounds),
"::",
stringify!(upperBound)
)
);
}
extern "C" {
#[doc = " ZSTD_cParam_getBounds() :\n All parameters must belong to an interval with lower and upper bounds,\n otherwise they will either trigger an error or be automatically clamped.\n @return : a structure, ZSTD_bounds, which contains\n - an error status field, which must be tested using ZSTD_isError()\n - lower and upper bounds, both inclusive"]
pub fn ZSTD_cParam_getBounds(cParam: ZSTD_cParameter) -> ZSTD_bounds;
}
extern "C" {
#[doc = " ZSTD_CCtx_setParameter() :\n Set one compression parameter, selected by enum ZSTD_cParameter.\n All parameters have valid bounds. Bounds can be queried using ZSTD_cParam_getBounds().\n Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter).\n Setting a parameter is generally only possible during frame initialization (before starting compression).\n Exception : when using multi-threading mode (nbWorkers >= 1),\n the following parameters can be updated _during_ compression (within same frame):\n => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy.\n new parameters will be active for next job only (after a flush()).\n @return : an error code (which can be tested using ZSTD_isError())."]
pub fn ZSTD_CCtx_setParameter(
cctx: *mut ZSTD_CCtx,
param: ZSTD_cParameter,
value: ::std::os::raw::c_int,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_CCtx_setPledgedSrcSize() :\n Total input data size to be compressed as a single frame.\n Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag.\n This value will also be controlled at end of frame, and trigger an error if not respected.\n @result : 0, or an error code (which can be tested with ZSTD_isError()).\n Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame.\n In order to mean \"unknown content size\", pass constant ZSTD_CONTENTSIZE_UNKNOWN.\n ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame.\n Note 2 : pledgedSrcSize is only valid once, for the next frame.\n It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN.\n Note 3 : Whenever all input data is provided and consumed in a single round,\n for example with ZSTD_compress2(),\n or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end),\n this value is automatically overridden by srcSize instead."]
pub fn ZSTD_CCtx_setPledgedSrcSize(
cctx: *mut ZSTD_CCtx,
pledgedSrcSize: ::std::os::raw::c_ulonglong,
) -> usize;
}
pub const ZSTD_ResetDirective_ZSTD_reset_session_only: ZSTD_ResetDirective = 1;
pub const ZSTD_ResetDirective_ZSTD_reset_parameters: ZSTD_ResetDirective = 2;
pub const ZSTD_ResetDirective_ZSTD_reset_session_and_parameters: ZSTD_ResetDirective = 3;
pub type ZSTD_ResetDirective = ::std::os::raw::c_int;
extern "C" {
#[doc = " ZSTD_CCtx_reset() :\n There are 2 different things that can be reset, independently or jointly :\n - The session : will stop compressing current frame, and make CCtx ready to start a new one.\n Useful after an error, or to interrupt any ongoing compression.\n Any internal data not yet flushed is cancelled.\n Compression parameters and dictionary remain unchanged.\n They will be used to compress next frame.\n Resetting session never fails.\n - The parameters : changes all parameters back to \"default\".\n This also removes any reference to any dictionary or external sequence producer.\n Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing)\n otherwise the reset fails, and function returns an error value (which can be tested using ZSTD_isError())\n - Both : similar to resetting the session, followed by resetting parameters."]
pub fn ZSTD_CCtx_reset(cctx: *mut ZSTD_CCtx, reset: ZSTD_ResetDirective) -> usize;
}
extern "C" {
#[doc = " ZSTD_compress2() :\n Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API.\n ZSTD_compress2() always starts a new frame.\n Should cctx hold data from a previously unfinished frame, everything about it is forgotten.\n - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()\n - The function is always blocking, returns when compression is completed.\n Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.\n @return : compressed size written into `dst` (<= `dstCapacity),\n or an error code if it fails (which can be tested using ZSTD_isError())."]
pub fn ZSTD_compress2(
cctx: *mut ZSTD_CCtx,
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
srcSize: usize,
) -> usize;
}
pub const ZSTD_dParameter_ZSTD_d_windowLogMax: ZSTD_dParameter = 100;
pub const ZSTD_dParameter_ZSTD_d_experimentalParam1: ZSTD_dParameter = 1000;
pub const ZSTD_dParameter_ZSTD_d_experimentalParam2: ZSTD_dParameter = 1001;
pub const ZSTD_dParameter_ZSTD_d_experimentalParam3: ZSTD_dParameter = 1002;
pub const ZSTD_dParameter_ZSTD_d_experimentalParam4: ZSTD_dParameter = 1003;
pub const ZSTD_dParameter_ZSTD_d_experimentalParam5: ZSTD_dParameter = 1004;
#[doc = " Advanced decompression API (Requires v1.4.0+)"]
pub type ZSTD_dParameter = ::std::os::raw::c_int;
extern "C" {
#[doc = " ZSTD_dParam_getBounds() :\n All parameters must belong to an interval with lower and upper bounds,\n otherwise they will either trigger an error or be automatically clamped.\n @return : a structure, ZSTD_bounds, which contains\n - an error status field, which must be tested using ZSTD_isError()\n - both lower and upper bounds, inclusive"]
pub fn ZSTD_dParam_getBounds(dParam: ZSTD_dParameter) -> ZSTD_bounds;
}
extern "C" {
#[doc = " ZSTD_DCtx_setParameter() :\n Set one compression parameter, selected by enum ZSTD_dParameter.\n All parameters have valid bounds. Bounds can be queried using ZSTD_dParam_getBounds().\n Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter).\n Setting a parameter is only possible during frame initialization (before starting decompression).\n @return : 0, or an error code (which can be tested using ZSTD_isError())."]
pub fn ZSTD_DCtx_setParameter(
dctx: *mut ZSTD_DCtx,
param: ZSTD_dParameter,
value: ::std::os::raw::c_int,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_DCtx_reset() :\n Return a DCtx to clean state.\n Session and parameters can be reset jointly or separately.\n Parameters can only be reset when no active frame is being decompressed.\n @return : 0, or an error code, which can be tested with ZSTD_isError()"]
pub fn ZSTD_DCtx_reset(dctx: *mut ZSTD_DCtx, reset: ZSTD_ResetDirective) -> usize;
}
#[doc = " Streaming"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ZSTD_inBuffer_s {
#[doc = "< start of input buffer"]
pub src: *const ::std::os::raw::c_void,
#[doc = "< size of input buffer"]
pub size: usize,
#[doc = "< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size"]
pub pos: usize,
}
#[test]
fn bindgen_test_layout_ZSTD_inBuffer_s() {
const UNINIT: ::std::mem::MaybeUninit<ZSTD_inBuffer_s> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ZSTD_inBuffer_s>(),
24usize,
concat!("Size of: ", stringify!(ZSTD_inBuffer_s))
);
assert_eq!(
::std::mem::align_of::<ZSTD_inBuffer_s>(),
8usize,
concat!("Alignment of ", stringify!(ZSTD_inBuffer_s))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).src) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_inBuffer_s),
"::",
stringify!(src)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_inBuffer_s),
"::",
stringify!(size)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).pos) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_inBuffer_s),
"::",
stringify!(pos)
)
);
}
#[doc = " Streaming"]
pub type ZSTD_inBuffer = ZSTD_inBuffer_s;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ZSTD_outBuffer_s {
#[doc = "< start of output buffer"]
pub dst: *mut ::std::os::raw::c_void,
#[doc = "< size of output buffer"]
pub size: usize,
#[doc = "< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size"]
pub pos: usize,
}
#[test]
fn bindgen_test_layout_ZSTD_outBuffer_s() {
const UNINIT: ::std::mem::MaybeUninit<ZSTD_outBuffer_s> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ZSTD_outBuffer_s>(),
24usize,
concat!("Size of: ", stringify!(ZSTD_outBuffer_s))
);
assert_eq!(
::std::mem::align_of::<ZSTD_outBuffer_s>(),
8usize,
concat!("Alignment of ", stringify!(ZSTD_outBuffer_s))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).dst) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_outBuffer_s),
"::",
stringify!(dst)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_outBuffer_s),
"::",
stringify!(size)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).pos) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(ZSTD_outBuffer_s),
"::",
stringify!(pos)
)
);
}
pub type ZSTD_outBuffer = ZSTD_outBuffer_s;
pub type ZSTD_CStream = ZSTD_CCtx;
extern "C" {
pub fn ZSTD_createCStream() -> *mut ZSTD_CStream;
}
extern "C" {
pub fn ZSTD_freeCStream(zcs: *mut ZSTD_CStream) -> usize;
}
pub const ZSTD_EndDirective_ZSTD_e_continue: ZSTD_EndDirective = 0;
pub const ZSTD_EndDirective_ZSTD_e_flush: ZSTD_EndDirective = 1;
pub const ZSTD_EndDirective_ZSTD_e_end: ZSTD_EndDirective = 2;
pub type ZSTD_EndDirective = ::std::os::raw::c_int;
extern "C" {
#[doc = " ZSTD_compressStream2() : Requires v1.4.0+\n Behaves about the same as ZSTD_compressStream, with additional control on end directive.\n - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()\n - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)\n - output->pos must be <= dstCapacity, input->pos must be <= srcSize\n - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.\n - endOp must be a valid directive\n - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.\n - When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available,\n and then immediately returns, just indicating that there is some data remaining to be flushed.\n The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.\n - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking.\n - @return provides a minimum amount of data remaining to be flushed from internal buffers\n or an error code, which can be tested using ZSTD_isError().\n if @return != 0, flush is not fully completed, there is still some data left within internal buffers.\n This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers.\n For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed.\n - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0),\n only ZSTD_e_end or ZSTD_e_flush operations are allowed.\n Before starting a new compression job, or changing compression parameters,\n it is required to fully flush internal buffers."]
pub fn ZSTD_compressStream2(
cctx: *mut ZSTD_CCtx,
output: *mut ZSTD_outBuffer,
input: *mut ZSTD_inBuffer,
endOp: ZSTD_EndDirective,
) -> usize;
}
extern "C" {
pub fn ZSTD_CStreamInSize() -> usize;
}
extern "C" {
pub fn ZSTD_CStreamOutSize() -> usize;
}
extern "C" {
#[doc = " Equivalent to:\n\n ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);\n ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any)\n ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);\n\n Note that ZSTD_initCStream() clears any previously set dictionary. Use the new API\n to compress with a dictionary."]
pub fn ZSTD_initCStream(
zcs: *mut ZSTD_CStream,
compressionLevel: ::std::os::raw::c_int,
) -> usize;
}
extern "C" {
#[doc = " Alternative for ZSTD_compressStream2(zcs, output, input, ZSTD_e_continue).\n NOTE: The return value is different. ZSTD_compressStream() returns a hint for\n the next read size (if non-zero and not an error). ZSTD_compressStream2()\n returns the minimum nb of bytes left to flush (if non-zero and not an error)."]
pub fn ZSTD_compressStream(
zcs: *mut ZSTD_CStream,
output: *mut ZSTD_outBuffer,
input: *mut ZSTD_inBuffer,
) -> usize;
}
extern "C" {
#[doc = " Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush)."]
pub fn ZSTD_flushStream(zcs: *mut ZSTD_CStream, output: *mut ZSTD_outBuffer) -> usize;
}
extern "C" {
#[doc = " Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end)."]
pub fn ZSTD_endStream(zcs: *mut ZSTD_CStream, output: *mut ZSTD_outBuffer) -> usize;
}
pub type ZSTD_DStream = ZSTD_DCtx;
extern "C" {
pub fn ZSTD_createDStream() -> *mut ZSTD_DStream;
}
extern "C" {
pub fn ZSTD_freeDStream(zds: *mut ZSTD_DStream) -> usize;
}
extern "C" {
#[doc = " ZSTD_initDStream() :\n Initialize/reset DStream state for new decompression operation.\n Call before new decompression operation using same DStream.\n\n Note : This function is redundant with the advanced API and equivalent to:\n ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);\n ZSTD_DCtx_refDDict(zds, NULL);"]
pub fn ZSTD_initDStream(zds: *mut ZSTD_DStream) -> usize;
}
extern "C" {
#[doc = " ZSTD_decompressStream() :\n Streaming decompression function.\n Call repetitively to consume full input updating it as necessary.\n Function will update both input and output `pos` fields exposing current state via these fields:\n - `input.pos < input.size`, some input remaining and caller should provide remaining input\n on the next call.\n - `output.pos < output.size`, decoder finished and flushed all remaining buffers.\n - `output.pos == output.size`, potentially uncflushed data present in the internal buffers,\n call ZSTD_decompressStream() again to flush remaining data to output.\n Note : with no additional input, amount of data flushed <= ZSTD_BLOCKSIZE_MAX.\n\n @return : 0 when a frame is completely decoded and fully flushed,\n or an error code, which can be tested using ZSTD_isError(),\n or any other value > 0, which means there is some decoding or flushing to do to complete current frame."]
pub fn ZSTD_decompressStream(
zds: *mut ZSTD_DStream,
output: *mut ZSTD_outBuffer,
input: *mut ZSTD_inBuffer,
) -> usize;
}
extern "C" {
pub fn ZSTD_DStreamInSize() -> usize;
}
extern "C" {
pub fn ZSTD_DStreamOutSize() -> usize;
}
extern "C" {
#[doc = " Simple dictionary API\n/\n/*! ZSTD_compress_usingDict() :\n Compression at an explicit compression level using a Dictionary.\n A dictionary can be any arbitrary data segment (also called a prefix),\n or a buffer with specified information (see zdict.h).\n Note : This function loads the dictionary, resulting in significant startup delay.\n It's intended for a dictionary used only once.\n Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used."]
pub fn ZSTD_compress_usingDict(
ctx: *mut ZSTD_CCtx,
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
srcSize: usize,
dict: *const ::std::os::raw::c_void,
dictSize: usize,
compressionLevel: ::std::os::raw::c_int,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_decompress_usingDict() :\n Decompression using a known Dictionary.\n Dictionary must be identical to the one used during compression.\n Note : This function loads the dictionary, resulting in significant startup delay.\n It's intended for a dictionary used only once.\n Note : When `dict == NULL || dictSize < 8` no dictionary is used."]
pub fn ZSTD_decompress_usingDict(
dctx: *mut ZSTD_DCtx,
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
srcSize: usize,
dict: *const ::std::os::raw::c_void,
dictSize: usize,
) -> usize;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ZSTD_CDict_s {
_unused: [u8; 0],
}
#[doc = " Bulk processing dictionary API"]
pub type ZSTD_CDict = ZSTD_CDict_s;
extern "C" {
#[doc = " ZSTD_createCDict() :\n When compressing multiple messages or blocks using the same dictionary,\n it's recommended to digest the dictionary only once, since it's a costly operation.\n ZSTD_createCDict() will create a state from digesting a dictionary.\n The resulting state can be used for future compression operations with very limited startup cost.\n ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.\n @dictBuffer can be released after ZSTD_CDict creation, because its content is copied within CDict.\n Note 1 : Consider experimental function `ZSTD_createCDict_byReference()` if you prefer to not duplicate @dictBuffer content.\n Note 2 : A ZSTD_CDict can be created from an empty @dictBuffer,\n in which case the only thing that it transports is the @compressionLevel.\n This can be useful in a pipeline featuring ZSTD_compress_usingCDict() exclusively,\n expecting a ZSTD_CDict parameter with any data, including those without a known dictionary."]
pub fn ZSTD_createCDict(
dictBuffer: *const ::std::os::raw::c_void,
dictSize: usize,
compressionLevel: ::std::os::raw::c_int,
) -> *mut ZSTD_CDict;
}
extern "C" {
#[doc = " ZSTD_freeCDict() :\n Function frees memory allocated by ZSTD_createCDict().\n If a NULL pointer is passed, no operation is performed."]
pub fn ZSTD_freeCDict(CDict: *mut ZSTD_CDict) -> usize;
}
extern "C" {
#[doc = " ZSTD_compress_usingCDict() :\n Compression using a digested Dictionary.\n Recommended when same dictionary is used multiple times.\n Note : compression level is _decided at dictionary creation time_,\n and frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no)"]
pub fn ZSTD_compress_usingCDict(
cctx: *mut ZSTD_CCtx,
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
srcSize: usize,
cdict: *const ZSTD_CDict,
) -> usize;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ZSTD_DDict_s {
_unused: [u8; 0],
}
pub type ZSTD_DDict = ZSTD_DDict_s;
extern "C" {
#[doc = " ZSTD_createDDict() :\n Create a digested dictionary, ready to start decompression operation without startup delay.\n dictBuffer can be released after DDict creation, as its content is copied inside DDict."]
pub fn ZSTD_createDDict(
dictBuffer: *const ::std::os::raw::c_void,
dictSize: usize,
) -> *mut ZSTD_DDict;
}
extern "C" {
#[doc = " ZSTD_freeDDict() :\n Function frees memory allocated with ZSTD_createDDict()\n If a NULL pointer is passed, no operation is performed."]
pub fn ZSTD_freeDDict(ddict: *mut ZSTD_DDict) -> usize;
}
extern "C" {
#[doc = " ZSTD_decompress_usingDDict() :\n Decompression using a digested Dictionary.\n Recommended when same dictionary is used multiple times."]
pub fn ZSTD_decompress_usingDDict(
dctx: *mut ZSTD_DCtx,
dst: *mut ::std::os::raw::c_void,
dstCapacity: usize,
src: *const ::std::os::raw::c_void,
srcSize: usize,
ddict: *const ZSTD_DDict,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_getDictID_fromDict() : Requires v1.4.0+\n Provides the dictID stored within dictionary.\n if @return == 0, the dictionary is not conformant with Zstandard specification.\n It can still be loaded, but as a content-only dictionary."]
pub fn ZSTD_getDictID_fromDict(
dict: *const ::std::os::raw::c_void,
dictSize: usize,
) -> ::std::os::raw::c_uint;
}
extern "C" {
#[doc = " ZSTD_getDictID_fromCDict() : Requires v1.5.0+\n Provides the dictID of the dictionary loaded into `cdict`.\n If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.\n Non-conformant dictionaries can still be loaded, but as content-only dictionaries."]
pub fn ZSTD_getDictID_fromCDict(cdict: *const ZSTD_CDict) -> ::std::os::raw::c_uint;
}
extern "C" {
#[doc = " ZSTD_getDictID_fromDDict() : Requires v1.4.0+\n Provides the dictID of the dictionary loaded into `ddict`.\n If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.\n Non-conformant dictionaries can still be loaded, but as content-only dictionaries."]
pub fn ZSTD_getDictID_fromDDict(ddict: *const ZSTD_DDict) -> ::std::os::raw::c_uint;
}
extern "C" {
#[doc = " ZSTD_getDictID_fromFrame() : Requires v1.4.0+\n Provides the dictID required to decompressed the frame stored within `src`.\n If @return == 0, the dictID could not be decoded.\n This could for one of the following reasons :\n - The frame does not require a dictionary to be decoded (most common case).\n - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden piece of information.\n Note : this use case also happens when using a non-conformant dictionary.\n - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`).\n - This is not a Zstandard frame.\n When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code."]
pub fn ZSTD_getDictID_fromFrame(
src: *const ::std::os::raw::c_void,
srcSize: usize,
) -> ::std::os::raw::c_uint;
}
extern "C" {
#[doc = " ZSTD_CCtx_loadDictionary() : Requires v1.4.0+\n Create an internal CDict from `dict` buffer.\n Decompression will have to use same dictionary.\n @result : 0, or an error code (which can be tested with ZSTD_isError()).\n Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary,\n meaning \"return to no-dictionary mode\".\n Note 1 : Dictionary is sticky, it will be used for all future compressed frames,\n until parameters are reset, a new dictionary is loaded, or the dictionary\n is explicitly invalidated by loading a NULL dictionary.\n Note 2 : Loading a dictionary involves building tables.\n It's also a CPU consuming operation, with non-negligible impact on latency.\n Tables are dependent on compression parameters, and for this reason,\n compression parameters can no longer be changed after loading a dictionary.\n Note 3 :`dict` content will be copied internally.\n Use experimental ZSTD_CCtx_loadDictionary_byReference() to reference content instead.\n In such a case, dictionary buffer must outlive its users.\n Note 4 : Use ZSTD_CCtx_loadDictionary_advanced()\n to precisely select how dictionary content must be interpreted."]
pub fn ZSTD_CCtx_loadDictionary(
cctx: *mut ZSTD_CCtx,
dict: *const ::std::os::raw::c_void,
dictSize: usize,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_CCtx_refCDict() : Requires v1.4.0+\n Reference a prepared dictionary, to be used for all future compressed frames.\n Note that compression parameters are enforced from within CDict,\n and supersede any compression parameter previously set within CCtx.\n The parameters ignored are labelled as \"superseded-by-cdict\" in the ZSTD_cParameter enum docs.\n The ignored parameters will be used again if the CCtx is returned to no-dictionary mode.\n The dictionary will remain valid for future compressed frames using same CCtx.\n @result : 0, or an error code (which can be tested with ZSTD_isError()).\n Special : Referencing a NULL CDict means \"return to no-dictionary mode\".\n Note 1 : Currently, only one dictionary can be managed.\n Referencing a new dictionary effectively \"discards\" any previous one.\n Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx."]
pub fn ZSTD_CCtx_refCDict(cctx: *mut ZSTD_CCtx, cdict: *const ZSTD_CDict) -> usize;
}
extern "C" {
#[doc = " ZSTD_CCtx_refPrefix() : Requires v1.4.0+\n Reference a prefix (single-usage dictionary) for next compressed frame.\n A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end).\n Decompression will need same prefix to properly regenerate data.\n Compressing with a prefix is similar in outcome as performing a diff and compressing it,\n but performs much faster, especially during decompression (compression speed is tunable with compression level).\n @result : 0, or an error code (which can be tested with ZSTD_isError()).\n Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary\n Note 1 : Prefix buffer is referenced. It **must** outlive compression.\n Its content must remain unmodified during compression.\n Note 2 : If the intention is to diff some large src data blob with some prior version of itself,\n ensure that the window size is large enough to contain the entire source.\n See ZSTD_c_windowLog.\n Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters.\n It's a CPU consuming operation, with non-negligible impact on latency.\n If there is a need to use the same prefix multiple times, consider loadDictionary instead.\n Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dct_rawContent).\n Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation."]
pub fn ZSTD_CCtx_refPrefix(
cctx: *mut ZSTD_CCtx,
prefix: *const ::std::os::raw::c_void,
prefixSize: usize,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_DCtx_loadDictionary() : Requires v1.4.0+\n Create an internal DDict from dict buffer, to be used to decompress all future frames.\n The dictionary remains valid for all future frames, until explicitly invalidated, or\n a new dictionary is loaded.\n @result : 0, or an error code (which can be tested with ZSTD_isError()).\n Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary,\n meaning \"return to no-dictionary mode\".\n Note 1 : Loading a dictionary involves building tables,\n which has a non-negligible impact on CPU usage and latency.\n It's recommended to \"load once, use many times\", to amortize the cost\n Note 2 :`dict` content will be copied internally, so `dict` can be released after loading.\n Use ZSTD_DCtx_loadDictionary_byReference() to reference dictionary content instead.\n Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to take control of\n how dictionary content is loaded and interpreted."]
pub fn ZSTD_DCtx_loadDictionary(
dctx: *mut ZSTD_DCtx,
dict: *const ::std::os::raw::c_void,
dictSize: usize,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_DCtx_refDDict() : Requires v1.4.0+\n Reference a prepared dictionary, to be used to decompress next frames.\n The dictionary remains active for decompression of future frames using same DCtx.\n\n If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function\n will store the DDict references in a table, and the DDict used for decompression\n will be determined at decompression time, as per the dict ID in the frame.\n The memory for the table is allocated on the first call to refDDict, and can be\n freed with ZSTD_freeDCtx().\n\n If called with ZSTD_d_refMultipleDDicts disabled (the default), only one dictionary\n will be managed, and referencing a dictionary effectively \"discards\" any previous one.\n\n @result : 0, or an error code (which can be tested with ZSTD_isError()).\n Special: referencing a NULL DDict means \"return to no-dictionary mode\".\n Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx."]
pub fn ZSTD_DCtx_refDDict(dctx: *mut ZSTD_DCtx, ddict: *const ZSTD_DDict) -> usize;
}
extern "C" {
#[doc = " ZSTD_DCtx_refPrefix() : Requires v1.4.0+\n Reference a prefix (single-usage dictionary) to decompress next frame.\n This is the reverse operation of ZSTD_CCtx_refPrefix(),\n and must use the same prefix as the one used during compression.\n Prefix is **only used once**. Reference is discarded at end of frame.\n End of frame is reached when ZSTD_decompressStream() returns 0.\n @result : 0, or an error code (which can be tested with ZSTD_isError()).\n Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary\n Note 2 : Prefix buffer is referenced. It **must** outlive decompression.\n Prefix buffer must remain unmodified up to the end of frame,\n reached when ZSTD_decompressStream() returns 0.\n Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent).\n Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode (Experimental section)\n Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost.\n A full dictionary is more costly, as it requires building tables."]
pub fn ZSTD_DCtx_refPrefix(
dctx: *mut ZSTD_DCtx,
prefix: *const ::std::os::raw::c_void,
prefixSize: usize,
) -> usize;
}
extern "C" {
#[doc = " ZSTD_sizeof_*() : Requires v1.4.0+\n These functions give the _current_ memory usage of selected object.\n Note that object memory usage can evolve (increase or decrease) over time."]
pub fn ZSTD_sizeof_CCtx(cctx: *const ZSTD_CCtx) -> usize;
}
extern "C" {
pub fn ZSTD_sizeof_DCtx(dctx: *const ZSTD_DCtx) -> usize;
}
extern "C" {
pub fn ZSTD_sizeof_CStream(zcs: *const ZSTD_CStream) -> usize;
}
extern "C" {
pub fn ZSTD_sizeof_DStream(zds: *const ZSTD_DStream) -> usize;
}
extern "C" {
pub fn ZSTD_sizeof_CDict(cdict: *const ZSTD_CDict) -> usize;
}
extern "C" {
pub fn ZSTD_sizeof_DDict(ddict: *const ZSTD_DDict) -> usize;
}

825
csbindgen-tests/src/zstd_ffi.rs vendored Normal file
View File

@ -0,0 +1,825 @@
/* automatically generated by csbindgen */
#[allow(unused)]
use ::std::os::raw::*;
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_versionNumber(
) -> c_uint
{
ZSTD_versionNumber(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_versionString(
) -> *const c_char
{
ZSTD_versionString(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_compress(
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
srcSize: usize,
compressionLevel: c_int
) -> usize
{
ZSTD_compress(
dst,
dstCapacity,
src,
srcSize,
compressionLevel
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_decompress(
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
compressedSize: usize
) -> usize
{
ZSTD_decompress(
dst,
dstCapacity,
src,
compressedSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_getFrameContentSize(
src: *const c_void,
srcSize: usize
) -> c_ulonglong
{
ZSTD_getFrameContentSize(
src,
srcSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_getDecompressedSize(
src: *const c_void,
srcSize: usize
) -> c_ulonglong
{
ZSTD_getDecompressedSize(
src,
srcSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_findFrameCompressedSize(
src: *const c_void,
srcSize: usize
) -> usize
{
ZSTD_findFrameCompressedSize(
src,
srcSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_compressBound(
srcSize: usize
) -> usize
{
ZSTD_compressBound(
srcSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_isError(
code: usize
) -> c_uint
{
ZSTD_isError(
code
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_getErrorName(
code: usize
) -> *const c_char
{
ZSTD_getErrorName(
code
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_minCLevel(
) -> c_int
{
ZSTD_minCLevel(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_maxCLevel(
) -> c_int
{
ZSTD_maxCLevel(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_defaultCLevel(
) -> c_int
{
ZSTD_defaultCLevel(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_createCCtx(
) -> *mut ZSTD_CCtx
{
ZSTD_createCCtx(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_freeCCtx(
cctx: *mut ZSTD_CCtx
) -> usize
{
ZSTD_freeCCtx(
cctx
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_compressCCtx(
cctx: *mut ZSTD_CCtx,
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
srcSize: usize,
compressionLevel: c_int
) -> usize
{
ZSTD_compressCCtx(
cctx,
dst,
dstCapacity,
src,
srcSize,
compressionLevel
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_createDCtx(
) -> *mut ZSTD_DCtx
{
ZSTD_createDCtx(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_freeDCtx(
dctx: *mut ZSTD_DCtx
) -> usize
{
ZSTD_freeDCtx(
dctx
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_decompressDCtx(
dctx: *mut ZSTD_DCtx,
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
srcSize: usize
) -> usize
{
ZSTD_decompressDCtx(
dctx,
dst,
dstCapacity,
src,
srcSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_cParam_getBounds(
cParam: ZSTD_cParameter
) -> ZSTD_bounds
{
ZSTD_cParam_getBounds(
cParam
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_CCtx_setParameter(
cctx: *mut ZSTD_CCtx,
param: ZSTD_cParameter,
value: c_int
) -> usize
{
ZSTD_CCtx_setParameter(
cctx,
param,
value
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_CCtx_setPledgedSrcSize(
cctx: *mut ZSTD_CCtx,
pledgedSrcSize: c_ulonglong
) -> usize
{
ZSTD_CCtx_setPledgedSrcSize(
cctx,
pledgedSrcSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_CCtx_reset(
cctx: *mut ZSTD_CCtx,
reset: ZSTD_ResetDirective
) -> usize
{
ZSTD_CCtx_reset(
cctx,
reset
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_compress2(
cctx: *mut ZSTD_CCtx,
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
srcSize: usize
) -> usize
{
ZSTD_compress2(
cctx,
dst,
dstCapacity,
src,
srcSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_dParam_getBounds(
dParam: ZSTD_dParameter
) -> ZSTD_bounds
{
ZSTD_dParam_getBounds(
dParam
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_DCtx_setParameter(
dctx: *mut ZSTD_DCtx,
param: ZSTD_dParameter,
value: c_int
) -> usize
{
ZSTD_DCtx_setParameter(
dctx,
param,
value
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_DCtx_reset(
dctx: *mut ZSTD_DCtx,
reset: ZSTD_ResetDirective
) -> usize
{
ZSTD_DCtx_reset(
dctx,
reset
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_createCStream(
) -> *mut ZSTD_CStream
{
ZSTD_createCStream(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_freeCStream(
zcs: *mut ZSTD_CStream
) -> usize
{
ZSTD_freeCStream(
zcs
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_compressStream2(
cctx: *mut ZSTD_CCtx,
output: *mut ZSTD_outBuffer,
input: *mut ZSTD_inBuffer,
endOp: ZSTD_EndDirective
) -> usize
{
ZSTD_compressStream2(
cctx,
output,
input,
endOp
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_CStreamInSize(
) -> usize
{
ZSTD_CStreamInSize(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_CStreamOutSize(
) -> usize
{
ZSTD_CStreamOutSize(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_initCStream(
zcs: *mut ZSTD_CStream,
compressionLevel: c_int
) -> usize
{
ZSTD_initCStream(
zcs,
compressionLevel
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_compressStream(
zcs: *mut ZSTD_CStream,
output: *mut ZSTD_outBuffer,
input: *mut ZSTD_inBuffer
) -> usize
{
ZSTD_compressStream(
zcs,
output,
input
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_flushStream(
zcs: *mut ZSTD_CStream,
output: *mut ZSTD_outBuffer
) -> usize
{
ZSTD_flushStream(
zcs,
output
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_endStream(
zcs: *mut ZSTD_CStream,
output: *mut ZSTD_outBuffer
) -> usize
{
ZSTD_endStream(
zcs,
output
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_createDStream(
) -> *mut ZSTD_DStream
{
ZSTD_createDStream(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_freeDStream(
zds: *mut ZSTD_DStream
) -> usize
{
ZSTD_freeDStream(
zds
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_initDStream(
zds: *mut ZSTD_DStream
) -> usize
{
ZSTD_initDStream(
zds
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_decompressStream(
zds: *mut ZSTD_DStream,
output: *mut ZSTD_outBuffer,
input: *mut ZSTD_inBuffer
) -> usize
{
ZSTD_decompressStream(
zds,
output,
input
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_DStreamInSize(
) -> usize
{
ZSTD_DStreamInSize(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_DStreamOutSize(
) -> usize
{
ZSTD_DStreamOutSize(
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_compress_usingDict(
ctx: *mut ZSTD_CCtx,
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
srcSize: usize,
dict: *const c_void,
dictSize: usize,
compressionLevel: c_int
) -> usize
{
ZSTD_compress_usingDict(
ctx,
dst,
dstCapacity,
src,
srcSize,
dict,
dictSize,
compressionLevel
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_decompress_usingDict(
dctx: *mut ZSTD_DCtx,
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
srcSize: usize,
dict: *const c_void,
dictSize: usize
) -> usize
{
ZSTD_decompress_usingDict(
dctx,
dst,
dstCapacity,
src,
srcSize,
dict,
dictSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_createCDict(
dictBuffer: *const c_void,
dictSize: usize,
compressionLevel: c_int
) -> *mut ZSTD_CDict
{
ZSTD_createCDict(
dictBuffer,
dictSize,
compressionLevel
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_freeCDict(
CDict: *mut ZSTD_CDict
) -> usize
{
ZSTD_freeCDict(
CDict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_compress_usingCDict(
cctx: *mut ZSTD_CCtx,
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
srcSize: usize,
cdict: *const ZSTD_CDict
) -> usize
{
ZSTD_compress_usingCDict(
cctx,
dst,
dstCapacity,
src,
srcSize,
cdict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_createDDict(
dictBuffer: *const c_void,
dictSize: usize
) -> *mut ZSTD_DDict
{
ZSTD_createDDict(
dictBuffer,
dictSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_freeDDict(
ddict: *mut ZSTD_DDict
) -> usize
{
ZSTD_freeDDict(
ddict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_decompress_usingDDict(
dctx: *mut ZSTD_DCtx,
dst: *mut c_void,
dstCapacity: usize,
src: *const c_void,
srcSize: usize,
ddict: *const ZSTD_DDict
) -> usize
{
ZSTD_decompress_usingDDict(
dctx,
dst,
dstCapacity,
src,
srcSize,
ddict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_getDictID_fromDict(
dict: *const c_void,
dictSize: usize
) -> c_uint
{
ZSTD_getDictID_fromDict(
dict,
dictSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_getDictID_fromCDict(
cdict: *const ZSTD_CDict
) -> c_uint
{
ZSTD_getDictID_fromCDict(
cdict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_getDictID_fromDDict(
ddict: *const ZSTD_DDict
) -> c_uint
{
ZSTD_getDictID_fromDDict(
ddict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_getDictID_fromFrame(
src: *const c_void,
srcSize: usize
) -> c_uint
{
ZSTD_getDictID_fromFrame(
src,
srcSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_CCtx_loadDictionary(
cctx: *mut ZSTD_CCtx,
dict: *const c_void,
dictSize: usize
) -> usize
{
ZSTD_CCtx_loadDictionary(
cctx,
dict,
dictSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_CCtx_refCDict(
cctx: *mut ZSTD_CCtx,
cdict: *const ZSTD_CDict
) -> usize
{
ZSTD_CCtx_refCDict(
cctx,
cdict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_CCtx_refPrefix(
cctx: *mut ZSTD_CCtx,
prefix: *const c_void,
prefixSize: usize
) -> usize
{
ZSTD_CCtx_refPrefix(
cctx,
prefix,
prefixSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_DCtx_loadDictionary(
dctx: *mut ZSTD_DCtx,
dict: *const c_void,
dictSize: usize
) -> usize
{
ZSTD_DCtx_loadDictionary(
dctx,
dict,
dictSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_DCtx_refDDict(
dctx: *mut ZSTD_DCtx,
ddict: *const ZSTD_DDict
) -> usize
{
ZSTD_DCtx_refDDict(
dctx,
ddict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_DCtx_refPrefix(
dctx: *mut ZSTD_DCtx,
prefix: *const c_void,
prefixSize: usize
) -> usize
{
ZSTD_DCtx_refPrefix(
dctx,
prefix,
prefixSize
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_sizeof_CCtx(
cctx: *const ZSTD_CCtx
) -> usize
{
ZSTD_sizeof_CCtx(
cctx
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_sizeof_DCtx(
dctx: *const ZSTD_DCtx
) -> usize
{
ZSTD_sizeof_DCtx(
dctx
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_sizeof_CStream(
zcs: *const ZSTD_CStream
) -> usize
{
ZSTD_sizeof_CStream(
zcs
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_sizeof_DStream(
zds: *const ZSTD_DStream
) -> usize
{
ZSTD_sizeof_DStream(
zds
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_sizeof_CDict(
cdict: *const ZSTD_CDict
) -> usize
{
ZSTD_sizeof_CDict(
cdict
)
}
#[no_mangle]
pub unsafe extern "C" fn csbindgen_zstd_ZSTD_sizeof_DDict(
ddict: *const ZSTD_DDict
) -> usize
{
ZSTD_sizeof_DDict(
ddict
)
}

151
csbindgen/src/alias_map.rs Normal file
View File

@ -0,0 +1,151 @@
use std::{cell::RefCell, collections::HashMap, rc::Rc};
use crate::type_meta::{RustType, TypeKind};
#[derive(Clone, Debug)]
pub struct AliasMap {
nodes: HashMap<String, Rc<RefCell<Node>>>,
}
impl AliasMap {
pub fn new() -> Self {
Self {
nodes: HashMap::new(),
}
}
}
#[derive(Clone, Debug)]
struct Node {
pub value: RustType,
pub next: Option<Rc<RefCell<Node>>>,
}
impl Node {
pub fn get_last_value(&self) -> RustType {
match &self.next {
Some(x) => x.borrow().get_last_value(),
None => self.value.clone(),
}
}
}
impl AliasMap {
pub fn insert(&mut self, name: &String, alias: &RustType) {
match (self.nodes.get(name), self.nodes.get(&alias.type_name)) {
(Some(_), Some(_)) => {} // duplicate is not allowed in system
(Some(left), None) => {
let right_node = Rc::new(RefCell::new(Node {
value: alias.clone(),
next: None,
}));
left.borrow_mut().next = Some(right_node.clone());
self.nodes.insert(alias.type_name.to_owned(), right_node);
}
(None, Some(right)) => {
let left_node = Rc::new(RefCell::new(Node {
value: RustType {
type_name: name.to_owned(),
type_kind: TypeKind::Normal,
},
next: Some(right.clone()),
}));
self.nodes.insert(name.to_owned(), left_node);
}
(None, None) => {
let right_node = Rc::new(RefCell::new(Node {
value: alias.clone(),
next: None,
}));
let left_node = Rc::new(RefCell::new(Node {
value: RustType {
type_name: name.to_owned(),
type_kind: TypeKind::Normal,
},
next: Some(right_node.clone()),
}));
self.nodes.insert(name.to_owned(), left_node);
self.nodes.insert(alias.type_name.to_owned(), right_node);
}
}
}
#[allow(dead_code)]
pub fn contains(&self, name: &String) -> bool {
self.nodes.contains_key(name)
}
pub fn get_mapped_value(&self, name: &String) -> Option<RustType> {
match self.nodes.get(name) {
Some(x) => Some(x.borrow().get_last_value()),
None => None,
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn alias_map_test() {
// SSIZE_T -> LONG_PTR -> c_longlong
// SSIZE_T2 -> LONG_PTR -> c_longlong
let mut map = AliasMap::new();
map.insert(
&"SSIZE_T".to_string(),
&RustType {
type_name: "LONG_PTR".to_string(),
type_kind: TypeKind::Normal,
},
);
map.insert(
&"LONG_PTR".to_string(),
&RustType {
type_name: "c_longlong".to_string(),
type_kind: TypeKind::Normal,
},
);
map.insert(
&"SSIZE_T2".to_string(),
&RustType {
type_name: "LONG_PTR".to_string(),
type_kind: TypeKind::Normal,
},
);
assert!(map.contains(&"LONG_PTR".to_string()));
assert!(map.contains(&"c_longlong".to_string()));
assert!(map.contains(&"SSIZE_T".to_string()));
assert!(map.contains(&"SSIZE_T2".to_string()));
assert_eq!(
map.get_mapped_value(&"SSIZE_T".to_string())
.unwrap()
.type_name,
"c_longlong"
);
assert_eq!(
map.get_mapped_value(&"SSIZE_T2".to_string())
.unwrap()
.type_name,
"c_longlong"
);
assert_eq!(
map.get_mapped_value(&"LONG_PTR".to_string())
.unwrap()
.type_name,
"c_longlong"
);
assert_eq!(
map.get_mapped_value(&"c_longlong".to_string())
.unwrap()
.type_name,
"c_longlong"
);
}
}

View File

@ -1,5 +1,4 @@
use std::collections::HashMap; use crate::alias_map::AliasMap;
use crate::builder::BindgenOptions; use crate::builder::BindgenOptions;
use crate::type_meta::*; use crate::type_meta::*;
use crate::util::*; use crate::util::*;
@ -77,7 +76,7 @@ use ::std::os::raw::*;
pub fn emit_csharp( pub fn emit_csharp(
methods: &Vec<ExternMethod>, methods: &Vec<ExternMethod>,
aliases: &HashMap<String, RustType>, aliases: &AliasMap,
structs: &Vec<RustStruct>, structs: &Vec<RustStruct>,
enums: &Vec<RustEnum>, enums: &Vec<RustEnum>,
options: &BindgenOptions, options: &BindgenOptions,

View File

@ -1,3 +1,4 @@
mod alias_map;
mod builder; mod builder;
mod emitter; mod emitter;
mod parser; mod parser;
@ -45,15 +46,13 @@ pub(crate) fn generate(
using_types.insert(p.rust_type.type_name.clone()); using_types.insert(p.rust_type.type_name.clone());
} }
} }
for item in &structs { for item in &structs {
if using_types.contains(&item.struct_name) {
for item in &item.fields { for item in &item.fields {
using_types.insert(item.rust_type.type_name.clone()); using_types.insert(item.rust_type.type_name.clone());
} }
} }
let aliases = reduce_type_alias(&aliases, &using_types);
for alias in &aliases {
using_types.insert(alias.1.type_name.clone());
} }
let structs = reduce_struct(&structs, &using_types); let structs = reduce_struct(&structs, &using_types);

View File

@ -1,5 +1,5 @@
use crate::{builder::BindgenOptions, type_meta::*}; use crate::{alias_map::AliasMap, builder::BindgenOptions, type_meta::*};
use std::collections::{HashMap, HashSet}; use std::collections::HashSet;
use syn::{ForeignItem, Item, Pat, ReturnType}; use syn::{ForeignItem, Item, Pat, ReturnType};
enum FnItem { enum FnItem {
@ -105,36 +105,37 @@ fn parse_method(item: FnItem, options: &BindgenOptions) -> Option<ExternMethod>
method_name, method_name,
parameters, parameters,
return_type, return_type,
doc_comment doc_comment,
}); });
} }
None None
} }
pub fn collect_type_alias(ast: &syn::File) -> Vec<(String, RustType)> { pub fn collect_type_alias(ast: &syn::File) -> AliasMap {
let mut result = Vec::new(); let mut result = AliasMap::new();
for item in ast.items.iter() { for item in ast.items.iter() {
if let Item::Type(t) = item { if let Item::Type(t) = item {
let name = t.ident.to_string(); let name = t.ident.to_string();
let alias = parse_type(&t.ty); let alias = parse_type(&t.ty);
result.push((name, alias)); result.insert(&name, &alias);
} else if let Item::Use(t) = item { } else if let Item::Use(t) = item {
if let syn::UseTree::Path(t) = &t.tree { if let syn::UseTree::Path(t) = &t.tree {
if let syn::UseTree::Rename(t) = &*t.tree { if let syn::UseTree::Rename(t) = &*t.tree {
let name = t.rename.to_string(); let name = t.rename.to_string();
let alias = t.ident.to_string(); let alias = t.ident.to_string();
result.push(( result.insert(
name, &name,
RustType { &RustType {
type_name: alias.to_string(), type_name: alias,
type_kind: TypeKind::Normal, type_kind: TypeKind::Normal,
}, },
)); );
} }
} }
} }
} }
result result
} }
@ -226,27 +227,6 @@ pub fn collect_enum(ast: &syn::File) -> Vec<RustEnum> {
result result
} }
pub fn reduce_type_alias(
aliases: &Vec<(String, RustType)>,
using_types: &HashSet<String>,
) -> HashMap<String, RustType> {
let mut map = HashMap::new();
for (name, rust_type) in aliases {
if using_types.contains(name) {
map.insert(name.clone(), rust_type.clone());
}
}
for (name, rust_type) in aliases {
let pointed = map.get(rust_type.type_name.as_str());
if let Some(x) = pointed {
map.insert(name.to_string(), x.clone());
}
}
map
}
pub fn reduce_struct(structs: &Vec<RustStruct>, using_types: &HashSet<String>) -> Vec<RustStruct> { pub fn reduce_struct(structs: &Vec<RustStruct>, using_types: &HashSet<String>) -> Vec<RustStruct> {
let mut result = Vec::new(); let mut result = Vec::new();
for item in structs { for item in structs {

View File

@ -1,6 +1,4 @@
use std::collections::HashMap; use crate::{builder::BindgenOptions, alias_map::AliasMap};
use crate::builder::BindgenOptions;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Parameter { pub struct Parameter {
@ -177,7 +175,7 @@ impl RustType {
pub fn to_csharp_string( pub fn to_csharp_string(
&self, &self,
options: &BindgenOptions, options: &BindgenOptions,
alias_map: &HashMap<String, RustType>, alias_map: &AliasMap,
) -> String { ) -> String {
fn convert_type_name(type_name: &str, options: &BindgenOptions) -> String { fn convert_type_name(type_name: &str, options: &BindgenOptions) -> String {
let name = match type_name { let name = match type_name {
@ -221,9 +219,9 @@ impl RustType {
} }
// resolve alias // resolve alias
let (use_type, use_alias) = match alias_map.get(&self.type_name) { let (use_type, use_alias) = match alias_map.get_mapped_value(&self.type_name) {
Some(x) => (x, true), Some(x) => (x, true),
None => (self, false), None => (self.clone(), false),
}; };
let mut sb = String::new(); let mut sb = String::new();

1773
dotnet-sandbox/bullet3_bindgen.cs vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -20,15 +20,15 @@ namespace CsBindgen
public static extern int LZ4_versionNumber(); public static extern int LZ4_versionNumber();
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_versionString", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_versionString", CallingConvention = CallingConvention.Cdecl)]
public static extern byte* LZ4_versionString(); public static extern byte** LZ4_versionString();
/// <summary>LZ4_compress_default() : Compresses 'srcSize' bytes from buffer 'src' into already allocated 'dst' buffer of size 'dstCapacity'. Compression is guaranteed to succeed if 'dstCapacity' &gt;= LZ4_compressBound(srcSize). It also runs faster, so it's a recommended setting. If the function cannot compress 'src' into a more limited 'dst' budget, compression stops *immediately*, and the function result is zero. In which case, 'dst' content is undefined (invalid). srcSize : max supported value is LZ4_MAX_INPUT_SIZE. dstCapacity : size of buffer 'dst' (which must be already allocated) @return : the number of bytes written into buffer 'dst' (necessarily &lt;= dstCapacity) or 0 if compression fails Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).</summary> /// <summary>LZ4_compress_default() : Compresses 'srcSize' bytes from buffer 'src' into already allocated 'dst' buffer of size 'dstCapacity'. Compression is guaranteed to succeed if 'dstCapacity' &gt;= LZ4_compressBound(srcSize). It also runs faster, so it's a recommended setting. If the function cannot compress 'src' into a more limited 'dst' budget, compression stops *immediately*, and the function result is zero. In which case, 'dst' content is undefined (invalid). srcSize : max supported value is LZ4_MAX_INPUT_SIZE. dstCapacity : size of buffer 'dst' (which must be already allocated) @return : the number of bytes written into buffer 'dst' (necessarily &lt;= dstCapacity) or 0 if compression fails Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_default", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_default", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_default(byte* src, byte* dst, int srcSize, int dstCapacity); public static extern int LZ4_compress_default(byte** src, byte** dst, int srcSize, int dstCapacity);
/// <summary>LZ4_decompress_safe() : @compressedSize : is the exact complete size of the compressed block. @dstCapacity : is the size of destination buffer (which must be already allocated), is an upper bound of decompressed size. @return : the number of bytes decompressed into destination buffer (necessarily &lt;= dstCapacity) If destination buffer is not large enough, decoding will stop and output an error code (negative value). If the source stream is detected malformed, the function will stop decoding and return a negative result. Note 1 : This function is protected against malicious data packets : it will never writes outside 'dst' buffer, nor read outside 'source' buffer, even if the compressed block is maliciously modified to order the decoder to do these actions. In such case, the decoder stops immediately, and considers the compressed block malformed. Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them. The implementation is free to send / store / derive this information in whichever way is most beneficial. If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.</summary> /// <summary>LZ4_decompress_safe() : @compressedSize : is the exact complete size of the compressed block. @dstCapacity : is the size of destination buffer (which must be already allocated), is an upper bound of decompressed size. @return : the number of bytes decompressed into destination buffer (necessarily &lt;= dstCapacity) If destination buffer is not large enough, decoding will stop and output an error code (negative value). If the source stream is detected malformed, the function will stop decoding and return a negative result. Note 1 : This function is protected against malicious data packets : it will never writes outside 'dst' buffer, nor read outside 'source' buffer, even if the compressed block is maliciously modified to order the decoder to do these actions. In such case, the decoder stops immediately, and considers the compressed block malformed. Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them. The implementation is free to send / store / derive this information in whichever way is most beneficial. If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_safe(byte* src, byte* dst, int compressedSize, int dstCapacity); public static extern int LZ4_decompress_safe(byte** src, byte** dst, int compressedSize, int dstCapacity);
/// <summary>LZ4_compressBound() :Provides the maximum size that LZ4 compression may output in a \"worst case\" scenario (input data not compressible)This function is primarily useful for memory allocation purposes (destination buffer size).Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).Note that LZ4_compress_default() compresses faster when dstCapacity is &gt;= LZ4_compressBound(srcSize)inputSize : max supported value is LZ4_MAX_INPUT_SIZEreturn : maximum output size in a \"worst case\" scenarioor 0, if input size is incorrect (too large or negative)</summary> /// <summary>LZ4_compressBound() :Provides the maximum size that LZ4 compression may output in a \"worst case\" scenario (input data not compressible)This function is primarily useful for memory allocation purposes (destination buffer size).Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).Note that LZ4_compress_default() compresses faster when dstCapacity is &gt;= LZ4_compressBound(srcSize)inputSize : max supported value is LZ4_MAX_INPUT_SIZEreturn : maximum output size in a \"worst case\" scenarioor 0, if input size is incorrect (too large or negative)</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressBound", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressBound", CallingConvention = CallingConvention.Cdecl)]
@ -36,22 +36,22 @@ namespace CsBindgen
/// <summary>LZ4_compress_fast() :Same as LZ4_compress_default(), but allows selection of \"acceleration\" factor.The larger the acceleration value, the faster the algorithm, but also the lesser the compression.It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.An acceleration value of \"1\" is the same as regular LZ4_compress_default()Values &lt;= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c).Values &gt; LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c).</summary> /// <summary>LZ4_compress_fast() :Same as LZ4_compress_default(), but allows selection of \"acceleration\" factor.The larger the acceleration value, the faster the algorithm, but also the lesser the compression.It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.An acceleration value of \"1\" is the same as regular LZ4_compress_default()Values &lt;= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c).Values &gt; LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c).</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_fast", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_fast", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_fast(byte* src, byte* dst, int srcSize, int dstCapacity, int acceleration); public static extern int LZ4_compress_fast(byte** src, byte** dst, int srcSize, int dstCapacity, int acceleration);
/// <summary>LZ4_compress_fast_extState() : Same as LZ4_compress_fast(), using an externally allocated memory space for its state. Use LZ4_sizeofState() to know how much memory must be allocated, and allocate it on 8-bytes boundaries (using `malloc()` typically). Then, provide this buffer as `void* state` to compression function.</summary> /// <summary>LZ4_compress_fast_extState() : Same as LZ4_compress_fast(), using an externally allocated memory space for its state. Use LZ4_sizeofState() to know how much memory must be allocated, and allocate it on 8-bytes boundaries (using `malloc()` typically). Then, provide this buffer as `void* state` to compression function.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_sizeofState", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_sizeofState", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_sizeofState(); public static extern int LZ4_sizeofState();
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_fast_extState", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_fast_extState", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_fast_extState(void* state, byte* src, byte* dst, int srcSize, int dstCapacity, int acceleration); public static extern int LZ4_compress_fast_extState(void* state, byte** src, byte** dst, int srcSize, int dstCapacity, int acceleration);
/// <summary>LZ4_compress_destSize() : Reverse the logic : compresses as much data as possible from 'src' buffer into already allocated buffer 'dst', of size &gt;= 'targetDestSize'. This function either compresses the entire 'src' content into 'dst' if it's large enough, or fill 'dst' buffer completely with as much data as possible from 'src'. note: acceleration parameter is fixed to \"default\". *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'. New value is necessarily &lt;= input value. @return : Nb bytes written into 'dst' (necessarily &lt;= targetDestSize) or 0 if compression fails. Note : from v1.8.2 to v1.9.1, this function had a bug (fixed un v1.9.2+): the produced compressed content could, in specific circumstances, require to be decompressed into a destination buffer larger by at least 1 byte than the content to decompress. If an application uses `LZ4_compress_destSize()`, it's highly recommended to update liblz4 to v1.9.2 or better. If this can't be done or ensured, the receiving decompression function should provide a dstCapacity which is &gt; decompressedSize, by at least 1 byte. See https://github.com/lz4/lz4/issues/859 for details</summary> /// <summary>LZ4_compress_destSize() : Reverse the logic : compresses as much data as possible from 'src' buffer into already allocated buffer 'dst', of size &gt;= 'targetDestSize'. This function either compresses the entire 'src' content into 'dst' if it's large enough, or fill 'dst' buffer completely with as much data as possible from 'src'. note: acceleration parameter is fixed to \"default\". *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'. New value is necessarily &lt;= input value. @return : Nb bytes written into 'dst' (necessarily &lt;= targetDestSize) or 0 if compression fails. Note : from v1.8.2 to v1.9.1, this function had a bug (fixed un v1.9.2+): the produced compressed content could, in specific circumstances, require to be decompressed into a destination buffer larger by at least 1 byte than the content to decompress. If an application uses `LZ4_compress_destSize()`, it's highly recommended to update liblz4 to v1.9.2 or better. If this can't be done or ensured, the receiving decompression function should provide a dstCapacity which is &gt; decompressedSize, by at least 1 byte. See https://github.com/lz4/lz4/issues/859 for details</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_destSize", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_destSize", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_destSize(byte* src, byte* dst, int* srcSizePtr, int targetDstSize); public static extern int LZ4_compress_destSize(byte** src, byte** dst, int* srcSizePtr, int targetDstSize);
/// <summary>LZ4_decompress_safe_partial() : Decompress an LZ4 compressed block, of size 'srcSize' at position 'src', into destination buffer 'dst' of size 'dstCapacity'. Up to 'targetOutputSize' bytes will be decoded. The function stops decoding on reaching this objective. This can be useful to boost performance whenever only the beginning of a block is required. @return : the number of bytes decoded in `dst` (necessarily &lt;= targetOutputSize) If source stream is detected malformed, function returns a negative result. Note 1 : @return can be &lt; targetOutputSize, if compressed block contains less data. Note 2 : targetOutputSize must be &lt;= dstCapacity Note 3 : this function effectively stops decoding on reaching targetOutputSize, so dstCapacity is kind of redundant. This is because in older versions of this function, decoding operation would still write complete sequences. Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize, it could write more bytes, though only up to dstCapacity. Some \"margin\" used to be required for this operation to work properly. Thankfully, this is no longer necessary. The function nonetheless keeps the same signature, in an effort to preserve API compatibility. Note 4 : If srcSize is the exact size of the block, then targetOutputSize can be any value, including larger than the block's decompressed size. The function will, at most, generate block's decompressed size. Note 5 : If srcSize is _larger_ than block's compressed size, then targetOutputSize **MUST** be &lt;= block's decompressed size. Otherwise, *silent corruption will occur*.</summary> /// <summary>LZ4_decompress_safe_partial() : Decompress an LZ4 compressed block, of size 'srcSize' at position 'src', into destination buffer 'dst' of size 'dstCapacity'. Up to 'targetOutputSize' bytes will be decoded. The function stops decoding on reaching this objective. This can be useful to boost performance whenever only the beginning of a block is required. @return : the number of bytes decoded in `dst` (necessarily &lt;= targetOutputSize) If source stream is detected malformed, function returns a negative result. Note 1 : @return can be &lt; targetOutputSize, if compressed block contains less data. Note 2 : targetOutputSize must be &lt;= dstCapacity Note 3 : this function effectively stops decoding on reaching targetOutputSize, so dstCapacity is kind of redundant. This is because in older versions of this function, decoding operation would still write complete sequences. Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize, it could write more bytes, though only up to dstCapacity. Some \"margin\" used to be required for this operation to work properly. Thankfully, this is no longer necessary. The function nonetheless keeps the same signature, in an effort to preserve API compatibility. Note 4 : If srcSize is the exact size of the block, then targetOutputSize can be any value, including larger than the block's decompressed size. The function will, at most, generate block's decompressed size. Note 5 : If srcSize is _larger_ than block's compressed size, then targetOutputSize **MUST** be &lt;= block's decompressed size. Otherwise, *silent corruption will occur*.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_partial", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_partial", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_safe_partial(byte* src, byte* dst, int srcSize, int targetOutputSize, int dstCapacity); public static extern int LZ4_decompress_safe_partial(byte** src, byte** dst, int srcSize, int targetOutputSize, int dstCapacity);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_createStream", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_createStream", CallingConvention = CallingConvention.Cdecl)]
public static extern LZ4_stream_u* LZ4_createStream(); public static extern LZ4_stream_u* LZ4_createStream();
@ -65,15 +65,15 @@ namespace CsBindgen
/// <summary>LZ4_loadDict() : Use this function to reference a static dictionary into LZ4_stream_t. The dictionary must remain available during compression. LZ4_loadDict() triggers a reset, so any previous data will be forgotten. The same dictionary will have to be loaded on decompression side for successful decoding. Dictionary are useful for better compression of small data (KB range). While LZ4 accept any input as dictionary, results are generally better when using Zstandard's Dictionary Builder. Loading a size of 0 is allowed, and is the same as reset. @return : loaded dictionary size, in bytes (necessarily &lt;= 64 KB)</summary> /// <summary>LZ4_loadDict() : Use this function to reference a static dictionary into LZ4_stream_t. The dictionary must remain available during compression. LZ4_loadDict() triggers a reset, so any previous data will be forgotten. The same dictionary will have to be loaded on decompression side for successful decoding. Dictionary are useful for better compression of small data (KB range). While LZ4 accept any input as dictionary, results are generally better when using Zstandard's Dictionary Builder. Loading a size of 0 is allowed, and is the same as reset. @return : loaded dictionary size, in bytes (necessarily &lt;= 64 KB)</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_loadDict", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_loadDict", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_loadDict(LZ4_stream_u* streamPtr, byte* dictionary, int dictSize); public static extern int LZ4_loadDict(LZ4_stream_u* streamPtr, byte** dictionary, int dictSize);
/// <summary>LZ4_compress_fast_continue() : Compress 'src' content using data from previously compressed blocks, for better compression ratio. 'dst' buffer must be already allocated. If dstCapacity &gt;= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. @return : size of compressed block or 0 if there is an error (typically, cannot fit into 'dst'). Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block. Each block has precise boundaries. Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata. It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together. Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory ! Note 3 : When input is structured as a double-buffer, each buffer can have any size, including &lt; 64 KB. Make sure that buffers are separated, by at least one byte. This construction ensures that each block only depends on previous block. Note 4 : If input buffer is a ring-buffer, it can have any size, including &lt; 64 KB. Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.</summary> /// <summary>LZ4_compress_fast_continue() : Compress 'src' content using data from previously compressed blocks, for better compression ratio. 'dst' buffer must be already allocated. If dstCapacity &gt;= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. @return : size of compressed block or 0 if there is an error (typically, cannot fit into 'dst'). Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block. Each block has precise boundaries. Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata. It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together. Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory ! Note 3 : When input is structured as a double-buffer, each buffer can have any size, including &lt; 64 KB. Make sure that buffers are separated, by at least one byte. This construction ensures that each block only depends on previous block. Note 4 : If input buffer is a ring-buffer, it can have any size, including &lt; 64 KB. Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_fast_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_fast_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_fast_continue(LZ4_stream_u* streamPtr, byte* src, byte* dst, int srcSize, int dstCapacity, int acceleration); public static extern int LZ4_compress_fast_continue(LZ4_stream_u* streamPtr, byte** src, byte** dst, int srcSize, int dstCapacity, int acceleration);
/// <summary>LZ4_saveDict() : If last 64KB data cannot be guaranteed to remain available at its current memory location, save it into a safer place (char* safeBuffer). This is schematically equivalent to a memcpy() followed by LZ4_loadDict(), but is much faster, because LZ4_saveDict() doesn't need to rebuild tables. @return : saved dictionary size in bytes (necessarily &lt;= maxDictSize), or 0 if error.</summary> /// <summary>LZ4_saveDict() : If last 64KB data cannot be guaranteed to remain available at its current memory location, save it into a safer place (char* safeBuffer). This is schematically equivalent to a memcpy() followed by LZ4_loadDict(), but is much faster, because LZ4_saveDict() doesn't need to rebuild tables. @return : saved dictionary size in bytes (necessarily &lt;= maxDictSize), or 0 if error.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_saveDict", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_saveDict", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_saveDict(LZ4_stream_u* streamPtr, byte* safeBuffer, int maxDictSize); public static extern int LZ4_saveDict(LZ4_stream_u* streamPtr, byte** safeBuffer, int maxDictSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_createStreamDecode", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_createStreamDecode", CallingConvention = CallingConvention.Cdecl)]
public static extern LZ4_streamDecode_u* LZ4_createStreamDecode(); public static extern LZ4_streamDecode_u* LZ4_createStreamDecode();
@ -83,7 +83,7 @@ namespace CsBindgen
/// <summary>LZ4_setStreamDecode() : An LZ4_streamDecode_t context can be allocated once and re-used multiple times. Use this function to start decompression of a new stream of blocks. A dictionary can optionally be set. Use NULL or size 0 for a reset order. Dictionary is presumed stable : it must remain accessible and unmodified during next decompression. @return : 1 if OK, 0 if error</summary> /// <summary>LZ4_setStreamDecode() : An LZ4_streamDecode_t context can be allocated once and re-used multiple times. Use this function to start decompression of a new stream of blocks. A dictionary can optionally be set. Use NULL or size 0 for a reset order. Dictionary is presumed stable : it must remain accessible and unmodified during next decompression. @return : 1 if OK, 0 if error</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_setStreamDecode", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_setStreamDecode", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_setStreamDecode(LZ4_streamDecode_u* LZ4_streamDecode, byte* dictionary, int dictSize); public static extern int LZ4_setStreamDecode(LZ4_streamDecode_u* LZ4_streamDecode, byte** dictionary, int dictSize);
/// <summary>LZ4_decoderRingBufferSize() : v1.8.2+ Note : in a ring buffer scenario (optional), blocks are presumed decompressed next to each other up to the moment there is not enough remaining space for next block (remainingSize &lt; maxBlockSize), at which stage it resumes from beginning of ring buffer. When setting such a ring buffer for streaming decompression, provides the minimum size of this ring buffer to be compatible with any source respecting maxBlockSize condition. @return : minimum ring buffer size, or 0 if there is an error (invalid maxBlockSize).</summary> /// <summary>LZ4_decoderRingBufferSize() : v1.8.2+ Note : in a ring buffer scenario (optional), blocks are presumed decompressed next to each other up to the moment there is not enough remaining space for next block (remainingSize &lt; maxBlockSize), at which stage it resumes from beginning of ring buffer. When setting such a ring buffer for streaming decompression, provides the minimum size of this ring buffer to be compatible with any source respecting maxBlockSize condition. @return : minimum ring buffer size, or 0 if there is an error (invalid maxBlockSize).</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decoderRingBufferSize", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decoderRingBufferSize", CallingConvention = CallingConvention.Cdecl)]
@ -91,15 +91,15 @@ namespace CsBindgen
/// <summary>LZ4_decompress_safe_continue() : This decoding function allows decompression of consecutive blocks in \"streaming\" mode. The difference with the usual independent blocks is that new blocks are allowed to find references into former blocks. A block is an unsplittable entity, and must be presented entirely to the decompression function. LZ4_decompress_safe_continue() only accepts one block at a time. It's modeled after `LZ4_decompress_safe()` and behaves similarly. @LZ4_streamDecode : decompression state, tracking the position in memory of past data @compressedSize : exact complete size of one compressed block. @dstCapacity : size of destination buffer (which must be already allocated), must be an upper bound of decompressed size. @return : number of bytes decompressed into destination buffer (necessarily &lt;= dstCapacity) If destination buffer is not large enough, decoding will stop and output an error code (negative value). If the source stream is detected malformed, the function will stop decoding and return a negative result. The last 64KB of previously decoded data *must* remain available and unmodified at the memory position where they were previously decoded. If less than 64KB of data has been decoded, all the data must be present. Special : if decompression side sets a ring buffer, it must respect one of the following conditions : - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize). maxBlockSize is the maximum size of any single block. It can have any value &gt; 16 bytes. In which case, encoding and decoding buffers do not need to be synchronized. Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize. - Synchronized mode : Decompression buffer size is _exactly_ the same as compression buffer size, and follows exactly same update rule (block boundaries at same positions), and decoding function is provided with exact decompressed size of each block (exception for last block of the stream), _then_ decoding & encoding ring buffer can have any size, including small ones ( &lt; 64 KB). - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes. In which case, encoding and decoding buffers do not need to be synchronized, and encoding ring buffer can have any size, including small ones ( &lt; 64 KB). Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression, then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.</summary> /// <summary>LZ4_decompress_safe_continue() : This decoding function allows decompression of consecutive blocks in \"streaming\" mode. The difference with the usual independent blocks is that new blocks are allowed to find references into former blocks. A block is an unsplittable entity, and must be presented entirely to the decompression function. LZ4_decompress_safe_continue() only accepts one block at a time. It's modeled after `LZ4_decompress_safe()` and behaves similarly. @LZ4_streamDecode : decompression state, tracking the position in memory of past data @compressedSize : exact complete size of one compressed block. @dstCapacity : size of destination buffer (which must be already allocated), must be an upper bound of decompressed size. @return : number of bytes decompressed into destination buffer (necessarily &lt;= dstCapacity) If destination buffer is not large enough, decoding will stop and output an error code (negative value). If the source stream is detected malformed, the function will stop decoding and return a negative result. The last 64KB of previously decoded data *must* remain available and unmodified at the memory position where they were previously decoded. If less than 64KB of data has been decoded, all the data must be present. Special : if decompression side sets a ring buffer, it must respect one of the following conditions : - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize). maxBlockSize is the maximum size of any single block. It can have any value &gt; 16 bytes. In which case, encoding and decoding buffers do not need to be synchronized. Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize. - Synchronized mode : Decompression buffer size is _exactly_ the same as compression buffer size, and follows exactly same update rule (block boundaries at same positions), and decoding function is provided with exact decompressed size of each block (exception for last block of the stream), _then_ decoding & encoding ring buffer can have any size, including small ones ( &lt; 64 KB). - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes. In which case, encoding and decoding buffers do not need to be synchronized, and encoding ring buffer can have any size, including small ones ( &lt; 64 KB). Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression, then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_safe_continue(LZ4_streamDecode_u* LZ4_streamDecode, byte* src, byte* dst, int srcSize, int dstCapacity); public static extern int LZ4_decompress_safe_continue(LZ4_streamDecode_u* LZ4_streamDecode, byte** src, byte** dst, int srcSize, int dstCapacity);
/// <summary>LZ4_decompress_safe_usingDict() : Works the same as a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue() However, it's stateless: it doesn't need any LZ4_streamDecode_t state. Dictionary is presumed stable : it must remain accessible and unmodified during decompression. Performance tip : Decompression speed can be substantially increased when dst == dictStart + dictSize.</summary> /// <summary>LZ4_decompress_safe_usingDict() : Works the same as a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue() However, it's stateless: it doesn't need any LZ4_streamDecode_t state. Dictionary is presumed stable : it must remain accessible and unmodified during decompression. Performance tip : Decompression speed can be substantially increased when dst == dictStart + dictSize.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_usingDict", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_usingDict", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_safe_usingDict(byte* src, byte* dst, int srcSize, int dstCapacity, byte* dictStart, int dictSize); public static extern int LZ4_decompress_safe_usingDict(byte** src, byte** dst, int srcSize, int dstCapacity, byte** dictStart, int dictSize);
/// <summary>LZ4_decompress_safe_partial_usingDict() : Behaves the same as LZ4_decompress_safe_partial() with the added ability to specify a memory segment for past data. Performance tip : Decompression speed can be substantially increased when dst == dictStart + dictSize.</summary> /// <summary>LZ4_decompress_safe_partial_usingDict() : Behaves the same as LZ4_decompress_safe_partial() with the added ability to specify a memory segment for past data. Performance tip : Decompression speed can be substantially increased when dst == dictStart + dictSize.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_partial_usingDict", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_partial_usingDict", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_safe_partial_usingDict(byte* src, byte* dst, int compressedSize, int targetOutputSize, int maxOutputSize, byte* dictStart, int dictSize); public static extern int LZ4_decompress_safe_partial_usingDict(byte** src, byte** dst, int compressedSize, int targetOutputSize, int maxOutputSize, byte** dictStart, int dictSize);
/// <summary>LZ4_initStream() : v1.9.0+ An LZ4_stream_t structure must be initialized at least once. This is automatically done when invoking LZ4_createStream(), but it's not when the structure is simply declared on stack (for example). Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t. It can also initialize any arbitrary buffer of sufficient size, and will @return a pointer of proper type upon initialization. Note : initialization fails if size and alignment conditions are not respected. In which case, the function will @return NULL. Note2: An LZ4_stream_t structure guarantees correct alignment and size. Note3: Before v1.9.0, use LZ4_resetStream() instead</summary> /// <summary>LZ4_initStream() : v1.9.0+ An LZ4_stream_t structure must be initialized at least once. This is automatically done when invoking LZ4_createStream(), but it's not when the structure is simply declared on stack (for example). Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t. It can also initialize any arbitrary buffer of sufficient size, and will @return a pointer of proper type upon initialization. Note : initialization fails if size and alignment conditions are not respected. In which case, the function will @return NULL. Note2: An LZ4_stream_t structure guarantees correct alignment and size. Note3: Before v1.9.0, use LZ4_resetStream() instead</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_initStream", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_initStream", CallingConvention = CallingConvention.Cdecl)]
@ -107,58 +107,58 @@ namespace CsBindgen
/// <summary>Obsolete compression functions (since v1.7.3)</summary> /// <summary>Obsolete compression functions (since v1.7.3)</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress(byte* src, byte* dest, int srcSize); public static extern int LZ4_compress(byte** src, byte** dest, int srcSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_limitedOutput", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_limitedOutput", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_limitedOutput(byte* src, byte* dest, int srcSize, int maxOutputSize); public static extern int LZ4_compress_limitedOutput(byte** src, byte** dest, int srcSize, int maxOutputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_withState", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_withState", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_withState(void* state, byte* source, byte* dest, int inputSize); public static extern int LZ4_compress_withState(void* state, byte** source, byte** dest, int inputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_limitedOutput_withState", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_limitedOutput_withState", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_limitedOutput_withState(void* state, byte* source, byte* dest, int inputSize, int maxOutputSize); public static extern int LZ4_compress_limitedOutput_withState(void* state, byte** source, byte** dest, int inputSize, int maxOutputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_continue(LZ4_stream_u* LZ4_streamPtr, byte* source, byte* dest, int inputSize); public static extern int LZ4_compress_continue(LZ4_stream_u* LZ4_streamPtr, byte** source, byte** dest, int inputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_limitedOutput_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_limitedOutput_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_limitedOutput_continue(LZ4_stream_u* LZ4_streamPtr, byte* source, byte* dest, int inputSize, int maxOutputSize); public static extern int LZ4_compress_limitedOutput_continue(LZ4_stream_u* LZ4_streamPtr, byte** source, byte** dest, int inputSize, int maxOutputSize);
/// <summary>Obsolete decompression functions (since v1.8.0)</summary> /// <summary>Obsolete decompression functions (since v1.8.0)</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_uncompress", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_uncompress", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_uncompress(byte* source, byte* dest, int outputSize); public static extern int LZ4_uncompress(byte** source, byte** dest, int outputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_uncompress_unknownOutputSize", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_uncompress_unknownOutputSize", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_uncompress_unknownOutputSize(byte* source, byte* dest, int isize_, int maxOutputSize); public static extern int LZ4_uncompress_unknownOutputSize(byte** source, byte** dest, int isize_, int maxOutputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_create", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_create", CallingConvention = CallingConvention.Cdecl)]
public static extern void* LZ4_create(byte* inputBuffer); public static extern void* LZ4_create(byte** inputBuffer);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_sizeofStreamState", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_sizeofStreamState", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_sizeofStreamState(); public static extern int LZ4_sizeofStreamState();
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_resetStreamState", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_resetStreamState", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_resetStreamState(void* state, byte* inputBuffer); public static extern int LZ4_resetStreamState(void* state, byte** inputBuffer);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_slideInputBuffer", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_slideInputBuffer", CallingConvention = CallingConvention.Cdecl)]
public static extern byte* LZ4_slideInputBuffer(void* state); public static extern byte** LZ4_slideInputBuffer(void* state);
/// <summary>Obsolete streaming decoding functions (since v1.7.0)</summary> /// <summary>Obsolete streaming decoding functions (since v1.7.0)</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_withPrefix64k", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_safe_withPrefix64k", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_safe_withPrefix64k(byte* src, byte* dst, int compressedSize, int maxDstSize); public static extern int LZ4_decompress_safe_withPrefix64k(byte** src, byte** dst, int compressedSize, int maxDstSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_fast_withPrefix64k", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_fast_withPrefix64k", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_fast_withPrefix64k(byte* src, byte* dst, int originalSize); public static extern int LZ4_decompress_fast_withPrefix64k(byte** src, byte** dst, int originalSize);
/// <summary>Obsolete LZ4_decompress_fast variants (since v1.9.0) : These functions used to be faster than LZ4_decompress_safe(), but this is no longer the case. They are now slower. This is because LZ4_decompress_fast() doesn't know the input size, and therefore must progress more cautiously into the input buffer to not read beyond the end of block. On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability. As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated. The last remaining LZ4_decompress_fast() specificity is that it can decompress a block without knowing its compressed size. Such functionality can be achieved in a more secure manner by employing LZ4_decompress_safe_partial(). Parameters: originalSize : is the uncompressed size to regenerate. `dst` must be already allocated, its size must be &gt;= 'originalSize' bytes. @return : number of bytes read from source buffer (== compressed size). The function expects to finish at block's end exactly. If the source stream is detected malformed, the function stops decoding and returns a negative result. note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer. However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds. Also, since match offsets are not validated, match reads from 'src' may underflow too. These issues never happen if input (compressed) data is correct. But they may happen if input data is invalid (error or intentional tampering). As a consequence, use these functions in trusted environments with trusted data **only**.</summary> /// <summary>Obsolete LZ4_decompress_fast variants (since v1.9.0) : These functions used to be faster than LZ4_decompress_safe(), but this is no longer the case. They are now slower. This is because LZ4_decompress_fast() doesn't know the input size, and therefore must progress more cautiously into the input buffer to not read beyond the end of block. On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability. As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated. The last remaining LZ4_decompress_fast() specificity is that it can decompress a block without knowing its compressed size. Such functionality can be achieved in a more secure manner by employing LZ4_decompress_safe_partial(). Parameters: originalSize : is the uncompressed size to regenerate. `dst` must be already allocated, its size must be &gt;= 'originalSize' bytes. @return : number of bytes read from source buffer (== compressed size). The function expects to finish at block's end exactly. If the source stream is detected malformed, the function stops decoding and returns a negative result. note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer. However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds. Also, since match offsets are not validated, match reads from 'src' may underflow too. These issues never happen if input (compressed) data is correct. But they may happen if input data is invalid (error or intentional tampering). As a consequence, use these functions in trusted environments with trusted data **only**.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_fast", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_fast", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_fast(byte* src, byte* dst, int originalSize); public static extern int LZ4_decompress_fast(byte** src, byte** dst, int originalSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_fast_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_fast_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_fast_continue(LZ4_streamDecode_u* LZ4_streamDecode, byte* src, byte* dst, int originalSize); public static extern int LZ4_decompress_fast_continue(LZ4_streamDecode_u* LZ4_streamDecode, byte** src, byte** dst, int originalSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_fast_usingDict", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_decompress_fast_usingDict", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_decompress_fast_usingDict(byte* src, byte* dst, int originalSize, byte* dictStart, int dictSize); public static extern int LZ4_decompress_fast_usingDict(byte** src, byte** dst, int originalSize, byte** dictStart, int dictSize);
/// <summary>LZ4_resetStream() : An LZ4_stream_t structure must be initialized at least once. This is done with LZ4_initStream(), or LZ4_resetStream(). Consider switching to LZ4_initStream(), invoking LZ4_resetStream() will trigger deprecation warnings in the future.</summary> /// <summary>LZ4_resetStream() : An LZ4_stream_t structure must be initialized at least once. This is done with LZ4_initStream(), or LZ4_resetStream(). Consider switching to LZ4_initStream(), invoking LZ4_resetStream() will trigger deprecation warnings in the future.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_resetStream", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_resetStream", CallingConvention = CallingConvention.Cdecl)]
@ -166,18 +166,18 @@ namespace CsBindgen
/// <summary>LZ4_compress_HC() : Compress data from `src` into `dst`, using the powerful but slower \"HC\" algorithm. `dst` must be already allocated. Compression is guaranteed to succeed if `dstCapacity &gt;= LZ4_compressBound(srcSize)` (see \"lz4.h\") Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see \"lz4.h\") `compressionLevel` : any value between 1 and LZ4HC_CLEVEL_MAX will work. Values &gt; LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX. @return : the number of bytes written into 'dst' or 0 if compression fails.</summary> /// <summary>LZ4_compress_HC() : Compress data from `src` into `dst`, using the powerful but slower \"HC\" algorithm. `dst` must be already allocated. Compression is guaranteed to succeed if `dstCapacity &gt;= LZ4_compressBound(srcSize)` (see \"lz4.h\") Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see \"lz4.h\") `compressionLevel` : any value between 1 and LZ4HC_CLEVEL_MAX will work. Values &gt; LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX. @return : the number of bytes written into 'dst' or 0 if compression fails.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_HC(byte* src, byte* dst, int srcSize, int dstCapacity, int compressionLevel); public static extern int LZ4_compress_HC(byte** src, byte** dst, int srcSize, int dstCapacity, int compressionLevel);
/// <summary>LZ4_compress_HC_extStateHC() : Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`. `state` size is provided by LZ4_sizeofStateHC(). Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).</summary> /// <summary>LZ4_compress_HC_extStateHC() : Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`. `state` size is provided by LZ4_sizeofStateHC(). Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_sizeofStateHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_sizeofStateHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_sizeofStateHC(); public static extern int LZ4_sizeofStateHC();
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC_extStateHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC_extStateHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_HC_extStateHC(void* stateHC, byte* src, byte* dst, int srcSize, int maxDstSize, int compressionLevel); public static extern int LZ4_compress_HC_extStateHC(void* stateHC, byte** src, byte** dst, int srcSize, int maxDstSize, int compressionLevel);
/// <summary>LZ4_compress_HC_destSize() : v1.9.0+ Will compress as much data as possible from `src` to fit into `targetDstSize` budget. Result is provided in 2 parts : @return : the number of bytes written into 'dst' (necessarily &lt;= targetDstSize) or 0 if compression fails. `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src`</summary> /// <summary>LZ4_compress_HC_destSize() : v1.9.0+ Will compress as much data as possible from `src` to fit into `targetDstSize` budget. Result is provided in 2 parts : @return : the number of bytes written into 'dst' (necessarily &lt;= targetDstSize) or 0 if compression fails. `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src`</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC_destSize", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC_destSize", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_HC_destSize(void* stateHC, byte* src, byte* dst, int* srcSizePtr, int targetDstSize, int compressionLevel); public static extern int LZ4_compress_HC_destSize(void* stateHC, byte** src, byte** dst, int* srcSizePtr, int targetDstSize, int compressionLevel);
/// <summary>LZ4_createStreamHC() and LZ4_freeStreamHC() : These functions create and release memory for LZ4 HC streaming state. Newly created states are automatically initialized. A same state can be used multiple times consecutively, starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.</summary> /// <summary>LZ4_createStreamHC() and LZ4_freeStreamHC() : These functions create and release memory for LZ4 HC streaming state. Newly created states are automatically initialized. A same state can be used multiple times consecutively, starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_createStreamHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_createStreamHC", CallingConvention = CallingConvention.Cdecl)]
@ -190,71 +190,71 @@ namespace CsBindgen
public static extern void LZ4_resetStreamHC_fast(LZ4_streamHC_u* streamHCPtr, int compressionLevel); public static extern void LZ4_resetStreamHC_fast(LZ4_streamHC_u* streamHCPtr, int compressionLevel);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_loadDictHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_loadDictHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_loadDictHC(LZ4_streamHC_u* streamHCPtr, byte* dictionary, int dictSize); public static extern int LZ4_loadDictHC(LZ4_streamHC_u* streamHCPtr, byte** dictionary, int dictSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_HC_continue(LZ4_streamHC_u* streamHCPtr, byte* src, byte* dst, int srcSize, int maxDstSize); public static extern int LZ4_compress_HC_continue(LZ4_streamHC_u* streamHCPtr, byte** src, byte** dst, int srcSize, int maxDstSize);
/// <summary>LZ4_compress_HC_continue_destSize() : v1.9.0+ Similar to LZ4_compress_HC_continue(), but will read as much data as possible from `src` to fit into `targetDstSize` budget. Result is provided into 2 parts : @return : the number of bytes written into 'dst' (necessarily &lt;= targetDstSize) or 0 if compression fails. `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`. Note that this function may not consume the entire input.</summary> /// <summary>LZ4_compress_HC_continue_destSize() : v1.9.0+ Similar to LZ4_compress_HC_continue(), but will read as much data as possible from `src` to fit into `targetDstSize` budget. Result is provided into 2 parts : @return : the number of bytes written into 'dst' (necessarily &lt;= targetDstSize) or 0 if compression fails. `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`. Note that this function may not consume the entire input.</summary>
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC_continue_destSize", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compress_HC_continue_destSize", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compress_HC_continue_destSize(LZ4_streamHC_u* LZ4_streamHCPtr, byte* src, byte* dst, int* srcSizePtr, int targetDstSize); public static extern int LZ4_compress_HC_continue_destSize(LZ4_streamHC_u* LZ4_streamHCPtr, byte** src, byte** dst, int* srcSizePtr, int targetDstSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_saveDictHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_saveDictHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_saveDictHC(LZ4_streamHC_u* streamHCPtr, byte* safeBuffer, int maxDictSize); public static extern int LZ4_saveDictHC(LZ4_streamHC_u* streamHCPtr, byte** safeBuffer, int maxDictSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_initStreamHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_initStreamHC", CallingConvention = CallingConvention.Cdecl)]
public static extern LZ4_streamHC_u* LZ4_initStreamHC(void* buffer, UIntPtr size); public static extern LZ4_streamHC_u* LZ4_initStreamHC(void* buffer, UIntPtr size);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC(byte* source, byte* dest, int inputSize); public static extern int LZ4_compressHC(byte** source, byte** dest, int inputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_limitedOutput", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_limitedOutput", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC_limitedOutput(byte* source, byte* dest, int inputSize, int maxOutputSize); public static extern int LZ4_compressHC_limitedOutput(byte** source, byte** dest, int inputSize, int maxOutputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC2(byte* source, byte* dest, int inputSize, int compressionLevel); public static extern int LZ4_compressHC2(byte** source, byte** dest, int inputSize, int compressionLevel);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_limitedOutput", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_limitedOutput", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC2_limitedOutput(byte* source, byte* dest, int inputSize, int maxOutputSize, int compressionLevel); public static extern int LZ4_compressHC2_limitedOutput(byte** source, byte** dest, int inputSize, int maxOutputSize, int compressionLevel);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_withStateHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_withStateHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC_withStateHC(void* state, byte* source, byte* dest, int inputSize); public static extern int LZ4_compressHC_withStateHC(void* state, byte** source, byte** dest, int inputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_limitedOutput_withStateHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_limitedOutput_withStateHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC_limitedOutput_withStateHC(void* state, byte* source, byte* dest, int inputSize, int maxOutputSize); public static extern int LZ4_compressHC_limitedOutput_withStateHC(void* state, byte** source, byte** dest, int inputSize, int maxOutputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_withStateHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_withStateHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC2_withStateHC(void* state, byte* source, byte* dest, int inputSize, int compressionLevel); public static extern int LZ4_compressHC2_withStateHC(void* state, byte** source, byte** dest, int inputSize, int compressionLevel);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_limitedOutput_withStateHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_limitedOutput_withStateHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC2_limitedOutput_withStateHC(void* state, byte* source, byte* dest, int inputSize, int maxOutputSize, int compressionLevel); public static extern int LZ4_compressHC2_limitedOutput_withStateHC(void* state, byte** source, byte** dest, int inputSize, int maxOutputSize, int compressionLevel);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC_continue(LZ4_streamHC_u* LZ4_streamHCPtr, byte* source, byte* dest, int inputSize); public static extern int LZ4_compressHC_continue(LZ4_streamHC_u* LZ4_streamHCPtr, byte** source, byte** dest, int inputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_limitedOutput_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC_limitedOutput_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC_limitedOutput_continue(LZ4_streamHC_u* LZ4_streamHCPtr, byte* source, byte* dest, int inputSize, int maxOutputSize); public static extern int LZ4_compressHC_limitedOutput_continue(LZ4_streamHC_u* LZ4_streamHCPtr, byte** source, byte** dest, int inputSize, int maxOutputSize);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_createHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_createHC", CallingConvention = CallingConvention.Cdecl)]
public static extern void* LZ4_createHC(byte* inputBuffer); public static extern void* LZ4_createHC(byte** inputBuffer);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_freeHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_freeHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_freeHC(void* LZ4HC_Data); public static extern int LZ4_freeHC(void* LZ4HC_Data);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_slideInputBufferHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_slideInputBufferHC", CallingConvention = CallingConvention.Cdecl)]
public static extern byte* LZ4_slideInputBufferHC(void* LZ4HC_Data); public static extern byte** LZ4_slideInputBufferHC(void* LZ4HC_Data);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC2_continue(void* LZ4HC_Data, byte* source, byte* dest, int inputSize, int compressionLevel); public static extern int LZ4_compressHC2_continue(void* LZ4HC_Data, byte** source, byte** dest, int inputSize, int compressionLevel);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_limitedOutput_continue", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_compressHC2_limitedOutput_continue", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_compressHC2_limitedOutput_continue(void* LZ4HC_Data, byte* source, byte* dest, int inputSize, int maxOutputSize, int compressionLevel); public static extern int LZ4_compressHC2_limitedOutput_continue(void* LZ4HC_Data, byte** source, byte** dest, int inputSize, int maxOutputSize, int compressionLevel);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_sizeofStreamStateHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_sizeofStreamStateHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_sizeofStreamStateHC(); public static extern int LZ4_sizeofStreamStateHC();
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_resetStreamStateHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_resetStreamStateHC", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4_resetStreamStateHC(void* state, byte* inputBuffer); public static extern int LZ4_resetStreamStateHC(void* state, byte** inputBuffer);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4_resetStreamHC", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4_resetStreamHC", CallingConvention = CallingConvention.Cdecl)]
public static extern void LZ4_resetStreamHC(LZ4_streamHC_u* streamHCPtr, int compressionLevel); public static extern void LZ4_resetStreamHC(LZ4_streamHC_u* streamHCPtr, int compressionLevel);
@ -263,7 +263,7 @@ namespace CsBindgen
public static extern uint LZ4F_isError(UIntPtr code); public static extern uint LZ4F_isError(UIntPtr code);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4F_getErrorName", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4F_getErrorName", CallingConvention = CallingConvention.Cdecl)]
public static extern byte* LZ4F_getErrorName(UIntPtr code); public static extern byte** LZ4F_getErrorName(UIntPtr code);
[DllImport(__DllName, EntryPoint = "csbindgen_LZ4F_compressionLevel_max", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "csbindgen_LZ4F_compressionLevel_max", CallingConvention = CallingConvention.Cdecl)]
public static extern int LZ4F_compressionLevel_max(); public static extern int LZ4F_compressionLevel_max();
@ -332,70 +332,6 @@ namespace CsBindgen
} }
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct LZ4_stream_t_internal
{
public fixed uint hashTable[4096];
public byte* dictionary;
public LZ4_stream_t_internal* dictCtx;
public uint currentOffset;
public uint tableType;
public uint dictSize;
}
[StructLayout(LayoutKind.Explicit)]
public unsafe partial struct LZ4_stream_u
{
[FieldOffset(0)]
public fixed byte minStateSize[16416];
[FieldOffset(0)]
public LZ4_stream_t_internal internal_donotuse;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct LZ4_streamDecode_t_internal
{
public byte* externalDict;
public byte* prefixEnd;
public UIntPtr extDictSize;
public UIntPtr prefixSize;
}
[StructLayout(LayoutKind.Explicit)]
public unsafe partial struct LZ4_streamDecode_u
{
[FieldOffset(0)]
public fixed byte minStateSize[32];
[FieldOffset(0)]
public LZ4_streamDecode_t_internal internal_donotuse;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct LZ4HC_CCtx_internal
{
public fixed uint hashTable[32768];
public fixed ushort chainTable[65536];
public byte* end;
public byte* prefixStart;
public byte* dictStart;
public uint dictLimit;
public uint lowLimit;
public uint nextToUpdate;
public short compressionLevel;
public sbyte favorDecSpeed;
public sbyte dirty;
public LZ4HC_CCtx_internal* dictCtx;
}
[StructLayout(LayoutKind.Explicit)]
public unsafe partial struct LZ4_streamHC_u
{
[FieldOffset(0)]
public fixed byte minStateSize[262200];
[FieldOffset(0)]
public LZ4HC_CCtx_internal internal_donotuse;
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe partial struct LZ4F_frameInfo_t public unsafe partial struct LZ4F_frameInfo_t
{ {
@ -418,12 +354,6 @@ namespace CsBindgen
public fixed uint reserved[3]; public fixed uint reserved[3];
} }
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct LZ4F_cctx_s
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe partial struct LZ4F_compressOptions_t public unsafe partial struct LZ4F_compressOptions_t
{ {
@ -431,12 +361,6 @@ namespace CsBindgen
public fixed uint reserved[3]; public fixed uint reserved[3];
} }
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct LZ4F_dctx_s
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public unsafe partial struct LZ4F_decompressOptions_t public unsafe partial struct LZ4F_decompressOptions_t
{ {

560
dotnet-sandbox/quiche_bindgen.cs vendored Normal file
View File

@ -0,0 +1,560 @@
// <auto-generated>
// This code is generated by csbindgen.
// DON'T CHANGE THIS DIRECTLY.
// </auto-generated>
using System;
using System.Runtime.InteropServices;
namespace CsBindgen
{
internal static unsafe partial class LibQuiche
{
const string __DllName = "libquiche";
[DllImport(__DllName, EntryPoint = "quiche_version", CallingConvention = CallingConvention.Cdecl)]
public static extern byte** quiche_version();
[DllImport(__DllName, EntryPoint = "quiche_enable_debug_logging", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_enable_debug_logging(delegate* unmanaged[Cdecl]<byte**, void**, void> cb, void** argp);
[DllImport(__DllName, EntryPoint = "quiche_config_new", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_config* quiche_config_new(uint version);
[DllImport(__DllName, EntryPoint = "quiche_config_load_cert_chain_from_pem_file", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_config_load_cert_chain_from_pem_file(quiche_config* config, byte** path);
[DllImport(__DllName, EntryPoint = "quiche_config_load_priv_key_from_pem_file", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_config_load_priv_key_from_pem_file(quiche_config* config, byte** path);
[DllImport(__DllName, EntryPoint = "quiche_config_load_verify_locations_from_file", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_config_load_verify_locations_from_file(quiche_config* config, byte** path);
[DllImport(__DllName, EntryPoint = "quiche_config_load_verify_locations_from_directory", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_config_load_verify_locations_from_directory(quiche_config* config, byte** path);
[DllImport(__DllName, EntryPoint = "quiche_config_verify_peer", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_verify_peer(quiche_config* config, [MarshalAs(UnmanagedType.U1)] bool v);
[DllImport(__DllName, EntryPoint = "quiche_config_grease", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_grease(quiche_config* config, [MarshalAs(UnmanagedType.U1)] bool v);
[DllImport(__DllName, EntryPoint = "quiche_config_log_keys", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_log_keys(quiche_config* config);
[DllImport(__DllName, EntryPoint = "quiche_config_enable_early_data", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_enable_early_data(quiche_config* config);
[DllImport(__DllName, EntryPoint = "quiche_config_set_application_protos", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_config_set_application_protos(quiche_config* config, byte* protos, UIntPtr protos_len);
[DllImport(__DllName, EntryPoint = "quiche_config_set_max_idle_timeout", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_max_idle_timeout(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_max_recv_udp_payload_size", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_max_recv_udp_payload_size(quiche_config* config, UIntPtr v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_max_send_udp_payload_size", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_max_send_udp_payload_size(quiche_config* config, UIntPtr v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_initial_max_data", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_initial_max_data(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_initial_max_stream_data_bidi_local", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_initial_max_stream_data_bidi_local(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_initial_max_stream_data_bidi_remote", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_initial_max_stream_data_bidi_remote(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_initial_max_stream_data_uni", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_initial_max_stream_data_uni(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_initial_max_streams_bidi", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_initial_max_streams_bidi(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_initial_max_streams_uni", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_initial_max_streams_uni(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_ack_delay_exponent", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_ack_delay_exponent(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_max_ack_delay", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_max_ack_delay(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_disable_active_migration", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_disable_active_migration(quiche_config* config, [MarshalAs(UnmanagedType.U1)] bool v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_cc_algorithm", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_cc_algorithm(quiche_config* config, int algo);
[DllImport(__DllName, EntryPoint = "quiche_config_enable_hystart", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_enable_hystart(quiche_config* config, [MarshalAs(UnmanagedType.U1)] bool v);
[DllImport(__DllName, EntryPoint = "quiche_config_enable_pacing", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_enable_pacing(quiche_config* config, [MarshalAs(UnmanagedType.U1)] bool v);
[DllImport(__DllName, EntryPoint = "quiche_config_enable_dgram", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_enable_dgram(quiche_config* config, [MarshalAs(UnmanagedType.U1)] bool enabled, UIntPtr recv_queue_len, UIntPtr send_queue_len);
[DllImport(__DllName, EntryPoint = "quiche_config_set_max_connection_window", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_max_connection_window(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_max_stream_window", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_max_stream_window(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_active_connection_id_limit", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_active_connection_id_limit(quiche_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_config_set_stateless_reset_token", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_set_stateless_reset_token(quiche_config* config, byte* v);
[DllImport(__DllName, EntryPoint = "quiche_config_free", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_config_free(quiche_config* config);
[DllImport(__DllName, EntryPoint = "quiche_header_info", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_header_info(byte* buf, UIntPtr buf_len, UIntPtr dcil, uint* version, byte* type_, byte* scid, UIntPtr* scid_len, byte* dcid, UIntPtr* dcid_len, byte* token, UIntPtr* token_len);
[DllImport(__DllName, EntryPoint = "quiche_accept", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_conn* quiche_accept(byte* scid, UIntPtr scid_len, byte* odcid, UIntPtr odcid_len, sockaddr* local, UIntPtr local_len, sockaddr* peer, UIntPtr peer_len, quiche_config* config);
[DllImport(__DllName, EntryPoint = "quiche_connect", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_conn* quiche_connect(byte** server_name, byte* scid, UIntPtr scid_len, sockaddr* local, UIntPtr local_len, sockaddr* peer, UIntPtr peer_len, quiche_config* config);
[DllImport(__DllName, EntryPoint = "quiche_negotiate_version", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_negotiate_version(byte* scid, UIntPtr scid_len, byte* dcid, UIntPtr dcid_len, byte* @out, UIntPtr out_len);
[DllImport(__DllName, EntryPoint = "quiche_retry", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_retry(byte* scid, UIntPtr scid_len, byte* dcid, UIntPtr dcid_len, byte* new_scid, UIntPtr new_scid_len, byte* token, UIntPtr token_len, uint version, byte* @out, UIntPtr out_len);
[DllImport(__DllName, EntryPoint = "quiche_version_is_supported", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_version_is_supported(uint version);
[DllImport(__DllName, EntryPoint = "quiche_conn_new_with_tls", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_conn* quiche_conn_new_with_tls(byte* scid, UIntPtr scid_len, byte* odcid, UIntPtr odcid_len, sockaddr* local, UIntPtr local_len, sockaddr* peer, UIntPtr peer_len, quiche_config* config, void** ssl, [MarshalAs(UnmanagedType.U1)] bool is_server);
[DllImport(__DllName, EntryPoint = "quiche_conn_set_keylog_path", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_set_keylog_path(quiche_conn* conn, byte** path);
[DllImport(__DllName, EntryPoint = "quiche_conn_set_keylog_fd", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_set_keylog_fd(quiche_conn* conn, int fd);
[DllImport(__DllName, EntryPoint = "quiche_conn_set_qlog_path", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_set_qlog_path(quiche_conn* conn, byte** path, byte** log_title, byte** log_desc);
[DllImport(__DllName, EntryPoint = "quiche_conn_set_qlog_fd", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_set_qlog_fd(quiche_conn* conn, int fd, byte** log_title, byte** log_desc);
[DllImport(__DllName, EntryPoint = "quiche_conn_set_session", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_conn_set_session(quiche_conn* conn, byte* buf, UIntPtr buf_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_recv", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_recv(quiche_conn* conn, byte* buf, UIntPtr buf_len, quiche_recv_info* info);
[DllImport(__DllName, EntryPoint = "quiche_conn_send", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_send(quiche_conn* conn, byte* @out, UIntPtr out_len, quiche_send_info* out_info);
[DllImport(__DllName, EntryPoint = "quiche_conn_send_quantum", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr quiche_conn_send_quantum(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_recv", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_stream_recv(quiche_conn* conn, ulong stream_id, byte* @out, UIntPtr buf_len, bool* fin);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_send", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_stream_send(quiche_conn* conn, ulong stream_id, byte* buf, UIntPtr buf_len, [MarshalAs(UnmanagedType.U1)] bool fin);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_priority", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_conn_stream_priority(quiche_conn* conn, ulong stream_id, byte urgency, [MarshalAs(UnmanagedType.U1)] bool incremental);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_shutdown", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_conn_stream_shutdown(quiche_conn* conn, ulong stream_id, int direction, ulong err);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_capacity", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_stream_capacity(quiche_conn* conn, ulong stream_id);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_readable", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_stream_readable(quiche_conn* conn, ulong stream_id);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_readable_next", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_stream_readable_next(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_writable", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_conn_stream_writable(quiche_conn* conn, ulong stream_id, UIntPtr len);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_writable_next", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_stream_writable_next(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_finished", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_stream_finished(quiche_conn* conn, ulong stream_id);
[DllImport(__DllName, EntryPoint = "quiche_conn_readable", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_stream_iter* quiche_conn_readable(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_writable", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_stream_iter* quiche_conn_writable(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_max_send_udp_payload_size", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr quiche_conn_max_send_udp_payload_size(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_timeout_as_nanos", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong quiche_conn_timeout_as_nanos(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_timeout_as_millis", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong quiche_conn_timeout_as_millis(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_on_timeout", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_on_timeout(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_close", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_conn_close(quiche_conn* conn, [MarshalAs(UnmanagedType.U1)] bool app, ulong err, byte* reason, UIntPtr reason_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_trace_id", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_trace_id(quiche_conn* conn, byte** @out, UIntPtr* out_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_source_id", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_source_id(quiche_conn* conn, byte** @out, UIntPtr* out_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_destination_id", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_destination_id(quiche_conn* conn, byte** @out, UIntPtr* out_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_application_proto", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_application_proto(quiche_conn* conn, byte** @out, UIntPtr* out_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_peer_cert", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_peer_cert(quiche_conn* conn, byte** @out, UIntPtr* out_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_session", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_session(quiche_conn* conn, byte** @out, UIntPtr* out_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_is_established", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_is_established(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_is_in_early_data", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_is_in_early_data(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_is_readable", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_is_readable(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_is_draining", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_is_draining(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_peer_streams_left_bidi", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong quiche_conn_peer_streams_left_bidi(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_peer_streams_left_uni", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong quiche_conn_peer_streams_left_uni(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_is_closed", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_is_closed(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_is_timed_out", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_is_timed_out(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_peer_error", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_peer_error(quiche_conn* conn, bool* is_app, ulong* error_code, byte** reason, UIntPtr* reason_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_local_error", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_conn_local_error(quiche_conn* conn, bool* is_app, ulong* error_code, byte** reason, UIntPtr* reason_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_init_application_data", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_conn_stream_init_application_data(quiche_conn* conn, ulong stream_id, void** data);
[DllImport(__DllName, EntryPoint = "quiche_conn_stream_application_data", CallingConvention = CallingConvention.Cdecl)]
public static extern void** quiche_conn_stream_application_data(quiche_conn* conn, ulong stream_id);
[DllImport(__DllName, EntryPoint = "quiche_stream_iter_next", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_stream_iter_next(quiche_stream_iter* iter, ulong* stream_id);
[DllImport(__DllName, EntryPoint = "quiche_stream_iter_free", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_stream_iter_free(quiche_stream_iter* iter);
[DllImport(__DllName, EntryPoint = "quiche_conn_stats", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_stats(quiche_conn* conn, quiche_stats* @out);
[DllImport(__DllName, EntryPoint = "quiche_conn_path_stats", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_conn_path_stats(quiche_conn* conn, UIntPtr idx, quiche_path_stats* @out);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_max_writable_len", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_dgram_max_writable_len(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_recv_front_len", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_dgram_recv_front_len(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_recv_queue_len", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_dgram_recv_queue_len(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_recv_queue_byte_size", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_dgram_recv_queue_byte_size(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_send_queue_len", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_dgram_send_queue_len(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_send_queue_byte_size", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_dgram_send_queue_byte_size(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_recv", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_dgram_recv(quiche_conn* conn, byte* buf, UIntPtr buf_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_send", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_dgram_send(quiche_conn* conn, byte* buf, UIntPtr buf_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_dgram_purge_outgoing", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_dgram_purge_outgoing(quiche_conn* conn, delegate* unmanaged[Cdecl]<byte*, UIntPtr, bool> f);
[DllImport(__DllName, EntryPoint = "quiche_conn_send_ack_eliciting", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_send_ack_eliciting(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_conn_send_ack_eliciting_on_path", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_conn_send_ack_eliciting_on_path(quiche_conn* conn, sockaddr* local, UIntPtr local_len, sockaddr* peer, UIntPtr peer_len);
[DllImport(__DllName, EntryPoint = "quiche_conn_free", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_conn_free(quiche_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_h3_config_new", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_h3_config* quiche_h3_config_new();
[DllImport(__DllName, EntryPoint = "quiche_h3_config_set_max_field_section_size", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_h3_config_set_max_field_section_size(quiche_h3_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_h3_config_set_qpack_max_table_capacity", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_h3_config_set_qpack_max_table_capacity(quiche_h3_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_h3_config_set_qpack_blocked_streams", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_h3_config_set_qpack_blocked_streams(quiche_h3_config* config, ulong v);
[DllImport(__DllName, EntryPoint = "quiche_h3_config_enable_extended_connect", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_h3_config_enable_extended_connect(quiche_h3_config* config, [MarshalAs(UnmanagedType.U1)] bool enabled);
[DllImport(__DllName, EntryPoint = "quiche_h3_config_free", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_h3_config_free(quiche_h3_config* config);
[DllImport(__DllName, EntryPoint = "quiche_h3_accept", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_h3_conn* quiche_h3_accept(quiche_conn* quiche_conn, quiche_h3_config* config);
[DllImport(__DllName, EntryPoint = "quiche_h3_conn_new_with_transport", CallingConvention = CallingConvention.Cdecl)]
public static extern quiche_h3_conn* quiche_h3_conn_new_with_transport(quiche_conn* quiche_conn, quiche_h3_config* config);
[DllImport(__DllName, EntryPoint = "quiche_h3_conn_poll", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_h3_conn_poll(quiche_h3_conn* conn, quiche_conn* quic_conn, quiche_h3_event** ev);
[DllImport(__DllName, EntryPoint = "quiche_h3_event_type", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_h3_event_type(quiche_h3_event* ev);
[DllImport(__DllName, EntryPoint = "quiche_h3_event_for_each_header", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_h3_event_for_each_header(quiche_h3_event* ev, delegate* unmanaged[Cdecl]<byte*, UIntPtr, byte*, UIntPtr, void**, int> cb, void** argp);
[DllImport(__DllName, EntryPoint = "quiche_h3_for_each_setting", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_h3_for_each_setting(quiche_h3_conn* conn, delegate* unmanaged[Cdecl]<ulong, ulong, void**, int> cb, void** argp);
[DllImport(__DllName, EntryPoint = "quiche_h3_event_headers_has_body", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_h3_event_headers_has_body(quiche_h3_event* ev);
[DllImport(__DllName, EntryPoint = "quiche_h3_extended_connect_enabled_by_peer", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_h3_extended_connect_enabled_by_peer(quiche_h3_conn* conn);
[DllImport(__DllName, EntryPoint = "quiche_h3_event_free", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_h3_event_free(quiche_h3_event* ev);
[DllImport(__DllName, EntryPoint = "quiche_h3_send_request", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_h3_send_request(quiche_h3_conn* conn, quiche_conn* quic_conn, quiche_h3_header* headers, UIntPtr headers_len, [MarshalAs(UnmanagedType.U1)] bool fin);
[DllImport(__DllName, EntryPoint = "quiche_h3_send_response", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_h3_send_response(quiche_h3_conn* conn, quiche_conn* quic_conn, ulong stream_id, quiche_h3_header* headers, UIntPtr headers_len, [MarshalAs(UnmanagedType.U1)] bool fin);
[DllImport(__DllName, EntryPoint = "quiche_h3_send_response_with_priority", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_h3_send_response_with_priority(quiche_h3_conn* conn, quiche_conn* quic_conn, ulong stream_id, quiche_h3_header* headers, UIntPtr headers_len, quiche_h3_priority* priority, [MarshalAs(UnmanagedType.U1)] bool fin);
[DllImport(__DllName, EntryPoint = "quiche_h3_send_body", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_h3_send_body(quiche_h3_conn* conn, quiche_conn* quic_conn, ulong stream_id, byte* body, UIntPtr body_len, [MarshalAs(UnmanagedType.U1)] bool fin);
[DllImport(__DllName, EntryPoint = "quiche_h3_recv_body", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_h3_recv_body(quiche_h3_conn* conn, quiche_conn* quic_conn, ulong stream_id, byte* @out, UIntPtr out_len);
[DllImport(__DllName, EntryPoint = "quiche_h3_parse_extensible_priority", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_h3_parse_extensible_priority(byte* priority, UIntPtr priority_len, quiche_h3_priority* parsed);
/// <summary>Sends a PRIORITY_UPDATE frame on the control stream with specified request stream ID and priority.</summary>
[DllImport(__DllName, EntryPoint = "quiche_h3_send_priority_update_for_request", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_h3_send_priority_update_for_request(quiche_h3_conn* conn, quiche_conn* quic_conn, ulong stream_id, quiche_h3_priority* priority);
[DllImport(__DllName, EntryPoint = "quiche_h3_take_last_priority_update", CallingConvention = CallingConvention.Cdecl)]
public static extern int quiche_h3_take_last_priority_update(quiche_h3_conn* conn, ulong prioritized_element_id, delegate* unmanaged[Cdecl]<byte*, ulong, void**, int> cb, void** argp);
[DllImport(__DllName, EntryPoint = "quiche_h3_dgram_enabled_by_peer", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool quiche_h3_dgram_enabled_by_peer(quiche_h3_conn* conn, quiche_conn* quic_conn);
[DllImport(__DllName, EntryPoint = "quiche_h3_send_dgram", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_h3_send_dgram(quiche_h3_conn* conn, quiche_conn* quic_conn, ulong flow_id, byte* data, UIntPtr data_len);
[DllImport(__DllName, EntryPoint = "quiche_h3_recv_dgram", CallingConvention = CallingConvention.Cdecl)]
public static extern long quiche_h3_recv_dgram(quiche_h3_conn* conn, quiche_conn* quic_conn, ulong* flow_id, UIntPtr* flow_id_len, byte* @out, UIntPtr out_len);
[DllImport(__DllName, EntryPoint = "quiche_h3_conn_free", CallingConvention = CallingConvention.Cdecl)]
public static extern void quiche_h3_conn_free(quiche_h3_conn* conn);
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct sockaddr
{
public ushort sa_family;
public fixed byte sa_data[14];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct sockaddr_storage
{
public ushort ss_family;
public fixed byte __ss_pad1[6];
public long __ss_align;
public fixed byte __ss_pad2[112];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct timespec
{
public long tv_sec;
public int* tv_nsec;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_config
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_conn
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_recv_info
{
public sockaddr* from;
public int from_len;
public sockaddr* to;
public int to_len;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_send_info
{
public sockaddr_storage from;
public int from_len;
public sockaddr_storage to;
public int to_len;
public timespec at;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_stream_iter
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_stats
{
public UIntPtr recv;
public UIntPtr sent;
public UIntPtr lost;
public UIntPtr retrans;
public ulong sent_bytes;
public ulong recv_bytes;
public ulong lost_bytes;
public ulong stream_retrans_bytes;
public UIntPtr paths_count;
public ulong peer_max_idle_timeout;
public ulong peer_max_udp_payload_size;
public ulong peer_initial_max_data;
public ulong peer_initial_max_stream_data_bidi_local;
public ulong peer_initial_max_stream_data_bidi_remote;
public ulong peer_initial_max_stream_data_uni;
public ulong peer_initial_max_streams_bidi;
public ulong peer_initial_max_streams_uni;
public ulong peer_ack_delay_exponent;
public ulong peer_max_ack_delay;
[MarshalAs(UnmanagedType.U1)] public bool peer_disable_active_migration;
public ulong peer_active_conn_id_limit;
public long peer_max_datagram_frame_size;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_path_stats
{
public sockaddr_storage local_addr;
public int local_addr_len;
public sockaddr_storage peer_addr;
public int peer_addr_len;
public long validation_state;
[MarshalAs(UnmanagedType.U1)] public bool active;
public UIntPtr recv;
public UIntPtr sent;
public UIntPtr lost;
public UIntPtr retrans;
public ulong rtt;
public UIntPtr cwnd;
public ulong sent_bytes;
public ulong recv_bytes;
public ulong lost_bytes;
public ulong stream_retrans_bytes;
public UIntPtr pmtu;
public ulong delivery_rate;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_h3_config
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_h3_conn
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_h3_event
{
public fixed byte _unused[1];
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_h3_header
{
public byte* name;
public UIntPtr name_len;
public byte* value;
public UIntPtr value_len;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct quiche_h3_priority
{
public byte urgency;
[MarshalAs(UnmanagedType.U1)] public bool incremental;
}
}

268
dotnet-sandbox/zstd_bindgen.cs vendored Normal file
View File

@ -0,0 +1,268 @@
// <auto-generated>
// This code is generated by csbindgen.
// DON'T CHANGE THIS DIRECTLY.
// </auto-generated>
using System;
using System.Runtime.InteropServices;
namespace CsBindgen
{
internal static unsafe partial class LibZstd
{
const string __DllName = "libzsd";
/// <summary>ZSTD_versionNumber() : Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_versionNumber", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ZSTD_versionNumber();
/// <summary>ZSTD_versionString() : Return runtime library version, like \"1.4.5\". Requires v1.3.0+.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_versionString", CallingConvention = CallingConvention.Cdecl)]
public static extern byte** ZSTD_versionString();
/// <summary>Simple API//*! ZSTD_compress() : Compresses `src` content as a single zstd compressed frame into already allocated `dst`. Hint : compression runs faster if `dstCapacity` &gt;= `ZSTD_compressBound(srcSize)`. @return : compressed size written into `dst` (&lt;= `dstCapacity), or an error code if it fails (which can be tested using ZSTD_isError()).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_compress", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_compress(void* dst, UIntPtr dstCapacity, void* src, UIntPtr srcSize, int compressionLevel);
/// <summary>ZSTD_decompress() : `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames. `dstCapacity` is an upper bound of originalSize to regenerate. If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data. @return : the number of bytes decompressed into `dst` (&lt;= `dstCapacity`), or an errorCode if it fails (which can be tested using ZSTD_isError()).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_decompress", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_decompress(void* dst, UIntPtr dstCapacity, void* src, UIntPtr compressedSize);
[DllImport(__DllName, EntryPoint = "ZSTD_getFrameContentSize", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ZSTD_getFrameContentSize(void* src, UIntPtr srcSize);
/// <summary>ZSTD_getDecompressedSize() : NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize(). Both functions work the same way, but ZSTD_getDecompressedSize() blends \"empty\", \"unknown\" and \"error\" results to the same return value (0), while ZSTD_getFrameContentSize() gives them separate return values. @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_getDecompressedSize", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ZSTD_getDecompressedSize(void* src, UIntPtr srcSize);
/// <summary>ZSTD_findFrameCompressedSize() : Requires v1.4.0+ `src` should point to the start of a ZSTD frame or skippable frame. `srcSize` must be &gt;= first frame size @return : the compressed size of the first frame starting at `src`, suitable to pass as `srcSize` to `ZSTD_decompress` or similar, or an error code if input is invalid</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_findFrameCompressedSize", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_findFrameCompressedSize(void* src, UIntPtr srcSize);
[DllImport(__DllName, EntryPoint = "ZSTD_compressBound", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_compressBound(UIntPtr srcSize);
[DllImport(__DllName, EntryPoint = "ZSTD_isError", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ZSTD_isError(UIntPtr code);
[DllImport(__DllName, EntryPoint = "ZSTD_getErrorName", CallingConvention = CallingConvention.Cdecl)]
public static extern byte** ZSTD_getErrorName(UIntPtr code);
[DllImport(__DllName, EntryPoint = "ZSTD_minCLevel", CallingConvention = CallingConvention.Cdecl)]
public static extern int ZSTD_minCLevel();
[DllImport(__DllName, EntryPoint = "ZSTD_maxCLevel", CallingConvention = CallingConvention.Cdecl)]
public static extern int ZSTD_maxCLevel();
[DllImport(__DllName, EntryPoint = "ZSTD_defaultCLevel", CallingConvention = CallingConvention.Cdecl)]
public static extern int ZSTD_defaultCLevel();
[DllImport(__DllName, EntryPoint = "ZSTD_createCCtx", CallingConvention = CallingConvention.Cdecl)]
public static extern ZSTD_CCtx_s* ZSTD_createCCtx();
[DllImport(__DllName, EntryPoint = "ZSTD_freeCCtx", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_freeCCtx(ZSTD_CCtx_s* cctx);
/// <summary>ZSTD_compressCCtx() : Same as ZSTD_compress(), using an explicit ZSTD_CCtx. Important : in order to behave similarly to `ZSTD_compress()`, this function compresses at requested compression level, __ignoring any other parameter__ . If any advanced parameter was set using the advanced API, they will all be reset. Only `compressionLevel` remains.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_compressCCtx", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_compressCCtx(ZSTD_CCtx_s* cctx, void* dst, UIntPtr dstCapacity, void* src, UIntPtr srcSize, int compressionLevel);
[DllImport(__DllName, EntryPoint = "ZSTD_createDCtx", CallingConvention = CallingConvention.Cdecl)]
public static extern ZSTD_DCtx_s* ZSTD_createDCtx();
[DllImport(__DllName, EntryPoint = "ZSTD_freeDCtx", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_freeDCtx(ZSTD_DCtx_s* dctx);
/// <summary>ZSTD_decompressDCtx() : Same as ZSTD_decompress(), requires an allocated ZSTD_DCtx. Compatible with sticky parameters.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_decompressDCtx", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_decompressDCtx(ZSTD_DCtx_s* dctx, void* dst, UIntPtr dstCapacity, void* src, UIntPtr srcSize);
/// <summary>ZSTD_cParam_getBounds() : All parameters must belong to an interval with lower and upper bounds, otherwise they will either trigger an error or be automatically clamped. @return : a structure, ZSTD_bounds, which contains - an error status field, which must be tested using ZSTD_isError() - lower and upper bounds, both inclusive</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_cParam_getBounds", CallingConvention = CallingConvention.Cdecl)]
public static extern ZSTD_bounds ZSTD_cParam_getBounds(int cParam);
/// <summary>ZSTD_CCtx_setParameter() : Set one compression parameter, selected by enum ZSTD_cParameter. All parameters have valid bounds. Bounds can be queried using ZSTD_cParam_getBounds(). Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). Setting a parameter is generally only possible during frame initialization (before starting compression). Exception : when using multi-threading mode (nbWorkers &gt;= 1), the following parameters can be updated _during_ compression (within same frame): =&gt; compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy. new parameters will be active for next job only (after a flush()). @return : an error code (which can be tested using ZSTD_isError()).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_CCtx_setParameter", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_CCtx_setParameter(ZSTD_CCtx_s* cctx, int param, int value);
/// <summary>ZSTD_CCtx_setPledgedSrcSize() : Total input data size to be compressed as a single frame. Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag. This value will also be controlled at end of frame, and trigger an error if not respected. @result : 0, or an error code (which can be tested with ZSTD_isError()). Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame. In order to mean \"unknown content size\", pass constant ZSTD_CONTENTSIZE_UNKNOWN. ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame. Note 2 : pledgedSrcSize is only valid once, for the next frame. It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN. Note 3 : Whenever all input data is provided and consumed in a single round, for example with ZSTD_compress2(), or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end), this value is automatically overridden by srcSize instead.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_CCtx_setPledgedSrcSize", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx_s* cctx, ulong pledgedSrcSize);
/// <summary>ZSTD_CCtx_reset() : There are 2 different things that can be reset, independently or jointly : - The session : will stop compressing current frame, and make CCtx ready to start a new one. Useful after an error, or to interrupt any ongoing compression. Any internal data not yet flushed is cancelled. Compression parameters and dictionary remain unchanged. They will be used to compress next frame. Resetting session never fails. - The parameters : changes all parameters back to \"default\". This also removes any reference to any dictionary or external sequence producer. Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing) otherwise the reset fails, and function returns an error value (which can be tested using ZSTD_isError()) - Both : similar to resetting the session, followed by resetting parameters.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_CCtx_reset", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_CCtx_reset(ZSTD_CCtx_s* cctx, int reset);
/// <summary>ZSTD_compress2() : Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API. ZSTD_compress2() always starts a new frame. Should cctx hold data from a previously unfinished frame, everything about it is forgotten. - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() - The function is always blocking, returns when compression is completed. Hint : compression runs faster if `dstCapacity` &gt;= `ZSTD_compressBound(srcSize)`. @return : compressed size written into `dst` (&lt;= `dstCapacity), or an error code if it fails (which can be tested using ZSTD_isError()).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_compress2", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_compress2(ZSTD_CCtx_s* cctx, void* dst, UIntPtr dstCapacity, void* src, UIntPtr srcSize);
/// <summary>ZSTD_dParam_getBounds() : All parameters must belong to an interval with lower and upper bounds, otherwise they will either trigger an error or be automatically clamped. @return : a structure, ZSTD_bounds, which contains - an error status field, which must be tested using ZSTD_isError() - both lower and upper bounds, inclusive</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_dParam_getBounds", CallingConvention = CallingConvention.Cdecl)]
public static extern ZSTD_bounds ZSTD_dParam_getBounds(int dParam);
/// <summary>ZSTD_DCtx_setParameter() : Set one compression parameter, selected by enum ZSTD_dParameter. All parameters have valid bounds. Bounds can be queried using ZSTD_dParam_getBounds(). Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). Setting a parameter is only possible during frame initialization (before starting decompression). @return : 0, or an error code (which can be tested using ZSTD_isError()).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_DCtx_setParameter", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_DCtx_setParameter(ZSTD_DCtx_s* dctx, int param, int value);
/// <summary>ZSTD_DCtx_reset() : Return a DCtx to clean state. Session and parameters can be reset jointly or separately. Parameters can only be reset when no active frame is being decompressed. @return : 0, or an error code, which can be tested with ZSTD_isError()</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_DCtx_reset", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_DCtx_reset(ZSTD_DCtx_s* dctx, int reset);
[DllImport(__DllName, EntryPoint = "ZSTD_createCStream", CallingConvention = CallingConvention.Cdecl)]
public static extern ZSTD_CCtx_s* ZSTD_createCStream();
[DllImport(__DllName, EntryPoint = "ZSTD_freeCStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_freeCStream(ZSTD_CCtx_s* zcs);
/// <summary>ZSTD_compressStream2() : Requires v1.4.0+ Behaves about the same as ZSTD_compressStream, with additional control on end directive. - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode) - output-&gt;pos must be &lt;= dstCapacity, input-&gt;pos must be &lt;= srcSize - output-&gt;pos and input-&gt;pos will be updated. They are guaranteed to remain below their respective limit. - endOp must be a valid directive - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller. - When nbWorkers&gt;=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available, and then immediately returns, just indicating that there is some data remaining to be flushed. The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte. - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking. - @return provides a minimum amount of data remaining to be flushed from internal buffers or an error code, which can be tested using ZSTD_isError(). if @return != 0, flush is not fully completed, there is still some data left within internal buffers. This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers. For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed. - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0), only ZSTD_e_end or ZSTD_e_flush operations are allowed. Before starting a new compression job, or changing compression parameters, it is required to fully flush internal buffers.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_compressStream2", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_compressStream2(ZSTD_CCtx_s* cctx, ZSTD_outBuffer_s* output, ZSTD_inBuffer_s* input, int endOp);
[DllImport(__DllName, EntryPoint = "ZSTD_CStreamInSize", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_CStreamInSize();
[DllImport(__DllName, EntryPoint = "ZSTD_CStreamOutSize", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_CStreamOutSize();
/// <summary>Equivalent to: ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); Note that ZSTD_initCStream() clears any previously set dictionary. Use the new API to compress with a dictionary.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_initCStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_initCStream(ZSTD_CCtx_s* zcs, int compressionLevel);
/// <summary>Alternative for ZSTD_compressStream2(zcs, output, input, ZSTD_e_continue). NOTE: The return value is different. ZSTD_compressStream() returns a hint for the next read size (if non-zero and not an error). ZSTD_compressStream2() returns the minimum nb of bytes left to flush (if non-zero and not an error).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_compressStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_compressStream(ZSTD_CCtx_s* zcs, ZSTD_outBuffer_s* output, ZSTD_inBuffer_s* input);
/// <summary>Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_flushStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_flushStream(ZSTD_CCtx_s* zcs, ZSTD_outBuffer_s* output);
/// <summary>Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end).</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_endStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_endStream(ZSTD_CCtx_s* zcs, ZSTD_outBuffer_s* output);
[DllImport(__DllName, EntryPoint = "ZSTD_createDStream", CallingConvention = CallingConvention.Cdecl)]
public static extern ZSTD_DCtx_s* ZSTD_createDStream();
[DllImport(__DllName, EntryPoint = "ZSTD_freeDStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_freeDStream(ZSTD_DCtx_s* zds);
/// <summary>ZSTD_initDStream() : Initialize/reset DStream state for new decompression operation. Call before new decompression operation using same DStream. Note : This function is redundant with the advanced API and equivalent to: ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); ZSTD_DCtx_refDDict(zds, NULL);</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_initDStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_initDStream(ZSTD_DCtx_s* zds);
/// <summary>ZSTD_decompressStream() : Streaming decompression function. Call repetitively to consume full input updating it as necessary. Function will update both input and output `pos` fields exposing current state via these fields: - `input.pos &lt; input.size`, some input remaining and caller should provide remaining input on the next call. - `output.pos &lt; output.size`, decoder finished and flushed all remaining buffers. - `output.pos == output.size`, potentially uncflushed data present in the internal buffers, call ZSTD_decompressStream() again to flush remaining data to output. Note : with no additional input, amount of data flushed &lt;= ZSTD_BLOCKSIZE_MAX. @return : 0 when a frame is completely decoded and fully flushed, or an error code, which can be tested using ZSTD_isError(), or any other value &gt; 0, which means there is some decoding or flushing to do to complete current frame.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_decompressStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_decompressStream(ZSTD_DCtx_s* zds, ZSTD_outBuffer_s* output, ZSTD_inBuffer_s* input);
[DllImport(__DllName, EntryPoint = "ZSTD_DStreamInSize", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_DStreamInSize();
[DllImport(__DllName, EntryPoint = "ZSTD_DStreamOutSize", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_DStreamOutSize();
/// <summary>Simple dictionary API//*! ZSTD_compress_usingDict() : Compression at an explicit compression level using a Dictionary. A dictionary can be any arbitrary data segment (also called a prefix), or a buffer with specified information (see zdict.h). Note : This function loads the dictionary, resulting in significant startup delay. It's intended for a dictionary used only once. Note 2 : When `dict == NULL || dictSize &lt; 8` no dictionary is used.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_compress_usingDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_compress_usingDict(ZSTD_CCtx_s* ctx, void* dst, UIntPtr dstCapacity, void* src, UIntPtr srcSize, void* dict, UIntPtr dictSize, int compressionLevel);
/// <summary>ZSTD_decompress_usingDict() : Decompression using a known Dictionary. Dictionary must be identical to the one used during compression. Note : This function loads the dictionary, resulting in significant startup delay. It's intended for a dictionary used only once. Note : When `dict == NULL || dictSize &lt; 8` no dictionary is used.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_decompress_usingDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_decompress_usingDict(ZSTD_DCtx_s* dctx, void* dst, UIntPtr dstCapacity, void* src, UIntPtr srcSize, void* dict, UIntPtr dictSize);
/// <summary>ZSTD_createCDict() : When compressing multiple messages or blocks using the same dictionary, it's recommended to digest the dictionary only once, since it's a costly operation. ZSTD_createCDict() will create a state from digesting a dictionary. The resulting state can be used for future compression operations with very limited startup cost. ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. @dictBuffer can be released after ZSTD_CDict creation, because its content is copied within CDict. Note 1 : Consider experimental function `ZSTD_createCDict_byReference()` if you prefer to not duplicate @dictBuffer content. Note 2 : A ZSTD_CDict can be created from an empty @dictBuffer, in which case the only thing that it transports is the @compressionLevel. This can be useful in a pipeline featuring ZSTD_compress_usingCDict() exclusively, expecting a ZSTD_CDict parameter with any data, including those without a known dictionary.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_createCDict", CallingConvention = CallingConvention.Cdecl)]
public static extern ZSTD_CDict_s* ZSTD_createCDict(void* dictBuffer, UIntPtr dictSize, int compressionLevel);
/// <summary>ZSTD_freeCDict() : Function frees memory allocated by ZSTD_createCDict(). If a NULL pointer is passed, no operation is performed.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_freeCDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_freeCDict(ZSTD_CDict_s* CDict);
/// <summary>ZSTD_compress_usingCDict() : Compression using a digested Dictionary. Recommended when same dictionary is used multiple times. Note : compression level is _decided at dictionary creation time_, and frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no)</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_compress_usingCDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_compress_usingCDict(ZSTD_CCtx_s* cctx, void* dst, UIntPtr dstCapacity, void* src, UIntPtr srcSize, ZSTD_CDict_s* cdict);
/// <summary>ZSTD_createDDict() : Create a digested dictionary, ready to start decompression operation without startup delay. dictBuffer can be released after DDict creation, as its content is copied inside DDict.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_createDDict", CallingConvention = CallingConvention.Cdecl)]
public static extern ZSTD_DDict_s* ZSTD_createDDict(void* dictBuffer, UIntPtr dictSize);
/// <summary>ZSTD_freeDDict() : Function frees memory allocated with ZSTD_createDDict() If a NULL pointer is passed, no operation is performed.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_freeDDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_freeDDict(ZSTD_DDict_s* ddict);
/// <summary>ZSTD_decompress_usingDDict() : Decompression using a digested Dictionary. Recommended when same dictionary is used multiple times.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_decompress_usingDDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_decompress_usingDDict(ZSTD_DCtx_s* dctx, void* dst, UIntPtr dstCapacity, void* src, UIntPtr srcSize, ZSTD_DDict_s* ddict);
/// <summary>ZSTD_getDictID_fromDict() : Requires v1.4.0+ Provides the dictID stored within dictionary. if @return == 0, the dictionary is not conformant with Zstandard specification. It can still be loaded, but as a content-only dictionary.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_getDictID_fromDict", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ZSTD_getDictID_fromDict(void* dict, UIntPtr dictSize);
/// <summary>ZSTD_getDictID_fromCDict() : Requires v1.5.0+ Provides the dictID of the dictionary loaded into `cdict`. If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. Non-conformant dictionaries can still be loaded, but as content-only dictionaries.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_getDictID_fromCDict", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ZSTD_getDictID_fromCDict(ZSTD_CDict_s* cdict);
/// <summary>ZSTD_getDictID_fromDDict() : Requires v1.4.0+ Provides the dictID of the dictionary loaded into `ddict`. If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. Non-conformant dictionaries can still be loaded, but as content-only dictionaries.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_getDictID_fromDDict", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ZSTD_getDictID_fromDDict(ZSTD_DDict_s* ddict);
/// <summary>ZSTD_getDictID_fromFrame() : Requires v1.4.0+ Provides the dictID required to decompressed the frame stored within `src`. If @return == 0, the dictID could not be decoded. This could for one of the following reasons : - The frame does not require a dictionary to be decoded (most common case). - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden piece of information. Note : this use case also happens when using a non-conformant dictionary. - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize &lt; ZSTD_FRAMEHEADERSIZE_MAX`). - This is not a Zstandard frame. When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_getDictID_fromFrame", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ZSTD_getDictID_fromFrame(void* src, UIntPtr srcSize);
/// <summary>ZSTD_CCtx_loadDictionary() : Requires v1.4.0+ Create an internal CDict from `dict` buffer. Decompression will have to use same dictionary. @result : 0, or an error code (which can be tested with ZSTD_isError()). Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary, meaning \"return to no-dictionary mode\". Note 1 : Dictionary is sticky, it will be used for all future compressed frames, until parameters are reset, a new dictionary is loaded, or the dictionary is explicitly invalidated by loading a NULL dictionary. Note 2 : Loading a dictionary involves building tables. It's also a CPU consuming operation, with non-negligible impact on latency. Tables are dependent on compression parameters, and for this reason, compression parameters can no longer be changed after loading a dictionary. Note 3 :`dict` content will be copied internally. Use experimental ZSTD_CCtx_loadDictionary_byReference() to reference content instead. In such a case, dictionary buffer must outlive its users. Note 4 : Use ZSTD_CCtx_loadDictionary_advanced() to precisely select how dictionary content must be interpreted.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_CCtx_loadDictionary", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_CCtx_loadDictionary(ZSTD_CCtx_s* cctx, void* dict, UIntPtr dictSize);
/// <summary>ZSTD_CCtx_refCDict() : Requires v1.4.0+ Reference a prepared dictionary, to be used for all future compressed frames. Note that compression parameters are enforced from within CDict, and supersede any compression parameter previously set within CCtx. The parameters ignored are labelled as \"superseded-by-cdict\" in the ZSTD_cParameter enum docs. The ignored parameters will be used again if the CCtx is returned to no-dictionary mode. The dictionary will remain valid for future compressed frames using same CCtx. @result : 0, or an error code (which can be tested with ZSTD_isError()). Special : Referencing a NULL CDict means \"return to no-dictionary mode\". Note 1 : Currently, only one dictionary can be managed. Referencing a new dictionary effectively \"discards\" any previous one. Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_CCtx_refCDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_CCtx_refCDict(ZSTD_CCtx_s* cctx, ZSTD_CDict_s* cdict);
/// <summary>ZSTD_CCtx_refPrefix() : Requires v1.4.0+ Reference a prefix (single-usage dictionary) for next compressed frame. A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end). Decompression will need same prefix to properly regenerate data. Compressing with a prefix is similar in outcome as performing a diff and compressing it, but performs much faster, especially during decompression (compression speed is tunable with compression level). @result : 0, or an error code (which can be tested with ZSTD_isError()). Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary Note 1 : Prefix buffer is referenced. It **must** outlive compression. Its content must remain unmodified during compression. Note 2 : If the intention is to diff some large src data blob with some prior version of itself, ensure that the window size is large enough to contain the entire source. See ZSTD_c_windowLog. Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters. It's a CPU consuming operation, with non-negligible impact on latency. If there is a need to use the same prefix multiple times, consider loadDictionary instead. Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dct_rawContent). Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_CCtx_refPrefix", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_CCtx_refPrefix(ZSTD_CCtx_s* cctx, void* prefix, UIntPtr prefixSize);
/// <summary>ZSTD_DCtx_loadDictionary() : Requires v1.4.0+ Create an internal DDict from dict buffer, to be used to decompress all future frames. The dictionary remains valid for all future frames, until explicitly invalidated, or a new dictionary is loaded. @result : 0, or an error code (which can be tested with ZSTD_isError()). Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary, meaning \"return to no-dictionary mode\". Note 1 : Loading a dictionary involves building tables, which has a non-negligible impact on CPU usage and latency. It's recommended to \"load once, use many times\", to amortize the cost Note 2 :`dict` content will be copied internally, so `dict` can be released after loading. Use ZSTD_DCtx_loadDictionary_byReference() to reference dictionary content instead. Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to take control of how dictionary content is loaded and interpreted.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_DCtx_loadDictionary", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_DCtx_loadDictionary(ZSTD_DCtx_s* dctx, void* dict, UIntPtr dictSize);
/// <summary>ZSTD_DCtx_refDDict() : Requires v1.4.0+ Reference a prepared dictionary, to be used to decompress next frames. The dictionary remains active for decompression of future frames using same DCtx. If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function will store the DDict references in a table, and the DDict used for decompression will be determined at decompression time, as per the dict ID in the frame. The memory for the table is allocated on the first call to refDDict, and can be freed with ZSTD_freeDCtx(). If called with ZSTD_d_refMultipleDDicts disabled (the default), only one dictionary will be managed, and referencing a dictionary effectively \"discards\" any previous one. @result : 0, or an error code (which can be tested with ZSTD_isError()). Special: referencing a NULL DDict means \"return to no-dictionary mode\". Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_DCtx_refDDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_DCtx_refDDict(ZSTD_DCtx_s* dctx, ZSTD_DDict_s* ddict);
/// <summary>ZSTD_DCtx_refPrefix() : Requires v1.4.0+ Reference a prefix (single-usage dictionary) to decompress next frame. This is the reverse operation of ZSTD_CCtx_refPrefix(), and must use the same prefix as the one used during compression. Prefix is **only used once**. Reference is discarded at end of frame. End of frame is reached when ZSTD_decompressStream() returns 0. @result : 0, or an error code (which can be tested with ZSTD_isError()). Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary Note 2 : Prefix buffer is referenced. It **must** outlive decompression. Prefix buffer must remain unmodified up to the end of frame, reached when ZSTD_decompressStream() returns 0. Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent). Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode (Experimental section) Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost. A full dictionary is more costly, as it requires building tables.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_DCtx_refPrefix", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_DCtx_refPrefix(ZSTD_DCtx_s* dctx, void* prefix, UIntPtr prefixSize);
/// <summary>ZSTD_sizeof_*() : Requires v1.4.0+ These functions give the _current_ memory usage of selected object. Note that object memory usage can evolve (increase or decrease) over time.</summary>
[DllImport(__DllName, EntryPoint = "ZSTD_sizeof_CCtx", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_sizeof_CCtx(ZSTD_CCtx_s* cctx);
[DllImport(__DllName, EntryPoint = "ZSTD_sizeof_DCtx", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_sizeof_DCtx(ZSTD_DCtx_s* dctx);
[DllImport(__DllName, EntryPoint = "ZSTD_sizeof_CStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_sizeof_CStream(ZSTD_CCtx_s* zcs);
[DllImport(__DllName, EntryPoint = "ZSTD_sizeof_DStream", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_sizeof_DStream(ZSTD_DCtx_s* zds);
[DllImport(__DllName, EntryPoint = "ZSTD_sizeof_CDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_sizeof_CDict(ZSTD_CDict_s* cdict);
[DllImport(__DllName, EntryPoint = "ZSTD_sizeof_DDict", CallingConvention = CallingConvention.Cdecl)]
public static extern UIntPtr ZSTD_sizeof_DDict(ZSTD_DDict_s* ddict);
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe partial struct ZSTD_bounds
{
public UIntPtr error;
public int lowerBound;
public int upperBound;
}
}