Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
minor updates in c api

NOTE: test zip thing is broken atm due to layout of tdefl_decompressor not being the same in rust as in the original
and zip doesn't treat is as an opaque pointer
  • Loading branch information
oyvindln committed Aug 7, 2019
1 parent a149e43 commit 284ff4a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 44 deletions.
10 changes: 7 additions & 3 deletions cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated usi
include_version = true
language = "C"

[export]
include = ["CAPIReturnStatus", "CAPIFlush", "CAPICompressionStrategy"]

[export.rename]
"DecompressorOxide" = "tinfl_decompressor"

"Compressor" = "tinfl_compressor"

[parse]
# Whether to parse dependent crates and include their types in the output
Expand All @@ -24,6 +27,7 @@ include = ["miniz_oxide"]
# A black list of crate names that are not allowed to be parsed.
exclude = ["libc"]

[parse.expand]
crates = ["miniz_oxide_c_api"]
extra_bindings = ["miniz_oxide"]

[parse.expand]
crates = ["miniz_oxide_c_api", "miniz_oxide"]
4 changes: 2 additions & 2 deletions miniz_oxide/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "miniz_oxide"
authors = ["Frommi <[email protected]>"]
version = "0.3.0"
authors = ["Frommi <[email protected]>", "oyvindln <[email protected]>"]
version = "0.3.1"
license = "MIT"
readme = "Readme.md"
keywords = ["zlib", "miniz", "deflate", "encoding"]
Expand Down
72 changes: 33 additions & 39 deletions src/c_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,46 @@ use lib_oxide::{InternalState, StateType, StateTypeEnum, StreamOxide, MZ_ADLER32

use miniz_oxide::{mz_adler32_oxide, MZError};

pub mod return_status {
use libc::c_int;
use miniz_oxide::MZStatus;
use MZError::*;
pub const MZ_ERRNO: c_int = ErrNo as c_int;
pub const MZ_STREAM_ERROR: c_int = Stream as c_int;
pub const MZ_DATA_ERROR: c_int = Data as c_int;
pub const MZ_BUF_ERROR: c_int = Buf as c_int;
pub const MZ_VERSION_ERROR: c_int = Version as c_int;
pub const MZ_PARAM_ERROR: c_int = Param as c_int;

pub const MZ_OK: c_int = MZStatus::Ok as c_int;
pub const MZ_STREAM_END: c_int = MZStatus::StreamEnd as c_int;
pub const MZ_NEED_DICT: c_int = MZStatus::NeedDict as c_int;
#[allow(bad_style)]
#[repr(C)]
#[derive(PartialEq, Eq)]
pub enum CAPIReturnStatus {
MZ_PARAM_ERROR = -10000,
MZ_VERSION_ERROR = -6,
MZ_BUF_ERROR = -5,
MZ_MEM_ERROR = -4,
MZ_DATA_ERROR = -3,
MZ_STREAM_ERROR = -2,
MZ_ERRNO = -1,
MZ_OK = 0,
MZ_STREAM_END = 1,
MZ_NEED_DICT = 2,
}

pub use return_status::*;

/// Deflate flush modes.
pub mod flush_modes {
use libc::c_int;
use miniz_oxide::deflate::core::TDEFLFlush;
pub const MZ_NO_FLUSH: c_int = TDEFLFlush::None as c_int;
// TODO: This is simply sync flush for now, miniz also treats it as such.
pub const MZ_PARTIAL_FLUSH: c_int = 1;
pub const MZ_SYNC_FLUSH: c_int = TDEFLFlush::Sync as c_int;
pub const MZ_FULL_FLUSH: c_int = TDEFLFlush::Full as c_int;
pub const MZ_FINISH: c_int = TDEFLFlush::Finish as c_int;
// TODO: Doesn't seem to be implemented by miniz.
pub const MZ_BLOCK: c_int = 5;
#[allow(bad_style)]
#[repr(C)]
#[derive(PartialEq, Eq)]
pub enum CAPIFlush {
MZ_NO_FLUSH = 0,
MZ_PARTIAL_FLUSH = 1,
MZ_SYNC_FLUSH = 2,
MZ_FULL_FLUSH = 3,
MZ_FINISH = 4,
MZ_BLOCK = 5,
}

pub use flush_modes::*;

pub mod strategy {
use libc::c_int;
use miniz_oxide::deflate::core::CompressionStrategy::*;
pub const MZ_DEFAULT_STRATEGY: c_int = Default as c_int;
pub const MZ_FILTERED: c_int = Filtered as c_int;
pub const MZ_HUFFMAN_ONLY: c_int = HuffmanOnly as c_int;
pub const MZ_RLE: c_int = RLE as c_int;
pub const MZ_FIXED: c_int = Fixed as c_int;
#[allow(bad_style)]
#[repr(C)]
#[derive(PartialEq, Eq)]
pub enum CAPICompressionStrategy {
MZ_DEFAULT_STRATEGY = 0,
MZ_FILTERED = 1,
MZ_HUFFMAN_ONLY = 2,
MZ_RLE = 3,
MZ_FIXED = 4
}

pub use strategy::*;

pub const MZ_CRC32_INIT: c_ulong = 0;

pub fn mz_crc32_oxide(crc32: c_uint, data: &[u8]) -> c_uint {
Expand Down

0 comments on commit 284ff4a

Please sign in to comment.