bzip2-0.6.1/.cargo_vcs_info.json0000644000000001360000000000100120660ustar { "git": { "sha1": "eebf6e470f6c4a14295fcaf43c619ae4a0e5690a" }, "path_in_vcs": "" }bzip2-0.6.1/.github/dependabot.yml000064400000000000000000000002211046102023000150410ustar 00000000000000version: 2 updates: - package-ecosystem: cargo directory: "/" schedule: interval: daily time: "08:00" open-pull-requests-limit: 10 bzip2-0.6.1/.github/workflows/main.yml000064400000000000000000000064341046102023000157310ustar 00000000000000name: CI on: [push, pull_request] jobs: test: name: Test runs-on: ${{ matrix.os }} strategy: matrix: build: [stable, beta, nightly, msrv, macos, win32, win64, win32-gnu, win64-gnu] include: - build: stable os: ubuntu-latest rust: stable - build: beta os: ubuntu-latest rust: beta - build: nightly os: ubuntu-latest rust: nightly - build: msrv os: ubuntu-latest rust: nightly - build: wasm32 os: ubuntu-latest rust: stable - build: macos os: macos-latest rust: stable - build: win32 os: windows-latest rust: stable-i686-msvc - build: win64 os: windows-latest rust: stable-x86_64-msvc - build: win32-gnu os: windows-latest rust: stable-i686-gnu - build: win64-gnu os: windows-latest rust: stable-x86_64-gnu steps: - uses: actions/checkout@master - name: Install Rust (rustup) run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} shell: bash if: matrix.build != 'msrv' - name: Install wasmtime run: | curl https://wasmtime.dev/install.sh -sSf | bash /home/runner/.wasmtime/bin/wasmtime --version if: matrix.build == 'wasm32' - name: Configure Toolchain (msrv) run: | # extract the MSRV from the Cargo.toml's `rust-version` MSRV=$(awk -F'"' '/rust-version/ {print $2}' Cargo.toml) TOOLCHAIN="${MSRV}-x86_64-unknown-linux-gnu" rustup update $TOOLCHAIN --no-self-update && rustup default $TOOLCHAIN shell: bash if: matrix.build == 'msrv' - name: Install target (wasm32) run: | rustup target add wasm32-wasip2 shell: bash if: matrix.build == 'wasm32' - name: Run cargo doc, deny warnings (libbzip2-rs-sys) env: RUSTDOCFLAGS: "-D warnings" run: | cargo doc -p bzip2 --no-deps - name: Run cargo doc, deny warnings (bzip2-sys) env: RUSTDOCFLAGS: "-Dwarnings" run: | cargo doc -p bzip2-sys --no-deps cargo doc -p bzip2 --no-deps --no-default-features --features bzip2-sys - name: Configure wasm32 env vars run: | echo "CARGO_TARGET_WASM32_WASIP2_RUNNER=/home/runner/.wasmtime/bin/wasmtime" >> $GITHUB_ENV echo "CARGO_BUILD_TARGET=wasm32-wasip2" >> $GITHUB_ENV if: matrix.build == 'wasm32' - name: Run cargo test (libbzip2-rs-sys) run: cargo test - name: Run cargo test (bzip2-sys) run: cargo test --no-default-features --features bzip2-sys if: matrix.build != 'wasm32' rustfmt: name: Rustfmt runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: Install Rust run: rustup update stable && rustup default stable && rustup component add rustfmt - run: cargo fmt -- --check clippy: name: Clippy runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: Install Rust run: rustup update stable && rustup default stable && rustup component add clippy - run: cargo clippy -- -D warnings bzip2-0.6.1/.gitignore000064400000000000000000000000321046102023000126410ustar 00000000000000target Cargo.lock .cargo/ bzip2-0.6.1/Cargo.lock0000644000000254360000000000100100530ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "bitflags" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bzip2" version = "0.6.1" dependencies = [ "bzip2-sys", "libbz2-rs-sys", "partial-io", "quickcheck", "rand 0.9.0", ] [[package]] name = "bzip2-sys" version = "0.1.13+1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" dependencies = [ "cc", "pkg-config", ] [[package]] name = "cc" version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" dependencies = [ "shlex", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "env_logger" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" dependencies = [ "log", "regex", ] [[package]] name = "getrandom" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] name = "getrandom" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" dependencies = [ "cfg-if", "libc", "wasi 0.13.3+wasi-0.2.2", "windows-targets", ] [[package]] name = "libbz2-rs-sys" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775bf80d5878ab7c2b1080b5351a48b2f737d9f6f8b383574eebcc22be0dfccb" [[package]] name = "libc" version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "log" version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "partial-io" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af95cf22649f58b48309da6d05caeb5fab4bb335eba4a3f9ac7c3a8e176d0e16" dependencies = [ "quickcheck", "rand 0.8.5", ] [[package]] name = "pkg-config" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "ppv-lite86" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ "zerocopy 0.7.35", ] [[package]] name = "proc-macro2" version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] [[package]] name = "quickcheck" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ "env_logger", "log", "rand 0.8.5", ] [[package]] name = "quote" version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] [[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.4", ] [[package]] name = "rand" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.0", "zerocopy 0.8.17", ] [[package]] name = "rand_chacha" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core 0.6.4", ] [[package]] name = "rand_chacha" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", "rand_core 0.9.0", ] [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom 0.2.15", ] [[package]] name = "rand_core" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" dependencies = [ "getrandom 0.3.1", "zerocopy 0.8.17", ] [[package]] name = "regex" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "unicode-ident" version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi" version = "0.13.3+wasi-0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" dependencies = [ "wit-bindgen-rt", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "wit-bindgen-rt" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" dependencies = [ "bitflags", ] [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", "zerocopy-derive 0.7.35", ] [[package]] name = "zerocopy" version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa91407dacce3a68c56de03abe2760159582b846c6a4acd2f456618087f12713" dependencies = [ "zerocopy-derive 0.8.17", ] [[package]] name = "zerocopy-derive" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "zerocopy-derive" version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06718a168365cad3d5ff0bb133aad346959a2074bd4a85c121255a11304a8626" dependencies = [ "proc-macro2", "quote", "syn", ] bzip2-0.6.1/Cargo.toml0000644000000031000000000000100100560ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.82.0" name = "bzip2" version = "0.6.1" build = false publish = true autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = """ Bindings to libbzip2 for bzip2 compression and decompression exposed as Reader/Writer streams. """ homepage = "https://github.com/trifectatechfoundation/bzip2-rs" documentation = "https://docs.rs/bzip2" readme = "README.md" keywords = [ "bzip", "encoding", ] categories = [ "compression", "api-bindings", ] license = "MIT OR Apache-2.0" repository = "https://github.com/trifectatechfoundation/bzip2-rs" [features] bzip2-sys = ["dep:bzip2-sys"] default = ["dep:libbz2-rs-sys"] static = ["bzip2-sys?/static"] [lib] name = "bzip2" path = "src/lib.rs" [dependencies.bzip2-sys] version = "0.1.13" optional = true [dependencies.libbz2-rs-sys] version = "0.2.1" features = ["rust-allocator"] optional = true default-features = false [dev-dependencies.partial-io] version = "0.5.4" features = ["quickcheck1"] [dev-dependencies.quickcheck] version = "1.0" [dev-dependencies.rand] version = "0.9" bzip2-0.6.1/Cargo.toml.orig000064400000000000000000000023571046102023000135540ustar 00000000000000[package] edition = "2021" name = "bzip2" version = "0.6.1" license = "MIT OR Apache-2.0" readme = "README.md" keywords = ["bzip", "encoding"] repository = "https://github.com/trifectatechfoundation/bzip2-rs" homepage = "https://github.com/trifectatechfoundation/bzip2-rs" documentation = "https://docs.rs/bzip2" description = """ Bindings to libbzip2 for bzip2 compression and decompression exposed as Reader/Writer streams. """ categories = ["compression", "api-bindings"] rust-version = "1.82.0" # MSRV publish = true [workspace] [dependencies] bzip2-sys = { version = "0.1.13", path = "bzip2-sys", optional = true } [dependencies.libbz2-rs-sys] version = "0.2.1" # Don't enable the stdio feature for better portability. default-features = false features = ["rust-allocator"] optional = true [dev-dependencies] rand = "0.9" partial-io = { version = "0.5.4", features = ["quickcheck1"] } quickcheck = "1.0" [features] default = ["dep:libbz2-rs-sys"] # Use the C bzip2 implementation. This will try to find the bzip2 dynamic library on your system, or build it from source. bzip2-sys = ["dep:bzip2-sys"] # Always build `libbz2` from C source, and statically link it. # This flag is only meaningful when `bzip2-sys` is used, static = ["bzip2-sys?/static"] bzip2-0.6.1/LICENSE-APACHE000064400000000000000000000251371046102023000126120ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. bzip2-0.6.1/LICENSE-MIT000064400000000000000000000020671046102023000123170ustar 00000000000000Copyright (c) 2014-2025 Alex Crichton and Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. bzip2-0.6.1/README.md000064400000000000000000000022561046102023000121420ustar 00000000000000# bzip2 [Documentation](https://docs.rs/bzip2) A streaming bzip2 compression/decompression library for rust. ## Features *`bzip2-sys`* Attempt to use the system `libbz2`. When `libbz2` is not available, built from source. A from-source build requires a functional C toolchain for your target, and may not work for all targets (in particular webassembly). ```sh bzip2 = { version = "0.5.1", default-features = false, features = ["bzip2-sys"] } ``` *`static`* Always build `libbz2` from C source, and statically link it. This flag is only meaningful when `bzip2-sys` is used, and has no effect when the default `libbz2-rs-sys` is used as the bzip2 implementation. ## License This project is licensed under either of * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. ### Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this repository by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. bzip2-0.6.1/SECURITY.md000064400000000000000000000023631046102023000124530ustar 00000000000000Security policy =============== **Do not report security vulnerabilities through public GitHub issues.** Instead, you can report security vulnerabilities using [our security page]. Please include as much of the following information as possible: * Type of issue (e.g. buffer overflow, privilege escalation, etc.) * The location of the affected source code (tag/branch/commit or direct URL) * Any special configuration required to reproduce the issue * If applicable, which platforms are affected * Step-by-step instructions to reproduce the issue * Impact of the issue, including how an attacker might exploit the issue ## Preferred Languages We prefer to receive reports in English. If necessary, we also understand Dutch and Frisian. ## Disclosure Policy We adhere to the principle of [coordinated vulnerability disclosure]. Security Advisories =================== Security advisories will be published on our [github advisories page] and possibly through other channels. [our security page]: https://github.com/trifectatechfoundation/bzip2-rs/security [coordinated vulnerability disclosure]: https://vuls.cert.org/confluence/display/CVD/Executive+Summary [github advisories page]: https://github.com/trifectatechfoundation/libbzip2-rs/security/advisories bzip2-0.6.1/src/bufread.rs000064400000000000000000000221511046102023000134240ustar 00000000000000//! I/O streams for wrapping `BufRead` types as encoders/decoders use std::io; use std::io::prelude::*; use crate::{Action, Compress, Compression, Decompress, Status}; /// A bz2 encoder, or compressor. /// /// This structure implements a [`BufRead`] interface and will read uncompressed /// data from an underlying stream and emit a stream of compressed data. pub struct BzEncoder { obj: R, data: Compress, done: bool, } /// A bz2 decoder, or decompressor. /// /// This structure implements a [`BufRead`] interface and takes a stream of /// compressed data as input, providing the decompressed data when read from. pub struct BzDecoder { obj: R, data: Decompress, done: bool, multi: bool, } impl BzEncoder { /// Creates a new encoder which will read uncompressed data from the given /// stream and emit the compressed stream. pub fn new(r: R, level: Compression) -> Self { Self { obj: r, data: Compress::new(level, 30), done: false, } } } impl BzEncoder { /// Acquires a reference to the underlying stream pub fn get_ref(&self) -> &R { &self.obj } /// Acquires a mutable reference to the underlying stream /// /// Note that mutation of the stream may result in surprising results if /// this encoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { &mut self.obj } /// Consumes this encoder, returning the underlying reader. pub fn into_inner(self) -> R { self.obj } /// Returns the number of bytes produced by the compressor /// (e.g. the number of bytes read from this stream) /// /// Note that, due to buffering, this only bears any relation to /// total_in() when the compressor chooses to flush its data /// (unfortunately, this won't happen in general /// at the end of the stream, because the compressor doesn't know /// if there's more data to come). At that point, /// `total_out() / total_in()` would be the compression ratio. pub fn total_out(&self) -> u64 { self.data.total_out() } /// Returns the number of bytes consumed by the compressor /// (e.g. the number of bytes read from the underlying stream) pub fn total_in(&self) -> u64 { self.data.total_in() } } impl Read for BzEncoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { if self.done { return Ok(0); } loop { let (read, consumed, eof, ret); { let input = self.obj.fill_buf()?; eof = input.is_empty(); let before_out = self.data.total_out(); let before_in = self.data.total_in(); let action = if eof { Action::Finish } else { Action::Run }; ret = self.data.compress(input, buf, action); read = (self.data.total_out() - before_out) as usize; consumed = (self.data.total_in() - before_in) as usize; } self.obj.consume(consumed); // we should never get the sequence error that's possible to be // returned from compression let ret = ret.unwrap(); // If we haven't ready any data and we haven't hit EOF yet, then we // need to keep asking for more data because if we return that 0 // bytes of data have been read then it will be interpreted as EOF. if read == 0 && !eof && !buf.is_empty() { continue; } if ret == Status::StreamEnd { self.done = true; } return Ok(read); } } } impl Write for BzEncoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) } fn flush(&mut self) -> io::Result<()> { self.get_mut().flush() } } impl BzDecoder { /// Creates a new decoder which will decompress data read from the given /// stream. pub fn new(r: R) -> Self { Self { obj: r, data: Decompress::new(false), done: false, multi: false, } } fn multi(mut self, flag: bool) -> Self { self.multi = flag; self } } impl BzDecoder { /// Acquires a reference to the underlying stream pub fn get_ref(&self) -> &R { &self.obj } /// Acquires a mutable reference to the underlying stream /// /// Note that mutation of the stream may result in surprising results if /// this encoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { &mut self.obj } /// Consumes this decoder, returning the underlying reader. pub fn into_inner(self) -> R { self.obj } /// Returns the number of bytes that the decompressor has consumed. /// /// Note that this will likely be smaller than what the decompressor /// actually read from the underlying stream due to buffering. pub fn total_in(&self) -> u64 { self.data.total_in() } /// Returns the number of bytes that the decompressor has produced. pub fn total_out(&self) -> u64 { self.data.total_out() } } impl Read for BzDecoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { loop { if self.done && !self.multi { return Ok(0); } let (read, consumed, remaining, ret); { let input = self.obj.fill_buf()?; if self.done { assert!(self.multi); if input.is_empty() { // beyond last stream in multi-stream case return Ok(0); } else { // previous stream ended, more data follows => create new decompressor self.data = Decompress::new(false); self.done = false; } } let before_out = self.data.total_out(); let before_in = self.data.total_in(); ret = self.data.decompress(input, buf); read = (self.data.total_out() - before_out) as usize; consumed = (self.data.total_in() - before_in) as usize; remaining = input.len() - consumed; } self.obj.consume(consumed); let ret = ret.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?; if ret == Status::StreamEnd { self.done = true; } else if consumed == 0 && remaining == 0 && read == 0 { return Err(io::Error::new( io::ErrorKind::UnexpectedEof, "decompression not finished but EOF reached", )); } if read > 0 || buf.is_empty() { return Ok(read); } } } } impl Write for BzDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) } fn flush(&mut self) -> io::Result<()> { self.get_mut().flush() } } /// A bzip2 streaming decoder that decodes all members of a multistream. /// /// Wikipedia, particularly, uses bzip2 multistream for their dumps, and the /// `pbzip2` tool creates such data as well. pub struct MultiBzDecoder(BzDecoder); impl MultiBzDecoder { /// Creates a new decoder from the given reader. If the bzip2 stream contains multiple members /// all will be decoded. pub fn new(r: R) -> Self { Self(BzDecoder::new(r).multi(true)) } } impl MultiBzDecoder { /// Acquires a reference to the underlying reader. pub fn get_ref(&self) -> &R { self.0.get_ref() } /// Acquires a mutable reference to the underlying stream. /// /// Note that mutation of the stream may result in surprising results if /// this encoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.0.get_mut() } /// Consumes this decoder, returning the underlying reader. pub fn into_inner(self) -> R { self.0.into_inner() } } impl Read for MultiBzDecoder { fn read(&mut self, into: &mut [u8]) -> io::Result { self.0.read(into) } } impl Write for MultiBzDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) } fn flush(&mut self) -> io::Result<()> { self.get_mut().flush() } } #[cfg(test)] mod tests { use super::MultiBzDecoder; use std::io::{BufReader, Read}; #[test] fn bug_61() { let compressed_bytes = include_bytes!("../tests/bug_61.bz2"); let uncompressed_bytes = include_bytes!("../tests/bug_61.raw"); let reader = BufReader::with_capacity(8192, compressed_bytes.as_ref()); let mut d = MultiBzDecoder::new(reader); let mut data = Vec::new(); assert_eq!(d.read_to_end(&mut data).unwrap(), uncompressed_bytes.len()); assert_eq!(data, uncompressed_bytes); } } bzip2-0.6.1/src/lib.rs000064400000000000000000000116051046102023000125640ustar 00000000000000//! Bzip compression for Rust //! //! This library contains bindings to [`libbz2`] to support bzip compression and //! decompression for Rust. The streams offered in this library are primarily //! found in the [`mod@read`] and [`mod@write`] modules. Both compressors and //! decompressors are available in each module depending on what operation you //! need. //! //! A more low-level interface, much closer to the interface of [`libbz2`], is //! available via the [`Compress`] and [`Decompress`] structs. //! //! [`libbz2`]: https://sourceware.org/bzip2/manual/manual.html //! //! # Example //! //! ``` //! use std::io::{BufRead, Read, Write}; //! use bzip2::Compression; //! use bzip2::read::{BzEncoder, BzDecoder}; //! //! // Round trip some bytes from a byte source, into a compressor, into a //! // decompressor, and finally into a vector. //! let data = "Hello, World!".as_bytes(); //! let compressor = BzEncoder::new(data, Compression::best()); //! let mut decompressor = BzDecoder::new(compressor); //! //! let mut contents = String::new(); //! decompressor.read_to_string(&mut contents).unwrap(); //! assert_eq!(contents, "Hello, World!"); //! ``` //! //! # Multistreams (e.g. Wikipedia or pbzip2) //! //! Some tools such as pbzip2 or data from sources such as Wikipedia //! are encoded as so called bzip2 "multistreams," meaning they //! contain back to back chunks of bzip'd data. `BzDecoder` does not //! attempt to convert anything after the first bzip chunk in the //! source stream. Thus, if you wish to decode all bzip chunks from //! the input until end of file, use `MultiBzDecoder`. //! //! *Protip*: If you use `BzDecoder` to decode data and the output is //! incomplete and exactly 900K bytes, you probably need a //! `MultiBzDecoder`. //! //! All methods are internally capable of working with streams that may return //! [`ErrorKind::WouldBlock`](std::io::ErrorKind::WouldBlock) when they're not //! ready to perform the particular operation. //! //! Note that care needs to be taken when using these objects, however. The //! Tokio runtime, in particular, requires that data is fully flushed before //! dropping streams. For compatibility with blocking streams all streams are //! flushed/written when they are dropped, and this is not always a suitable //! time to perform I/O. If I/O streams are flushed before drop, however, then //! these operations will be a noop. #![deny(missing_docs)] #![doc(html_root_url = "https://docs.rs/bzip2/")] #[cfg(feature = "bzip2-sys")] extern crate bzip2_sys as ffi; #[cfg(not(feature = "bzip2-sys"))] extern crate libbz2_rs_sys as ffi; #[cfg(test)] extern crate partial_io; #[cfg(test)] extern crate quickcheck; #[cfg(test)] extern crate rand; pub use mem::{Action, Compress, Decompress, Error, Status}; mod mem; pub mod bufread; pub mod read; pub mod write; /// When compressing data, the compression level can be specified by a value in /// this enum. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct Compression(u32); impl Compression { /// Create a new compression spec with a specific numeric level in the range `1..=9`. /// /// # Panics /// /// A level outside of the `1..=9` range will throw a panic. Use [`Self::try_new`] to /// gracefully handle invalid levels (e.g. from user input). #[track_caller] pub const fn new(level: u32) -> Self { match Self::try_new(level) { Some(v) => v, None => panic!("expected a compression level in the range 1..=9"), } } /// Create a new compression spec with a specific numeric level in the range `1..=9`. pub const fn try_new(level: u32) -> Option { match level { 1..=9 => Some(Self(level)), _ => None, } } /// Do not compress. #[deprecated(since = "0.5.1", note = "libbz2 does not support compression level 0")] pub fn none() -> Self { Self(0) } /// Optimize for the best speed of encoding. pub const fn fast() -> Self { Self(1) } /// Optimize for smallest output size. pub const fn best() -> Self { Self(9) } /// Return the compression level as an integer. pub const fn level(&self) -> u32 { self.0 } } impl Default for Compression { /// Choose the default compression, a balance between speed and size. fn default() -> Self { Self(6) } } #[cfg(test)] mod test { use super::*; #[test] #[should_panic] fn new_level_0() { Compression::new(0); } #[test] #[should_panic] fn new_level_10() { Compression::new(10); } #[test] fn try_new() { assert!(Compression::try_new(0).is_none()); assert!(Compression::try_new(10).is_none()); assert_eq!(Compression::try_new(1), Some(Compression::fast())); assert_eq!(Compression::try_new(6), Some(Compression::default())); assert_eq!(Compression::try_new(9), Some(Compression::best())); } } bzip2-0.6.1/src/mem.rs000064400000000000000000000267761046102023000126130ustar 00000000000000//! Raw low-level manipulations of bz streams. use std::error; use std::fmt; use std::marker; use std::mem; use core::ffi::{c_int, c_uint}; use crate::{ffi, Compression}; /// Representation of an in-memory compression stream. /// /// An instance of [`Compress`] can be used to compress a stream of bz2 data. pub struct Compress { inner: Stream, } /// Representation of an in-memory decompression stream. /// /// An instance of [`Decompress`] can be used to decompress a stream of bz2-encoded /// data. pub struct Decompress { inner: Stream, } struct Stream { // libbz2 requires a stable address for this stream. raw: Box, _marker: marker::PhantomData, } unsafe impl Send for Stream {} unsafe impl Sync for Stream {} trait Direction { unsafe fn destroy(stream: *mut ffi::bz_stream) -> c_int; } enum DirCompress {} enum DirDecompress {} /// Possible actions to take on compression. #[derive(PartialEq, Eq, Copy, Debug, Clone)] pub enum Action { /// Normal compression. Run = ffi::BZ_RUN as isize, /// Flush any existing output, but do not read any more input Flush = ffi::BZ_FLUSH as isize, /// Request that the compression stream be finalized. Finish = ffi::BZ_FINISH as isize, } /// Result of compression or decompression #[derive(PartialEq, Eq, Copy, Debug, Clone)] pub enum Status { /// Decompression went fine, nothing much to report. Ok, /// The Flush action on a compression went ok. FlushOk, /// The Run action on compression went ok. RunOk, /// The Finish action on compression went ok. FinishOk, /// The stream's end has been met, meaning that no more data can be input. StreamEnd, /// There was insufficient memory in the input or output buffer to complete /// the request, but otherwise everything went normally. MemNeeded, } /// Fatal errors encountered when compressing/decompressing bytes. /// /// These errors indicate that progress could not be made in any form due to /// input or output parameters. #[derive(PartialEq, Eq, Copy, Debug, Clone)] pub enum Error { /// The sequence of operations called on a decompression/compression stream /// were invalid. See methods for details. Sequence, /// The data being decompressed was invalid, or it was not a valid bz2 /// stream. Data, /// The magic bz2 header wasn't present when decompressing. DataMagic, /// The parameters to this function were invalid. Param, } impl Compress { /// Creates a new stream prepared for compression. /// /// The `work_factor` parameter controls how the compression phase behaves /// when presented with worst case, highly repetitive, input data. If /// compression runs into difficulties caused by repetitive data, the /// library switches from the standard sorting algorithm to a fallback /// algorithm. The fallback is slower than the standard algorithm by perhaps /// a factor of three, but always behaves reasonably, no matter how bad the /// input. /// /// Lower values of `work_factor` reduce the amount of effort the standard /// algorithm will expend before resorting to the fallback. You should set /// this parameter carefully; too low, and many inputs will be handled by /// the fallback algorithm and so compress rather slowly, too high, and your /// average-to-worst case compression times can become very large. The /// default value of 30 gives reasonable behaviour over a wide range of /// circumstances. /// /// Allowable values range from 0 to 250 inclusive. 0 is a special case, /// equivalent to using the default value of 30. pub fn new(lvl: Compression, work_factor: u32) -> Self { unsafe { let mut raw = Box::new(mem::zeroed()); assert_eq!( ffi::BZ2_bzCompressInit(&mut *raw, lvl.level() as c_int, 0, work_factor as c_int), 0 ); Self { inner: Stream { raw, _marker: marker::PhantomData, }, } } } unsafe fn compress_inner( &mut self, input: &[u8], output_ptr: *mut u8, output_len: usize, action: Action, ) -> Result { // apparently 0-length compression requests which don't actually make // any progress are returned as BZ_PARAM_ERROR, which we don't want, to // just translate to a success here. if input.is_empty() && action == Action::Run { return Ok(Status::RunOk); } self.inner.raw.next_in = input.as_ptr() as *mut _; self.inner.raw.avail_in = input.len().min(c_uint::MAX as usize) as c_uint; self.inner.raw.next_out = output_ptr as *mut _; self.inner.raw.avail_out = output_len.min(c_uint::MAX as usize) as c_uint; unsafe { match ffi::BZ2_bzCompress(&mut *self.inner.raw, action as c_int) { ffi::BZ_RUN_OK => Ok(Status::RunOk), ffi::BZ_FLUSH_OK => Ok(Status::FlushOk), ffi::BZ_FINISH_OK => Ok(Status::FinishOk), ffi::BZ_STREAM_END => Ok(Status::StreamEnd), ffi::BZ_SEQUENCE_ERROR => Err(Error::Sequence), c => panic!("unknown return status: {c}"), } } } /// Compress a block of input into a block of output. /// /// If anything other than [`BZ_OK`] is seen, `Err` is returned. /// /// The action given must be one of [`Action::Run`], [`Action::Flush`] or [`Action::Finish`]. /// /// [`BZ_OK`]: ffi::BZ_OK pub fn compress( &mut self, input: &[u8], output: &mut [u8], action: Action, ) -> Result { unsafe { self.compress_inner(input, output.as_mut_ptr(), output.len(), action) } } /// Same as [`Self::compress`] but accepts an uninitialised `output` buffer. pub fn compress_uninit( &mut self, input: &[u8], output: &mut [mem::MaybeUninit], action: Action, ) -> Result { unsafe { self.compress_inner(input, output.as_mut_ptr() as *mut _, output.len(), action) } } /// Compress a block of input into an output vector. /// /// This function will not grow `output`, but it will fill the space after /// its current length up to its capacity. The length of the vector will be /// adjusted appropriately. pub fn compress_vec( &mut self, input: &[u8], output: &mut Vec, action: Action, ) -> Result { let len = output.len(); unsafe { let before = self.total_out(); let ret = self.compress_uninit(input, output.spare_capacity_mut(), action); output.set_len((self.total_out() - before) as usize + len); ret } } /// Total number of bytes processed as input pub fn total_in(&self) -> u64 { self.inner.total_in() } /// Total number of bytes processed as output pub fn total_out(&self) -> u64 { self.inner.total_out() } } impl Decompress { /// Creates a new stream prepared for decompression. /// /// If `small` is true, then the library will use an alternative /// decompression algorithm which uses less memory but at the cost of /// decompressing more slowly (roughly speaking, half the speed, but the /// maximum memory requirement drops to around 2300k). pub fn new(small: bool) -> Self { unsafe { let mut raw = Box::new(mem::zeroed()); assert_eq!(ffi::BZ2_bzDecompressInit(&mut *raw, 0, small as c_int), 0); Self { inner: Stream { raw, _marker: marker::PhantomData, }, } } } unsafe fn decompress_inner( &mut self, input: &[u8], output_ptr: *mut u8, output_len: usize, ) -> Result { self.inner.raw.next_in = input.as_ptr() as *mut _; self.inner.raw.avail_in = input.len().min(c_uint::MAX as usize) as c_uint; self.inner.raw.next_out = output_ptr as *mut _; self.inner.raw.avail_out = output_len.min(c_uint::MAX as usize) as c_uint; unsafe { match ffi::BZ2_bzDecompress(&mut *self.inner.raw) { ffi::BZ_OK => Ok(Status::Ok), ffi::BZ_MEM_ERROR => Ok(Status::MemNeeded), ffi::BZ_STREAM_END => Ok(Status::StreamEnd), ffi::BZ_PARAM_ERROR => Err(Error::Param), ffi::BZ_DATA_ERROR => Err(Error::Data), ffi::BZ_DATA_ERROR_MAGIC => Err(Error::DataMagic), ffi::BZ_SEQUENCE_ERROR => Err(Error::Sequence), c => panic!("wut: {c}"), } } } /// Decompress a block of input into a block of output. pub fn decompress(&mut self, input: &[u8], output: &mut [u8]) -> Result { unsafe { self.decompress_inner(input, output.as_mut_ptr(), output.len()) } } /// Same as [`Self::decompress`] but accepts an uninitialized buffer. pub fn decompress_uninit( &mut self, input: &[u8], output: &mut [mem::MaybeUninit], ) -> Result { unsafe { self.decompress_inner(input, output.as_mut_ptr() as *mut _, output.len()) } } /// Decompress a block of input into an output vector. /// /// This function will not grow `output`, but it will fill the space after /// its current length up to its capacity. The length of the vector will be /// adjusted appropriately. pub fn decompress_vec(&mut self, input: &[u8], output: &mut Vec) -> Result { let len = output.len(); unsafe { let before = self.total_out(); let ret = self.decompress_uninit(input, output.spare_capacity_mut()); output.set_len((self.total_out() - before) as usize + len); ret } } /// Total number of bytes processed as input pub fn total_in(&self) -> u64 { self.inner.total_in() } /// Total number of bytes processed as output pub fn total_out(&self) -> u64 { self.inner.total_out() } } impl Stream { fn total_in(&self) -> u64 { (self.raw.total_in_lo32 as u64) | ((self.raw.total_in_hi32 as u64) << 32) } fn total_out(&self) -> u64 { (self.raw.total_out_lo32 as u64) | ((self.raw.total_out_hi32 as u64) << 32) } } impl error::Error for Error {} impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let description = match self { Self::Sequence => "bzip2: sequence of operations invalid", Self::Data => "bzip2: invalid data", Self::DataMagic => "bzip2: bz2 header missing", Self::Param => "bzip2: invalid parameters", }; f.write_str(description) } } impl From for std::io::Error { fn from(data: Error) -> Self { Self::other(data) } } impl Direction for DirCompress { unsafe fn destroy(stream: *mut ffi::bz_stream) -> c_int { ffi::BZ2_bzCompressEnd(stream) } } impl Direction for DirDecompress { unsafe fn destroy(stream: *mut ffi::bz_stream) -> c_int { ffi::BZ2_bzDecompressEnd(stream) } } impl Drop for Stream { fn drop(&mut self) { unsafe { let _ = D::destroy(&mut *self.raw); } } } bzip2-0.6.1/src/read.rs000064400000000000000000000237221046102023000127340ustar 00000000000000//! Reader-based compression/decompression streams use std::io::prelude::*; use std::io::{self, BufReader}; use crate::bufread; use crate::Compression; /// A compression stream which wraps an uncompressed stream of data. Compressed /// data will be read from the stream. pub struct BzEncoder { inner: bufread::BzEncoder>, } /// A decompression stream which wraps a compressed stream of data. Decompressed /// data will be read from the stream. pub struct BzDecoder { inner: bufread::BzDecoder>, } impl BzEncoder { /// Create a new compression stream which will compress at the given level /// to read compress output to the give output stream. pub fn new(r: R, level: Compression) -> Self { Self { inner: bufread::BzEncoder::new(BufReader::new(r), level), } } /// Acquires a reference to the underlying stream pub fn get_ref(&self) -> &R { self.inner.get_ref().get_ref() } /// Acquires a mutable reference to the underlying stream /// /// Note that mutation of the stream may result in surprising results if /// this encoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.inner.get_mut().get_mut() } /// Unwrap the underlying writer, finishing the compression stream. pub fn into_inner(self) -> R { self.inner.into_inner().into_inner() } /// Returns the number of bytes produced by the compressor /// (e.g. the number of bytes read from this stream) /// /// Note that, due to buffering, this only bears any relation to /// total_in() when the compressor chooses to flush its data /// (unfortunately, this won't happen in general /// at the end of the stream, because the compressor doesn't know /// if there's more data to come). At that point, /// `total_out() / total_in()` would be the compression ratio. pub fn total_out(&self) -> u64 { self.inner.total_out() } /// Returns the number of bytes consumed by the compressor /// (e.g. the number of bytes read from the underlying stream) pub fn total_in(&self) -> u64 { self.inner.total_in() } } impl Read for BzEncoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) } } impl Write for BzEncoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) } fn flush(&mut self) -> io::Result<()> { self.get_mut().flush() } } impl BzDecoder { /// Create a new decompression stream, which will read compressed /// data from the given input stream and decompress it. pub fn new(r: R) -> Self { Self { inner: bufread::BzDecoder::new(BufReader::new(r)), } } /// Acquires a reference to the underlying stream pub fn get_ref(&self) -> &R { self.inner.get_ref().get_ref() } /// Acquires a mutable reference to the underlying stream /// /// Note that mutation of the stream may result in surprising results if /// this encoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.inner.get_mut().get_mut() } /// Unwrap the underlying writer, finishing the compression stream. pub fn into_inner(self) -> R { self.inner.into_inner().into_inner() } /// Returns the number of bytes produced by the decompressor /// (e.g. the number of bytes read from this stream) /// /// Note that, due to buffering, this only bears any relation to /// total_in() when the decompressor reaches a sync point /// (e.g. where the original compressed stream was flushed). /// At that point, `total_in() / total_out()` is the compression ratio. pub fn total_out(&self) -> u64 { self.inner.total_out() } /// Returns the number of bytes consumed by the decompressor /// (e.g. the number of bytes read from the underlying stream) pub fn total_in(&self) -> u64 { self.inner.total_in() } } impl Read for BzDecoder { fn read(&mut self, into: &mut [u8]) -> io::Result { self.inner.read(into) } } impl Write for BzDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) } fn flush(&mut self) -> io::Result<()> { self.get_mut().flush() } } /// A bzip2 streaming decoder that decodes all members of a multistream /// /// Wikipedia, particularly, uses bzip2 multistream for their dumps. pub struct MultiBzDecoder { inner: bufread::MultiBzDecoder>, } impl MultiBzDecoder { /// Creates a new decoder from the given reader, immediately parsing the /// (first) gzip header. If the gzip stream contains multiple members all will /// be decoded. pub fn new(r: R) -> Self { Self { inner: bufread::MultiBzDecoder::new(BufReader::new(r)), } } } impl MultiBzDecoder { /// Acquires a reference to the underlying reader. pub fn get_ref(&self) -> &R { self.inner.get_ref().get_ref() } /// Acquires a mutable reference to the underlying stream. /// /// Note that mutation of the stream may result in surprising results if /// this encoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.inner.get_mut().get_mut() } /// Consumes this decoder, returning the underlying reader. pub fn into_inner(self) -> R { self.inner.into_inner().into_inner() } } impl Read for MultiBzDecoder { fn read(&mut self, into: &mut [u8]) -> io::Result { self.inner.read(into) } } #[cfg(test)] mod tests { use crate::read::{BzDecoder, BzEncoder, MultiBzDecoder}; use crate::Compression; use partial_io::quickcheck_types::{GenInterrupted, PartialWithErrors}; use partial_io::PartialRead; use rand::distr::StandardUniform; use rand::{rng, Rng}; use std::io::Read; #[test] fn smoke() { let m: &[u8] = &[1, 2, 3, 4, 5, 6, 7, 8]; let mut c = BzEncoder::new(m, Compression::default()); let mut data = vec![]; c.read_to_end(&mut data).unwrap(); let mut d = BzDecoder::new(&data[..]); let mut data2 = Vec::new(); d.read_to_end(&mut data2).unwrap(); assert_eq!(data2, m); } #[test] fn smoke2() { let m: &[u8] = &[1, 2, 3, 4, 5, 6, 7, 8]; let c = BzEncoder::new(m, Compression::default()); let mut d = BzDecoder::new(c); let mut data = vec![]; d.read_to_end(&mut data).unwrap(); assert_eq!(data, [1, 2, 3, 4, 5, 6, 7, 8]); } #[test] fn smoke3() { let m = vec![3u8; 128 * 1024 + 1]; let c = BzEncoder::new(&m[..], Compression::default()); let mut d = BzDecoder::new(c); let mut data = vec![]; d.read_to_end(&mut data).unwrap(); assert!(data == m[..]); } #[test] fn self_terminating() { let m = vec![3u8; 128 * 1024 + 1]; let mut c = BzEncoder::new(&m[..], Compression::default()); let mut result = Vec::new(); c.read_to_end(&mut result).unwrap(); let v = rng() .sample_iter(&StandardUniform) .take(1024) .collect::>(); for _ in 0..200 { result.extend(v.iter().copied()); } let mut d = BzDecoder::new(&result[..]); let mut data = vec![0; m.len()]; assert!(d.read(&mut data).unwrap() == m.len()); assert!(data == m[..]); } #[test] fn zero_length_read_at_eof() { let m = Vec::new(); let mut c = BzEncoder::new(&m[..], Compression::default()); let mut result = Vec::new(); c.read_to_end(&mut result).unwrap(); let mut d = BzDecoder::new(&result[..]); let mut data = Vec::new(); assert!(d.read(&mut data).unwrap() == 0); } #[test] fn zero_length_read_with_data() { let m = vec![3u8; 128 * 1024 + 1]; let mut c = BzEncoder::new(&m[..], Compression::default()); let mut result = Vec::new(); c.read_to_end(&mut result).unwrap(); let mut d = BzDecoder::new(&result[..]); let mut data = Vec::new(); assert!(d.read(&mut data).unwrap() == 0); } #[test] fn multistream_read_till_eof() { let m = vec![3u8; 128 * 1024 + 1]; let repeat = 3; let mut result = Vec::new(); for _i in 0..repeat { let mut c = BzEncoder::new(&m[..], Compression::default()); c.read_to_end(&mut result).unwrap(); } let mut d = MultiBzDecoder::new(&result[..]); let mut data = Vec::new(); let a = d.read_to_end(&mut data).unwrap(); let b = m.len() * repeat; assert!(a == b, "{} {}", a, b); } #[test] fn empty() { let r = BzEncoder::new(&[][..], Compression::default()); let mut r = BzDecoder::new(r); let mut v2 = Vec::new(); r.read_to_end(&mut v2).unwrap(); assert!(v2.is_empty()); } #[test] fn qc() { ::quickcheck::quickcheck(test as fn(_) -> _); fn test(v: Vec) -> bool { let r = BzEncoder::new(&v[..], Compression::default()); let mut r = BzDecoder::new(r); let mut v2 = Vec::new(); r.read_to_end(&mut v2).unwrap(); v == v2 } } #[test] fn qc_partial() { ::quickcheck::quickcheck(test as fn(_, _, _) -> _); fn test( v: Vec, encode_ops: PartialWithErrors, decode_ops: PartialWithErrors, ) -> bool { let r = BzEncoder::new(PartialRead::new(&v[..], encode_ops), Compression::default()); let mut r = BzDecoder::new(PartialRead::new(r, decode_ops)); let mut v2 = Vec::new(); r.read_to_end(&mut v2).unwrap(); v == v2 } } } bzip2-0.6.1/src/write.rs000064400000000000000000000333461046102023000131560ustar 00000000000000//! Writer-based compression/decompression streams use std::io; use std::io::prelude::*; use crate::{Action, Compress, Compression, Decompress, Status}; /// A compression stream which will have uncompressed data written to it and /// will write compressed data to an output stream. pub struct BzEncoder { data: Compress, obj: Option, buf: Vec, done: bool, panicked: bool, } /// A compression stream which will have compressed data written to it and /// will write uncompressed data to an output stream. pub struct BzDecoder { data: Decompress, obj: Option, buf: Vec, done: bool, panicked: bool, } impl BzEncoder { /// Create a new compression stream which will compress at the given level /// to write compress output to the give output stream. pub fn new(obj: W, level: Compression) -> Self { Self { data: Compress::new(level, 30), obj: Some(obj), buf: Vec::with_capacity(32 * 1024), done: false, panicked: false, } } fn dump(&mut self) -> io::Result<()> { while !self.buf.is_empty() { self.panicked = true; let r = self.obj.as_mut().unwrap().write(&self.buf); self.panicked = false; match r { Ok(n) => self.buf.drain(..n), Err(ref err) if err.kind() == io::ErrorKind::Interrupted => continue, Err(err) => return Err(err), }; } Ok(()) } /// Acquires a reference to the underlying writer. pub fn get_ref(&self) -> &W { self.obj.as_ref().unwrap() } /// Acquires a mutable reference to the underlying writer. /// /// Note that mutating the output/input state of the stream may corrupt this /// object, so care must be taken when using this method. pub fn get_mut(&mut self) -> &mut W { self.obj.as_mut().unwrap() } /// Attempt to finish this output stream, writing out final chunks of data. /// /// Note that this function can only be used once data has finished being /// written to the output stream. After this function is called then further /// calls to [`write`] may result in a panic. /// /// # Panics /// /// Attempts to write data to this stream may result in a panic after this /// function is called. /// /// [`write`]: Self::write pub fn try_finish(&mut self) -> io::Result<()> { while !self.done { self.dump()?; let res = self.data.compress_vec(&[], &mut self.buf, Action::Finish); if res == Ok(Status::StreamEnd) { self.done = true; break; } } self.dump() } /// Consumes this encoder, flushing the output stream. /// /// This will flush the underlying data stream and then return the contained /// writer if the flush succeeded. /// /// Note that this function may not be suitable to call in a situation where /// the underlying stream is an asynchronous I/O stream. To finish a stream /// the [`try_finish`] (or `shutdown`) method should be used instead. To /// re-acquire ownership of a stream it is safe to call this method after /// [`try_finish`] or `shutdown` has returned `Ok`. /// /// [`try_finish`]: Self::try_finish pub fn finish(mut self) -> io::Result { self.try_finish()?; Ok(self.obj.take().unwrap()) } /// Returns the number of bytes produced by the compressor /// /// Note that, due to buffering, this only bears any relation to /// [`total_in`] after a call to [`flush`]. At that point, /// `total_out() / total_in()` is the compression ratio. /// /// [`flush`]: Self::flush /// [`total_in`]: Self::total_in pub fn total_out(&self) -> u64 { self.data.total_out() } /// Returns the number of bytes consumed by the compressor /// (e.g. the number of bytes written to this stream.) pub fn total_in(&self) -> u64 { self.data.total_in() } } impl Write for BzEncoder { fn write(&mut self, data: &[u8]) -> io::Result { loop { self.dump()?; let total_in = self.total_in(); self.data .compress_vec(data, &mut self.buf, Action::Run) .unwrap(); let written = (self.total_in() - total_in) as usize; if written > 0 || data.is_empty() { return Ok(written); } } } fn flush(&mut self) -> io::Result<()> { loop { self.dump()?; let before = self.total_out(); self.data .compress_vec(&[], &mut self.buf, Action::Flush) .unwrap(); if before == self.total_out() { break; } } self.obj.as_mut().unwrap().flush() } } impl BzDecoder { /// Create a new decoding stream which will decompress all data written /// to it into `obj`. pub fn new(obj: W) -> Self { Self { data: Decompress::new(false), obj: Some(obj), buf: Vec::with_capacity(32 * 1024), done: false, panicked: false, } } /// Acquires a reference to the underlying writer. pub fn get_ref(&self) -> &W { self.obj.as_ref().unwrap() } /// Acquires a mutable reference to the underlying writer. /// /// Note that mutating the output/input state of the stream may corrupt this /// object, so care must be taken when using this method. pub fn get_mut(&mut self) -> &mut W { self.obj.as_mut().unwrap() } fn dump(&mut self) -> io::Result<()> { while !self.buf.is_empty() { self.panicked = true; let r = self.obj.as_mut().unwrap().write(&self.buf); self.panicked = false; match r { Ok(n) => self.buf.drain(..n), Err(ref err) if err.kind() == io::ErrorKind::Interrupted => continue, Err(err) => return Err(err), }; } Ok(()) } /// Attempt to finish this output stream, writing out final chunks of data. /// /// Note that this function can only be used once data has finished being /// written to the output stream. After this function is called then further /// calls to [`write`] may result in a panic. /// /// # Panics /// /// Attempts to write data to this stream may result in a panic after this /// function is called. /// /// [`write`]: Self::write pub fn try_finish(&mut self) -> io::Result<()> { while !self.done { // The write is effectively a `self.flush()`, but we want to know how many // bytes were written. exit if no input was read and no output was written if self.write(&[])? == 0 { // finishing the output stream is effectively EOF of the input let msg = "Input EOF reached before logical stream end"; return Err(io::Error::new(io::ErrorKind::UnexpectedEof, msg)); } } self.dump() } /// Unwrap the underlying writer, finishing the compression stream. /// /// Note that this function may not be suitable to call in a situation where /// the underlying stream is an asynchronous I/O stream. To finish a stream /// the [`try_finish`] (or `shutdown`) method should be used instead. To /// re-acquire ownership of a stream it is safe to call this method after /// [`try_finish`] or `shutdown` has returned `Ok`. /// /// [`try_finish`]: Self::try_finish pub fn finish(&mut self) -> io::Result { self.try_finish()?; Ok(self.obj.take().unwrap()) } /// Returns the number of bytes produced by the decompressor /// /// Note that, due to buffering, this only bears any relation to /// [`total_in`] after a call to [`flush`]. At that point, /// `total_in() / total_out()` is the compression ratio. /// /// [`flush`]: Self::flush /// [`total_in`]: Self::total_in pub fn total_out(&self) -> u64 { self.data.total_out() } /// Returns the number of bytes consumed by the decompressor /// (e.g. the number of bytes written to this stream.) pub fn total_in(&self) -> u64 { self.data.total_in() } } impl Write for BzDecoder { fn write(&mut self, data: &[u8]) -> io::Result { if self.done { return Ok(0); } loop { self.dump()?; let before = self.total_in(); let res = self.data.decompress_vec(data, &mut self.buf); let written = (self.total_in() - before) as usize; // make sure that a subsequent call exits early when there is nothing useful left to do self.done |= matches!(res, Err(_) | Ok(Status::StreamEnd)); if let Err(e) = res { return Err(io::Error::new(io::ErrorKind::InvalidInput, e)); } if written > 0 || data.is_empty() || self.done { return Ok(written); } } } fn flush(&mut self) -> io::Result<()> { self.dump()?; self.obj.as_mut().unwrap().flush() } } impl Drop for BzDecoder { fn drop(&mut self) { if self.obj.is_some() { let _ = self.try_finish(); } } } impl Drop for BzEncoder { fn drop(&mut self) { if self.obj.is_some() && !self.panicked { let _ = self.try_finish(); } } } #[cfg(test)] mod tests { use super::{BzDecoder, BzEncoder}; use crate::Compression; use partial_io::quickcheck_types::{GenInterrupted, PartialWithErrors}; use partial_io::PartialWrite; use std::io::prelude::*; #[test] fn smoke() { let d = BzDecoder::new(Vec::new()); let mut c = BzEncoder::new(d, Compression::default()); c.write_all(b"12834").unwrap(); let s = "12345".repeat(100000); c.write_all(s.as_bytes()).unwrap(); let data = c.finish().unwrap().finish().unwrap(); assert_eq!(&data[0..5], b"12834"); assert_eq!(data.len(), 500005); assert!(format!("12834{}", s).as_bytes() == &*data); } #[test] fn roundtrip_empty() { // this encodes and then decodes an empty input file let d = BzDecoder::new(Vec::new()); let mut c = BzEncoder::new(d, Compression::default()); let _ = c.write(b"").unwrap(); let data = c.finish().unwrap().finish().unwrap(); assert_eq!(&data[..], b""); } #[test] fn finish_empty_explicit() { // The empty sequence is not a valid .bzip2 file! // A valid file at least includes the magic bytes, the checksum, etc. // // This used to loop infinitely, see // // - https://github.com/trifectatechfoundation/bzip2-rs/issues/96 // - https://github.com/trifectatechfoundation/bzip2-rs/pull/97 let mut d = BzDecoder::new(Vec::new()); d.write(b"").unwrap(); let e = d.finish().unwrap_err(); assert_eq!(e.kind(), std::io::ErrorKind::UnexpectedEof); } #[test] fn finish_empty_drop() { // the drop implementation used to loop infinitely for empty input // // see https://github.com/trifectatechfoundation/bzip2-rs/pull/118 let d = BzDecoder::new(Vec::new()); drop(d); } #[test] fn write_invalid() { // see https://github.com/trifectatechfoundation/bzip2-rs/issues/98 let mut d = BzDecoder::new(Vec::new()); let e = d.write(b"BZh\xfb").unwrap_err(); assert_eq!(e.kind(), std::io::ErrorKind::InvalidInput); } #[test] fn qc() { ::quickcheck::quickcheck(test as fn(_) -> _); fn test(v: Vec) -> bool { let w = BzDecoder::new(Vec::new()); let mut w = BzEncoder::new(w, Compression::default()); w.write_all(&v).unwrap(); v == w.finish().unwrap().finish().unwrap() } } #[test] fn qc_partial() { quickcheck::quickcheck(test as fn(_, _, _) -> _); fn test( v: Vec, encode_ops: PartialWithErrors, decode_ops: PartialWithErrors, ) -> bool { let w = BzDecoder::new(PartialWrite::new(Vec::new(), decode_ops)); let mut w = BzEncoder::new(PartialWrite::new(w, encode_ops), Compression::default()); w.write_all(&v).unwrap(); v == w .finish() .unwrap() .into_inner() .finish() .unwrap() .into_inner() } } #[test] fn terminate_on_drop() { // Test that dropping the BzEncoder flushes bytes to the output, so that // we get a valid, decompressable datastream // // see https://github.com/trifectatechfoundation/bzip2-rs/pull/121 let s = "12345".repeat(100); let mut compressed = Vec::new(); { let mut c: Box = Box::new(BzEncoder::new(&mut compressed, Compression::default())); c.write_all(b"12834").unwrap(); c.write_all(s.as_bytes()).unwrap(); c.flush().unwrap(); } assert!(!compressed.is_empty()); let uncompressed = { let mut d = BzDecoder::new(Vec::new()); d.write_all(&compressed).unwrap(); d.finish().unwrap() }; assert_eq!(&uncompressed[0..5], b"12834"); assert_eq!(uncompressed.len(), s.len() + "12834".len()); assert!(format!("12834{}", s).as_bytes() == &*uncompressed); } } bzip2-0.6.1/tests/bug_61.bz2000064400000000000000000000201001046102023000135130ustar 00000000000000BZh91AY&SY ,K^o}7K{^w5ٕ;]{{Zg}nw7|ݷ{wuy x)S!dQ(OT4ژM?D Sy #$L*o644=&ѦIOI)ꞧmM)#F44= 144T F52dFOIсzd!}~-D R? >Irfڡ1Œޔ7FkS6MsJoQtsuBH˲Tޠ(+-}426ZW?LfEY^}2_|g:I]b}s(9ȄbJd;j+ i}Pet9UajfrliIRLd0UE[:'A UPU$]E8FvjT]z;䶗8nrFb#O˵m|=:vkosH[Z*"_"Yb,h2T061(dmp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