├── .gitignore ├── COPYING ├── COPYING.LESSER ├── Changelog ├── INSTALL ├── Makefile.in ├── README.LICENSE ├── README.md ├── adaptive_compress.c ├── allocator.c ├── allocator.h ├── archive ├── dispack_helper.cpp ├── libarchive │ ├── CMakeLists.txt │ ├── COPYING │ ├── INSTALL │ ├── Makefile.am │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── VERSION │ ├── aclocal.m4 │ ├── build │ │ ├── autoconf │ │ │ ├── check_stdcall_func.m4 │ │ │ ├── compile │ │ │ ├── config.guess │ │ │ ├── config.rpath │ │ │ ├── config.sub │ │ │ ├── depcomp │ │ │ ├── iconv.m4 │ │ │ ├── install-sh │ │ │ ├── la_uid_t.m4 │ │ │ ├── lib-ld.m4 │ │ │ ├── lib-link.m4 │ │ │ ├── lib-prefix.m4 │ │ │ ├── ltmain.sh │ │ │ └── missing │ │ ├── autogen.sh │ │ ├── bump-version.sh │ │ ├── clean.sh │ │ ├── cmake │ │ │ ├── CheckFileOffsetBits.c │ │ │ ├── CheckFileOffsetBits.cmake │ │ │ ├── CheckFuncs.cmake │ │ │ ├── CheckFuncs_stub.c.in │ │ │ ├── CheckHeaderDirent.cmake │ │ │ ├── CheckStructMember.cmake │ │ │ ├── CheckTypeExists.cmake │ │ │ ├── FindLZMA.cmake │ │ │ ├── FindLibGCC.cmake │ │ │ ├── FindNettle.cmake │ │ │ ├── FindPCREPOSIX.cmake │ │ │ ├── LibarchiveCheckCSourceCompiles.cmake │ │ │ ├── LibarchiveCheckCSourceRuns.cmake │ │ │ └── config.h.in │ │ ├── pkgconfig │ │ │ └── libarchive.pc.in │ │ └── version │ ├── config.h.in │ ├── configure │ ├── configure.ac │ ├── libarchive │ │ ├── CMakeLists.txt │ │ ├── archive.h │ │ ├── archive_acl.c │ │ ├── archive_acl_private.h │ │ ├── archive_check_magic.c │ │ ├── archive_cmdline.c │ │ ├── archive_cmdline_private.h │ │ ├── archive_crc32.h │ │ ├── archive_crypto.c │ │ ├── archive_crypto_private.h │ │ ├── archive_endian.h │ │ ├── archive_entry.c │ │ ├── archive_entry.h │ │ ├── archive_entry_copy_bhfi.c │ │ ├── archive_entry_copy_stat.c │ │ ├── archive_entry_link_resolver.c │ │ ├── archive_entry_locale.h │ │ ├── archive_entry_private.h │ │ ├── archive_entry_sparse.c │ │ ├── archive_entry_stat.c │ │ ├── archive_entry_strmode.c │ │ ├── archive_entry_xattr.c │ │ ├── archive_getdate.c │ │ ├── archive_match.c │ │ ├── archive_options.c │ │ ├── archive_options_private.h │ │ ├── archive_pathmatch.c │ │ ├── archive_pathmatch.h │ │ ├── archive_platform.h │ │ ├── archive_ppmd7.c │ │ ├── archive_ppmd7_private.h │ │ ├── archive_ppmd_private.h │ │ ├── archive_private.h │ │ ├── archive_rb.c │ │ ├── archive_rb.h │ │ ├── archive_read.c │ │ ├── archive_read_append_filter.c │ │ ├── archive_read_data_into_fd.c │ │ ├── archive_read_disk_entry_from_file.c │ │ ├── archive_read_disk_posix.c │ │ ├── archive_read_disk_private.h │ │ ├── archive_read_disk_set_standard_lookup.c │ │ ├── archive_read_disk_windows.c │ │ ├── archive_read_extract.c │ │ ├── archive_read_open_fd.c │ │ ├── archive_read_open_file.c │ │ ├── archive_read_open_filename.c │ │ ├── archive_read_open_memory.c │ │ ├── archive_read_private.h │ │ ├── archive_read_set_format.c │ │ ├── archive_read_set_options.c │ │ ├── archive_read_support_filter_all.c │ │ ├── archive_read_support_filter_bzip2.c │ │ ├── archive_read_support_filter_compress.c │ │ ├── archive_read_support_filter_grzip.c │ │ ├── archive_read_support_filter_gzip.c │ │ ├── archive_read_support_filter_lrzip.c │ │ ├── archive_read_support_filter_lzop.c │ │ ├── archive_read_support_filter_none.c │ │ ├── archive_read_support_filter_program.c │ │ ├── archive_read_support_filter_rpm.c │ │ ├── archive_read_support_filter_uu.c │ │ ├── archive_read_support_filter_xz.c │ │ ├── archive_read_support_format_7zip.c │ │ ├── archive_read_support_format_all.c │ │ ├── archive_read_support_format_ar.c │ │ ├── archive_read_support_format_by_code.c │ │ ├── archive_read_support_format_cab.c │ │ ├── archive_read_support_format_cpio.c │ │ ├── archive_read_support_format_empty.c │ │ ├── archive_read_support_format_iso9660.c │ │ ├── archive_read_support_format_lha.c │ │ ├── archive_read_support_format_mtree.c │ │ ├── archive_read_support_format_rar.c │ │ ├── archive_read_support_format_raw.c │ │ ├── archive_read_support_format_tar.c │ │ ├── archive_read_support_format_xar.c │ │ ├── archive_read_support_format_zip.c │ │ ├── archive_string.c │ │ ├── archive_string.h │ │ ├── archive_string_composition.h │ │ ├── archive_string_sprintf.c │ │ ├── archive_util.c │ │ ├── archive_virtual.c │ │ ├── archive_windows.c │ │ ├── archive_windows.h │ │ ├── archive_write.c │ │ ├── archive_write_add_filter.c │ │ ├── archive_write_add_filter_b64encode.c │ │ ├── archive_write_add_filter_by_name.c │ │ ├── archive_write_add_filter_bzip2.c │ │ ├── archive_write_add_filter_compress.c │ │ ├── archive_write_add_filter_grzip.c │ │ ├── archive_write_add_filter_gzip.c │ │ ├── archive_write_add_filter_lrzip.c │ │ ├── archive_write_add_filter_lzop.c │ │ ├── archive_write_add_filter_none.c │ │ ├── archive_write_add_filter_program.c │ │ ├── archive_write_add_filter_uuencode.c │ │ ├── archive_write_add_filter_xz.c │ │ ├── archive_write_disk_acl.c │ │ ├── archive_write_disk_posix.c │ │ ├── archive_write_disk_private.h │ │ ├── archive_write_disk_set_standard_lookup.c │ │ ├── archive_write_disk_windows.c │ │ ├── archive_write_open_fd.c │ │ ├── archive_write_open_file.c │ │ ├── archive_write_open_filename.c │ │ ├── archive_write_open_memory.c │ │ ├── archive_write_private.h │ │ ├── archive_write_set_format.c │ │ ├── archive_write_set_format_7zip.c │ │ ├── archive_write_set_format_ar.c │ │ ├── archive_write_set_format_by_name.c │ │ ├── archive_write_set_format_cpio.c │ │ ├── archive_write_set_format_cpio_newc.c │ │ ├── archive_write_set_format_gnutar.c │ │ ├── archive_write_set_format_iso9660.c │ │ ├── archive_write_set_format_mtree.c │ │ ├── archive_write_set_format_pax.c │ │ ├── archive_write_set_format_shar.c │ │ ├── archive_write_set_format_ustar.c │ │ ├── archive_write_set_format_v7tar.c │ │ ├── archive_write_set_format_xar.c │ │ ├── archive_write_set_format_zip.c │ │ ├── archive_write_set_options.c │ │ ├── config_freebsd.h │ │ ├── filter_fork.h │ │ ├── filter_fork_posix.c │ │ └── filter_fork_windows.c │ └── libarchive_fe │ │ ├── err.c │ │ ├── err.h │ │ ├── lafe_platform.h │ │ ├── line_reader.c │ │ └── line_reader.h ├── pc_arc_filter.c ├── pc_arc_filter.h ├── pc_archive.c ├── pc_archive.h ├── pjpg_helper.cpp ├── ppnm_helper.cpp └── wavpack_helper.c ├── bsc ├── AUTHORS ├── CHANGES ├── COPYING ├── COPYING.LIB ├── README ├── VERSION ├── bsc.cpp ├── libbsc │ ├── adler32 │ │ ├── adler32.cpp │ │ └── adler32.h │ ├── bwt │ │ ├── bwt.cpp │ │ ├── bwt.h │ │ └── divsufsort │ │ │ ├── divsufsort.c │ │ │ └── divsufsort.h │ ├── coder │ │ ├── coder.cpp │ │ ├── coder.h │ │ ├── common │ │ │ ├── predictor.h │ │ │ ├── rangecoder.h │ │ │ └── tables.h │ │ └── qlfc │ │ │ ├── qlfc.cpp │ │ │ ├── qlfc.h │ │ │ ├── qlfc_model.cpp │ │ │ └── qlfc_model.h │ ├── filters.h │ ├── filters │ │ ├── detectors.cpp │ │ ├── preprocessing.cpp │ │ └── tables.h │ ├── libbsc.h │ ├── libbsc │ │ └── libbsc.cpp │ ├── lzp │ │ ├── lzp.cpp │ │ └── lzp.h │ └── platform │ │ ├── platform.cpp │ │ └── platform.h └── makefile ├── bsdiff ├── bscommon.h ├── bsdiff.c ├── bspatch.c └── rle_encoder.c ├── bzip2_compress.c ├── compressed_file_format.txt ├── config ├── crypto ├── aes │ ├── OPENSSL.LICENSE │ ├── aesni-x86_64.s │ ├── crypto_aes.c │ ├── crypto_aes.h │ └── vpaes-x86_64.s ├── blake2 │ ├── blake2-config.h │ ├── blake2-impl.h │ ├── blake2-kat.h │ ├── blake2.h │ ├── blake2_digest.h │ ├── blake2b-load-sse2.h │ ├── blake2b-load-sse41.h │ ├── blake2b-round.h │ ├── blake2b.c │ ├── blake2b_avx.c │ ├── blake2b_sse2.c │ ├── blake2b_sse41.c │ ├── blake2b_ssse3.c │ ├── blake2bp.c │ ├── blake2bp_avx.c │ ├── blake2bp_sse2.c │ ├── blake2bp_sse41.c │ └── blake2bp_ssse3.c ├── crypto_utils.c ├── crypto_utils.h ├── keccak │ ├── KeccakDuplex.c │ ├── KeccakDuplex.h │ ├── KeccakF-1600-64.macros │ ├── KeccakF-1600-int-set.h │ ├── KeccakF-1600-interface.h │ ├── KeccakF-1600-opt64-settings.h │ ├── KeccakF-1600-opt64.c │ ├── KeccakF-1600-simd128.macros │ ├── KeccakF-1600-simd64.macros │ ├── KeccakF-1600-unrolling.macros │ ├── KeccakF-1600-x86-64-asm.c │ ├── KeccakF-1600-x86-64-gas.s │ ├── KeccakF-1600-x86-64-gas_yasm.s │ ├── KeccakNISTInterface.c │ ├── KeccakNISTInterface.h │ ├── KeccakSponge.c │ ├── KeccakSponge.h │ ├── brg_endian.h │ └── genKAT.c ├── old │ ├── sha2_utils_old.c │ ├── sha2_utils_old.h │ ├── sha3_utils_old.c │ └── sha3_utils_old.h ├── scrypt │ ├── crypto_aesctr.c │ ├── crypto_aesctr.h │ ├── crypto_scrypt-nosse.c │ ├── crypto_scrypt.h │ ├── sha256.c │ ├── sha256.h │ └── sysendian.h ├── sha2 │ ├── _hmac.c │ ├── intel │ │ ├── open_software_license.txt │ │ ├── sha512_avx.asm │ │ └── sha512_sse4.asm │ ├── sha512.c │ └── sha512.h ├── sha2_utils.c ├── sha2_utils.h ├── sha3_utils.c ├── sha3_utils.h ├── skein │ ├── SHA3api_ref.c │ ├── SHA3api_ref.h │ ├── brg_endian.h │ ├── brg_types.h │ ├── skein.c │ ├── skein.h │ ├── skein_block.c │ ├── skein_block_x64.s │ ├── skein_debug.c │ ├── skein_debug.h │ ├── skein_iv.h │ └── skein_port.h └── xsalsa20 │ ├── crypto_core_hsalsa20.h │ ├── crypto_stream_salsa20.h │ ├── crypto_xsalsa20.h │ ├── hsalsa_core.c │ ├── stream.c │ ├── stream.s │ └── xsalsa20_xor.c ├── filters ├── analyzer │ ├── analyzer.c │ └── analyzer.h ├── delta2 │ ├── delta2.c │ └── delta2.h ├── dict │ ├── Common.h │ ├── DictFilter.cpp │ └── DictFilter.h ├── dispack │ ├── dis.cpp │ ├── dis.hpp │ └── types.hpp ├── lzp │ ├── lzp.c │ └── lzp.h ├── packjpg │ ├── Readme.txt │ ├── aricoder.cpp │ ├── aricoder.h │ ├── bitops.cpp │ ├── bitops.h │ ├── dct8x8.h │ ├── lgpl-3.0.txt │ ├── packjpg.cpp │ ├── packjpglib.h │ └── pjpgtbl.h ├── packpnm │ ├── lgpl-3.0.txt │ ├── packpnm.cpp │ ├── packpnmlib.h │ ├── ppnmbitlen.h │ └── ppnmtbl.h └── transpose │ ├── transpose.c │ └── transpose.h ├── libbsc_compress.c ├── licensing_utils ├── LICENSE.MPLV2 ├── lic_header.asm ├── lic_header.c ├── lic_header.s └── lic_header.sh ├── lz4 ├── lz4.c ├── lz4.h ├── lz4hc.c └── lz4hc.h ├── lz4_compress.c ├── lzfx ├── lzfx.c └── lzfx.h ├── lzfx_compress.c ├── lzma ├── Common │ ├── MyGuidDef.h │ └── MyWindows.h ├── CpuArch.c ├── CpuArch.h ├── LzFind.c ├── LzFind.h ├── LzFindMt.c ├── LzFindMt.h ├── LzHash.h ├── LzmaDec.c ├── LzmaDec.h ├── LzmaEnc.c ├── LzmaEnc.h ├── Ppmd.h ├── Ppmd8.c ├── Ppmd8.h ├── Ppmd8Dec.c ├── Ppmd8Enc.c ├── Threads.c ├── Threads.h ├── Types.h ├── basetyps.h ├── crc32_fast.c ├── crc32_table.c ├── crc32_table_be.h ├── crc32_table_le.h ├── crc32_tablegen.c ├── crc64_fast.c ├── crc64_table.c ├── crc64_table_be.h ├── crc64_table_le.h ├── crc64_tablegen.c ├── crc_macros.h ├── lzma_crc.h └── windows.h ├── lzma_compress.c ├── main.c ├── make_mplv2.ksh ├── meta_stream.c ├── meta_stream.h ├── none_compress.c ├── pcompress.c ├── pcompress.h ├── ppmd_compress.c ├── rabin ├── global │ ├── dedupe_config.c │ ├── dedupe_config.h │ ├── index.c │ └── index.h ├── rabin_dedup.c └── rabin_dedup.h ├── test ├── res │ ├── jpg │ │ └── screen.jpg │ └── xml │ │ └── iso_639_3.xml ├── run_test.sh ├── t1.tst ├── t2.tst ├── t3.tst ├── t4.tst ├── t5.tst ├── t6.tst ├── t7.tst ├── t8.tst └── t9.tst ├── utils ├── cpuid.c ├── cpuid.h ├── fixlic.sh ├── heap.c ├── heap.h ├── pcompress.sh ├── phash │ ├── Makefile │ ├── Makefile.test │ ├── extensions.h │ ├── extensions.txt │ ├── genhash.sh │ ├── lookupa.c │ ├── lookupa.h │ ├── perfect.c │ ├── perfect.h │ ├── perfhex.c │ ├── phash.c │ ├── phash.h │ ├── recycle.c │ ├── recycle.h │ ├── standard.h │ └── testperf.c ├── qsort.h ├── qsort_bsd.h ├── qsort_gnu.h ├── sse_level.c ├── utils.c ├── utils.h ├── winsupport.h ├── xxhash.c ├── xxhash.h ├── xxhash_base.c ├── xxhash_sse2.c └── xxhash_sse4.c └── zlib_compress.c /.gitignore: -------------------------------------------------------------------------------- 1 | files.lst 2 | *.pc* 3 | .seg* 4 | *.o 5 | *.so 6 | pcompress 7 | libpcompress* 8 | Makefile 9 | test.log 10 | test/datafiles 11 | *~ 12 | core.* 13 | *.kate-swp 14 | bsc/bsc 15 | *.a 16 | *.lo 17 | config.h 18 | config.log 19 | config.status 20 | *.la 21 | libtool 22 | .deps 23 | .dirstamp 24 | stamp-h1 25 | .libs 26 | buildtmp 27 | *.dSYM 28 | -------------------------------------------------------------------------------- /README.LICENSE: -------------------------------------------------------------------------------- 1 | ######### LICENSING NOTE ########## 2 | Pcompress is dual licensed under GNU Lesser General Public License V3 and 3 | also under the Mozilla Public License V2. 4 | 5 | Normally the default license that applies is the GNU LGPLv3. However it is 6 | possible to create an alternate source tree that is licensed under the MPLv2 7 | by running the following at the top of the source tree: 8 | 9 | ksh make_mplv2.ksh 10 | 11 | NOTE that most of Pcompress is covered under MPLv2. However a couple of 12 | third party components like LZP and PackJPG use LGPLv2/3 upstream license 13 | and are omitted in the MPLv2 variant. 14 | 15 | -------------------------------------------------------------------------------- /allocator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef __ALLOCATOR_H__ 27 | #define __ALLOCATOR_H__ 28 | 29 | #include 30 | #include 31 | 32 | void slab_init(); 33 | void slab_cleanup(int quiet); 34 | void *slab_alloc(void *p, size_t size); 35 | void *slab_calloc(void *p, size_t items, size_t size); 36 | void slab_free(void *p, void *address); 37 | void slab_release(void *p, void *address); 38 | int slab_cache_add(uint64_t size); 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /archive/libarchive/COPYING: -------------------------------------------------------------------------------- 1 | The libarchive distribution as a whole is Copyright by Tim Kientzle 2 | and is subject to the copyright notice reproduced at the bottom of 3 | this file. 4 | 5 | Each individual file in this distribution should have a clear 6 | copyright/licensing statement at the beginning of the file. If any do 7 | not, please let me know and I will rectify it. The following is 8 | intended to summarize the copyright status of the individual files; 9 | the actual statements in the files are controlling. 10 | 11 | * Except as listed below, all C sources (including .c and .h files) 12 | and documentation files are subject to the copyright notice reproduced 13 | at the bottom of this file. 14 | 15 | * The following source files are also subject in whole or in part to 16 | a 3-clause UC Regents copyright; please read the individual source 17 | files for details: 18 | libarchive/archive_entry.c 19 | libarchive/archive_read_support_filter_compress.c 20 | libarchive/archive_write_set_filter_compress.c 21 | libarchive/mtree.5 22 | tar/matching.c 23 | 24 | * The following source files are in the public domain: 25 | tar/getdate.c 26 | 27 | * The build files---including Makefiles, configure scripts, 28 | and auxiliary scripts used as part of the compile process---have 29 | widely varying licensing terms. Please check individual files before 30 | distributing them to see if those restrictions apply to you. 31 | 32 | I intend for all new source code to use the license below and hope over 33 | time to replace code with other licenses with new implementations that 34 | do use the license below. The varying licensing of the build scripts 35 | seems to be an unavoidable mess. 36 | 37 | 38 | Copyright (c) 2003-2009 39 | All rights reserved. 40 | 41 | Redistribution and use in source and binary forms, with or without 42 | modification, are permitted provided that the following conditions 43 | are met: 44 | 1. Redistributions of source code must retain the above copyright 45 | notice, this list of conditions and the following disclaimer 46 | in this position and unchanged. 47 | 2. Redistributions in binary form must reproduce the above copyright 48 | notice, this list of conditions and the following disclaimer in the 49 | documentation and/or other materials provided with the distribution. 50 | 51 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 52 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 53 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 54 | IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 55 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 56 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 58 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 59 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 60 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 | -------------------------------------------------------------------------------- /archive/libarchive/INSTALL: -------------------------------------------------------------------------------- 1 | More complete build documentation is available on the libarchive 2 | Wiki: http://libarchive.googlecode.com/ 3 | 4 | On most Unix-like systems, you should be able to install libarchive, 5 | bsdtar, and bsdcpio using the following common steps: 6 | ./configure 7 | make 8 | make install 9 | 10 | If you need to customize the target directories or otherwise adjust 11 | the build setting, use 12 | ./configure --help 13 | to list the configure options. 14 | 15 | If you are developing libarchive and need to update the 16 | configure script and other build files: 17 | /bin/sh build/autogen.sh 18 | 19 | To create a distribution, please use the 'distcheck' target: 20 | /bin/sh build/autogen.sh && ./configure && make distcheck 21 | 22 | On Unix-like and non-Unix-like systems, use the "cmake" utility (available from 23 | http://cmake.org/) to generate suitable build files for your platform. 24 | Cmake requires the name of the directory containing CmakeLists.txt and 25 | the "generator" to use for your build environment. For example, to 26 | build with Xcode on Mac OS, you can use the following command: 27 | cmake -G "Xcode" ~/libarchive-download-dir/ 28 | The result will be appropriate makefiles, solution files, or project 29 | files that can be used with the corresponding development tool. 30 | The default on Unix-like systems is to generate Makefiles, so you 31 | can also use cmake instead of the configure script: 32 | cmake ~/libarchive-download-dir/ 33 | make 34 | make install 35 | See the libarchive Wiki or the cmake site for further documentation. 36 | -------------------------------------------------------------------------------- /archive/libarchive/VERSION: -------------------------------------------------------------------------------- 1 | 3.1.2 2 | -------------------------------------------------------------------------------- /archive/libarchive/build/autoconf/check_stdcall_func.m4: -------------------------------------------------------------------------------- 1 | # AC_LANG_STDCALL_FUNC_LINK_TRY(FUNCTION, SIGNATURE) 2 | # ------------------------------- 3 | # Produce a source which links correctly iff the FUNCTION exists. 4 | AC_DEFUN([AC_LANG_STDCALL_FUNC_LINK_TRY], 5 | [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) 6 | 7 | # AC_CHECK_STDCALL_FUNC(FUNCTION, SIGNATURE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 8 | # ----------------------------------------------------------------- 9 | AC_DEFUN([AC_CHECK_STDCALL_FUNC], 10 | [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl 11 | AC_CACHE_CHECK([for $1], ac_var, 12 | [AC_LINK_IFELSE([AC_LANG_STDCALL_FUNC_LINK_TRY([$1],[$2])], 13 | [AS_VAR_SET(ac_var, yes)], 14 | [AS_VAR_SET(ac_var, no)])]) 15 | AS_IF([test AS_VAR_GET(ac_var) = yes], [$3], [$4])dnl 16 | AS_VAR_POPDEF([ac_var])dnl 17 | ])# AC_CHECK_FUNC 18 | 19 | # AC_LANG_STDCALL_FUNC_LINK_TRY(C)(FUNCTION, SIGNATURE) 20 | # ---------------------------------- 21 | # Don't include because on OSF/1 3.0 it includes 22 | # which includes which contains a 23 | # prototype for select. Similarly for bzero. 24 | m4_define([AC_LANG_STDCALL_FUNC_LINK_TRY(C)], 25 | [AC_LANG_PROGRAM( 26 | [/* System header to define __stub macros and hopefully few prototypes, 27 | which can conflict with char __stdcall $1 ( $2 ) below. */ 28 | #include 29 | /* Override any gcc2 internal prototype to avoid an error. */ 30 | #ifdef __cplusplus 31 | extern "C" 32 | #endif 33 | /* We use char because int might match the return type of a gcc2 34 | builtin and then its argument prototype would still apply. */ 35 | char __stdcall $1 ( $2 ); 36 | char (*f) ( $2 ); 37 | ], 38 | [/* The GNU C library defines this for functions which it implements 39 | to always fail with ENOSYS. Some functions are actually named 40 | something starting with __ and the normal name is an alias. */ 41 | #if defined (__stub_$1) || defined (__stub___$1) 42 | choke me 43 | #else 44 | f = $1; 45 | #endif 46 | ])]) 47 | 48 | # AC_LANG_STDCALL_FUNC_LINK_TRY(C++)(FUNCTION) 49 | # ------------------------------------ 50 | m4_copy([AC_LANG_STDCALL_FUNC_LINK_TRY(C)], [AC_LANG_STDCALL_FUNC_LINK_TRY(C++)]) 51 | 52 | -------------------------------------------------------------------------------- /archive/libarchive/build/autoconf/la_uid_t.m4: -------------------------------------------------------------------------------- 1 | # la_TYPE_UID_T 2 | # ------------- 3 | AC_DEFUN([la_TYPE_UID_T], 4 | [AC_REQUIRE([AC_CANONICAL_HOST])dnl 5 | AC_CACHE_CHECK(for uid_t in sys/types.h, la_cv_type_uid_t, 6 | [AC_EGREP_HEADER(uid_t, sys/types.h, 7 | la_cv_type_uid_t=yes, la_cv_type_uid_t=no)]) 8 | if test $la_cv_type_uid_t = no; then 9 | case $host in 10 | *mingw*) def_uid_t=short ;; 11 | *) def_uid_t=int ;; 12 | esac 13 | AC_DEFINE_UNQUOTED(uid_t, [$def_uid_t], 14 | [Define to match typeof st_uid field of struct stat if doesn't define.]) 15 | AC_DEFINE_UNQUOTED(gid_t, [$def_uid_t], 16 | [Define to match typeof st_gid field of struct stat if doesn't define.]) 17 | fi 18 | ]) 19 | AU_ALIAS([AC_TYPE_UID_T], [la_TYPE_UID_T]) 20 | 21 | -------------------------------------------------------------------------------- /archive/libarchive/build/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PATH=/usr/local/gnu-autotools/bin/:$PATH 4 | export PATH 5 | 6 | # Start from one level above the build directory 7 | if [ -f version ]; then 8 | cd .. 9 | fi 10 | 11 | if [ \! -f build/version ]; then 12 | echo "Can't find source directory" 13 | exit 1 14 | fi 15 | 16 | # BSD make's "OBJDIR" support freaks out the automake-generated 17 | # Makefile. Effectively disable it. 18 | export MAKEOBJDIRPREFIX=/junk 19 | 20 | # Start from the build directory, where the version file is located 21 | if [ -f build/version ]; then 22 | cd build 23 | fi 24 | 25 | if [ \! -f version ]; then 26 | echo "Can't find version file" 27 | exit 1 28 | fi 29 | 30 | # Update the build number in the 'version' file. 31 | # Separate number from additional alpha/beta/etc marker 32 | MARKER=`cat version | sed 's/[0-9.]//g'` 33 | # Bump the number 34 | VN=`cat version | sed 's/[^0-9.]//g'` 35 | # Build out the string. 36 | VS="$(($VN/1000000)).$(( ($VN/1000)%1000 )).$(( $VN%1000 ))$MARKER" 37 | 38 | cd .. 39 | 40 | # Clean up the source dir as much as we can. 41 | /bin/sh build/clean.sh 42 | 43 | # Substitute the versions into Libarchive's archive.h and archive_entry.h 44 | perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive.h 45 | perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive_entry.h 46 | perl -p -i -e "s/^(#define\tARCHIVE_VERSION_STRING).*/\$1 \"libarchive $VS\"/" libarchive/archive.h 47 | # Substitute versions into configure.ac as well 48 | perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_S\]),.*\)/$1,['"$VS"'])/' configure.ac 49 | perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_N\]),.*\)/$1,['"$VN"'])/' configure.ac 50 | 51 | # Remove developer CFLAGS if a release build is being made 52 | if [ -n "${MAKE_LIBARCHIVE_RELEASE}" ]; then 53 | perl -p -i -e "s/^(DEV_CFLAGS.*)/# \$1/" Makefile.am 54 | fi 55 | 56 | set -xe 57 | aclocal -I build/autoconf 58 | 59 | # Note: --automake flag needed only for libtoolize from 60 | # libtool 1.5.x; in libtool 2.2.x it is a synonym for --quiet 61 | case `uname` in 62 | Darwin) glibtoolize --automake -c;; 63 | *) libtoolize --automake -c;; 64 | esac 65 | autoconf 66 | autoheader 67 | automake -a -c 68 | -------------------------------------------------------------------------------- /archive/libarchive/build/bump-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh +v 2 | 3 | # Start from the build directory, where the version file is located 4 | if [ -f build/version ]; then 5 | cd build 6 | fi 7 | 8 | if [ \! -f version ]; then 9 | echo "Can't find version file" 10 | exit 1 11 | fi 12 | 13 | # Update the build number in the 'version' file. 14 | # Separate number from additional alpha/beta/etc marker 15 | MARKER=`cat version | sed 's/[0-9.]//g'` 16 | # Bump the number 17 | VN=`cat version | sed 's/[^0-9.]//g'` 18 | # Reassemble and write back out 19 | VN=$(($VN + 1)) 20 | rm -f version.old 21 | mv version version.old 22 | chmod +w version.old 23 | echo $VN$MARKER > version 24 | VS="$(($VN/1000000)).$(( ($VN/1000)%1000 )).$(( $VN%1000 ))$MARKER" 25 | cd .. 26 | 27 | ANNOUNCE=`date +"%b %d, %Y:"`" libarchive $VS released" 28 | 29 | echo $ANNOUNCE 30 | 31 | # Add a version notice to NEWS 32 | mv NEWS NEWS.bak 33 | chmod +w NEWS.bak 34 | echo $ANNOUNCE >> NEWS 35 | echo >> NEWS 36 | cat NEWS.bak >> NEWS 37 | -------------------------------------------------------------------------------- /archive/libarchive/build/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Attempt to remove as many generated files as we can. 5 | # Ideally, a well-used development sandbox would look like 6 | # a pristine checkout after running this script. 7 | # 8 | 9 | if [ \! -f build/version ]; then 10 | echo 'Must run the clean script from the top-level dir of the libarchive distribution' 1>&2 11 | exit 1 12 | fi 13 | 14 | # If we're on BSD, blow away the build dir under /usr/obj 15 | rm -rf /usr/obj`pwd` 16 | 17 | # 18 | # Try to clean up a bit more... 19 | # 20 | 21 | find . -name '*.So' | xargs rm -f 22 | find . -name '*.a' | xargs rm -f 23 | find . -name '*.la' | xargs rm -f 24 | find . -name '*.lo' | xargs rm -f 25 | find . -name '*.o' | xargs rm -f 26 | find . -name '*.orig' | xargs rm -f 27 | find . -name '*.po' | xargs rm -f 28 | find . -name '*.rej' | xargs rm -f 29 | find . -name '*~' | xargs rm -f 30 | find . -name '.depend' | xargs rm -f 31 | find . -name '.deps' | xargs rm -rf 32 | find . -name '.dirstamp' | xargs rm -f 33 | find . -name '.libs' | xargs rm -rf 34 | find . -name 'CMakeFiles' | xargs rm -rf 35 | find . -name 'cmake_install.cmake' | xargs rm -f 36 | find . -name 'CTestTestfile.cmake' | xargs rm -f 37 | 38 | rm -rf Testing 39 | rm -rf autom4te.cache 40 | rm -rf bin 41 | rm -rf cmake.tmp 42 | rm -rf libarchive/Testing 43 | 44 | rm -f CMakeCache.txt 45 | rm -f DartConfiguration.tcl 46 | rm -f Makefile 47 | rm -f Makefile.in 48 | rm -f aclocal.m4 49 | rm -f bsdcpio 50 | rm -f bsdcpio_test 51 | rm -f bsdtar 52 | rm -f bsdtar_test 53 | rm -f build/autoconf/compile 54 | rm -f build/autoconf/config.guess 55 | rm -f build/autoconf/config.sub 56 | rm -f build/autoconf/depcomp 57 | rm -f build/autoconf/install-sh 58 | rm -f build/autoconf/libtool.m4 59 | rm -f build/autoconf/ltmain.sh 60 | rm -f build/autoconf/ltoptions.m4 61 | rm -f build/autoconf/ltsugar.m4 62 | rm -f build/autoconf/ltversion.m4 63 | rm -f build/autoconf/lt~obsolete.m4 64 | rm -f build/autoconf/missing 65 | rm -f build/pkgconfig/libarchive.pc 66 | rm -f build/version.old 67 | rm -f config.h 68 | rm -f config.h.in 69 | rm -f config.log 70 | rm -f config.status 71 | rm -f configure 72 | rm -f cpio/*.1.gz 73 | rm -f cpio/Makefile 74 | rm -f cpio/bsdcpio 75 | rm -f cpio/test/Makefile 76 | rm -f cpio/test/bsdcpio_test 77 | rm -f cpio/test/list.h 78 | rm -f doc/html/* 79 | rm -f doc/man/* 80 | rm -f doc/pdf/* 81 | rm -f doc/text/* 82 | rm -f doc/wiki/* 83 | rm -f libarchive/*.[35].gz 84 | rm -f libarchive/Makefile 85 | rm -f libarchive/libarchive.so* 86 | rm -f libarchive/test/Makefile 87 | rm -f libarchive/test/libarchive_test 88 | rm -f libarchive/test/list.h 89 | rm -f libarchive_test 90 | rm -f libtool 91 | rm -f stamp-h1 92 | rm -f tar/*.1.gz 93 | rm -f tar/Makefile 94 | rm -f tar/bsdtar 95 | rm -f tar/test/Makefile 96 | rm -f tar/test/bsdtar_test 97 | rm -f tar/test/list.h 98 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/CheckFileOffsetBits.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define KB ((off_t)1024) 4 | #define MB ((off_t)1024 * KB) 5 | #define GB ((off_t)1024 * MB) 6 | #define TB ((off_t)1024 * GB) 7 | int t2[(((64 * GB -1) % 671088649) == 268434537) 8 | && (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1]; 9 | 10 | int main() 11 | { 12 | ; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/CheckFileOffsetBits.cmake: -------------------------------------------------------------------------------- 1 | # - Check if _FILE_OFFSET_BITS macro needed for large files 2 | # CHECK_FILE_OFFSET_BITS () 3 | # 4 | # The following variables may be set before calling this macro to 5 | # modify the way the check is run: 6 | # 7 | # CMAKE_REQUIRED_FLAGS = string of compile command line flags 8 | # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) 9 | # CMAKE_REQUIRED_INCLUDES = list of include directories 10 | # Copyright (c) 2009, Michihiro NAKAJIMA 11 | # 12 | # Redistribution and use is allowed according to the terms of the BSD license. 13 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 14 | 15 | #INCLUDE(CheckCXXSourceCompiles) 16 | 17 | GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits 18 | "${CMAKE_CURRENT_LIST_FILE}" PATH) 19 | 20 | MACRO (CHECK_FILE_OFFSET_BITS) 21 | IF(NOT DEFINED _FILE_OFFSET_BITS) 22 | MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files") 23 | TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64 24 | ${CMAKE_CURRENT_BINARY_DIR} 25 | ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c 26 | COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}) 27 | IF(NOT __WITHOUT_FILE_OFFSET_BITS_64) 28 | TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64 29 | ${CMAKE_CURRENT_BINARY_DIR} 30 | ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c 31 | COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64) 32 | ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64) 33 | 34 | IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) 35 | SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") 36 | MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - needed") 37 | ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) 38 | SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") 39 | MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - not needed") 40 | ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) 41 | ENDIF(NOT DEFINED _FILE_OFFSET_BITS) 42 | 43 | ENDMACRO (CHECK_FILE_OFFSET_BITS) 44 | 45 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/CheckFuncs.cmake: -------------------------------------------------------------------------------- 1 | # Check if the system has the specified function; treat glibc "stub" 2 | # functions as nonexistent: 3 | # CHECK_FUNCTION_EXISTS_GLIBC (FUNCTION FUNCVAR) 4 | # 5 | # FUNCTION - the function(s) where the prototype should be declared 6 | # FUNCVAR - variable to define if the function does exist 7 | # 8 | # In particular, this understands the glibc convention of 9 | # defining macros __stub_XXXX or __stub___XXXX if the function 10 | # does appear in the library but is merely a stub that does nothing. 11 | # By detecting this case, we can select alternate behavior on 12 | # platforms that don't support this functionality. 13 | # 14 | # The following variables may be set before calling this macro to 15 | # modify the way the check is run: 16 | # 17 | # CMAKE_REQUIRED_FLAGS = string of compile command line flags 18 | # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) 19 | # CMAKE_REQUIRED_INCLUDES = list of include directories 20 | # Copyright (c) 2009, Michihiro NAKAJIMA 21 | # 22 | # Redistribution and use is allowed according to the terms of the BSD license. 23 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 24 | 25 | INCLUDE(CheckFunctionExists) 26 | GET_FILENAME_COMPONENT(_selfdir_CheckFunctionExistsGlibc 27 | "${CMAKE_CURRENT_LIST_FILE}" PATH) 28 | 29 | MACRO (CHECK_FUNCTION_EXISTS_GLIBC _FUNC _FUNCVAR) 30 | IF(NOT DEFINED ${_FUNCVAR}) 31 | SET(CHECK_STUB_FUNC_1 "__stub_${_FUNC}") 32 | SET(CHECK_STUB_FUNC_2 "__stub___${_FUNC}") 33 | CONFIGURE_FILE( ${_selfdir_CheckFunctionExistsGlibc}/CheckFuncs_stub.c.in 34 | ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c IMMEDIATE) 35 | TRY_COMPILE(__stub 36 | ${CMAKE_CURRENT_BINARY_DIR} 37 | ${CMAKE_CURRENT_BINARY_DIR}/cmake.tmp/CheckFuncs_stub.c 38 | COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} 39 | CMAKE_FLAGS 40 | -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS} 41 | "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}") 42 | IF (__stub) 43 | SET("${_FUNCVAR}" "" CACHE INTERNAL "Have function ${_FUNC}") 44 | ELSE (__stub) 45 | CHECK_FUNCTION_EXISTS("${_FUNC}" "${_FUNCVAR}") 46 | ENDIF (__stub) 47 | ENDIF(NOT DEFINED ${_FUNCVAR}) 48 | ENDMACRO (CHECK_FUNCTION_EXISTS_GLIBC) 49 | 50 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/CheckFuncs_stub.c.in: -------------------------------------------------------------------------------- 1 | #ifdef __STDC__ 2 | #include 3 | #else 4 | #include 5 | #endif 6 | 7 | int 8 | main() 9 | { 10 | #if defined ${CHECK_STUB_FUNC_1} || defined ${CHECK_STUB_FUNC_2} 11 | return 0; 12 | #else 13 | this system have stub 14 | return 0; 15 | #endif 16 | } 17 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/CheckHeaderDirent.cmake: -------------------------------------------------------------------------------- 1 | # - Check if the system has the specified type 2 | # CHECK_HEADER_DIRENT (HEADER1 HEARDER2 ...) 3 | # 4 | # HEADER - the header(s) where the prototype should be declared 5 | # 6 | # The following variables may be set before calling this macro to 7 | # modify the way the check is run: 8 | # 9 | # CMAKE_REQUIRED_FLAGS = string of compile command line flags 10 | # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) 11 | # CMAKE_REQUIRED_INCLUDES = list of include directories 12 | # Copyright (c) 2009, Michihiro NAKAJIMA 13 | # 14 | # Redistribution and use is allowed according to the terms of the BSD license. 15 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 16 | 17 | 18 | INCLUDE(CheckTypeExists) 19 | 20 | MACRO (CHECK_HEADER_DIRENT) 21 | CHECK_TYPE_EXISTS("DIR *" dirent.h HAVE_DIRENT_H) 22 | IF(NOT HAVE_DIRENT_H) 23 | CHECK_TYPE_EXISTS("DIR *" sys/ndir.h HAVE_SYS_NDIR_H) 24 | IF(NOT HAVE_SYS_NDIR_H) 25 | CHECK_TYPE_EXISTS("DIR *" ndir.h HAVE_NDIR_H) 26 | IF(NOT HAVE_NDIR_H) 27 | CHECK_TYPE_EXISTS("DIR *" sys/dir.h HAVE_SYS_DIR_H) 28 | ENDIF(NOT HAVE_NDIR_H) 29 | ENDIF(NOT HAVE_SYS_NDIR_H) 30 | ENDIF(NOT HAVE_DIRENT_H) 31 | ENDMACRO (CHECK_HEADER_DIRENT) 32 | 33 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/CheckStructMember.cmake: -------------------------------------------------------------------------------- 1 | # - Check if the given struct or class has the specified member variable 2 | # CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE) 3 | # 4 | # STRUCT - the name of the struct or class you are interested in 5 | # MEMBER - the member which existence you want to check 6 | # HEADER - the header(s) where the prototype should be declared 7 | # VARIABLE - variable to store the result 8 | # 9 | # The following variables may be set before calling this macro to 10 | # modify the way the check is run: 11 | # 12 | # CMAKE_REQUIRED_FLAGS = string of compile command line flags 13 | # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) 14 | # CMAKE_REQUIRED_INCLUDES = list of include directories 15 | 16 | # Copyright (c) 2006, Alexander Neundorf, 17 | # 18 | # Redistribution and use is allowed according to the terms of the BSD license. 19 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 20 | 21 | 22 | INCLUDE(CheckCSourceCompiles) 23 | 24 | MACRO (CHECK_STRUCT_MEMBER _STRUCT _MEMBER _HEADER _RESULT) 25 | SET(_INCLUDE_FILES) 26 | FOREACH (it ${_HEADER}) 27 | SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") 28 | ENDFOREACH (it) 29 | 30 | SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE " 31 | ${_INCLUDE_FILES} 32 | int main() 33 | { 34 | static ${_STRUCT} tmp; 35 | if (sizeof(tmp.${_MEMBER})) 36 | return 0; 37 | return 0; 38 | } 39 | ") 40 | CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) 41 | 42 | ENDMACRO (CHECK_STRUCT_MEMBER) 43 | 44 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/CheckTypeExists.cmake: -------------------------------------------------------------------------------- 1 | # - Check if the system has the specified type 2 | # CHECK_TYPE_EXISTS (TYPE HEADER VARIABLE) 3 | # 4 | # TYPE - the name of the type or struct or class you are interested in 5 | # HEADER - the header(s) where the prototype should be declared 6 | # VARIABLE - variable to store the result 7 | # 8 | # The following variables may be set before calling this macro to 9 | # modify the way the check is run: 10 | # 11 | # CMAKE_REQUIRED_FLAGS = string of compile command line flags 12 | # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) 13 | # CMAKE_REQUIRED_INCLUDES = list of include directories 14 | # Copyright (c) 2009, Michihiro NAKAJIMA 15 | # Copyright (c) 2006, Alexander Neundorf, 16 | # 17 | # Redistribution and use is allowed according to the terms of the BSD license. 18 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 19 | 20 | 21 | INCLUDE(CheckCSourceCompiles) 22 | 23 | MACRO (CHECK_TYPE_EXISTS _TYPE _HEADER _RESULT) 24 | SET(_INCLUDE_FILES) 25 | FOREACH (it ${_HEADER}) 26 | SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n") 27 | ENDFOREACH (it) 28 | 29 | SET(_CHECK_TYPE_EXISTS_SOURCE_CODE " 30 | ${_INCLUDE_FILES} 31 | int main() 32 | { 33 | static ${_TYPE} tmp; 34 | if (sizeof(tmp)) 35 | return 0; 36 | return 0; 37 | } 38 | ") 39 | CHECK_C_SOURCE_COMPILES("${_CHECK_TYPE_EXISTS_SOURCE_CODE}" ${_RESULT}) 40 | 41 | ENDMACRO (CHECK_TYPE_EXISTS) 42 | 43 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/FindLZMA.cmake: -------------------------------------------------------------------------------- 1 | # - Find lzma and lzmadec 2 | # Find the native LZMA includes and library 3 | # 4 | # LZMA_INCLUDE_DIR - where to find lzma.h, etc. 5 | # LZMA_LIBRARIES - List of libraries when using liblzma. 6 | # LZMA_FOUND - True if liblzma found. 7 | # LZMADEC_INCLUDE_DIR - where to find lzmadec.h, etc. 8 | # LZMADEC_LIBRARIES - List of libraries when using liblzmadec. 9 | # LZMADEC_FOUND - True if liblzmadec found. 10 | 11 | IF (LZMA_INCLUDE_DIR) 12 | # Already in cache, be silent 13 | SET(LZMA_FIND_QUIETLY TRUE) 14 | ENDIF (LZMA_INCLUDE_DIR) 15 | 16 | FIND_PATH(LZMA_INCLUDE_DIR lzma.h) 17 | FIND_LIBRARY(LZMA_LIBRARY NAMES lzma liblzma) 18 | 19 | # handle the QUIETLY and REQUIRED arguments and set LZMA_FOUND to TRUE if 20 | # all listed variables are TRUE 21 | INCLUDE(FindPackageHandleStandardArgs) 22 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZMA DEFAULT_MSG LZMA_LIBRARY LZMA_INCLUDE_DIR) 23 | 24 | IF(LZMA_FOUND) 25 | SET( LZMA_LIBRARIES ${LZMA_LIBRARY} ) 26 | ELSE(LZMA_FOUND) 27 | SET( LZMA_LIBRARIES ) 28 | 29 | IF (LZMADEC_INCLUDE_DIR) 30 | # Already in cache, be silent 31 | SET(LZMADEC_FIND_QUIETLY TRUE) 32 | ENDIF (LZMADEC_INCLUDE_DIR) 33 | 34 | FIND_PATH(LZMADEC_INCLUDE_DIR lzmadec.h) 35 | FIND_LIBRARY(LZMADEC_LIBRARY NAMES lzmadec ) 36 | 37 | # handle the QUIETLY and REQUIRED arguments and set LZMADEC_FOUND to TRUE if 38 | # all listed variables are TRUE 39 | INCLUDE(FindPackageHandleStandardArgs) 40 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZMADEC DEFAULT_MSG LZMADEC_LIBRARY 41 | LZMADEC_INCLUDE_DIR) 42 | 43 | IF(LZMADEC_FOUND) 44 | SET( LZMADEC_LIBRARIES ${LZMADEC_LIBRARY} ) 45 | ELSE(LZMADEC_FOUND) 46 | SET( LZMADEC_LIBRARIES ) 47 | ENDIF(LZMADEC_FOUND) 48 | ENDIF(LZMA_FOUND) 49 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/FindLibGCC.cmake: -------------------------------------------------------------------------------- 1 | # - Find libgcc 2 | # Find the libgcc library. 3 | # 4 | # LIBGCC_LIBRARIES - List of libraries when using libgcc 5 | # LIBGCC_FOUND - True if libgcc found. 6 | 7 | IF (LIBGCC_LIBRARY) 8 | # Already in cache, be silent 9 | SET(LIBGCC_FIND_QUIETLY TRUE) 10 | ENDIF (LIBGCC_LIBRARY) 11 | 12 | FIND_LIBRARY(LIBGCC_LIBRARY NAMES gcc libgcc) 13 | 14 | # handle the QUIETLY and REQUIRED arguments and set LIBGCC_FOUND to TRUE if 15 | # all listed variables are TRUE 16 | INCLUDE(FindPackageHandleStandardArgs) 17 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGCC DEFAULT_MSG LIBGCC_LIBRARY) 18 | 19 | IF(LIBGCC_FOUND) 20 | SET(LIBGCC_LIBRARIES ${LIBGCC_LIBRARY}) 21 | SET(HAVE_LIBGCC 1) 22 | ENDIF(LIBGCC_FOUND) 23 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/FindNettle.cmake: -------------------------------------------------------------------------------- 1 | # - Find Nettle 2 | # Find the Nettle include directory and library 3 | # 4 | # NETTLE_INCLUDE_DIR - where to find , etc. 5 | # NETTLE_LIBRARIES - List of libraries when using libnettle. 6 | # NETTLE_FOUND - True if libnettle found. 7 | 8 | IF (NETTLE_INCLUDE_DIR) 9 | # Already in cache, be silent 10 | SET(NETTLE_FIND_QUIETLY TRUE) 11 | ENDIF (NETTLE_INCLUDE_DIR) 12 | 13 | FIND_PATH(NETTLE_INCLUDE_DIR nettle/md5.h nettle/ripemd160.h nettle/sha.h) 14 | FIND_LIBRARY(NETTLE_LIBRARY NAMES nettle libnettle) 15 | 16 | # handle the QUIETLY and REQUIRED arguments and set NETTLE_FOUND to TRUE if 17 | # all listed variables are TRUE 18 | INCLUDE(FindPackageHandleStandardArgs) 19 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETTLE DEFAULT_MSG NETTLE_LIBRARY NETTLE_INCLUDE_DIR) 20 | 21 | IF(NETTLE_FOUND) 22 | SET(NETTLE_LIBRARIES ${NETTLE_LIBRARY}) 23 | ENDIF(NETTLE_FOUND) 24 | -------------------------------------------------------------------------------- /archive/libarchive/build/cmake/FindPCREPOSIX.cmake: -------------------------------------------------------------------------------- 1 | # - Find pcreposix 2 | # Find the native PCRE and PCREPOSIX include and libraries 3 | # 4 | # PCRE_INCLUDE_DIR - where to find pcreposix.h, etc. 5 | # PCREPOSIX_LIBRARIES - List of libraries when using libpcreposix. 6 | # PCRE_LIBRARIES - List of libraries when using libpcre. 7 | # PCREPOSIX_FOUND - True if libpcreposix found. 8 | # PCRE_FOUND - True if libpcre found. 9 | 10 | IF (PCRE_INCLUDE_DIR) 11 | # Already in cache, be silent 12 | SET(PCRE_FIND_QUIETLY TRUE) 13 | ENDIF (PCRE_INCLUDE_DIR) 14 | 15 | FIND_PATH(PCRE_INCLUDE_DIR pcreposix.h) 16 | FIND_LIBRARY(PCREPOSIX_LIBRARY NAMES pcreposix libpcreposix) 17 | FIND_LIBRARY(PCRE_LIBRARY NAMES pcre libpcre) 18 | 19 | # handle the QUIETLY and REQUIRED arguments and set PCREPOSIX_FOUND to TRUE if 20 | # all listed variables are TRUE 21 | INCLUDE(FindPackageHandleStandardArgs) 22 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCREPOSIX DEFAULT_MSG PCREPOSIX_LIBRARY PCRE_INCLUDE_DIR) 23 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY) 24 | 25 | IF(PCREPOSIX_FOUND) 26 | SET(PCREPOSIX_LIBRARIES ${PCREPOSIX_LIBRARY}) 27 | SET(HAVE_LIBPCREPOSIX 1) 28 | SET(HAVE_PCREPOSIX_H 1) 29 | ENDIF(PCREPOSIX_FOUND) 30 | 31 | IF(PCRE_FOUND) 32 | SET(PCRE_LIBRARIES ${PCRE_LIBRARY}) 33 | SET(HAVE_LIBPCRE 1) 34 | ENDIF(PCRE_FOUND) 35 | -------------------------------------------------------------------------------- /archive/libarchive/build/pkgconfig/libarchive.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libarchive 7 | Description: library that can create and read several streaming archive formats 8 | Version: @VERSION@ 9 | Cflags: -I${includedir} 10 | Libs: -L${libdir} -larchive 11 | Libs.private: @LIBS@ 12 | -------------------------------------------------------------------------------- /archive/libarchive/build/version: -------------------------------------------------------------------------------- 1 | 3001002 2 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_cmdline_private.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012 Michihiro NAKAJIMA 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | * $FreeBSD$ 26 | */ 27 | 28 | #ifndef __LIBARCHIVE_BUILD 29 | #ifndef __LIBARCHIVE_TEST 30 | #error This header is only to be used internally to libarchive. 31 | #endif 32 | #endif 33 | 34 | #ifndef ARCHIVE_CMDLINE_PRIVATE_H 35 | #define ARCHIVE_CMDLINE_PRIVATE_H 36 | 37 | struct archive_cmdline { 38 | char *path; 39 | char **argv; 40 | int argc; 41 | }; 42 | 43 | struct archive_cmdline *__archive_cmdline_allocate(void); 44 | int __archive_cmdline_parse(struct archive_cmdline *, const char *); 45 | int __archive_cmdline_free(struct archive_cmdline *); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_entry_copy_bhfi.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2007 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include "archive_platform.h" 27 | __FBSDID("$FreeBSD$"); 28 | 29 | #include "archive_private.h" 30 | #include "archive_entry.h" 31 | 32 | #if defined(_WIN32) && !defined(__CYGWIN__) 33 | 34 | #define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000) 35 | 36 | __inline static void 37 | fileTimeToUtc(const FILETIME *filetime, time_t *t, long *ns) 38 | { 39 | ULARGE_INTEGER utc; 40 | 41 | utc.HighPart = filetime->dwHighDateTime; 42 | utc.LowPart = filetime->dwLowDateTime; 43 | if (utc.QuadPart >= EPOC_TIME) { 44 | utc.QuadPart -= EPOC_TIME; 45 | *t = (time_t)(utc.QuadPart / 10000000); /* milli seconds base */ 46 | *ns = (long)(utc.QuadPart % 10000000) * 100;/* nano seconds base */ 47 | } else { 48 | *t = 0; 49 | *ns = 0; 50 | } 51 | } 52 | 53 | void 54 | archive_entry_copy_bhfi(struct archive_entry *entry, 55 | BY_HANDLE_FILE_INFORMATION *bhfi) 56 | { 57 | time_t secs; 58 | long nsecs; 59 | 60 | fileTimeToUtc(&bhfi->ftLastAccessTime, &secs, &nsecs); 61 | archive_entry_set_atime(entry, secs, nsecs); 62 | fileTimeToUtc(&bhfi->ftLastWriteTime, &secs, &nsecs); 63 | archive_entry_set_mtime(entry, secs, nsecs); 64 | fileTimeToUtc(&bhfi->ftCreationTime, &secs, &nsecs); 65 | archive_entry_set_birthtime(entry, secs, nsecs); 66 | archive_entry_set_ctime(entry, secs, nsecs); 67 | archive_entry_set_dev(entry, bhfi->dwVolumeSerialNumber); 68 | archive_entry_set_ino64(entry, (((int64_t)bhfi->nFileIndexHigh) << 32) 69 | + bhfi->nFileIndexLow); 70 | archive_entry_set_nlink(entry, bhfi->nNumberOfLinks); 71 | archive_entry_set_size(entry, (((int64_t)bhfi->nFileSizeHigh) << 32) 72 | + bhfi->nFileSizeLow); 73 | /* archive_entry_set_mode(entry, st->st_mode); */ 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_entry_strmode.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2007 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include "archive_platform.h" 27 | __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_strmode.c,v 1.4 2008/06/15 05:14:01 kientzle Exp $"); 28 | 29 | #ifdef HAVE_SYS_STAT_H 30 | #include 31 | #endif 32 | #ifdef HAVE_STRING_H 33 | #include 34 | #endif 35 | 36 | #include "archive_entry.h" 37 | #include "archive_entry_private.h" 38 | 39 | const char * 40 | archive_entry_strmode(struct archive_entry *entry) 41 | { 42 | static const mode_t permbits[] = 43 | { 0400, 0200, 0100, 0040, 0020, 0010, 0004, 0002, 0001 }; 44 | char *bp = entry->strmode; 45 | mode_t mode; 46 | int i; 47 | 48 | /* Fill in a default string, then selectively override. */ 49 | strcpy(bp, "?rwxrwxrwx "); 50 | 51 | mode = archive_entry_mode(entry); 52 | switch (archive_entry_filetype(entry)) { 53 | case AE_IFREG: bp[0] = '-'; break; 54 | case AE_IFBLK: bp[0] = 'b'; break; 55 | case AE_IFCHR: bp[0] = 'c'; break; 56 | case AE_IFDIR: bp[0] = 'd'; break; 57 | case AE_IFLNK: bp[0] = 'l'; break; 58 | case AE_IFSOCK: bp[0] = 's'; break; 59 | case AE_IFIFO: bp[0] = 'p'; break; 60 | default: 61 | if (archive_entry_hardlink(entry) != NULL) { 62 | bp[0] = 'h'; 63 | break; 64 | } 65 | } 66 | 67 | for (i = 0; i < 9; i++) 68 | if (!(mode & permbits[i])) 69 | bp[i+1] = '-'; 70 | 71 | if (mode & S_ISUID) { 72 | if (mode & 0100) bp[3] = 's'; 73 | else bp[3] = 'S'; 74 | } 75 | if (mode & S_ISGID) { 76 | if (mode & 0010) bp[6] = 's'; 77 | else bp[6] = 'S'; 78 | } 79 | if (mode & S_ISVTX) { 80 | if (mode & 0001) bp[9] = 't'; 81 | else bp[9] = 'T'; 82 | } 83 | if (archive_entry_acl_count(entry, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)) 84 | bp[10] = '+'; 85 | 86 | return (bp); 87 | } 88 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_options_private.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2011 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include "archive_platform.h" 27 | __FBSDID("$FreeBSD$"); 28 | 29 | #include "archive_private.h" 30 | 31 | typedef int (*option_handler)(struct archive *a, 32 | const char *mod, const char *opt, const char *val); 33 | 34 | int 35 | _archive_set_option(struct archive *a, 36 | const char *mod, const char *opt, const char *val, 37 | int magic, const char *fn, option_handler use_option); 38 | 39 | int 40 | _archive_set_options(struct archive *a, const char *options, 41 | int magic, const char *fn, option_handler use_option); 42 | 43 | int 44 | _archive_set_either_option(struct archive *a, 45 | const char *m, const char *o, const char *v, 46 | option_handler use_format_option, option_handler use_filter_option); 47 | 48 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_pathmatch.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2007 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer 10 | * in this position and unchanged. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | * $FreeBSD$ 27 | */ 28 | 29 | #ifndef __LIBARCHIVE_BUILD 30 | #ifndef __LIBARCHIVE_TEST 31 | #error This header is only to be used internally to libarchive. 32 | #endif 33 | #endif 34 | 35 | #ifndef ARCHIVE_PATHMATCH_H 36 | #define ARCHIVE_PATHMATCH_H 37 | 38 | /* Don't anchor at beginning unless the pattern starts with "^" */ 39 | #define PATHMATCH_NO_ANCHOR_START 1 40 | /* Don't anchor at end unless the pattern ends with "$" */ 41 | #define PATHMATCH_NO_ANCHOR_END 2 42 | 43 | /* Note that "^" and "$" are not special unless you set the corresponding 44 | * flag above. */ 45 | 46 | int __archive_pathmatch(const char *p, const char *s, int flags); 47 | int __archive_pathmatch_w(const wchar_t *p, const wchar_t *s, int flags); 48 | 49 | #define archive_pathmatch(p, s, f) __archive_pathmatch(p, s, f) 50 | #define archive_pathmatch_w(p, s, f) __archive_pathmatch_w(p, s, f) 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_read_support_filter_none.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2007 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include "archive_platform.h" 27 | __FBSDID("$FreeBSD$"); 28 | 29 | #include "archive.h" 30 | #include "archive_private.h" 31 | 32 | #if ARCHIVE_VERSION_NUMBER < 4000000 33 | /* Deprecated; remove in libarchive 4.0 */ 34 | int 35 | archive_read_support_compression_none(struct archive *a) 36 | { 37 | return archive_read_support_filter_none(a); 38 | } 39 | #endif 40 | 41 | /* 42 | * Uncompressed streams are handled implicitly by the read core, 43 | * so this is now a no-op. 44 | */ 45 | int 46 | archive_read_support_filter_none(struct archive *a) 47 | { 48 | archive_check_magic(a, ARCHIVE_READ_MAGIC, 49 | ARCHIVE_STATE_NEW, "archive_read_support_filter_none"); 50 | 51 | return (ARCHIVE_OK); 52 | } 53 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_read_support_format_by_code.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2011 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include "archive_platform.h" 27 | __FBSDID("$FreeBSD$"); 28 | 29 | #include "archive.h" 30 | #include "archive_private.h" 31 | 32 | int 33 | archive_read_support_format_by_code(struct archive *a, int format_code) 34 | { 35 | archive_check_magic(a, ARCHIVE_READ_MAGIC, 36 | ARCHIVE_STATE_NEW, "archive_read_support_format_by_code"); 37 | 38 | switch (format_code & ARCHIVE_FORMAT_BASE_MASK) { 39 | case ARCHIVE_FORMAT_7ZIP: 40 | return archive_read_support_format_7zip(a); 41 | break; 42 | case ARCHIVE_FORMAT_AR: 43 | return archive_read_support_format_ar(a); 44 | break; 45 | case ARCHIVE_FORMAT_CAB: 46 | return archive_read_support_format_cab(a); 47 | break; 48 | case ARCHIVE_FORMAT_CPIO: 49 | return archive_read_support_format_cpio(a); 50 | break; 51 | case ARCHIVE_FORMAT_ISO9660: 52 | return archive_read_support_format_iso9660(a); 53 | break; 54 | case ARCHIVE_FORMAT_LHA: 55 | return archive_read_support_format_lha(a); 56 | break; 57 | case ARCHIVE_FORMAT_MTREE: 58 | return archive_read_support_format_mtree(a); 59 | break; 60 | case ARCHIVE_FORMAT_RAR: 61 | return archive_read_support_format_rar(a); 62 | break; 63 | case ARCHIVE_FORMAT_TAR: 64 | return archive_read_support_format_tar(a); 65 | break; 66 | case ARCHIVE_FORMAT_XAR: 67 | return archive_read_support_format_xar(a); 68 | break; 69 | case ARCHIVE_FORMAT_ZIP: 70 | return archive_read_support_format_zip(a); 71 | break; 72 | } 73 | return (ARCHIVE_FATAL); 74 | } 75 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_write_add_filter.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2012 Ondrej Holy 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include "archive_platform.h" 27 | __FBSDID("$FreeBSD$"); 28 | 29 | #ifdef HAVE_SYS_TYPES_H 30 | #include 31 | #endif 32 | 33 | #ifdef HAVE_ERRNO_H 34 | #include 35 | #endif 36 | 37 | #include "archive.h" 38 | #include "archive_private.h" 39 | 40 | /* A table that maps filter codes to functions. */ 41 | static 42 | struct { int code; int (*setter)(struct archive *); } codes[] = 43 | { 44 | { ARCHIVE_FILTER_NONE, archive_write_add_filter_none }, 45 | { ARCHIVE_FILTER_GZIP, archive_write_add_filter_gzip }, 46 | { ARCHIVE_FILTER_BZIP2, archive_write_add_filter_bzip2 }, 47 | { ARCHIVE_FILTER_COMPRESS, archive_write_add_filter_compress }, 48 | { ARCHIVE_FILTER_GRZIP, archive_write_add_filter_grzip }, 49 | { ARCHIVE_FILTER_LRZIP, archive_write_add_filter_lrzip }, 50 | { ARCHIVE_FILTER_LZIP, archive_write_add_filter_lzip }, 51 | { ARCHIVE_FILTER_LZMA, archive_write_add_filter_lzma }, 52 | { ARCHIVE_FILTER_LZOP, archive_write_add_filter_lzip }, 53 | { ARCHIVE_FILTER_UU, archive_write_add_filter_uuencode }, 54 | { ARCHIVE_FILTER_XZ, archive_write_add_filter_xz }, 55 | { -1, NULL } 56 | }; 57 | 58 | int 59 | archive_write_add_filter(struct archive *a, int code) 60 | { 61 | int i; 62 | 63 | for (i = 0; codes[i].code != -1; i++) { 64 | if (code == codes[i].code) 65 | return ((codes[i].setter)(a)); 66 | } 67 | 68 | archive_set_error(a, EINVAL, "No such filter"); 69 | return (ARCHIVE_FATAL); 70 | } 71 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_write_add_filter_by_name.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2007 Tim Kientzle 3 | * Copyright (c) 2012 Michihiro NAKAJIMA 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "archive_platform.h" 28 | __FBSDID("$FreeBSD$"); 29 | 30 | #ifdef HAVE_SYS_TYPES_H 31 | #include 32 | #endif 33 | 34 | #ifdef HAVE_ERRNO_H 35 | #include 36 | #endif 37 | #ifdef HAVE_STRING_H 38 | #include 39 | #endif 40 | 41 | #include "archive.h" 42 | #include "archive_private.h" 43 | 44 | /* A table that maps names to functions. */ 45 | static 46 | struct { const char *name; int (*setter)(struct archive *); } names[] = 47 | { 48 | { "b64encode", archive_write_add_filter_b64encode }, 49 | { "bzip2", archive_write_add_filter_bzip2 }, 50 | { "compress", archive_write_add_filter_compress }, 51 | { "grzip", archive_write_add_filter_grzip }, 52 | { "gzip", archive_write_add_filter_gzip }, 53 | { "lrzip", archive_write_add_filter_lrzip }, 54 | { "lzip", archive_write_add_filter_lzip }, 55 | { "lzma", archive_write_add_filter_lzma }, 56 | { "lzop", archive_write_add_filter_lzop }, 57 | { "uuencode", archive_write_add_filter_uuencode }, 58 | { "xz", archive_write_add_filter_xz }, 59 | { NULL, NULL } 60 | }; 61 | 62 | int 63 | archive_write_add_filter_by_name(struct archive *a, const char *name) 64 | { 65 | int i; 66 | 67 | for (i = 0; names[i].name != NULL; i++) { 68 | if (strcmp(name, names[i].name) == 0) 69 | return ((names[i].setter)(a)); 70 | } 71 | 72 | archive_set_error(a, EINVAL, "No such filter '%s'", name); 73 | a->state = ARCHIVE_STATE_FATAL; 74 | return (ARCHIVE_FATAL); 75 | } 76 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_write_add_filter_none.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2010 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include "archive_platform.h" 27 | __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_none.c 201080 2009-12-28 02:03:54Z kientzle $"); 28 | 29 | #include "archive.h" 30 | 31 | int 32 | archive_write_set_compression_none(struct archive *a) 33 | { 34 | (void)a; /* UNUSED */ 35 | return (ARCHIVE_OK); 36 | } 37 | 38 | int 39 | archive_write_add_filter_none(struct archive *a) 40 | { 41 | (void)a; /* UNUSED */ 42 | return (ARCHIVE_OK); 43 | } 44 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/archive_write_disk_private.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2007 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer 10 | * in this position and unchanged. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | * $FreeBSD: head/lib/libarchive/archive_write_disk_private.h 201086 2009-12-28 02:17:53Z kientzle $ 27 | */ 28 | 29 | #ifndef __LIBARCHIVE_BUILD 30 | #error This header is only to be used internally to libarchive. 31 | #endif 32 | 33 | #ifndef ARCHIVE_WRITE_DISK_PRIVATE_H_INCLUDED 34 | #define ARCHIVE_WRITE_DISK_PRIVATE_H_INCLUDED 35 | 36 | #include "archive_acl_private.h" 37 | 38 | struct archive_write_disk; 39 | 40 | int 41 | archive_write_disk_set_acls(struct archive *, int /* fd */, const char * /* pathname */, struct archive_acl *); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive/filter_fork.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2007 Joerg Sonnenberger 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | * $FreeBSD: head/lib/libarchive/filter_fork.h 201087 2009-12-28 02:18:26Z kientzle $ 26 | */ 27 | 28 | #ifndef __LIBARCHIVE_BUILD 29 | #error This header is only to be used internally to libarchive. 30 | #endif 31 | 32 | #ifndef FILTER_FORK_H 33 | #define FILTER_FORK_H 34 | 35 | pid_t 36 | __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout); 37 | 38 | void 39 | __archive_check_child(int in, int out); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive_fe/err.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2007 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer 10 | * in this position and unchanged. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "lafe_platform.h" 28 | __FBSDID("$FreeBSD$"); 29 | 30 | #ifdef HAVE_STDARG_H 31 | #include 32 | #endif 33 | #include 34 | #ifdef HAVE_STDLIB_H 35 | #include 36 | #endif 37 | #ifdef HAVE_STRING_H 38 | #include 39 | #endif 40 | 41 | #include "err.h" 42 | 43 | static void lafe_vwarnc(int, const char *, va_list) __LA_PRINTFLIKE(2, 0); 44 | 45 | const char *lafe_progname; 46 | 47 | static void 48 | lafe_vwarnc(int code, const char *fmt, va_list ap) 49 | { 50 | fprintf(stderr, "%s: ", lafe_progname); 51 | vfprintf(stderr, fmt, ap); 52 | if (code != 0) 53 | fprintf(stderr, ": %s", strerror(code)); 54 | fprintf(stderr, "\n"); 55 | } 56 | 57 | void 58 | lafe_warnc(int code, const char *fmt, ...) 59 | { 60 | va_list ap; 61 | 62 | va_start(ap, fmt); 63 | lafe_vwarnc(code, fmt, ap); 64 | va_end(ap); 65 | } 66 | 67 | void 68 | lafe_errc(int eval, int code, const char *fmt, ...) 69 | { 70 | va_list ap; 71 | 72 | va_start(ap, fmt); 73 | lafe_vwarnc(code, fmt, ap); 74 | va_end(ap); 75 | exit(eval); 76 | } 77 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive_fe/err.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009 Joerg Sonnenberger 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef LAFE_ERR_H 27 | #define LAFE_ERR_H 28 | 29 | #if defined(__GNUC__) && (__GNUC__ > 2 || \ 30 | (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) 31 | #define __LA_DEAD __attribute__((__noreturn__)) 32 | #else 33 | #define __LA_DEAD 34 | #endif 35 | 36 | #if defined(__GNUC__) && (__GNUC__ > 2 || \ 37 | (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) 38 | #define __LA_PRINTFLIKE(f,a) __attribute__((__format__(__printf__, f, a))) 39 | #else 40 | #define __LA_PRINTFLIKE(f,a) 41 | #endif 42 | 43 | extern const char *lafe_progname; 44 | 45 | void lafe_warnc(int code, const char *fmt, ...) __LA_PRINTFLIKE(2, 3); 46 | void lafe_errc(int eval, int code, const char *fmt, ...) __LA_DEAD 47 | __LA_PRINTFLIKE(3, 4); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive_fe/lafe_platform.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2003-2007 Tim Kientzle 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | * 25 | * $FreeBSD: src/usr.bin/cpio/cpio_platform.h,v 1.2 2008/12/06 07:15:42 kientzle Exp $ 26 | */ 27 | 28 | /* 29 | * This header is the first thing included in any of the libarchive_fe 30 | * source files. As far as possible, platform-specific issues should 31 | * be dealt with here and not within individual source files. 32 | */ 33 | 34 | #ifndef LAFE_PLATFORM_H_INCLUDED 35 | #define LAFE_PLATFORM_H_INCLUDED 36 | 37 | #if defined(PLATFORM_CONFIG_H) 38 | /* Use hand-built config.h in environments that need it. */ 39 | #include PLATFORM_CONFIG_H 40 | #else 41 | /* Read config.h or die trying. */ 42 | #include "config.h" 43 | #endif 44 | 45 | /* Get a real definition for __FBSDID if we can */ 46 | #if HAVE_SYS_CDEFS_H 47 | #include 48 | #endif 49 | 50 | /* If not, define it so as to avoid dangling semicolons. */ 51 | #ifndef __FBSDID 52 | #define __FBSDID(a) struct _undefined_hack 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /archive/libarchive/libarchive_fe/line_reader.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2009 Joerg Sonnenberger 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef LAFE_LINE_READER_H 27 | #define LAFE_LINE_READER_H 28 | 29 | struct lafe_line_reader; 30 | 31 | struct lafe_line_reader *lafe_line_reader(const char *, int nullSeparator); 32 | const char *lafe_line_reader_next(struct lafe_line_reader *); 33 | void lafe_line_reader_free(struct lafe_line_reader *); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /archive/pc_archive.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _PC_ARCHIVE_H 27 | #define _PC_ARCHIVE_H 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | typedef struct { 40 | char *fpath; 41 | int typeflag; 42 | size_t size; 43 | } archive_list_entry_t; 44 | 45 | /* 46 | * Archiving related functions. 47 | */ 48 | int setup_archiver(pc_ctx_t *pctx, struct stat *sbuf); 49 | int start_archiver(pc_ctx_t *pctx); 50 | int setup_extractor(pc_ctx_t *pctx); 51 | int start_extractor(pc_ctx_t *pctx); 52 | int64_t archiver_read(void *ctx, void *buf, uint64_t count); 53 | int64_t archiver_write(void *ctx, void *buf, uint64_t count); 54 | int archiver_close(void *ctx); 55 | int init_archive_mod(); 56 | int insert_filter_data(filter_func_ptr func, void *filter_private, const char *ext); 57 | void init_filters(struct filter_flags *ff); 58 | void disable_all_filters(); 59 | 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /archive/ppnm_helper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /* 27 | */ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #ifndef _MPLV2_LICENSE_ 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | typedef unsigned char uchar_t; 44 | 45 | /* a short reminder about input/output stream types 46 | for the pjglib_init_streams() function 47 | 48 | if input is file 49 | ---------------- 50 | in_scr -> name of input file 51 | in_type -> 0 52 | in_size -> ignore 53 | 54 | if input is memory 55 | ------------------ 56 | in_scr -> array containg data 57 | in_type -> 1 58 | in_size -> size of data array 59 | 60 | if input is *FILE (f.e. stdin) 61 | ------------------------------ 62 | in_src -> stream pointer 63 | in_type -> 2 64 | in_size -> ignore 65 | 66 | vice versa for output streams! */ 67 | 68 | /* 69 | * Helper routine to bridge to packPNM C++ lib, without changing packJPG itself. 70 | * packPNM has same API interface as packJPG. Just the function names are different. 71 | */ 72 | size_t 73 | packpnm_filter_process(uchar_t *in_buf, size_t len, uchar_t **out_buf) 74 | { 75 | unsigned int len1; 76 | 77 | ppnlib_init_streams(in_buf, 1, len, *out_buf, 1); 78 | len1 = len; 79 | if (!ppnlib_convert_stream2mem(out_buf, &len1, NULL)) 80 | return (0); 81 | if (len1 == len) 82 | return (0); 83 | return (len1); 84 | } 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif 90 | -------------------------------------------------------------------------------- /bsc/AUTHORS: -------------------------------------------------------------------------------- 1 | -- Authors of bsc and libbsc 2 | 3 | Ilya Grebnov 4 | 5 | -- This program is based on (at least) the work of 6 | 7 | Yuta Mori, Charles Bloom, Julian Seward, Mike Burrows, Matt Mahoney, 8 | David Wheeler, Sebastian Deorowicz, Florin Ghido, Peter Fenwick, 9 | Michael Schindler, Bulat Ziganshin, Eugene Shelwien, Yann Collet, 10 | Dmitry Shkarin, Mark Adler, Przemyslaw Skibinski, Duane Merrill. 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /bsc/CHANGES: -------------------------------------------------------------------------------- 1 | Changes in 3.1.0 (July 8, 2012) 2 | - Added Kepler GPU support with CUDA Toolkit 4.2 3 | 4 | Changes in 3.0.0 (August 26, 2011) 5 | - NVIDIA GPU acceleration of forward ST algorithms 6 | - Added Sort Transform of order 7 & 8 (GPU only) 7 | 8 | Changes in 2.8.0 (August 8, 2011) 9 | - Added parallel version of LZP algorithm 10 | - Large RAM pages (2 MB) support for Windows 11 | - Improved performance of ST and BWT algorithms 12 | 13 | Changes in 2.7.0 (June 5, 2011) 14 | - Improved performance of LZP algorithm 15 | 16 | Changes in 2.6.1 (May 4, 2011) 17 | - Fixed bug in segmentation algorithm 18 | 19 | Changes in 2.6.0 (April 30, 2011) 20 | - Added Sort Transform of order 6 21 | 22 | Changes in 2.5.0 (March 20, 2011) 23 | - Some minor performance improvments 24 | - CRC32 replaced with Adler32 25 | 26 | Changes in 2.4.5 (January 3, 2011) 27 | - Improved performance of reverse BWT and ST algorithms 28 | 29 | Changes in 2.4.0 (October 18, 2010) 30 | - Improved performance of reverse BWT and ST algorithms 31 | 32 | Changes in 2.3.0 (August 9, 2010) 33 | - Improved performance of QLFC algorithm 34 | 35 | Changes in 2.2.5 (July 5, 2010) 36 | - Added parallel version of segmentation algorithm 37 | 38 | Changes in 2.2.0 (June 15, 2010) 39 | - Added parallel version of reverse BWT transform 40 | - Added parallel version of forward ST transform 41 | 42 | Changes in 2.1.5 (June 1, 2010) 43 | - Improved multi-core systems support 44 | - Improved segmentation algorithm 45 | 46 | Changes in 2.1.0 (May 17, 2010) 47 | - Added GNU C++ compiler support 48 | - Added makefile 49 | 50 | Changes in 2.0.0 (May 3, 2010) 51 | - Released source code under LGPL license 52 | - Added multi-core systems support 53 | - Added fast "-f" compression mode 54 | - Added Sort Transform of order 3 55 | 56 | Changes in 1.0.3 (April 11, 2010) 57 | - Fixed bug in block-sorting algorithm 58 | - Added support for large files(>2Gb long) 59 | 60 | Changes in 1.0.1 (April 8, 2010) 61 | - Decreased memory usage from 6 to 5 times per block size 62 | 63 | Changes in 1.0.0 (April 7, 2010) 64 | - First public version for community technology preview 65 | -------------------------------------------------------------------------------- /bsc/VERSION: -------------------------------------------------------------------------------- 1 | 3.1.0 -------------------------------------------------------------------------------- /bsc/libbsc/adler32/adler32.cpp: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------*/ 2 | /* Block Sorting, Lossless Data Compression Library. */ 3 | /* Adler-32 checksum functions */ 4 | /*-----------------------------------------------------------*/ 5 | 6 | /*-- 7 | 8 | This file is a part of bsc and/or libbsc, a program and a library for 9 | lossless, block-sorting data compression. 10 | 11 | Copyright (c) 2009-2012 Ilya Grebnov 12 | 13 | See file AUTHORS for a full list of contributors. 14 | 15 | The bsc and libbsc is free software; you can redistribute it and/or modify 16 | it under the terms of the GNU Lesser General Public License as published by 17 | the Free Software Foundation; either version 3 of the License, or (at your 18 | option) any later version. 19 | 20 | The bsc and libbsc is distributed in the hope that it will be useful, but 21 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 22 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 23 | License for more details. 24 | 25 | You should have received a copy of the GNU Lesser General Public License 26 | along with the bsc and libbsc. If not, see http://www.gnu.org/licenses/. 27 | 28 | Please see the files COPYING and COPYING.LIB for full copyright information. 29 | 30 | See also the bsc and libbsc web site: 31 | http://libbsc.com/ for more information. 32 | 33 | --*/ 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #include "adler32.h" 40 | 41 | #include "../platform/platform.h" 42 | #include "../libbsc.h" 43 | 44 | #define BASE 65521UL 45 | #define NMAX 5552 46 | 47 | #define DO1(buf, i) { sum1 += (buf)[i]; sum2 += sum1; } 48 | #define DO2(buf, i) DO1(buf, i); DO1(buf, i + 1); 49 | #define DO4(buf, i) DO2(buf, i); DO2(buf, i + 2); 50 | #define DO8(buf, i) DO4(buf, i); DO4(buf, i + 4); 51 | #define DO16(buf) DO8(buf, 0); DO8(buf, 8); 52 | #define MOD(a) a %= BASE 53 | 54 | unsigned int bsc_adler32(const unsigned char * T, int n, int features) 55 | { 56 | unsigned int sum1 = 1; 57 | unsigned int sum2 = 0; 58 | 59 | while (n >= NMAX) 60 | { 61 | for (int i = 0; i < NMAX / 16; ++i) 62 | { 63 | DO16(T); T += 16; 64 | } 65 | MOD(sum1); MOD(sum2); n -= NMAX; 66 | } 67 | 68 | while (n >= 16) 69 | { 70 | DO16(T); T += 16; n -= 16; 71 | } 72 | 73 | while (n > 0) 74 | { 75 | DO1(T, 0); T += 1; n -= 1; 76 | } 77 | 78 | MOD(sum1); MOD(sum2); 79 | 80 | return sum1 | (sum2 << 16); 81 | } 82 | 83 | /*-----------------------------------------------------------*/ 84 | /* End adler32.cpp */ 85 | /*-----------------------------------------------------------*/ 86 | -------------------------------------------------------------------------------- /bsc/libbsc/adler32/adler32.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------*/ 2 | /* Block Sorting, Lossless Data Compression Library. */ 3 | /* Interface to Adler-32 checksum functions */ 4 | /*-----------------------------------------------------------*/ 5 | 6 | /*-- 7 | 8 | This file is a part of bsc and/or libbsc, a program and a library for 9 | lossless, block-sorting data compression. 10 | 11 | Copyright (c) 2009-2012 Ilya Grebnov 12 | 13 | See file AUTHORS for a full list of contributors. 14 | 15 | The bsc and libbsc is free software; you can redistribute it and/or modify 16 | it under the terms of the GNU Lesser General Public License as published by 17 | the Free Software Foundation; either version 3 of the License, or (at your 18 | option) any later version. 19 | 20 | The bsc and libbsc is distributed in the hope that it will be useful, but 21 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 22 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 23 | License for more details. 24 | 25 | You should have received a copy of the GNU Lesser General Public License 26 | along with the bsc and libbsc. If not, see http://www.gnu.org/licenses/. 27 | 28 | Please see the files COPYING and COPYING.LIB for full copyright information. 29 | 30 | See also the bsc and libbsc web site: 31 | http://libbsc.com/ for more information. 32 | 33 | --*/ 34 | 35 | #ifndef _LIBBSC_ADLER32_H 36 | #define _LIBBSC_ADLER32_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | * Calculates Adler-32 checksum for input memory block. 44 | * @param T - the input memory block of n bytes. 45 | * @param n - the length of the input memory block. 46 | * @param features - the set of additional features. 47 | * @return the value of cyclic redundancy check. 48 | */ 49 | unsigned int bsc_adler32(const unsigned char * T, int n, int features); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | 57 | /*-----------------------------------------------------------*/ 58 | /* End adler32.h */ 59 | /*-----------------------------------------------------------*/ 60 | -------------------------------------------------------------------------------- /bsc/libbsc/bwt/bwt.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------*/ 2 | /* Block Sorting, Lossless Data Compression Library. */ 3 | /* Interface to Burrows Wheeler Transform */ 4 | /*-----------------------------------------------------------*/ 5 | 6 | /*-- 7 | 8 | This file is a part of bsc and/or libbsc, a program and a library for 9 | lossless, block-sorting data compression. 10 | 11 | Copyright (c) 2009-2012 Ilya Grebnov 12 | 13 | See file AUTHORS for a full list of contributors. 14 | 15 | The bsc and libbsc is free software; you can redistribute it and/or modify 16 | it under the terms of the GNU Lesser General Public License as published by 17 | the Free Software Foundation; either version 3 of the License, or (at your 18 | option) any later version. 19 | 20 | The bsc and libbsc is distributed in the hope that it will be useful, but 21 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 22 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 23 | License for more details. 24 | 25 | You should have received a copy of the GNU Lesser General Public License 26 | along with the bsc and libbsc. If not, see http://www.gnu.org/licenses/. 27 | 28 | Please see the files COPYING and COPYING.LIB for full copyright information. 29 | 30 | See also the bsc and libbsc web site: 31 | http://libbsc.com/ for more information. 32 | 33 | --*/ 34 | 35 | #ifndef _LIBBSC_BWT_H 36 | #define _LIBBSC_BWT_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | * Constructs the burrows wheeler transformed string of a given string. 44 | * @param T - the input/output string of n chars. 45 | * @param n - the length of the given string. 46 | * @param num_indexes - the length of secondary indexes array, can be NULL. 47 | * @param indexes - the secondary indexes array, can be NULL. 48 | * @param features - the set of additional features. 49 | * @return the primary index if no error occurred, error code otherwise. 50 | */ 51 | int bsc_bwt_encode(unsigned char * T, int n, unsigned char * num_indexes, int * indexes, int features); 52 | 53 | /** 54 | * Reconstructs the original string from burrows wheeler transformed string. 55 | * @param T - the input/output string of n chars. 56 | * @param n - the length of the given string. 57 | * @param index - the primary index. 58 | * @param num_indexes - the length of secondary indexes array, can be 0. 59 | * @param indexes - the secondary indexes array, can be NULL. 60 | * @param features - the set of additional features. 61 | * @return LIBBSC_NO_ERROR if no error occurred, error code otherwise. 62 | */ 63 | int bsc_bwt_decode(unsigned char * T, int n, int index, unsigned char num_indexes, int * indexes, int features); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | 71 | /*-----------------------------------------------------------*/ 72 | /* End bwt.h */ 73 | /*-----------------------------------------------------------*/ 74 | -------------------------------------------------------------------------------- /bsc/libbsc/bwt/divsufsort/divsufsort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * divsufsort.h for libdivsufsort-lite 3 | * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person 6 | * obtaining a copy of this software and associated documentation 7 | * files (the "Software"), to deal in the Software without 8 | * restriction, including without limitation the rights to use, 9 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the 11 | * Software is furnished to do so, subject to the following 12 | * conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #ifndef _DIVSUFSORT_H 28 | #define _DIVSUFSORT_H 1 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif /* __cplusplus */ 33 | 34 | 35 | /*- Prototypes -*/ 36 | 37 | /** 38 | * Constructs the suffix array of a given string. 39 | * @param T[0..n-1] The input string. 40 | * @param SA[0..n-1] The output array of suffixes. 41 | * @param n The length of the given string. 42 | * @param openMP enables OpenMP optimization. 43 | * @return 0 if no error occurred, -1 or -2 otherwise. 44 | */ 45 | int 46 | divsufsort(const unsigned char *T, int *SA, int n, int openMP); 47 | 48 | /** 49 | * Constructs the burrows-wheeler transformed string of a given string. 50 | * @param T[0..n-1] The input string. 51 | * @param U[0..n-1] The output string. (can be T) 52 | * @param A[0..n-1] The temporary array. (can be NULL) 53 | * @param n The length of the given string. 54 | * @param num_indexes The length of secondary indexes array. (can be NULL) 55 | * @param indexes The secondary indexes array. (can be NULL) 56 | * @param openMP enables OpenMP optimization. 57 | * @return The primary index if no error occurred, -1 or -2 otherwise. 58 | */ 59 | int 60 | divbwt(const unsigned char *T, unsigned char *U, int *A, int n, unsigned char * num_indexes, int * indexes, int openMP); 61 | 62 | 63 | #ifdef __cplusplus 64 | } /* extern "C" */ 65 | #endif /* __cplusplus */ 66 | 67 | #endif /* _DIVSUFSORT_H */ 68 | -------------------------------------------------------------------------------- /bsc/libbsc/coder/qlfc/qlfc_model.cpp: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------*/ 2 | /* Block Sorting, Lossless Data Compression Library. */ 3 | /* Statistical data compression model for QLFC */ 4 | /*-----------------------------------------------------------*/ 5 | 6 | /*-- 7 | 8 | This file is a part of bsc and/or libbsc, a program and a library for 9 | lossless, block-sorting data compression. 10 | 11 | Copyright (c) 2009-2012 Ilya Grebnov 12 | 13 | See file AUTHORS for a full list of contributors. 14 | 15 | The bsc and libbsc is free software; you can redistribute it and/or modify 16 | it under the terms of the GNU Lesser General Public License as published by 17 | the Free Software Foundation; either version 3 of the License, or (at your 18 | option) any later version. 19 | 20 | The bsc and libbsc is distributed in the hope that it will be useful, but 21 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 22 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 23 | License for more details. 24 | 25 | You should have received a copy of the GNU Lesser General Public License 26 | along with the bsc and libbsc. If not, see http://www.gnu.org/licenses/. 27 | 28 | Please see the files COPYING and COPYING.LIB for full copyright information. 29 | 30 | See also the bsc and libbsc web site: 31 | http://libbsc.com/ for more information. 32 | 33 | --*/ 34 | 35 | #include 36 | #include 37 | 38 | #include "qlfc_model.h" 39 | 40 | #include "../../libbsc.h" 41 | #include "../../platform/platform.h" 42 | 43 | QlfcStatisticalModel g_QlfcStatisticalModel; 44 | 45 | void bsc_qlfc_memset_2048(void * dst, int size) 46 | { 47 | for (int i = 0; i < size / 2; ++i) ((short *)dst)[i] = 2048; 48 | } 49 | 50 | int bsc_qlfc_init_static_model() 51 | { 52 | for (int mixer = 0; mixer < ALPHABET_SIZE; ++mixer) 53 | { 54 | g_QlfcStatisticalModel.mixerOfRank[mixer].Init(); 55 | g_QlfcStatisticalModel.mixerOfRankEscape[mixer].Init(); 56 | g_QlfcStatisticalModel.mixerOfRun[mixer].Init(); 57 | } 58 | for (int bit = 0; bit < 8; ++bit) 59 | { 60 | g_QlfcStatisticalModel.mixerOfRankMantissa[bit].Init(); 61 | for (int context = 0; context < 8; ++context) 62 | g_QlfcStatisticalModel.mixerOfRankExponent[context][bit].Init(); 63 | } 64 | for (int bit = 0; bit < 32; ++bit) 65 | { 66 | g_QlfcStatisticalModel.mixerOfRunMantissa[bit].Init(); 67 | for (int context = 0; context < 32; ++context) 68 | g_QlfcStatisticalModel.mixerOfRunExponent[context][bit].Init(); 69 | } 70 | 71 | bsc_qlfc_memset_2048(&g_QlfcStatisticalModel.Rank, sizeof(g_QlfcStatisticalModel.Rank)); 72 | bsc_qlfc_memset_2048(&g_QlfcStatisticalModel.Run, sizeof(g_QlfcStatisticalModel.Run)); 73 | 74 | return LIBBSC_NO_ERROR; 75 | } 76 | 77 | void bsc_qlfc_init_model(QlfcStatisticalModel * model) 78 | { 79 | memcpy(model, &g_QlfcStatisticalModel, sizeof(QlfcStatisticalModel)); 80 | } 81 | 82 | /*-----------------------------------------------------------*/ 83 | /* End qlfc_model.cpp */ 84 | /*-----------------------------------------------------------*/ 85 | -------------------------------------------------------------------------------- /bsc/libbsc/lzp/lzp.h: -------------------------------------------------------------------------------- 1 | /*-----------------------------------------------------------*/ 2 | /* Block Sorting, Lossless Data Compression Library. */ 3 | /* Interface to Lempel Ziv Prediction functions */ 4 | /*-----------------------------------------------------------*/ 5 | 6 | /*-- 7 | 8 | This file is a part of bsc and/or libbsc, a program and a library for 9 | lossless, block-sorting data compression. 10 | 11 | Copyright (c) 2009-2012 Ilya Grebnov 12 | 13 | See file AUTHORS for a full list of contributors. 14 | 15 | The bsc and libbsc is free software; you can redistribute it and/or modify 16 | it under the terms of the GNU Lesser General Public License as published by 17 | the Free Software Foundation; either version 3 of the License, or (at your 18 | option) any later version. 19 | 20 | The bsc and libbsc is distributed in the hope that it will be useful, but 21 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 22 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 23 | License for more details. 24 | 25 | You should have received a copy of the GNU Lesser General Public License 26 | along with the bsc and libbsc. If not, see http://www.gnu.org/licenses/. 27 | 28 | Please see the files COPYING and COPYING.LIB for full copyright information. 29 | 30 | See also the bsc and libbsc web site: 31 | http://libbsc.com/ for more information. 32 | 33 | --*/ 34 | 35 | #ifndef _LIBBSC_LZP_H 36 | #define _LIBBSC_LZP_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | * Preprocess a memory block by LZP algorithm. 44 | * @param input - the input memory block of n bytes. 45 | * @param output - the output memory block of n bytes. 46 | * @param n - the length of the input/output memory blocks. 47 | * @param hashSize - the hash table size. 48 | * @param minLen - the minimum match length. 49 | * @param features - the set of additional features. 50 | * @return The length of preprocessed memory block if no error occurred, error code otherwise. 51 | */ 52 | int bsc_lzp_compress(const unsigned char * input, unsigned char * output, int n, int hashSize, int minLen, int features); 53 | 54 | /** 55 | * Reconstructs the original memory block after LZP algorithm. 56 | * @param input - the input memory block of n bytes. 57 | * @param output - the output memory block. 58 | * @param n - the length of the input memory block. 59 | * @param hashSize - the hash table size. 60 | * @param minLen - the minimum match length. 61 | * @param features - the set of additional features. 62 | * @return The length of original memory block if no error occurred, error code otherwise. 63 | */ 64 | int bsc_lzp_decompress(const unsigned char * input, unsigned char * output, int n, int hashSize, int minLen, int features); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | 72 | /*-----------------------------------------------------------*/ 73 | /* End lzp.h */ 74 | /*-----------------------------------------------------------*/ 75 | -------------------------------------------------------------------------------- /bsdiff/bscommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _BS_COMMON_ 27 | #define _BS_COMMON_ 28 | 29 | #include 30 | #include 31 | 32 | // Simple stream I/O to buffer 33 | typedef struct { 34 | uchar_t *buf; 35 | bsize_t pos; 36 | bsize_t buflen; 37 | } bufio_t; 38 | 39 | static int 40 | BUFOPEN(bufio_t *bio, uchar_t *buf, bsize_t len) 41 | { 42 | bio->buf = buf; bio->pos = 0; bio->buflen = len; 43 | return (0); 44 | } 45 | 46 | #ifndef __IN_BSPATCH__ 47 | static bsize_t 48 | BUFWRITE(bufio_t *bio, uchar_t *buf, bsize_t len) 49 | { 50 | if (bio->pos + len < bio->buflen) { 51 | memcpy(bio->buf + bio->pos, buf, len); 52 | bio->pos += len; 53 | return (len); 54 | } else { 55 | return (-1); 56 | } 57 | } 58 | #endif 59 | 60 | #ifndef __IN_BSDIFF__ 61 | static bsize_t 62 | BUFREAD(bufio_t *bio, uchar_t *buf, bsize_t len) 63 | { 64 | bsize_t actual; 65 | unsigned int tot; 66 | 67 | actual = len; 68 | tot = len; 69 | tot += bio->pos; 70 | if (tot > bio->buflen) { 71 | actual = bio->buflen - bio->pos; 72 | } 73 | if (actual == 0) return (0); 74 | memcpy(buf, bio->buf + bio->pos, actual); 75 | bio->pos += actual; 76 | return (actual); 77 | } 78 | #endif 79 | 80 | #ifndef __IN_BSPATCH__ 81 | static bsize_t 82 | BUFTELL(bufio_t *bio) 83 | { 84 | return (bio->pos); 85 | } 86 | 87 | static void * 88 | BUFPTR(bufio_t *bio) 89 | { 90 | return (bio->buf + bio->pos); 91 | } 92 | 93 | static int 94 | BUFSEEK(bufio_t *bio, bsize_t pos, int typ) 95 | { 96 | if (typ == SEEK_SET) { 97 | bio->pos = pos; 98 | 99 | } else if (typ == SEEK_CUR) { 100 | bio->pos += pos; 101 | 102 | } else { 103 | if (pos > 0) { 104 | fprintf(stderr, "Cannot seek beyond buffer end.\n"); 105 | return (-1); 106 | } else { 107 | bio->pos = bio->buflen + pos; 108 | } 109 | } 110 | return (0); 111 | } 112 | #endif 113 | 114 | extern int zero_rle_encode(const void *ibuf, const unsigned int ilen, 115 | void *obuf, unsigned int *olen); 116 | extern int zero_rle_decode(const void* ibuf, unsigned int ilen, 117 | void* obuf, unsigned int *olen); 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /crypto/aes/crypto_aes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _AES_CRYPTO_H 27 | #define _AES_CRYPTO_H 28 | 29 | #include 30 | #include 31 | #ifdef _USE_PBK 32 | #include 33 | #endif 34 | #include 35 | #include 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef struct { 42 | uint64_t nonce; 43 | AES_KEY key; 44 | int keylen; 45 | uchar_t pkey[MAX_KEYLEN]; 46 | } aes_ctx_t; 47 | 48 | int aes_init(aes_ctx_t *ctx, uchar_t *salt, int saltlen, uchar_t *pwd, int pwd_len, 49 | uint64_t nonce, int enc); 50 | int aes_encrypt(aes_ctx_t *ctx, uchar_t *plaintext, uchar_t *ciphertext, uint64_t len, uint64_t id); 51 | int aes_decrypt(aes_ctx_t *ctx, uchar_t *ciphertext, uchar_t *plaintext, uint64_t len, uint64_t id); 52 | uchar_t *aes_nonce(aes_ctx_t *ctx); 53 | void aes_clean_pkey(aes_ctx_t *ctx); 54 | void aes_cleanup(aes_ctx_t *ctx); 55 | void aes_module_init(processor_cap_t *pc); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /crypto/blake2/blake2-config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /* 27 | BLAKE2 reference source code package - optimized C implementations 28 | 29 | Written in 2012 by Samuel Neves 30 | 31 | To the extent possible under law, the author(s) have dedicated all copyright 32 | and related and neighboring rights to this software to the public domain 33 | worldwide. This software is distributed without any warranty. 34 | 35 | You should have received a copy of the CC0 Public Domain Dedication along with 36 | this software. If not, see . 37 | */ 38 | #pragma once 39 | #ifndef __BLAKE2_CONFIG_H__ 40 | #define __BLAKE2_CONFIG_H__ 41 | 42 | // These don't work everywhere 43 | #if defined(__SSE2__) 44 | #define HAVE_SSE2 45 | #endif 46 | 47 | #if defined(__SSSE3__) 48 | #define HAVE_SSSE3 49 | #endif 50 | 51 | #if defined(__SSE4_1__) 52 | #define HAVE_SSE41 53 | #endif 54 | 55 | #if defined(__AVX__) 56 | #define HAVE_AVX 57 | #endif 58 | 59 | #if defined(__XOP__) 60 | #define HAVE_XOP 61 | #endif 62 | 63 | 64 | #ifdef HAVE_AVX2 65 | #ifndef HAVE_AVX 66 | #define HAVE_AVX 67 | #endif 68 | #endif 69 | 70 | #ifdef HAVE_XOP 71 | #ifndef HAVE_AVX 72 | #define HAVE_AVX 73 | #endif 74 | #endif 75 | 76 | #ifdef HAVE_AVX 77 | #ifndef HAVE_SSE41 78 | #define HAVE_SSE41 79 | #endif 80 | #endif 81 | 82 | #ifdef HAVE_SSE41 83 | #ifndef HAVE_SSSE3 84 | #define HAVE_SSSE3 85 | #endif 86 | #endif 87 | 88 | #ifdef HAVE_SSSE3 89 | #define HAVE_SSE2 90 | #endif 91 | 92 | #if !defined(HAVE_SSE2) 93 | #error "This code requires at least SSE2." 94 | #endif 95 | 96 | #endif 97 | 98 | -------------------------------------------------------------------------------- /crypto/blake2/blake2b_avx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define HAVE_AVX 27 | #define BLAKE_NAMESPACE(x) x##_avx 28 | #include "blake2b.c" 29 | 30 | -------------------------------------------------------------------------------- /crypto/blake2/blake2b_sse2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define HAVE_SSE2 27 | #define BLAKE_NAMESPACE(x) x##_sse2 28 | #include "blake2b.c" 29 | 30 | -------------------------------------------------------------------------------- /crypto/blake2/blake2b_sse41.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define HAVE_SSE41 27 | #define BLAKE_NAMESPACE(x) x##_sse41 28 | #include "blake2b.c" 29 | 30 | -------------------------------------------------------------------------------- /crypto/blake2/blake2b_ssse3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define HAVE_SSSE3 27 | #define BLAKE_NAMESPACE(x) x##_ssse3 28 | #include "blake2b.c" 29 | 30 | -------------------------------------------------------------------------------- /crypto/blake2/blake2bp_avx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define HAVE_AVX 27 | #define BLAKE_NAMESPACE(x) x##_avx 28 | #include "blake2bp.c" 29 | 30 | -------------------------------------------------------------------------------- /crypto/blake2/blake2bp_sse2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define HAVE_SSE2 27 | #define BLAKE_NAMESPACE(x) x##_sse2 28 | #include "blake2bp.c" 29 | 30 | -------------------------------------------------------------------------------- /crypto/blake2/blake2bp_sse41.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define HAVE_SSE41 27 | #define BLAKE_NAMESPACE(x) x##_sse41 28 | #include "blake2bp.c" 29 | 30 | -------------------------------------------------------------------------------- /crypto/blake2/blake2bp_ssse3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define HAVE_SSSE3 27 | #define BLAKE_NAMESPACE(x) x##_ssse3 28 | #include "blake2bp.c" 29 | 30 | -------------------------------------------------------------------------------- /crypto/keccak/KeccakF-1600-int-set.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define ProvideFast576 27 | #define ProvideFast832 28 | #define ProvideFast1024 29 | #define ProvideFast1088 30 | #define ProvideFast1152 31 | #define ProvideFast1344 32 | -------------------------------------------------------------------------------- /crypto/keccak/KeccakF-1600-interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /* 27 | The Keccak sponge function, designed by Guido Bertoni, Joan Daemen, 28 | Michaël Peeters and Gilles Van Assche. For more information, feedback or 29 | questions, please refer to our website: http://keccak.noekeon.org/ 30 | 31 | Implementation by the designers, 32 | hereby denoted as "the implementer". 33 | 34 | To the extent possible under law, the implementer has waived all copyright 35 | and related or neighboring rights to the source code in this file. 36 | http://creativecommons.org/publicdomain/zero/1.0/ 37 | */ 38 | 39 | #ifndef _KeccakPermutationInterface_h_ 40 | #define _KeccakPermutationInterface_h_ 41 | 42 | #include "KeccakF-1600-int-set.h" 43 | 44 | void KeccakInitialize( void ); 45 | void KeccakInitializeState(unsigned char *state); 46 | void KeccakPermutation(unsigned char *state); 47 | #ifdef ProvideFast576 48 | void KeccakAbsorb576bits(unsigned char *state, const unsigned char *data); 49 | #endif 50 | #ifdef ProvideFast832 51 | void KeccakAbsorb832bits(unsigned char *state, const unsigned char *data); 52 | #endif 53 | #ifdef ProvideFast1024 54 | void KeccakAbsorb1024bits(unsigned char *state, const unsigned char *data); 55 | #endif 56 | #ifdef ProvideFast1088 57 | void KeccakAbsorb1088bits(unsigned char *state, const unsigned char *data); 58 | #endif 59 | #ifdef ProvideFast1152 60 | void KeccakAbsorb1152bits(unsigned char *state, const unsigned char *data); 61 | #endif 62 | #ifdef ProvideFast1344 63 | void KeccakAbsorb1344bits(unsigned char *state, const unsigned char *data); 64 | #endif 65 | void KeccakAbsorb(unsigned char *state, const unsigned char *data, unsigned int laneCount); 66 | #ifdef ProvideFast1024 67 | void KeccakExtract1024bits(const unsigned char *state, unsigned char *data); 68 | #endif 69 | void KeccakExtract(const unsigned char *state, unsigned char *data, unsigned int laneCount); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /crypto/keccak/KeccakF-1600-opt64-settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define Unrolling 24 27 | #define UseBebigokimisa 28 | //#define UseSSE 29 | //#define UseOnlySIMD64 30 | //#define UseMMX 31 | //#define UseSHLD 32 | //#define UseXOP 33 | -------------------------------------------------------------------------------- /crypto/keccak/KeccakF-1600-x86-64-asm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /* 27 | The Keccak sponge function, designed by Guido Bertoni, Joan Daemen, 28 | Michaël Peeters and Gilles Van Assche. For more information, feedback or 29 | questions, please refer to our website: http://keccak.noekeon.org/ 30 | 31 | Implementation by Ronny Van Keer, 32 | hereby denoted as "the implementer". 33 | 34 | To the extent possible under law, the implementer has waived all copyright 35 | and related or neighboring rights to the source code in this file. 36 | http://creativecommons.org/publicdomain/zero/1.0/ 37 | */ 38 | 39 | #include 40 | #include "KeccakF-1600-interface.h" 41 | 42 | #define UseBebigokimisa 43 | 44 | typedef unsigned char UINT8; 45 | typedef unsigned long long int UINT64; 46 | 47 | void KeccakInitialize() 48 | { 49 | } 50 | 51 | void KeccakExtract(const unsigned char *state, unsigned char *data, unsigned int laneCount) 52 | { 53 | memcpy(data, state, laneCount*8); 54 | #ifdef UseBebigokimisa 55 | if (laneCount > 8) 56 | { 57 | ((UINT64*)data)[ 1] = ~((UINT64*)data)[ 1]; 58 | ((UINT64*)data)[ 2] = ~((UINT64*)data)[ 2]; 59 | ((UINT64*)data)[ 8] = ~((UINT64*)data)[ 8]; 60 | 61 | if (laneCount > 12) 62 | { 63 | ((UINT64*)data)[12] = ~((UINT64*)data)[12]; 64 | if (laneCount > 17) 65 | { 66 | ((UINT64*)data)[17] = ~((UINT64*)data)[17]; 67 | if (laneCount > 20) 68 | { 69 | ((UINT64*)data)[20] = ~((UINT64*)data)[20]; 70 | } 71 | } 72 | } 73 | } 74 | else 75 | { 76 | if (laneCount > 1) 77 | { 78 | ((UINT64*)data)[ 1] = ~((UINT64*)data)[ 1]; 79 | if (laneCount > 2) 80 | { 81 | ((UINT64*)data)[ 2] = ~((UINT64*)data)[ 2]; 82 | } 83 | } 84 | } 85 | 86 | #endif 87 | } 88 | -------------------------------------------------------------------------------- /crypto/old/sha2_utils_old.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _SHA2_UTILS_OLD_H_ 27 | #define _SHA2_UTILS_OLD_H_ 28 | 29 | void ossl_SHA256_par_old(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 30 | void opt_SHA512t256_par_old(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 31 | 32 | void ossl_SHA512_par_old(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 33 | void opt_SHA512_par_old(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /crypto/old/sha3_utils_old.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _SHA3_UTILS_OLD_H_ 27 | #define _SHA3_UTILS_OLD_H_ 28 | 29 | int Keccak256_par_old(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 30 | 31 | int Keccak512_par_old(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /crypto/scrypt/sha256.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /*- 27 | * Copyright 2005,2007,2009 Colin Percival 28 | * All rights reserved. 29 | * 30 | * Redistribution and use in source and binary forms, with or without 31 | * modification, are permitted provided that the following conditions 32 | * are met: 33 | * 1. Redistributions of source code must retain the above copyright 34 | * notice, this list of conditions and the following disclaimer. 35 | * 2. Redistributions in binary form must reproduce the above copyright 36 | * notice, this list of conditions and the following disclaimer in the 37 | * documentation and/or other materials provided with the distribution. 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 40 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 42 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 43 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 44 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 45 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 47 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 48 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 49 | * SUCH DAMAGE. 50 | * 51 | * $FreeBSD: src/lib/libmd/sha256.h,v 1.2 2006/01/17 15:35:56 phk Exp $ 52 | */ 53 | 54 | #ifndef _SHA256_H_ 55 | #define _SHA256_H_ 56 | 57 | #include 58 | 59 | #include 60 | 61 | /** 62 | * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): 63 | * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and 64 | * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). 65 | */ 66 | void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t, 67 | uint64_t, uint8_t *, size_t); 68 | 69 | #endif /* !_SHA256_H_ */ 70 | -------------------------------------------------------------------------------- /crypto/sha2/intel/open_software_license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Intel Corporation 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the 15 | distribution. 16 | 17 | * Neither the name of the Intel Corporation nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | 22 | THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY 23 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /crypto/sha2_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _SHA2_UTILS_H_ 27 | #define _SHA2_UTILS_H_ 28 | 29 | void ossl_SHA256(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 30 | void ossl_SHA256_par(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 31 | void opt_SHA512t256(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 32 | void opt_SHA512t256_par(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 33 | 34 | void ossl_SHA512(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 35 | void ossl_SHA512_par(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 36 | void opt_SHA512(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 37 | void opt_SHA512_par(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /crypto/sha3_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _SHA3_UTILS_H_ 27 | #define _SHA3_UTILS_H_ 28 | 29 | int Keccak256(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 30 | int Keccak256_par(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 31 | 32 | int Keccak512(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 33 | int Keccak512_par(uchar_t *cksum_buf, uchar_t *buf, uint64_t bytes); 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /crypto/xsalsa20/crypto_core_hsalsa20.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef crypto_core_hsalsa20_H 26 | #define crypto_core_hsalsa20_H 27 | 28 | #define HSALSA_CRYPTO_OUTPUTBYTES 32 29 | #define HSALSA_CRYPTO_INPUTBYTES 16 30 | #define HSALSA_CRYPTO_CONSTBYTES 16 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in, const unsigned char *k, const unsigned char *c); 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /crypto/xsalsa20/crypto_stream_salsa20.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef crypto_stream_salsa20_H 26 | #define crypto_stream_salsa20_H 27 | 28 | #define crypto_stream_salsa20_amd64_xmm6_KEYBYTES 32 29 | #define crypto_stream_salsa20_amd64_xmm6_NONCEBYTES 8 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | extern int crypto_stream_salsa20_amd64_xmm6(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); 34 | extern int crypto_stream_salsa20_amd64_xmm6_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); 35 | extern int crypto_stream_salsa20_ref(unsigned char *c,unsigned long long clen, const unsigned char *n, const unsigned char *k); 36 | extern int crypto_stream_salsa20_ref_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *); 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #ifndef SALSA20_DEBUG 42 | #define crypto_stream_salsa20 crypto_stream_salsa20_amd64_xmm6 43 | #define crypto_stream_salsa20_xor crypto_stream_salsa20_amd64_xmm6_xor 44 | #else 45 | #define crypto_stream_salsa20 crypto_stream_salsa20_ref 46 | #define crypto_stream_salsa20_xor crypto_stream_salsa20_ref_xor 47 | #endif 48 | #define crypto_stream_salsa20_KEYBYTES crypto_stream_salsa20_amd64_xmm6_KEYBYTES 49 | #define crypto_stream_salsa20_NONCEBYTES crypto_stream_salsa20_amd64_xmm6_NONCEBYTES 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /crypto/xsalsa20/crypto_xsalsa20.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef crypto_xsalsa20_H 26 | #define crypto_xsalsa20_H 27 | 28 | #include 29 | #include 30 | 31 | #define XSALSA20_CRYPTO_KEYBYTES 32 32 | #define XSALSA20_CRYPTO_NONCEBYTES 24 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct { 39 | unsigned char nonce[XSALSA20_CRYPTO_NONCEBYTES]; 40 | uchar_t key[XSALSA20_CRYPTO_KEYBYTES]; 41 | int keylen; 42 | uchar_t pkey[XSALSA20_CRYPTO_KEYBYTES]; 43 | } salsa20_ctx_t; 44 | 45 | int salsa20_init(salsa20_ctx_t *ctx, uchar_t *salt, int saltlen, uchar_t *pwd, int pwd_len, uchar_t *nonce, int enc); 46 | int salsa20_encrypt(salsa20_ctx_t *ctx, uchar_t *plaintext, uchar_t *ciphertext, uint64_t len, uint64_t id); 47 | int salsa20_decrypt(salsa20_ctx_t *ctx, uchar_t *ciphertext, uchar_t *plaintext, uint64_t len, uint64_t id); 48 | uchar_t *salsa20_nonce(salsa20_ctx_t *ctx); 49 | void salsa20_clean_pkey(salsa20_ctx_t *ctx); 50 | void salsa20_cleanup(salsa20_ctx_t *ctx); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /filters/analyzer/analyzer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2014 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef _ANALYZER_H 26 | #define _ANALYZER_H 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | struct significance_value { 33 | int btype; 34 | }; 35 | 36 | typedef struct _analyzer_ctx { 37 | struct significance_value ten_pct; 38 | struct significance_value thirty_pct; 39 | struct significance_value fifty_pct; 40 | } analyzer_ctx_t; 41 | 42 | void analyze_buffer(void *src, uint64_t srclen, analyzer_ctx_t *actx); 43 | int analyze_buffer_simple(void *src, uint64_t srclen); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /filters/delta2/delta2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef _DELTA2_H 26 | #define _DELTA2_H 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #define NSTRIDES_STANDARD 3 38 | #define NSTRIDES_EXTRA 7 39 | #define STRIDE_MAX 8 40 | #define STRIDE_MIN 2 41 | 42 | int delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int rle_thresh, int nstrides); 43 | int delta2_decode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen); 44 | 45 | #define ULL_MAX (18446744073709551615ULL) 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /filters/dict/Common.h: -------------------------------------------------------------------------------- 1 | #ifndef _DATATYPE_H 2 | #define _DATATYPE_H 3 | 4 | #define CSA_VERSION 8 5 | 6 | 7 | typedef unsigned char u8; 8 | typedef uint16_t u16; 9 | typedef uint32_t u32; 10 | typedef uint64_t u64; 11 | typedef int i32; 12 | typedef int64_t i64; 13 | 14 | const u32 KB=1024; 15 | const u32 MB=1048576; 16 | const u32 MinBlockSize=8*1024; 17 | 18 | 19 | const u32 MaxChunkBits=21; 20 | const u32 MaxChunkSize=(1<<(21-1)); 21 | const u32 MaxDictSize=512*1048576;//Don't change 22 | const u32 DefaultOutStreamBlockSize=128*1024; 23 | const u32 DefaultInBufferSize=21; //Should >=MaxChunkSize 24 | #define DLT_CHANNEL_MAX 5 25 | const u32 DltIndex[DLT_CHANNEL_MAX]={1,2,3,4,8}; 26 | 27 | 28 | #define SAFEFREE(x) do{if ((x)!=NULL) free(x);x=NULL;}while(0) 29 | 30 | 31 | #define ENCODE 1 32 | #define DECODE 2 33 | 34 | 35 | /*****ERRORS*****************/ 36 | #define NO_ERROR 0 37 | #define CANT_OPEN_FILE (-100) 38 | #define CANT_CREATE_FILE (-99) 39 | #define NOT_CSC_FILE (-98) 40 | #define VERSION_INVALID (-97) 41 | #define CSC_FILE_INVALID (-95) 42 | #define DECODE_ERROR (-96) 43 | #define CANT_ALLOC_MEM (-94) 44 | #define ALREADY_INITIALIZED (-93) 45 | #define OPERATION_ERROR (-92) 46 | #define FILE_DIDNT_OPEN (-91) 47 | /*****ERRORS*****************/ 48 | 49 | /******Block Type*************/ 50 | #define DT_NONE 0 51 | #define DT_HARD 0x05 52 | #define DT_EXE 0x04 53 | #define DT_BAD 0x03 54 | #define DT_NORMAL 0x02 55 | #define DT_SKIP 0x01 56 | #define DT_AUDIO 0x06 57 | #define DT_RGB 0x07 58 | #define DT_FAST 0x08 59 | #define SIG_EOF 0x09 60 | #define DT_ENGTXT 0x0A 61 | #define DT_DLT 0x10 62 | #define DT_MAXINDEX 0x1F 63 | /******Block Type*************/ 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /filters/dict/DictFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@gmail.com, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | /* 26 | * Dict filter for text files. Adapted from Public Domain sources 27 | * of Fu Siyuan's CSC 3.2 archiver. 28 | */ 29 | 30 | #ifndef _FILTERS_H 31 | #define _FILTERS_H 32 | 33 | #include 34 | 35 | #include "Common.h" 36 | #define MAX_WORDTREE_NODE_NUM 300 //Enough now! 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | int dict_encode(uchar_t *from, uint64_t fromlen, uchar_t *to, uint64_t *dstlen, int is_fasta); 43 | int dict_decode(uchar_t *from, uint64_t fromlen, uchar_t *to, uint64_t *dstlen); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /filters/dispack/dis.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef __DIS_HPP__ 26 | #define __DIS_HPP__ 27 | 28 | #include 29 | #include "types.hpp" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | int dispack_encode(uchar_t *from, uint64_t fromlen, uchar_t *to, uint64_t *dstlen); 36 | int dispack_decode(uchar_t *from, uint64_t fromlen, uchar_t *to, uint64_t *dstlen); 37 | 38 | int Forward_E89(uint8_t *src, uint64_t sz); 39 | int Inverse_E89(uint8_t *src, uint64_t sz); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #ifdef __cplusplus 46 | sU8 *DisFilter(sU8 *src, sU32 size, sU32 origin, sU8 *dst, sU32 &outputSize); 47 | sBool DisUnFilter(sU8 *source,sU32 sourceSize,sU8 *dest,sU32 destSize,sU32 memStart); 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /filters/dispack/types.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #ifndef __TYPES_HPP__ 30 | #define __TYPES_HPP__ 31 | 32 | typedef unsigned char sU8; 33 | typedef signed char sS8; 34 | typedef unsigned short sU16; 35 | typedef signed short sS16; 36 | typedef unsigned int sU32; 37 | typedef signed int sS32; 38 | typedef uint64_t sU64; 39 | typedef int64_t sS64; 40 | typedef int sInt; 41 | typedef char sChar; 42 | typedef float sF32; 43 | typedef double sF64; 44 | 45 | #ifdef __cplusplus 46 | typedef bool sBool; 47 | #define sTRUE true 48 | #define sFALSE false 49 | #endif 50 | 51 | #define _byteswap_ushort htons 52 | #define _byteswap_ulong htonl 53 | #endif 54 | -------------------------------------------------------------------------------- /filters/packjpg/packjpglib.h: -------------------------------------------------------------------------------- 1 | // packJPGlib.h - function declarations for the packJPG library 2 | #if defined BUILD_DLL 3 | #define EXPORT __declspec( dllexport ) 4 | #else 5 | #define EXPORT extern 6 | #endif 7 | 8 | /* ----------------------------------------------- 9 | function declarations: library only functions 10 | ----------------------------------------------- */ 11 | 12 | EXPORT bool pjglib_convert_stream2stream( char* msg ); 13 | EXPORT bool pjglib_convert_file2file( char* in, char* out, char* msg ); 14 | EXPORT bool pjglib_convert_stream2mem( unsigned char** out_file, unsigned int* out_size, char* msg ); 15 | EXPORT void pjglib_init_streams( void* in_src, int in_type, int in_size, void* out_dest, int out_type ); 16 | EXPORT const char* pjglib_version_info( void ); 17 | EXPORT const char* pjglib_short_name( void ); 18 | 19 | /* a short reminder about input/output stream types 20 | for the pjglib_init_streams() function 21 | 22 | if input is file 23 | ---------------- 24 | in_scr -> name of input file 25 | in_type -> 0 26 | in_size -> ignore 27 | 28 | if input is memory 29 | ------------------ 30 | in_scr -> array containg data 31 | in_type -> 1 32 | in_size -> size of data array 33 | 34 | if input is *FILE (f.e. stdin) 35 | ------------------------------ 36 | in_src -> stream pointer 37 | in_type -> 2 38 | in_size -> ignore 39 | 40 | vice versa for output streams! */ 41 | -------------------------------------------------------------------------------- /filters/packpnm/packpnmlib.h: -------------------------------------------------------------------------------- 1 | // packPNMlib.h - function declarations for the packPNM library 2 | #if defined BUILD_DLL 3 | #define EXPORT __declspec( dllexport ) 4 | #else 5 | #define EXPORT extern 6 | #endif 7 | 8 | /* ----------------------------------------------- 9 | function declarations: library only functions 10 | ----------------------------------------------- */ 11 | 12 | EXPORT bool ppnlib_convert_stream2stream( char* msg ); 13 | EXPORT bool ppnlib_convert_file2file( char* in, char* out, char* msg ); 14 | EXPORT bool ppnlib_convert_stream2mem( unsigned char** out_file, unsigned int* out_size, char* msg ); 15 | EXPORT void ppnlib_init_streams( void* in_src, int in_type, int in_size, void* out_dest, int out_type ); 16 | EXPORT const char* ppnlib_version_info( void ); 17 | EXPORT const char* ppnlib_short_name( void ); 18 | 19 | /* a short reminder about input/output stream types 20 | for the ppnlib_init_streams() function 21 | 22 | if input is file 23 | ---------------- 24 | in_scr -> name of input file 25 | in_type -> 0 26 | in_size -> ignore 27 | 28 | if input is memory 29 | ------------------ 30 | in_scr -> array containg data 31 | in_type -> 1 32 | in_size -> size of data array 33 | 34 | if input is *FILE (f.e. stdin) 35 | ------------------------------ 36 | in_src -> stream pointer 37 | in_type -> 2 38 | in_size -> ignore 39 | 40 | vice versa for output streams! */ 41 | -------------------------------------------------------------------------------- /filters/packpnm/ppnmtbl.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------- 2 | defines for use in packPNM processing 3 | ----------------------------------------------- */ 4 | 5 | // action defines 6 | #define A_COMPRESS 1 7 | #define A_PGM_DUMP 2 8 | #define A_NFO_DUMP 3 9 | 10 | // file type defines 11 | #define F_PNM 1 12 | #define F_PPN 2 13 | #define F_UNK 0 14 | 15 | // sub type defines 16 | #define S_PBM 1 17 | #define S_PGM 2 18 | #define S_PPM 3 19 | #define S_BMP 4 20 | #define S_HDR 5 21 | #define S_UNK 0 22 | 23 | // color model defines 24 | #define C_MONO 1 25 | #define C_GRAY 2 26 | #define C_RGBA 3 27 | #define C_RGBE 4 28 | #define C_UNK 0 29 | 30 | // endianess defines 31 | #define E_BIG 0 // false 32 | #define E_LITTLE 1 // true 33 | -------------------------------------------------------------------------------- /filters/transpose/transpose.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #include "transpose.h" 26 | 27 | /* 28 | * Perform a simple matrix transpose of the given buffer in "from". 29 | * If the buffer contains tables of numbers or structured data a 30 | * transpose can potentially help improve compression ratio by 31 | * bringing repeating values in columns into row ordering. 32 | */ 33 | void 34 | transpose(unsigned char *from, unsigned char *to, uint64_t buflen, uint64_t stride, rowcol_t rc) 35 | { 36 | uint64_t rows, cols, i, j, k, l; 37 | 38 | if (rc == ROW) { 39 | rows = buflen / stride; 40 | cols = stride; 41 | } else { 42 | cols = buflen / stride; 43 | rows = stride; 44 | } 45 | k = 0; 46 | for (j = 0; j < rows; j++) { 47 | l = 0; 48 | for (i = 0; i < cols; i++) { 49 | to[j + l] = from[i + k]; 50 | l += rows; 51 | } 52 | k += cols; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /filters/transpose/transpose.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef _TRANSP_H 26 | #define _TRANSP_H 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | typedef enum { 37 | ROW = 0, 38 | COL = 1 39 | } rowcol_t; 40 | 41 | void transpose(unsigned char *from, unsigned char *to, uint64_t buflen, 42 | uint64_t stride, rowcol_t rc); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /licensing_utils/lic_header.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; This file is a part of Pcompress, a chunked parallel multi- 3 | ; algorithm lossless compression and decompression program. 4 | ; 5 | ; Copyright (C) 2012-2014 Moinak Ghosh. All rights reserved. 6 | ; Use is subject to license terms. 7 | ; 8 | ; This Source Code Form is subject to the terms of the Mozilla Public 9 | ; License, v. 2.0. If a copy of the MPL was not distributed with this 10 | ; file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | ; 12 | ; moinakg@belenix.org, http://moinakg.wordpress.com/ 13 | ; 14 | 15 | -------------------------------------------------------------------------------- /licensing_utils/lic_header.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2014 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This Source Code Form is subject to the terms of the Mozilla Public 9 | * License, v. 2.0. If a copy of the MPL was not distributed with this 10 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | * 12 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 13 | */ 14 | -------------------------------------------------------------------------------- /licensing_utils/lic_header.s: -------------------------------------------------------------------------------- 1 | ;# 2 | ;# This file is a part of Pcompress, a chunked parallel multi- 3 | ;# algorithm lossless compression and decompression program. 4 | ;# 5 | ;# Copyright (C) 2012-2014 Moinak Ghosh. All rights reserved. 6 | ;# Use is subject to license terms. 7 | ;# 8 | ;# This Source Code Form is subject to the terms of the Mozilla Public 9 | ;# License, v. 2.0. If a copy of the MPL was not distributed with this 10 | ;# file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | ;# 12 | ;# moinakg@belenix.org, http://moinakg.wordpress.com/ 13 | ;# 14 | 15 | -------------------------------------------------------------------------------- /licensing_utils/lic_header.sh: -------------------------------------------------------------------------------- 1 | # 2 | # This file is a part of Pcompress, a chunked parallel multi- 3 | # algorithm lossless compression and decompression program. 4 | # 5 | # Copyright (C) 2012-2014 Moinak Ghosh. All rights reserved. 6 | # Use is subject to license terms. 7 | # 8 | # This Source Code Form is subject to the terms of the Mozilla Public 9 | # License, v. 2.0. If a copy of the MPL was not distributed with this 10 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 11 | # 12 | # moinakg@belenix.org, http://moinakg.wordpress.com/ 13 | # 14 | -------------------------------------------------------------------------------- /lzma/Common/MyGuidDef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | // Common/MyGuidDef.h 27 | 28 | #ifndef GUID_DEFINED 29 | #define GUID_DEFINED 30 | 31 | #include "Types.h" 32 | 33 | typedef struct { 34 | UInt32 Data1; 35 | UInt16 Data2; 36 | UInt16 Data3; 37 | unsigned char Data4[8]; 38 | } GUID; 39 | 40 | #ifdef __cplusplus 41 | #define REFGUID const GUID & 42 | #else 43 | #define REFGUID const GUID * 44 | #endif 45 | 46 | #define REFCLSID REFGUID 47 | #define REFIID REFGUID 48 | 49 | #ifdef __cplusplus 50 | inline int operator==(REFGUID g1, REFGUID g2) 51 | { 52 | for (int i = 0; i < (int)sizeof(g1); i++) 53 | if (((unsigned char *)&g1)[i] != ((unsigned char *)&g2)[i]) 54 | return 0; 55 | return 1; 56 | } 57 | inline int operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); } 58 | #endif 59 | 60 | #ifdef __cplusplus 61 | #define MY_EXTERN_C extern "C" 62 | #else 63 | #define MY_EXTERN_C extern 64 | #endif 65 | 66 | #endif 67 | 68 | 69 | #ifdef DEFINE_GUID 70 | #undef DEFINE_GUID 71 | #endif 72 | 73 | #ifdef INITGUID 74 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 75 | MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } 76 | #else 77 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ 78 | MY_EXTERN_C const GUID name 79 | #endif 80 | -------------------------------------------------------------------------------- /lzma/basetyps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _BASETYPS_H 27 | #define _BASETYPS_H 28 | 29 | #ifdef ENV_HAVE_GCCVISIBILITYPATCH 30 | #define DLLEXPORT __attribute__ ((visibility("default"))) 31 | #else 32 | #define DLLEXPORT 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | #define STDAPI extern "C" DLLEXPORT HRESULT 37 | #else 38 | #define STDAPI extern DLLEXPORT HRESULT 39 | #endif /* __cplusplus */ 40 | 41 | typedef GUID IID; 42 | typedef GUID CLSID; 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /lzma/crc32_table.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | // 28 | /// \file crc32_table.c 29 | /// \brief Precalculated CRC32 table with correct endianness 30 | // 31 | // Author: Lasse Collin 32 | // 33 | // This file has been put into the public domain. 34 | // You can do whatever you want with this file. 35 | // 36 | /////////////////////////////////////////////////////////////////////////////// 37 | 38 | /* 39 | * This gives us BYTE_ORDER macro both on Linux and Solaris derived 40 | * systems. 41 | */ 42 | #include 43 | 44 | #if BYTE_ORDER == LITTLE_ENDIAN 45 | # include "crc32_table_le.h" 46 | #else 47 | # include "crc32_table_be.h" 48 | #endif 49 | -------------------------------------------------------------------------------- /lzma/crc64_table.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | // 28 | /// \file crc64_table.c 29 | /// \brief Precalculated CRC64 table with correct endianness 30 | // 31 | // Author: Lasse Collin 32 | // 33 | // This file has been put into the public domain. 34 | // You can do whatever you want with this file. 35 | // 36 | /////////////////////////////////////////////////////////////////////////////// 37 | 38 | /* 39 | * This gives us BYTE_ORDER macro both on Linux and Solaris derived 40 | * systems. 41 | */ 42 | #include 43 | 44 | #if BYTE_ORDER == LITTLE_ENDIAN 45 | # include "crc64_table_le.h" 46 | #else 47 | # include "crc64_table_be.h" 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /lzma/crc_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | // 28 | /// \file crc_macros.h 29 | /// \brief Some endian-dependent macros for CRC32 and CRC64 30 | // 31 | // Author: Lasse Collin 32 | // 33 | // This file has been put into the public domain. 34 | // You can do whatever you want with this file. 35 | // 36 | /////////////////////////////////////////////////////////////////////////////// 37 | 38 | #include 39 | 40 | #ifdef WORDS_BIGENDIAN 41 | # define A(x) ((x) >> 24) 42 | # define B(x) (((x) >> 16) & 0xFF) 43 | # define C(x) (((x) >> 8) & 0xFF) 44 | # define D(x) ((x) & 0xFF) 45 | 46 | # define S8(x) ((x) << 8) 47 | # define S32(x) ((x) << 32) 48 | 49 | #else 50 | # define A(x) ((x) & 0xFF) 51 | # define B(x) (((x) >> 8) & 0xFF) 52 | # define C(x) (((x) >> 16) & 0xFF) 53 | # define D(x) ((x) >> 24) 54 | 55 | # define S8(x) ((x) >> 8) 56 | # define S32(x) ((x) >> 32) 57 | #endif 58 | -------------------------------------------------------------------------------- /lzma/lzma_crc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef __LZMA_CRC_H__ 27 | #define __LZMA_CRC_H__ 28 | 29 | #include 30 | 31 | uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc); 32 | uint32_t lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc); 33 | 34 | 35 | #endif -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /* 27 | * pcompress - Do a chunked parallel compression/decompression of a file. 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include "pcompress.h" 39 | #include 40 | #include 41 | 42 | int 43 | main(int argc, char *argv[]) 44 | { 45 | int err; 46 | pc_ctx_t *pctx; 47 | 48 | err = 0; 49 | pctx = create_pc_context(); 50 | 51 | err = init_pc_context(pctx, argc, argv); 52 | if (err != 0 && err != 2) { 53 | log_msg(LOG_ERR, 0, "Invalid arguments to pcompress.\n"); 54 | log_msg(LOG_ERR, 0, "Please see usage.\n"); 55 | destroy_pc_context(pctx); 56 | return (err); 57 | 58 | } else if (err == 2) { 59 | usage(pctx); 60 | destroy_pc_context(pctx); 61 | return (0); 62 | } 63 | 64 | /* 65 | * Start the main routines. 66 | */ 67 | err = start_pcompress(pctx); 68 | destroy_pc_context(pctx); 69 | return (err); 70 | } 71 | -------------------------------------------------------------------------------- /make_mplv2.ksh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ksh 2 | 3 | 4 | exclude_list='^bsc|^filters/packjpg|^filters/lzp|^utils/qsort_gnu.h|^\.git/|^\.gitignore|^COPYING|^utils/fixlic.sh' 5 | my_path=./licensing_utils 6 | 7 | target_dir=../pcompress_mplv2 8 | if [ -d ${target_dir} ] 9 | then 10 | if [ "$1" = "-f" ] 11 | then 12 | rm -rf ${target_dir} 13 | else 14 | echo "${target_dir} exists" 15 | exit 1 16 | fi 17 | fi 18 | 19 | mkdir -p ${target_dir} 20 | 21 | for dir in `find * -type d` 22 | do 23 | echo ${dir} | egrep "$exclude_list" > /dev/null 24 | [ $? -eq 0 ] && continue 25 | mkdir -p ${target_dir}/${dir} 26 | done 27 | 28 | for f in `find * -type f` 29 | do 30 | echo ${f} | egrep "$exclude_list" > /dev/null 31 | [ $? -eq 0 ] && continue 32 | case ${f} in 33 | *.c) 34 | cp ${my_path}/lic_header.c ${target_dir}/${f} 35 | cat ${f} | sed '/This file is a part of Pcompress,/,/moinakg@belenix.org,/d' >> ${target_dir}/${f} 36 | ;; 37 | *.h) 38 | cp ${my_path}/lic_header.c ${target_dir}/${f} 39 | cat ${f} | sed '/This file is a part of Pcompress,/,/moinakg@belenix.org,/d' >> ${target_dir}/${f} 40 | ;; 41 | *.s) 42 | cp ${my_path}/lic_header.s ${target_dir}/${f} 43 | cat ${f} | sed '/This file is a part of Pcompress,/,/moinakg@belenix.org,/d' >> ${target_dir}/${f} 44 | ;; 45 | *.asm) 46 | cp ${my_path}/lic_header.asm ${target_dir}/${f} 47 | cat ${f} | sed '/This file is a part of Pcompress,/,/moinakg@belenix.org,/d' >> ${target_dir}/${f} 48 | ;; 49 | esac 50 | done 51 | 52 | f=Makefile.in 53 | cp ${my_path}/lic_header.sh ${target_dir}/${f} 54 | cat ${f} | sed ' 55 | s@\$(PJPGOBJS)@@ 56 | s@\$(PPNMOBJS)@@ 57 | s@\$(LZPOBJS)@@ 58 | s@BASE_CPPFLAGS =@BASE_CPPFLAGS = -D_MPLV2_LICENSE_@ 59 | s@\-I\./filters/packjpg@@ 60 | s@\-I\./filters/lzp@@ 61 | /This file is a part of Pcompress,/,/moinakg@belenix.org,/d 62 | ' >> ${target_dir}/${f} 63 | 64 | cat config | sed 's@my_license=LGPLv3@my_license=MPLv2@' > ${target_dir}/config.new 65 | cp ${my_path}/lic_header.sh ${target_dir}/config 66 | cat ${target_dir}/config.new | sed '/This file is a part of Pcompress,/,/moinakg@belenix.org,/d' >> ${target_dir}/config 67 | rm -f ${target_dir}/config.new 68 | 69 | cp ${my_path}/LICENSE.MPLV2 ${target_dir} 70 | -------------------------------------------------------------------------------- /meta_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2014 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #ifndef _META_STREAM_H 27 | #define _META_STREAM_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* 34 | * The chunk size value which indicates a metadata chunk. 35 | */ 36 | #define METADATA_INDICATOR 1 37 | 38 | /* 39 | * Metadata chunk header format: 40 | * 64-bit integer = 1: Compressed length: This indicates that this is a metadata chunk 41 | * 64-bit integer: Compressed length (data portion only) 42 | * 64-bit integer: Uncompressed original length 43 | * 1 Byte: Chunk flag 44 | * Upto 64-bytes: Checksum. This is HMAC if encrypting 45 | * 32-bit integer: Header CRC32 if not encrypting, otherwise empty. 46 | */ 47 | #define CKSUM_MAX 64 48 | #define CRC32_SIZE 4 49 | #define METADATA_HDR_SZ (8 * 3 + 1 + CKSUM_MAX + CRC32_SIZE) 50 | 51 | typedef struct _meta_ctx meta_ctx_t; 52 | 53 | typedef struct _meta_msg { 54 | const uchar_t *buf; 55 | size_t len; 56 | } meta_msg_t; 57 | 58 | meta_ctx_t *meta_ctx_create(void *pc, int file_version, int comp_fd); 59 | int meta_ctx_send(meta_ctx_t *mctx, const void **buf, size_t *len); 60 | int meta_ctx_done(meta_ctx_t *mctx); 61 | void meta_ctx_close_sink_channel(meta_ctx_t *mctx); 62 | void meta_ctx_close_src_channel(meta_ctx_t *mctx); 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /none_compress.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | void 37 | none_stats(int show) 38 | { 39 | } 40 | 41 | int 42 | none_init(void **data, int *level, int nthreads, uint64_t chunksize, 43 | int file_version, compress_op_t op) 44 | { 45 | return (0); 46 | } 47 | 48 | void 49 | none_props(algo_props_t *data, int level, uint64_t chunksize) { 50 | data->compress_mt_capable = 0; 51 | data->decompress_mt_capable = 0; 52 | data->buf_extra = 0; 53 | data->delta2_span = 50; 54 | } 55 | 56 | int 57 | none_deinit(void **data) 58 | { 59 | return (0); 60 | } 61 | 62 | int 63 | none_compress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, 64 | int level, uchar_t chdr, int btype, void *data) 65 | { 66 | memcpy(dst, src, srclen); 67 | return (0); 68 | } 69 | 70 | int 71 | none_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, 72 | int level, uchar_t chdr, int btype, void *data) 73 | { 74 | memcpy(dst, src, srclen); 75 | return (0); 76 | } 77 | -------------------------------------------------------------------------------- /rabin/global/index.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef _INDEX_H 26 | #define _INDEX_H 27 | 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* 35 | * Publically visible In-memory hashtable entry. 36 | */ 37 | typedef struct _hash_entry { 38 | uint64_t item_offset; 39 | uint32_t item_size; 40 | struct _hash_entry *next; 41 | uchar_t cksum[1]; 42 | } hash_entry_t; 43 | 44 | 45 | archive_config_t *init_global_db(char *configfile); 46 | int setup_db_config_s(archive_config_t *cfg, uint32_t chunksize, uint64_t *user_chunk_sz, 47 | int *pct_interval, const char *algo, cksum_t ck, cksum_t ck_sim, 48 | size_t file_sz, uint32_t *hash_slots, int *hash_entry_size, 49 | uint64_t *memreqd, size_t memlimit, char *tmppath); 50 | archive_config_t *init_global_db_s(char *path, char *tmppath, uint32_t chunksize, 51 | uint64_t user_chunk_sz, int pct_interval, const char *algo, 52 | cksum_t ck, cksum_t ck_sim, size_t file_sz, size_t memlimit, 53 | int nthreads); 54 | hash_entry_t *db_lookup_insert_s(archive_config_t *cfg, uchar_t *sim_cksum, int interval, 55 | uint64_t item_offset, uint32_t item_size, int do_insert); 56 | void destroy_global_db_s(archive_config_t *cfg); 57 | 58 | int db_segcache_write(archive_config_t *cfg, int tid, uchar_t *buf, uint32_t len, uint32_t blknum, uint64_t file_offset); 59 | uint64_t db_segcache_pos(archive_config_t *cfg, int tid); 60 | int db_segcache_map(archive_config_t *cfg, int tid, uint32_t *blknum, uint64_t *offset, uchar_t **blocks); 61 | int db_segcache_unmap(archive_config_t *cfg, int tid); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /test/res/jpg/screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moinakg/pcompress/c6e779c40041b7bb46259e9806fa92b20c7b78fb/test/res/jpg/screen.jpg -------------------------------------------------------------------------------- /test/run_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | tst=$1 4 | 5 | if [ ! -d datafiles ] 6 | then 7 | mkdir datafiles 8 | else 9 | rm -f datafiles/.pco* 10 | rm -f datafiles/*.pz 11 | rm -f datafiles/*.1 12 | fi 13 | PDIR=`pwd` 14 | 15 | if [ ! -f datafiles/files.lst ] 16 | then 17 | [ ! -f datafiles/bin.dat ] && (tar cpf - /usr/bin | dd of=datafiles/bin.dat bs=1024 count=5120; cat res/jpg/*.jpg >> datafiles/bin.dat) 18 | [ ! -f datafiles/share.dat ] && tar cpf - /usr/share | dd of=datafiles/share.dat bs=1024 count=5120 19 | [ ! -f datafiles/inc.dat ] && (tar cpf - /usr/include | dd of=datafiles/inc.dat bs=1024 count=5120; cat res/xml/*.xml >> datafiles/inc.dat) 20 | [ ! -f datafiles/combined.dat ] && cat datafiles/bin.dat datafiles/share.dat datafiles/inc.dat >> datafiles/combined.dat 21 | [ ! -f datafiles/comb_d.dat ] && sh -c "cat datafiles/combined.dat > datafiles/comb_d.dat; cat datafiles/combined.dat >> datafiles/comb_d.dat" 22 | 23 | pdir=`pwd` 24 | echo ${pdir}/datafiles/bin.dat > datafiles/files.lst 25 | echo ${pdir}/datafiles/share.dat >> datafiles/files.lst 26 | echo ${pdir}/datafiles/inc.dat >> datafiles/files.lst 27 | echo ${pdir}/datafiles/combined.dat >> datafiles/files.lst 28 | echo ${pdir}/datafiles/comb_d.dat >> datafiles/files.lst 29 | else 30 | for f in `cat datafiles/files.lst` 31 | do 32 | if [ ! -f ${f} ] 33 | then 34 | echo "Cannot find test data file: ${f}" 35 | exit 1 36 | fi 37 | dir=`dirname ${f}` 38 | rm -f ${dir}/.pco* 39 | rm -f ${dir}/*.pz 40 | rm -f ${dir}/*.1 41 | done 42 | fi 43 | 44 | 45 | 46 | failures=0 47 | if [ "x$tst" = "x" ] 48 | then 49 | for tf in * 50 | do 51 | echo "$tf" | grep "tst" > /dev/null 52 | [ $? -ne 0 ] && continue 53 | 54 | cd datafiles 55 | (. ../${tf}) 2>&1 | tee ${tf}.log 56 | fails=`egrep "^FATAL:" ${tf}.log | wc -l` 57 | failures=$((failures + fails)) 58 | cd $PDIR 59 | done 60 | else 61 | tf="t${tst}.tst" 62 | if [ -f $tf ] 63 | then 64 | cd datafiles 65 | (. ../${tf}) 66 | if [ $? -ne 0 ] 67 | then 68 | echo "FATAL: Test ${tf} failed" 69 | failures=$((failures + 1)) 70 | fi 71 | cd $PDIR 72 | else 73 | echo "No such test $tst" 74 | exit 1 75 | fi 76 | fi 77 | 78 | if [ $failures -gt 0 ] 79 | then 80 | echo "$failures tests Failed!" 81 | exit 1 82 | else 83 | echo "All tests PASSED" 84 | fi 85 | 86 | -------------------------------------------------------------------------------- /test/t1.tst: -------------------------------------------------------------------------------- 1 | # 2 | # Simple compress and decompress 3 | # 4 | echo "#################################################" 5 | echo "# Simple compress and decompress" 6 | echo "#################################################" 7 | 8 | for algo in lzfx lz4 zlib bzip2 lzma lzmaMt libbsc ppmd adapt adapt2 9 | do 10 | ../../pcompress 2>&1 | grep $algo > /dev/null 11 | [ $? -ne 0 ] && continue 12 | 13 | for level in 1 3 9 14 14 | do 15 | for tf in `cat files.lst` 16 | do 17 | for seg in 1m 100m 18 | do 19 | [ $level -lt 14 -a "$seg" = "100m" ] && continue 20 | 21 | cmd="../../pcompress -c ${algo} -l ${level} -s ${seg} ${tf}" 22 | echo "Running $cmd" 23 | eval $cmd 24 | if [ $? -ne 0 ] 25 | then 26 | echo "FATAL: Compression failed." 27 | rm -f ${tf}.pz 28 | continue 29 | fi 30 | cmd="../../pcompress -d ${tf}.pz ${tf}.1" 31 | echo "Running $cmd" 32 | eval $cmd 33 | if [ $? -ne 0 ] 34 | then 35 | echo "FATAL: Decompression failed." 36 | rm -f ${tf}.pz ${tf}.1 37 | continue 38 | fi 39 | diff ${tf} ${tf}.1 > /dev/null 40 | if [ $? -ne 0 ] 41 | then 42 | echo "FATAL: Decompression was not correct" 43 | fi 44 | rm -f ${tf}.pz ${tf}.1 45 | done 46 | done 47 | done 48 | done 49 | 50 | echo "#################################################" 51 | echo "" 52 | 53 | -------------------------------------------------------------------------------- /test/t2.tst: -------------------------------------------------------------------------------- 1 | # 2 | # Test all checksum mechanisms 3 | # 4 | echo "#################################################" 5 | echo "# All checksums" 6 | echo "#################################################" 7 | 8 | for algo in zlib ppmd 9 | do 10 | for tf in `cat files.lst` 11 | do 12 | for cksum in CRC64 SHA256 SHA512 BLAKE256 BLAKE512 KECCAK256 KECCAK512 13 | do 14 | cmd="../../pcompress -c ${algo} -l 6 -s 1m -S ${cksum} ${tf}" 15 | echo "Running $cmd" 16 | eval $cmd 17 | if [ $? -ne 0 ] 18 | then 19 | echo "FATAL: Compression failed." 20 | rm -f ${tf}.pz 21 | continue 22 | fi 23 | cmd="../../pcompress -d ${tf}.pz ${tf}.1" 24 | echo "Running $cmd" 25 | eval $cmd 26 | if [ $? -ne 0 ] 27 | then 28 | echo "FATAL: Decompression failed." 29 | rm -f ${tf}.pz ${tf}.1 30 | continue 31 | fi 32 | 33 | diff ${tf} ${tf}.1 > /dev/null 34 | if [ $? -ne 0 ] 35 | then 36 | echo "FATAL: Decompression was not correct" 37 | fi 38 | rm -f ${tf}.pz ${tf}.1 39 | done 40 | done 41 | done 42 | 43 | echo "#################################################" 44 | echo "" 45 | 46 | -------------------------------------------------------------------------------- /test/t3.tst: -------------------------------------------------------------------------------- 1 | # 2 | # Simple compress and decompress 3 | # 4 | 5 | clean() { 6 | for algo in lzfx lz4 zlib bzip2 lzma lzmaMt libbsc ppmd adapt adapt2 7 | do 8 | for tf in `cat files.lst` 9 | do 10 | rm -f ${tf}.${algo} 11 | done 12 | done 13 | } 14 | 15 | echo "#################################################" 16 | echo "# Compress compressed files" 17 | echo "#################################################" 18 | 19 | clean 20 | for algo in lzfx lz4 zlib bzip2 lzma lzmaMt libbsc ppmd adapt adapt2 21 | do 22 | ../../pcompress 2>&1 | grep $algo > /dev/null 23 | [ $? -ne 0 ] && continue 24 | 25 | for tf in `cat files.lst` 26 | do 27 | echo "Preparing ${algo} compressed ${tf} datafile ..." 28 | cmd="../../pcompress -c ${algo} -l5 -s500k ${tf}" 29 | eval $cmd 30 | if [ $? -ne 0 ] 31 | then 32 | echo "FATAL: ${cmd} errored. Cannot continue this test suite." 33 | exit 1 34 | fi 35 | mv ${tf}.pz ${tf}.${algo} 36 | done 37 | done 38 | 39 | for algo in lzfx lz4 zlib bzip2 lzma lzmaMt libbsc ppmd adapt adapt2 40 | do 41 | ../../pcompress 2>&1 | grep $algo > /dev/null 42 | [ $? -ne 0 ] && continue 43 | 44 | for level in 1 3 9 14 45 | do 46 | for tf in `cat files.lst` 47 | do 48 | for seg in 1m 100m 49 | do 50 | [ $level -lt 14 -a "$seg" = "100m" ] && continue 51 | 52 | cmd="../../pcompress -c ${algo} -l ${level} -s ${seg} ${tf}.${algo}" 53 | echo "Running $cmd" 54 | eval $cmd 55 | if [ $? -ne 0 ] 56 | then 57 | echo "FATAL: Compression errored." 58 | rm -f ${tf}.${algo}.pz 59 | continue 60 | fi 61 | cmd="../../pcompress -d ${tf}.${algo}.pz ${tf}.${algo}.1" 62 | echo "Running $cmd" 63 | eval $cmd 64 | if [ $? -ne 0 ] 65 | then 66 | echo "FATAL: Decompression failed." 67 | rm -f ${tf}.${algo}.pz ${tf}.${algo}.1 68 | continue 69 | fi 70 | diff ${tf}.${algo} ${tf}.${algo}.1 > /dev/null 71 | if [ $? -ne 0 ] 72 | then 73 | echo "FATAL: Decompression was not correct" 74 | fi 75 | rm -f ${tf}.${algo}.pz ${tf}.${algo}.1 76 | done 77 | done 78 | done 79 | done 80 | 81 | clean 82 | echo "#################################################" 83 | echo "" 84 | 85 | -------------------------------------------------------------------------------- /test/t4.tst: -------------------------------------------------------------------------------- 1 | # 2 | # Dedupe, Delta et al. 3 | # 4 | echo "#################################################" 5 | echo "# Test Deduplication, Delta Encoding and LZP" 6 | echo "#################################################" 7 | 8 | for algo in lzfx lz4 adapt 9 | do 10 | for tf in `cat files.lst` 11 | do 12 | rm -f ${tf}.* 13 | for feat in "-D" "-D -B3 -L" "-D -B4 -E" "-D -B0 -EE" "-D -B5 -EE -L" "-D -B2" "-P" "-D -P" "-D -L -P" \ 14 | "-G -D" "-G -F" "-G -L -P" "-G -B2" 15 | do 16 | for seg in 2m 11m 17 | do 18 | cmd="../../pcompress -c ${algo} -l 3 -s ${seg} $feat ${tf}" 19 | echo "Running $cmd" 20 | eval $cmd 21 | if [ $? -ne 0 ] 22 | then 23 | echo "FATAL: Compression errored." 24 | rm -f ${tf}.pz 25 | continue 26 | fi 27 | cmd="../../pcompress -d ${tf}.pz ${tf}.1" 28 | echo "Running $cmd" 29 | eval $cmd 30 | if [ $? -ne 0 ] 31 | then 32 | echo "FATAL: Decompression errored." 33 | rm -f ${tf}.pz ${tf}.1 34 | continue 35 | fi 36 | 37 | diff ${tf} ${tf}.1 > /dev/null 38 | if [ $? -ne 0 ] 39 | then 40 | echo "FATAL: Decompression was not correct" 41 | fi 42 | rm -f ${tf}.pz ${tf}.1 43 | done 44 | done 45 | done 46 | done 47 | 48 | # 49 | # Test Segmented Global Dedupe 50 | # 51 | 52 | echo "#################################################" 53 | echo "# Test Segmented Global Deduplication" 54 | echo "#################################################" 55 | 56 | # 57 | # Select a large file from the list 58 | # 59 | tstf= 60 | tsz=0 61 | for tf in `cat files.lst` 62 | do 63 | sz=`ls -l ${tf} | awk '{ print $5 }'` 64 | if [ $sz -gt $tsz ] 65 | then 66 | tsz=$sz 67 | tstf="$tf" 68 | fi 69 | done 70 | 71 | # 72 | # Compute minimum index memory needed for segmented dedupe 73 | # sizeof (hash_entry_t) = 20 + sizeof (CRC64) = 28 74 | # Each hashtable slot ptr = 8bytes 75 | # Total: 28 + 8 = 36 76 | # Segment size = 833848 77 | # 25 Similarity indicators per segment, each needing one hash_entry_t 78 | # 79 | nsegs=$((tsz / 833848 + 1)) 80 | nmem=$((nsegs * 25 * 36)) 81 | mem_mb=$((nmem / 1048576 + 1)) 82 | 83 | # 84 | # Now run Global Dedupe with index memory set to force segmented dedupe mechanism 85 | # 86 | export PCOMPRESS_INDEX_MEM=${mem_mb} 87 | cmd="../../pcompress -G -c lz4 -l1 -P -s50m $tstf" 88 | echo "Running $cmd" 89 | eval $cmd 90 | if [ $? -ne 0 ] 91 | then 92 | echo "FATAL: Compression errored." 93 | rm -f ${tstf}.pz 94 | exit 95 | fi 96 | cmd="../../pcompress -d ${tstf}.pz ${tstf}.1" 97 | echo "Running $cmd" 98 | eval $cmd 99 | if [ $? -ne 0 ] 100 | then 101 | echo "FATAL: Decompression errored." 102 | rm -f ${tstf}.pz ${tstf}.1 103 | exit 104 | fi 105 | diff ${tstf} ${tstf}.1 > /dev/null 106 | if [ $? -ne 0 ] 107 | then 108 | echo "FATAL: Decompression was not correct" 109 | fi 110 | rm -f ${tstf}.pz ${tstf}.1 111 | 112 | echo "#################################################" 113 | echo "" 114 | 115 | -------------------------------------------------------------------------------- /test/t5.tst: -------------------------------------------------------------------------------- 1 | # 2 | # Test crypto 3 | # 4 | echo "#################################################" 5 | echo "# Crypto tests" 6 | echo "#################################################" 7 | 8 | for algo in lzfx adapt2 9 | do 10 | for tf in `cat files.lst` 11 | do 12 | rm -f ${tf}.* 13 | for feat in "-e AES" "-e AES -L -S SHA256" "-D -e SALSA20 -S SHA512" "-D -EE -L -e SALSA20 -S BLAKE512" "-e AES -S CRC64" "-e SALSA20 -P" "-e AES -L -P -S KECCAK256" "-D -e SALSA20 -L -S KECCAK512" "-e AES -k16" "-e SALSA20 -k16" "-G -e AES -S SHA256" "-G -e SALSA20 -P" 14 | do 15 | for seg in 2m 100m 16 | do 17 | echo "sillypassword" > /tmp/pwf 18 | cmd="../../pcompress -c ${algo} -l 3 -s ${seg} $feat -w /tmp/pwf ${tf}" 19 | echo "Running $cmd" 20 | eval $cmd 21 | if [ $? -ne 0 ] 22 | then 23 | echo "FATAL: Compression errored." 24 | rm -f ${tf}.pz 25 | continue 26 | fi 27 | 28 | pw=`cat /tmp/pwf` 29 | if [ "$pw" = "sillypassword" ] 30 | then 31 | echo "FATAL: Password file /tmp/pwf not zeroed!" 32 | fi 33 | 34 | echo "sillypassword" > /tmp/pwf 35 | cmd="../../pcompress -d -w /tmp/pwf ${tf}.pz ${tf}.1" 36 | echo "Running $cmd" 37 | eval $cmd 38 | if [ $? -ne 0 ] 39 | then 40 | echo "FATAL: Decompression errored." 41 | rm -f ${tf}.pz ${tf}.1 42 | continue 43 | fi 44 | 45 | diff ${tf} ${tf}.1 > /dev/null 46 | if [ $? -ne 0 ] 47 | then 48 | echo "FATAL: Decompression was not correct" 49 | rm -f ${tf}.pz ${tf}.1 50 | continue 51 | fi 52 | 53 | pw=`cat /tmp/pwf` 54 | if [ "$pw" = "sillypassword" ] 55 | then 56 | echo "FATAL: Password file /tmp/pwf not zeroed!" 57 | fi 58 | 59 | # 60 | # Now try decompression with invalid password. It should 61 | # fail. 62 | # 63 | rm -f ${tf}.1 64 | cmd="../../pcompress -d -w /tmp/pwf ${tf}.pz ${tf}.1" 65 | echo "Running $cmd" 66 | eval $cmd 67 | if [ $? -eq 0 ] 68 | then 69 | echo "FATAL: Decompression did not fail where expected." 70 | fi 71 | rm -f ${tf}.pz ${tf}.1 72 | done 73 | done 74 | done 75 | done 76 | 77 | rm -f /tmp/pwf 78 | 79 | echo "#################################################" 80 | echo "" 81 | 82 | -------------------------------------------------------------------------------- /test/t6.tst: -------------------------------------------------------------------------------- 1 | # 2 | # Simple compress and decompress 3 | # 4 | echo "#################################################" 5 | echo "# Simple pipe mode compress and decompress" 6 | echo "#################################################" 7 | 8 | for algo in lzfx lz4 adapt 9 | do 10 | ../../pcompress 2>&1 | grep $algo > /dev/null 11 | [ $? -ne 0 ] && continue 12 | 13 | for level in 1 3 14 | do 15 | for tf in `cat files.lst` 16 | do 17 | rm -f ${tf}.* 18 | for seg in 1m 2m 3m 19 | do 20 | cmd="cat ${tf} | ../../pcompress -p -c ${algo} -l ${level} -s ${seg} > ${tf}.pz" 21 | echo "Running $cmd" 22 | eval $cmd 23 | if [ $? -ne 0 ] 24 | then 25 | echo "FATAL: Compression errored." 26 | rm -f ${tf}.pz 27 | continue 28 | fi 29 | cmd="../../pcompress -d ${tf}.pz ${tf}.1" 30 | echo "Running $cmd" 31 | eval $cmd 32 | if [ $? -ne 0 ] 33 | then 34 | echo "FATAL: Decompression errored." 35 | rm -f ${tf}.pz ${tf}.1 36 | continue 37 | fi 38 | diff ${tf} ${tf}.1 > /dev/null 39 | if [ $? -ne 0 ] 40 | then 41 | echo "FATAL: Decompression was not correct" 42 | fi 43 | rm -f ${tf}.pz ${tf}.1 44 | done 45 | done 46 | done 47 | done 48 | 49 | for algo in lz4 zlib 50 | do 51 | for dopts in "" "-G -D" "-G -F" "-D" 52 | do 53 | for tf in `cat files.lst` 54 | do 55 | rm -f ${tf}.* 56 | for seg in 2m 21m 57 | do 58 | cmd="../../pcompress -c ${algo} -l6 -s ${seg} ${dopts} ${tf} - > ${tf}.pz" 59 | echo "Running $cmd" 60 | eval $cmd 61 | if [ $? -ne 0 ] 62 | then 63 | echo "FATAL: Compression errored." 64 | rm -f ${tf}.pz 65 | continue 66 | fi 67 | cmd="cat ${tf}.pz | ../../pcompress -d - ${tf}.1" 68 | echo "Running $cmd" 69 | eval $cmd 70 | if [ $? -ne 0 ] 71 | then 72 | echo "FATAL: Decompression errored." 73 | rm -f ${tf}.pz ${tf}.1 74 | continue 75 | fi 76 | diff ${tf} ${tf}.1 > /dev/null 77 | if [ $? -ne 0 ] 78 | then 79 | echo "FATAL: Decompression was not correct" 80 | fi 81 | rm -f ${tf}.pz ${tf}.1 82 | done 83 | done 84 | done 85 | done 86 | 87 | echo "#################################################" 88 | echo "" 89 | 90 | -------------------------------------------------------------------------------- /test/t7.tst: -------------------------------------------------------------------------------- 1 | # 2 | # Test crypto 3 | # 4 | echo "#################################################" 5 | echo "# Pipe mode Crypto tests" 6 | echo "#################################################" 7 | 8 | rm -f *.pz 9 | rm -f *.1 10 | 11 | for algo in lzfx adapt2 12 | do 13 | for tf in `cat files.lst` 14 | do 15 | for feat in "-e SALSA20" "-e AES -L" "-D -e SALSA20" "-D -EE -L -e AES" "-e SALSA20 -S CRC64" "-e SALSA20 -L" "-e AES -E" 16 | do 17 | for seg in 2m 5m 18 | do 19 | echo "sillypassword" > /tmp/pwf 20 | cmd="cat ${tf} | ../../pcompress -c${algo} -p -l3 -s${seg} $feat -w /tmp/pwf > ${tf}.pz" 21 | echo "Running $cmd" 22 | eval $cmd 23 | if [ $? -ne 0 ] 24 | then 25 | echo "FATAL: Compression errored." 26 | rm -f ${tf}.pz ${tf}.1 27 | continue 28 | fi 29 | 30 | pw=`cat /tmp/pwf` 31 | if [ "$pw" = "sillypassword" ] 32 | then 33 | echo "FATAL: Password file /tmp/pwf not zeroed!" 34 | fi 35 | 36 | echo "sillypassword" > /tmp/pwf 37 | cmd="../../pcompress -d -w /tmp/pwf ${tf}.pz ${tf}.1" 38 | echo "Running $cmd" 39 | eval $cmd 40 | if [ $? -ne 0 ] 41 | then 42 | echo "FATAL: Decompression errored." 43 | rm -f ${tf}.pz ${tf}.1 44 | continue 45 | fi 46 | 47 | diff ${tf} ${tf}.1 > /dev/null 48 | if [ $? -ne 0 ] 49 | then 50 | echo "FATAL: Decompression was not correct" 51 | fi 52 | 53 | pw=`cat /tmp/pwf` 54 | if [ "$pw" = "sillypassword" ] 55 | then 56 | echo "FATAL: Password file /tmp/pwf not zeroed!" 57 | fi 58 | rm -f ${tf}.pz ${tf}.1 59 | done 60 | done 61 | done 62 | done 63 | 64 | for algo in lzfx zlib 65 | do 66 | for tf in `cat files.lst` 67 | do 68 | for feat in "-e SALSA20" "-e AES -L" "-D -e SALSA20" "-D -EE -L -e SALSA20 -S KECCAK256" "-G -e SALSA20" "-G -F -e AES" 69 | do 70 | for seg in 5m 71 | do 72 | echo "sillypassword" > /tmp/pwf 73 | cmd="../../pcompress -c${algo} -l3 -s${seg} $feat -w /tmp/pwf ${tf} - > ${tf}.pz" 74 | echo "Running $cmd" 75 | eval $cmd 76 | if [ $? -ne 0 ] 77 | then 78 | echo "FATAL: Compression errored." 79 | rm -f ${tf}.pz ${tf}.1 80 | continue 81 | fi 82 | 83 | pw=`cat /tmp/pwf` 84 | if [ "$pw" = "sillypassword" ] 85 | then 86 | echo "FATAL: Password file /tmp/pwf not zeroed!" 87 | fi 88 | 89 | echo "sillypassword" > /tmp/pwf 90 | cmd="cat ${tf}.pz | ../../pcompress -d -w /tmp/pwf - ${tf}.1" 91 | echo "Running $cmd" 92 | eval $cmd 93 | if [ $? -ne 0 ] 94 | then 95 | echo "FATAL: Decompression errored." 96 | rm -f ${tf}.pz ${tf}.1 97 | continue 98 | fi 99 | 100 | diff ${tf} ${tf}.1 > /dev/null 101 | if [ $? -ne 0 ] 102 | then 103 | echo "FATAL: Decompression was not correct" 104 | fi 105 | 106 | pw=`cat /tmp/pwf` 107 | if [ "$pw" = "sillypassword" ] 108 | then 109 | echo "FATAL: Password file /tmp/pwf not zeroed!" 110 | fi 111 | rm -f ${tf}.pz ${tf}.1 112 | done 113 | done 114 | done 115 | done 116 | 117 | rm -f /tmp/pwf 118 | 119 | echo "#################################################" 120 | echo "" 121 | 122 | -------------------------------------------------------------------------------- /test/t8.tst: -------------------------------------------------------------------------------- 1 | # 2 | # Fixed block dedupe 3 | # 4 | echo "#################################################" 5 | echo "# Test Fixed block Deduplication" 6 | echo "#################################################" 7 | 8 | rm -f *.pz 9 | rm -f *.1 10 | 11 | for algo in lzfx lz4 adapt adapt2 12 | do 13 | for tf in `cat files.lst` 14 | do 15 | for feat in "-F" "-F -B3 -L" "-F -B4" "-F -B5 -L" "-F -P" "-F -L -P" "-G -F -B3 -L" 16 | do 17 | for seg in 2m 100m 18 | do 19 | cmd="../../pcompress -c ${algo} -l 3 -s ${seg} $feat ${tf}" 20 | echo "Running $cmd" 21 | eval $cmd 22 | if [ $? -ne 0 ] 23 | then 24 | echo "FATAL: Compression errored." 25 | rm -f ${tf}.pz ${tf}.1 26 | continue 27 | fi 28 | cmd="../../pcompress -d ${tf}.pz ${tf}.1" 29 | echo "Running $cmd" 30 | eval $cmd 31 | if [ $? -ne 0 ] 32 | then 33 | echo "FATAL: Decompression errored." 34 | rm -f ${tf}.pz ${tf}.1 35 | continue 36 | fi 37 | 38 | diff ${tf} ${tf}.1 > /dev/null 39 | if [ $? -ne 0 ] 40 | then 41 | echo "FATAL: Decompression was not correct" 42 | fi 43 | rm -f ${tf}.pz ${tf}.1 44 | done 45 | done 46 | done 47 | done 48 | 49 | echo "#################################################" 50 | echo "" 51 | 52 | -------------------------------------------------------------------------------- /utils/fixlic.sh: -------------------------------------------------------------------------------- 1 | lic_txt='/* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | ' 26 | 27 | for fn in `find . \( -name "*.c" -o -name "*.h" \) | egrep -v '^.git'` 28 | do 29 | grep "This program is free software; you can redistribute it and/or" ${fn} > /dev/null 30 | if [ $? -ne 0 ] 31 | then 32 | echo "Adding license to ${fn}" 33 | echo "${lic_txt}" > ${fn}.lic 34 | cat ${fn} >> ${fn}.lic 35 | cp ${fn}.lic ${fn} 36 | rm ${fn}.lic 37 | continue 38 | fi 39 | 40 | sed -i ' 41 | / \* This program includes partly\-modified public domain\/LGPL source/d 42 | / \* This program includes partly\-modified public domain source/d 43 | / \* code from the LZMA SDK: http:\/\/www.7-zip.org\/sdk.html/d 44 | s/Copyright (C) 2012 /Copyright (C) 2012-2013 /' ${fn} 45 | 46 | grep "You should have received a copy of the GNU Lesser General Public" ${fn} > /dev/null 47 | if [ $? -ne 0 ] 48 | then 49 | sed -i ' 50 | / \* Lesser General Public License for more details./a\ 51 | \*\ 52 | \* You should have received a copy of the GNU Lesser General Public\ 53 | \* License along with this program.\ 54 | \* If not, see . 55 | ' ${fn} 56 | fi 57 | done 58 | 59 | 60 | -------------------------------------------------------------------------------- /utils/heap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | /* 26 | * Functions for a rudimentary fast min-heap implementation. 27 | * Adapted from "Algorithms with C", Kyle Loudon, O'Reilly. 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "heap.h" 37 | 38 | #define heap_parent(npos) ((__TYPE)(((npos) - 1) / 2)) 39 | #define heap_left(npos) (((npos) * 2) + 1) 40 | #define heap_right(npos) (((npos) * 2) + 2) 41 | 42 | static void 43 | heap_insert(MinHeap *heap, __TYPE data) 44 | { 45 | __TYPE temp; 46 | __TYPE ipos, ppos; 47 | 48 | heap->tree[heap_size(heap)] = data; 49 | ipos = heap_size(heap); 50 | ppos = heap_parent(ipos); 51 | 52 | while (ipos > 0 && heap->tree[ppos] > heap->tree[ipos]) { 53 | temp = heap->tree[ppos]; 54 | heap->tree[ppos] = heap->tree[ipos]; 55 | heap->tree[ipos] = temp; 56 | ipos = ppos; 57 | ppos = heap_parent(ipos); 58 | } 59 | if (heap->size < heap->totsize) 60 | heap->size++; 61 | } 62 | 63 | void 64 | heap_nsmallest(MinHeap *heap, __TYPE *data, __TYPE *heapbuf, __TYPE heapsize, __TYPE datasize) 65 | { 66 | __TYPE i; 67 | 68 | heap->size = 1; 69 | heap->totsize = heapsize; 70 | heap->tree = heapbuf; 71 | heap->tree[0] = data[0]; 72 | 73 | for (i = 1; i < datasize; i++) 74 | heap_insert(heap, data[i]); 75 | } 76 | -------------------------------------------------------------------------------- /utils/heap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef __HEAPQ_H_ 26 | 27 | #define __HEAPQ_H_ 28 | #define __TYPE int64_t 29 | 30 | typedef struct Heap_ { 31 | __TYPE size; 32 | __TYPE totsize; 33 | __TYPE *tree; 34 | } MinHeap; 35 | 36 | #define heap_size(heap) ((heap)->size) 37 | 38 | void heap_nsmallest(MinHeap *heap, __TYPE *data, __TYPE *heapbuf, __TYPE heapsize, __TYPE datasize); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /utils/pcompress.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PC_PATH="" 4 | LD_LIBRARY_PATH="${PC_PATH}" 5 | export LD_LIBRARY_PATH 6 | 7 | exec ${PC_PATH}/buildtmp/pcompress "$@" 8 | 9 | -------------------------------------------------------------------------------- /utils/phash/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -O 2 | 3 | .cc.o: 4 | gcc $(CFLAGS) -c $< 5 | 6 | O = lookupa.o recycle.o perfhex.o perfect.o 7 | 8 | all : $(O) 9 | gcc -o perfect $(O) -lm 10 | sh genhash.sh 11 | 12 | clean: 13 | rm -f perfect foo *.o 14 | 15 | # DEPENDENCIES 16 | 17 | lookupa.o : lookupa.c standard.h lookupa.h 18 | 19 | recycle.o : recycle.c standard.h recycle.h 20 | 21 | perfhex.o : perfhex.c standard.h lookupa.h recycle.h perfect.h 22 | 23 | perfect.o : perfect.c standard.h lookupa.h recycle.h perfect.h 24 | -------------------------------------------------------------------------------- /utils/phash/Makefile.test: -------------------------------------------------------------------------------- 1 | CFLAGS = -O 2 | 3 | .cc.o: 4 | gcc $(CFLAGS) -c $< 5 | 6 | O = lookupa.o recycle.o phash.o testperf.o 7 | 8 | foo : $(O) 9 | gcc -o foo $(O) -lm 10 | 11 | # DEPENDENCIES 12 | 13 | lookupa.o : lookupa.c standard.h lookupa.h 14 | 15 | recycle.o : recycle.c standard.h recycle.h 16 | 17 | phash.o : phash.c standard.h phash.h lookupa.h 18 | 19 | testperf.o : testperf.c standard.h recycle.h phash.h 20 | -------------------------------------------------------------------------------- /utils/phash/genhash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo ' 4 | /* Generated File. DO NOT EDIT. */ 5 | /* 6 | * List of extensions and their types. 7 | */ 8 | 9 | #ifndef __EXT_H__ 10 | #define __EXT_H__ 11 | struct ext_entry { 12 | char *ext; 13 | int type; 14 | int len; 15 | } extlist[] = {' > extensions.h 16 | 17 | rm -f extlist 18 | cat extensions.txt | while read line 19 | do 20 | [ "x$line" = "x" ] && continue 21 | echo "$line" | egrep "^#" > /dev/null 22 | [ $? -eq 0 ] && continue 23 | _OIFS="$IFS" 24 | IFS="," 25 | set -- $line 26 | IFS="$_OIFS" 27 | ext=$1 28 | type=$2 29 | len=`printf $ext | wc -c` 30 | echo $ext >> extlist 31 | echo " {\"${ext}\" , $type, $len}," >> extensions.h 32 | done 33 | 34 | echo '};' >> extensions.h 35 | echo "#endif" >> extensions.h 36 | ./perfect -nm < extlist 37 | rm -f extlist 38 | -------------------------------------------------------------------------------- /utils/phash/lookupa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /* 27 | ------------------------------------------------------------------------------ 28 | By Bob Jenkins, September 1996. 29 | lookupa.h, a hash function for table lookup, same function as lookup.c. 30 | Use this code in any way you wish. Public Domain. It has no warranty. 31 | Source is http://burtleburtle.net/bob/c/lookupa.h 32 | ------------------------------------------------------------------------------ 33 | */ 34 | 35 | #ifndef STANDARD 36 | #include "standard.h" 37 | #endif 38 | 39 | #ifndef LOOKUPA 40 | #define LOOKUPA 41 | 42 | #define CHECKSTATE 8 43 | #define hashsize(n) ((ub4)1<<(n)) 44 | #define hashmask(n) (hashsize(n)-1) 45 | 46 | ub4 lookup(/*_ ub1 *k, ub4 length, ub4 level _*/); 47 | void checksum(/*_ ub1 *k, ub4 length, ub4 *state _*/); 48 | 49 | #endif /* LOOKUPA */ 50 | -------------------------------------------------------------------------------- /utils/phash/phash.c: -------------------------------------------------------------------------------- 1 | /* Generated File, DO NOT EDIT */ 2 | /* table for the mapping for the perfect hash */ 3 | #ifndef STANDARD 4 | #include "standard.h" 5 | #endif /* STANDARD */ 6 | #ifndef PHASH 7 | #include "phash.h" 8 | #endif /* PHASH */ 9 | #ifndef LOOKUPA 10 | #include "lookupa.h" 11 | #endif /* LOOKUPA */ 12 | 13 | /* small adjustments to _a_ to make values distinct */ 14 | ub1 tab[] = { 15 | 0,0,87,235,113,131,120,120,113,85,0,220,125,0,131,7, 16 | 0,0,183,125,82,183,0,131,253,125,125,183,0,7,85,183, 17 | 0,0,0,145,183,0,131,113,253,183,0,220,0,7,0,113, 18 | 82,0,7,113,125,220,0,0,168,113,0,183,220,183,220,22, 19 | 0,183,0,235,113,0,183,82,22,27,125,253,142,124,125,235, 20 | 232,131,146,235,146,220,0,235,0,220,220,220,113,220,183,135, 21 | 87,125,113,220,220,32,229,97,131,40,0,184,237,113,148,184, 22 | 0,0,145,0,241,167,0,145,88,88,184,242,57,135,174,0, 23 | }; 24 | 25 | /* The hash function */ 26 | ub4 phash(char *key, int len) 27 | { 28 | ub4 rsl, val = lookup(key, len, 0x9e3779b9); 29 | rsl = ((val>>25)^tab[val&0x7f]); 30 | return rsl; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /utils/phash/phash.h: -------------------------------------------------------------------------------- 1 | /* Generated File, DO NOT EDIT */ 2 | /* Perfect hash definitions */ 3 | #ifndef STANDARD 4 | #include "standard.h" 5 | #endif /* STANDARD */ 6 | #ifndef PHASH 7 | #define PHASH 8 | 9 | extern ub1 tab[]; 10 | #define PHASHLEN 0x80 /* length of hash mapping table */ 11 | #define PHASHNKEYS 218 /* How many keys were hashed */ 12 | #define PHASHRANGE 256 /* Range any input might map to */ 13 | #define PHASHSALT 0x9e3779b9 /* internal, initialize normal hash */ 14 | 15 | ub4 phash(); 16 | 17 | #endif /* PHASH */ 18 | 19 | -------------------------------------------------------------------------------- /utils/phash/standard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | /* 27 | ------------------------------------------------------------------------------ 28 | Standard definitions and types, Bob Jenkins 29 | ------------------------------------------------------------------------------ 30 | */ 31 | #ifndef STANDARD 32 | # define STANDARD 33 | # ifndef STDIO 34 | # include 35 | # define STDIO 36 | # endif 37 | # ifndef STDDEF 38 | # include 39 | # define STDDEF 40 | # endif 41 | typedef unsigned long long ub8; 42 | #define UB8MAXVAL 0xffffffffffffffffLL 43 | #define UB8BITS 64 44 | typedef signed long long sb8; 45 | #define SB8MAXVAL 0x7fffffffffffffffLL 46 | typedef unsigned int ub4; /* unsigned 4-byte quantities */ 47 | #define UB4MAXVAL 0xffffffff 48 | typedef signed int sb4; 49 | #define UB4BITS 32 50 | #define SB4MAXVAL 0x7fffffff 51 | typedef unsigned short int ub2; 52 | #define UB2MAXVAL 0xffff 53 | #define UB2BITS 16 54 | typedef signed short int sb2; 55 | #define SB2MAXVAL 0x7fff 56 | typedef unsigned char ub1; 57 | #define UB1MAXVAL 0xff 58 | #define UB1BITS 8 59 | typedef signed char sb1; /* signed 1-byte quantities */ 60 | #define SB1MAXVAL 0x7f 61 | typedef int word; /* fastest type available */ 62 | 63 | #define bis(target,mask) ((target) |= (mask)) 64 | #define bic(target,mask) ((target) &= ~(mask)) 65 | #define bit(target,mask) ((target) & (mask)) 66 | #ifndef min 67 | # define min(a,b) (((a)<(b)) ? (a) : (b)) 68 | #endif /* min */ 69 | #ifndef max 70 | # define max(a,b) (((a)<(b)) ? (b) : (a)) 71 | #endif /* max */ 72 | #ifndef align 73 | # define align(a) (((ub4)a+(sizeof(void *)-1))&(~(sizeof(void *)-1))) 74 | #endif /* align */ 75 | #ifndef abs 76 | # define abs(a) (((a)>0) ? (a) : -(a)) 77 | #endif 78 | #define TRUE 1 79 | #define FALSE 0 80 | #define SUCCESS 0 /* 1 on VAX */ 81 | 82 | #endif /* STANDARD */ 83 | -------------------------------------------------------------------------------- /utils/qsort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #ifndef _MPLV2_LICENSE_ 26 | #include "qsort_gnu.h" 27 | #else 28 | #include "qsort_bsd.h" 29 | #endif 30 | -------------------------------------------------------------------------------- /utils/sse_level.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | void 31 | usage(void) 32 | { 33 | printf("Usage: sse_level [--avx]\n"); 34 | exit(1); 35 | } 36 | 37 | int 38 | main(int argc, char *argv[]) 39 | { 40 | processor_cap_t pc; 41 | int avx_detect = 0; 42 | cpuid_basic_identify(&pc); 43 | 44 | if (argc > 1) { 45 | if (strcmp(argv[1], "--avx") == 0) 46 | avx_detect = 1; 47 | else 48 | usage(); 49 | } 50 | if (!avx_detect) { 51 | if (pc.sse_level == 3 && pc.sse_sub_level == 1) { 52 | printf("ssse%d", pc.sse_level); 53 | pc.sse_sub_level = 0; 54 | } else { 55 | printf("sse%d", pc.sse_level); 56 | } 57 | if (pc.sse_sub_level > 0) 58 | printf(".%d\n", pc.sse_sub_level); 59 | else 60 | printf("\n"); 61 | } else { 62 | if (pc.avx_level == 1) 63 | printf("avx\n"); 64 | else if (pc.avx_level == 2) 65 | printf("avx2\n"); 66 | } 67 | 68 | return (0); 69 | } 70 | 71 | -------------------------------------------------------------------------------- /utils/xxhash_sse2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define CPUCAP_NM(x) x##_SSE2 27 | #include "xxhash.c" 28 | 29 | -------------------------------------------------------------------------------- /utils/xxhash_sse4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of Pcompress, a chunked parallel multi- 3 | * algorithm lossless compression and decompression program. 4 | * 5 | * Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved. 6 | * Use is subject to license terms. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 3 of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this program. 20 | * If not, see . 21 | * 22 | * moinakg@belenix.org, http://moinakg.wordpress.com/ 23 | * 24 | */ 25 | 26 | #define CPUCAP_NM(x) x##_SSE4 27 | #include "xxhash.c" 28 | 29 | --------------------------------------------------------------------------------